// if (lickey.match(reglid) != "" && (expiration) && (test <= expiration)){
// navigation.load_deck(2);
// }
- dump(e.message);
+ //dump(e.message);
return data;
}
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");
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) {
//
"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,"+
var accdata = appdb.dbquery(accsql);
- //jsdump(accsql);
+ //jsdump("accchildsql");
+ //jsdump(accsql);
var headerdata = getlabels("calmonth,weekdetails,reference,invoiced,payement,benefitamount,act");
//,monthtotalhourcosts,monthtotallunchcosts,monthtotalcosts
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!");
+ // }
+}