}catch(ex){
system.popup("Erreur d'Export!","L'export des données n'a pas completement fonctionné !\n");
}
- }
+ },
+ readinvoicepdf: function(){
+ try {
+ var lastdir = apppref.getpreference("support.lastfiledir");
+ var nsIFilePicker = Components.interfaces.nsIFilePicker;
+ var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
+ fp.init(window, "selectionner fichier PDF", nsIFilePicker.modeOpen);
+ fp.appendFilter("PDF", "*.pdf");
+ if (lastdir != '') {
+ var nsILocalFile= Components.interfaces.nsILocalFile;
+ var f = Components.classes["@mozilla.org/file/local;1"].createInstance(nsILocalFile);
+ f.initWithPath(lastdir);
+ fp.displayDirectory = f;
+ }
+ var res = fp.show();
+ if (res != nsIFilePicker.returnCancel) {
+ var pdffile = fp.file;
+ apppref.setpreference("support.lastfiledir",system.getDirectory(pdffile.path));
+
+ var cname = appdb.dbquery("select uuid from creche LIMIT 1;");
+ cruuid = cname.sqldata[0].uuid;
+ var importpath = FileUtils.File(curcfg.path.local + system.sep() +"imports" + system.sep() + cruuid);
+ var args = ["-db",'"' + appdb.dbFile.path + '"',"-p",'"' +pdffile.path + '"',"-o",'"' + importpath.path + '"',"-t",'"' + system.toolsdir() + '"',"-x","inv","-l", '"' + system.profiledir() + system.sep() + 'importerror.log"'];
+
+ var binpdf = system.toolsdir() + system.sep() + "pdfextract.exe";
+ if (system.os != "WINNT") {
+ binpdf = system.toolsdir() + system.sep() + "pdfextract";
+ }
+ //dump(binpdf + " " +JSON.stringify(args) + "\n");
+ system.popup("Import Factures!","Import du PDF '"+ pdffile.path +"' en cours!\n");
+ system.runcmdline(binpdf,args,function(data){
+ var strx = apppref.getpreference("pageconfig.lastpage");
+ var x = JSON.parse(strx);
+
+ if (x.module == 'accounting') {
+ navigation.load_appview(x.view,x.module,null,x.header);
+ }
+ system.popup("Import Factures!","Les factures ont été importées!\n");
+ });
+
+ }
+ } catch(ex){
+ system.popup("Erreur d'import!","Une Erreur s'est produite pendant l'import des factures!\n");
+ //dump("Error importing invoice PDF! " + ex + "\n");
+ }
+ },
+ readbenefitstatement: function(){
+ try {
+ var lastdir = apppref.getpreference("support.lastfiledir");
+ var nsIFilePicker = Components.interfaces.nsIFilePicker;
+ var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
+ fp.init(window, "selectionner fichier PDF", nsIFilePicker.modeOpen);
+ fp.appendFilter("PDF", "*.pdf");
+ if (lastdir != '') {
+ var nsILocalFile= Components.interfaces.nsILocalFile;
+ var f = Components.classes["@mozilla.org/file/local;1"].createInstance(nsILocalFile);
+ f.initWithPath(lastdir);
+ fp.displayDirectory = f;
+ }
+ var res = fp.show();
+ if (res != nsIFilePicker.returnCancel) {
+ var pdffile = fp.file;
+ apppref.setpreference("support.lastfiledir",system.getDirectory(pdffile.path));
+
+ var cname = appdb.dbquery("select uuid from creche LIMIT 1;");
+ cruuid = cname.sqldata[0].uuid;
+ var importpath = FileUtils.File(curcfg.path.local + system.sep() +"imports" + system.sep() + cruuid);
+ var args = ["-db",'"' + appdb.dbFile.path + '"',"-p",'"' + pdffile.path + '"',"-o",'"' + importpath.path +'"',"-t",'"' + system.toolsdir() + '"',"-x","stmt","-l",'"' + system.profiledir() + system.sep() + 'importerror.log"'];
+ var binpdf = system.toolsdir() + system.sep() + "pdfextract.exe";
+ if (system.os != "WINNT") {
+ binpdf = system.toolsdir() + system.sep() + "pdfextract";
+ }
+ system.runcmdline(binpdf,args,function(data){
+ system.popup("Import Prestations!","Les Prestations ont été importées!\n");
+ });
+ }
+ } catch(ex){
+ system.popup("Erreur d'import!","Une erreur s'est produite pendant l'import des prestations!\n");
+ //dump("Error importing statement PDF! " + ex + "\n");
+ }
+ }
};