accounting modifications 3.24.5
authorKilian Saffran <ksaffran@dks.lu>
Mon, 1 Oct 2018 07:40:14 +0000 (09:40 +0200)
committerKilian Saffran <ksaffran@dks.lu>
Mon, 1 Oct 2018 07:40:14 +0000 (09:40 +0200)
app_v3/chrome/content/js/license.js
app_v3/chrome/content/modules/accounting/js/accounting.js
app_v3/chrome/content/modules/accounting/js/accountingchild.js

index 6ccbe59..74810c1 100644 (file)
@@ -80,7 +80,7 @@ var license = {
 //             if (lickey.match(reglid) != "" && (expiration) && (test <= expiration)){
 //                     navigation.load_deck(2);
 //             }
-               dump(e.message);
+               //dump(e.message);
                return data;
             }
             
@@ -111,13 +111,13 @@ var license = {
                                var cruuid = appdb.generate_uuid();
                          var dbname = system.profiledir() + system.sep() + cruuid +".sqlite"; 
                          var dbclone = system.appdir() + system.sep() +"defaults"+system.sep()+"profile"+system.sep()+"creorga.sqlite";
-                         dump("DB to clone: " + dbclone);
+                         //dump("DB to clone: " + dbclone);
                          OS.File.copy(dbclone, dbname);
                                apppref.setpreference("support.database.currentdb.num", 1);
                                apppref.setpreference("support.database.currentdb.db",dbname);
                                appdb.dbFile=FileUtils.File(apppref.getpreference("support.database.currentdb.db"));
                                var nb = {name:'Crèche',uuid:cruuid,dbnum:1,path:{local:system.profiledir(),remote:null},lastsync:null};
-                               dump("Database set:" + JSON.stringify(nb) + "\n");
+                               //dump("Database set:" + JSON.stringify(nb) + "\n");
                                apppref.setpreference("support.database.1", nb);
                                curcfg.loadconfig(1);
                                //dump(appdb.dbFile.path + "\n");
index 510fe2f..891937a 100644 (file)
@@ -28,6 +28,7 @@ function initdata(){
   if (configdata != '') {
     pconfig = JSON.parse(configdata);
   }
+  
   if (!pconfig.printlayout) {
     pconfig.printlayout = 'list';
     apppref.setpreference("pageconfig.accounting",pconfig);
@@ -67,7 +68,6 @@ function initdata(){
   //load_column_selection();
 }
 
-
 function load_accounting_table(){
   //dump("accounting:" + JSON.stringify(pconfig) + "\n");
   var accyear = pconfig.accmonth.substring(3,7);
index d4f4188..827f149 100644 (file)
@@ -23,7 +23,7 @@ function initdata(){
   var ccreche = appdb.dbquery("select uuid from creche LIMIT 1;");
   crecheuuid = ccreche.sqldata[0].uuid;
   importpath = FileUtils.File(curcfg.path.local  + system.sep() +"imports" + system.sep() + crecheuuid);
-  
+  check_accountingtable();
   load_childlist();
   if (pconfig.accchild) {
   //  
@@ -93,7 +93,7 @@ function load_accounting_table(){
   "case when acc.invoiceamount is not null then printf(\"%.2f\",COALESCE(acc.invoiceamount,0.00)) || '€' || case when acc.invoicedate is not null then '<br/>(' || strftime('%d.%m.%Y',acc.invoicedate) || ')' || CASE WHEN acc.reminderdate1 IS NOT NULL THEN '<br/>R1:' || strftime('%d.%m.%Y',acc.reminderdate1) ELSE '' END || CASE WHEN acc.reminderdate2 IS NOT NULL THEN '<br/>R2:' || strftime('%d.%m.%Y',acc.reminderdate2) ELSE '' END || CASE WHEN acc.reminderdate3 IS NOT NULL THEN '<br/>R3:' || strftime('%d.%m.%Y',acc.reminderdate3) ELSE '' END else '' end else '' end  as invoiced, " +
   "case when acc.payedamount is not null then printf(\"%.2f\",COALESCE(acc.payedamount,0.00)) || '€' || case when acc.payeddate is not null then '<br/>(' || strftime('%d.%m.%Y',acc.payeddate) || ')' else '' end else '' end as payement," +
   "case when acc.benefitamount is not null then printf(\"%.2f\",COALESCE(acc.benefitamount,0.00)) || '€' else '' end as benefitamount," +
-  "'<button type=\"button\" class=\"btn btn-primary\" onclick=\"dlg_accounting(''' || acc.accmonth || ''');\" title=\"editer\"><span class=\"glyphicon glyphicon-pencil\"></span></button>' || CASE WHEN acc.invoicefile IS NOT NULL and acc.invoicefile != '' THEN '<button type=\"button\" class=\"btn btn-primary\" onclick=\"openfile(''' || acc.invoicefile ||  ''');\" title=\"editer\"><span class=\"glyphicon glyphicon-open\"></span>'  else '' end || CASE WHEN acc.childuuid IS NOT NULL AND acc.accmonth IS NOT NULL THEN '<button type=\"button\" class=\"btn btn-danger\" onclick=\" confirm_delete_accounting(''' || acc.childuuid || ''',''' || acc.accmonth || ''',''' || acc.accreference || ''');\" title=\"supprimer\"><span class=\"glyphicon glyphicon-remove\"></span></button>' ELSE '' END AS act  " +
+  "'<button type=\"button\" class=\"btn btn-primary\" onclick=\"dlg_accounting(''' || acc.accmonth || ''');\" title=\"editer\"><span class=\"glyphicon glyphicon-pencil\"></span></button>' || CASE WHEN acc.invoicefile IS NOT NULL and acc.invoicefile != '' THEN '<button type=\"button\" class=\"btn btn-primary\" onclick=\"openfile(''' || acc.invoicefile ||  ''');\" title=\"editer\"><span class=\"glyphicon glyphicon-open\"></span>'  else '' end || CASE WHEN acc.childuuid IS NOT NULL AND acc.accmonth IS NOT NULL THEN '<button type=\"button\" class=\"btn btn-danger\" onclick=\" confirm_delete_accounting(''' || acc.childuuid || ''',''' || acc.accmonth || ''',''' || acc.reference || ''');\" title=\"supprimer\"><span class=\"glyphicon glyphicon-remove\"></span></button>' ELSE '' END AS act  " +
   "FROM ( SELECT pch.childname, pch.childuuid, px.calweek, px.calmonth, px.sumdurationcalweek, px.sumlunchcalweek, " +
   "CASE WHEN px.sumdurationcalweek IS NOT NULL AND pch.checkservicenumber IS NOT NULL THEN ( SELECT coalesce(wc0.costsperhour,0.00) FROM costs wc0 WHERE wc0.startdate < date('"+yearmin+"','+' || caldays || ' days') and wc0.weeklyhourslimit <= px.sumdurationcalweek ORDER BY wc0.startdate DESC,wc0.weeklyhourslimit DESC LIMIT 1 ) WHEN px.sumdurationcalweek IS NOT NULL AND pch.checkservicenumber IS NULL THEN ( SELECT coalesce(wc0.costperhourfallback,0.00) FROM costs wc0 WHERE wc0.startdate < date('"+yearmin+"','+' || caldays || ' days') and wc0.weeklyhourslimit <= px.sumdurationcalweek ORDER BY wc0.startdate DESC,wc0.weeklyhourslimit DESC LIMIT 1 ) ELSE NULL END AS weekhourcosts,"+
   
@@ -140,7 +140,8 @@ function load_accounting_table(){
  
   
   var accdata = appdb.dbquery(accsql);
- //jsdump(accsql);
+  //jsdump("accchildsql");
+  //jsdump(accsql);
   var headerdata = getlabels("calmonth,weekdetails,reference,invoiced,payement,benefitamount,act");
  //,monthtotalhourcosts,monthtotallunchcosts,monthtotalcosts
   
@@ -516,4 +517,16 @@ function onhidecolumn(coltohide) {
             header: 'Décompte par enfant'
       });
   //dump("Hide column " + coltohide + "\n");
-}
\ No newline at end of file
+}
+
+function check_accountingtable(){
+  var cols = appdb.dbquery("SELECT type, name,tbl_name,sql FROM sqlite_master where tbl_name='accounting';");
+  //jsdump(JSON.stringify(cols));
+  if (cols.sqldata[0].sql.indexOf("nocheckservice") == -1){
+    //jsdump("Install missing column! ALTER TABLE accounting add column nocheckservice integer");
+    appdb.dbexec("ALTER TABLE accounting add column nocheckservice integer;");
+  }
+  // else {
+  //   jsdump("missing column found!");
+  // }
+}