From 91d6a1b6216547142c2f3f9c7704ec0b85031340 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Tue, 27 Mar 2018 06:40:12 +0200 Subject: [PATCH 01/10] fix sql error using no category --- htdocs/compta/bank/bankentries_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 91e496d998c21..d773d8ce8e418 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -455,7 +455,7 @@ $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql.= " FROM "; -if ($search_bid) $sql.= MAIN_DB_PREFIX."bank_class as l,"; +if ($search_bid>0) $sql.= MAIN_DB_PREFIX."bank_class as l,"; $sql.= " ".MAIN_DB_PREFIX."bank_account as ba,"; $sql.= " ".MAIN_DB_PREFIX."bank as b"; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_extrafields as ef on (b.rowid = ef.fk_object)"; From 930512d9a2e50df08654ffd637fe780e535a3b0b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Mar 2018 13:08:16 +0200 Subject: [PATCH 02/10] FIX Add a test to avoid to reset binding by error. --- htdocs/accountancy/customer/index.php | 28 +---------- htdocs/accountancy/customer/lines.php | 46 ++++++++++------- htdocs/accountancy/expensereport/index.php | 28 +---------- htdocs/accountancy/expensereport/lines.php | 49 +++++++++++-------- htdocs/accountancy/supplier/index.php | 28 +---------- htdocs/accountancy/supplier/lines.php | 47 +++++++++++------- .../core/class/html.formaccounting.class.php | 11 +++-- 7 files changed, 97 insertions(+), 140 deletions(-) diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index b7d61674fd8d4..aedaeda0e5b2c 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -117,30 +117,6 @@ $db->commit(); setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); } -} elseif ($action == 'cleanaccountancycode') { - $error = 0; - $db->begin(); - - // Now clean - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd"; - $sql1.= " SET fk_code_ventilation = 0"; - $sql1.= " WHERE fd.fk_facture IN ( SELECT f.rowid FROM " . MAIN_DB_PREFIX . "facture as f"; - $sql1.= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'"; - $sql1.= " AND f.datef <= '" . $db->idate($search_date_end) . "'"; - $sql1.= " AND f.entity IN (" . getEntity('accountancy') . ")"; - $sql1.=")"; - - dol_syslog("htdocs/accountancy/customer/index.php cleanaccountancycode", LOG_DEBUG); - - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - $db->rollback(); - setEventMessage($db->lasterror(), 'errors'); - } else { - $db->commit(); - setEventMessage($langs->trans('Done'), 'mesgs'); - } } @@ -183,8 +159,6 @@ $y = $year_current; $buttonbind = '' . $langs->trans("ValidateHistory") . ''; -$buttonreset = ''; -if ($conf->global->MAIN_FEATURES_LEVEL >= 2) $buttonreset = '' . $langs->trans("CleanHistory", $year_current) . ''; print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); @@ -262,7 +236,7 @@ print '
'; -print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), $buttonreset, ''); +print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), '', ''); print '
'; print ''; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index c4c3d03ee97ca..e696b4774d18d 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -110,27 +110,37 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { $error = 0; - $db->begin(); + if (! (GETPOST('account_parent','int') >= 0)) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors'); + } - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as l"; - $sql1 .= " SET l.fk_code_ventilation=" . GETPOST('account_parent','int'); - $sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')'; + $db->begin(); - dol_syslog('accountancy/customer/lines.php::changeaccount sql= ' . $sql1); - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - setEventMessages($db->lasterror(), null, 'errors'); - } - if (! $error) { - $db->commit(); - setEventMessages($langs->trans('Save'), null, 'mesgs'); - } else { - $db->rollback(); - setEventMessages($db->lasterror(), null, 'errors'); + if (! $error) + { + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as l"; + $sql1 .= " SET l.fk_code_ventilation=" . (GETPOST('account_parent','int') > 0 ? GETPOST('account_parent','int') : '0'); + $sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')'; + + dol_syslog('accountancy/customer/lines.php::changeaccount sql= ' . $sql1); + $resql1 = $db->query($sql1); + if (! $resql1) { + $error ++; + setEventMessages($db->lasterror(), null, 'errors'); + } + if (! $error) { + $db->commit(); + setEventMessages($langs->trans('Save'), null, 'mesgs'); + } else { + $db->rollback(); + setEventMessages($db->lasterror(), null, 'errors'); + } + + $account_parent = ''; // Protection to avoid to mass apply it a second time } - $account_parent = ''; // Protection to avoid to mass apply it a second time } @@ -272,7 +282,7 @@ print $langs->trans("DescVentilDoneCustomer") . '
'; print '
' . $langs->trans("ChangeAccount") . '
'; - print $formaccounting->select_account($account_parent, 'account_parent', 1); + print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle'); print '
'; $moreforfilter = ''; diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index 0768ee01bf898..cec7fbdced48b 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -114,30 +114,6 @@ $db->commit(); setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); } -} elseif ($action == 'cleanaccountancycode') { - $error = 0; - $db->begin(); - - // Now clean - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd"; - $sql1.= " SET fk_code_ventilation = 0"; - $sql1.= " WHERE erd.fk_expensereport IN ( SELECT er.rowid FROM " . MAIN_DB_PREFIX . "expensereport as er"; - $sql1.= " WHERE er.date_debut >= '" . $db->idate($search_date_start) . "'"; - $sql1.= " AND er.date_debut <= '" . $db->idate($search_date_end) . "'"; - $sql1.= " AND er.entity IN (" . getEntity('accountancy') . ")"; - $sql1.=")"; - - dol_syslog("htdocs/accountancy/customer/index.php cleanaccountancycode", LOG_DEBUG); - - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - $db->rollback(); - setEventMessage($db->lasterror(), 'errors'); - } else { - $db->commit(); - setEventMessage($langs->trans('Done'), 'mesgs'); - } } @@ -180,8 +156,6 @@ $y = $year_current; $buttonbind = '' . $langs->trans("ValidateHistory") . ''; -$buttonreset = ''; -if ($conf->global->MAIN_FEATURES_LEVEL >= 2) $buttonreset = '' . $langs->trans("CleanHistory", $year_current) . ''; print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); @@ -253,7 +227,7 @@ print '
'; -print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), $buttonreset, ''); +print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), '', ''); print '
'; diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index e00b4527818b4..28a44d23a5edd 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -43,7 +43,7 @@ $langs->load("trips"); $langs->load("productbatch"); -$account_parent = GETPOST('account_parent'); +$account_parent = GETPOST('account_parent','int'); $changeaccount = GETPOST('changeaccount'); // Search Getpost $search_expensereport = GETPOST('search_expensereport', 'alpha'); @@ -103,27 +103,36 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { $error = 0; - $db->begin(); + if (! (GETPOST('account_parent','int') >= 0)) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors'); + } - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd"; - $sql1 .= " SET erd.fk_code_ventilation=" . GETPOST('account_parent','int'); - $sql1 .= ' WHERE erd.rowid IN (' . implode(',', $changeaccount) . ')'; + $db->begin(); - dol_syslog('accountancy/expensereport/lines.php::changeaccount sql= ' . $sql1); - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - setEventMessages($db->lasterror(), null, 'errors'); + if (! $error) + { + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd"; + $sql1 .= " SET erd.fk_code_ventilation=" . (GETPOST('account_parent','int') > 0 ? GETPOST('account_parent','int') : '0'); + $sql1 .= ' WHERE erd.rowid IN (' . implode(',', $changeaccount) . ')'; + + dol_syslog('accountancy/expensereport/lines.php::changeaccount sql= ' . $sql1); + $resql1 = $db->query($sql1); + if (! $resql1) { + $error ++; + setEventMessages($db->lasterror(), null, 'errors'); + } + if (! $error) { + $db->commit(); + setEventMessages($langs->trans('Save'), null, 'mesgs'); + } else { + $db->rollback(); + setEventMessages($db->lasterror(), null, 'errors'); + } + + $account_parent = ''; // Protection to avoid to mass apply it a second time } - if (! $error) { - $db->commit(); - setEventMessages($langs->trans('Save'), null, 'mesgs'); - } else { - $db->rollback(); - setEventMessages($db->lasterror(), null, 'errors'); - } - - $account_parent = ''; // Protection to avoid to mass apply it a second time } @@ -246,7 +255,7 @@ print $langs->trans("DescVentilDoneExpenseReport") . '
'; print '
' . $langs->trans("ChangeAccount") . '
'; - print $formaccounting->select_account(GETPOST('account_parent'), 'account_parent', 1); + print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle'); print '
'; $moreforfilter = ''; diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 1425dde58f7cb..e9935fc8d7818 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -115,31 +115,9 @@ $db->commit(); setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); } -} elseif ($action == 'cleanaccountancycode') { - $error = 0; - $db->begin(); - - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; - $sql1.= " SET fk_code_ventilation = 0"; - $sql1.= " WHERE fd.fk_facture_fourn IN ( SELECT f.rowid FROM " . MAIN_DB_PREFIX . "facture_fourn as f"; - $sql1.= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($year_current, 1, false)) . "'"; - $sql1.= " AND f.datef <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "'"; - $sql1.= " AND f.entity IN (" . getEntity('accountancy') . ")"; - $sql1.= ")"; - - dol_syslog("htdocs/accountancy/customer/index.php cleanaccountancycode", LOG_DEBUG); - - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - $db->rollback(); - setEventMessage($db->lasterror(), 'errors'); - } else { - $db->commit(); - setEventMessage($langs->trans('Done'), 'mesgs'); - } } + /* * View */ @@ -178,8 +156,6 @@ $y = $year_current; $buttonbind = '' . $langs->trans("ValidateHistory") . ''; -$buttonreset = ''; -if ($conf->global->MAIN_FEATURES_LEVEL >= 2) $buttonreset = '' . $langs->trans("CleanHistory", $year_current) . ''; print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); @@ -252,7 +228,7 @@ print '
'; -print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), $buttonreset, ''); +print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), '', ''); print '
'; print '
'; diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index af9d82e5056e4..6ad8731a4157d 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -111,27 +111,36 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { $error = 0; - $db->begin(); + if (! (GETPOST('account_parent','int') >= 0)) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors'); + } - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as l"; - $sql1 .= " SET l.fk_code_ventilation=" . GETPOST('account_parent','int'); - $sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')'; + $db->begin(); - dol_syslog('accountancy/supplier/lines.php::changeaccount sql= ' . $sql1); - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - setEventMessages($db->lasterror(), null, 'errors'); + if (! $error) + { + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as l"; + $sql1 .= " SET l.fk_code_ventilation=" . (GETPOST('account_parent','int') > 0 ? GETPOST('account_parent','int') : '0'); + $sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')'; + + dol_syslog('accountancy/supplier/lines.php::changeaccount sql= ' . $sql1); + $resql1 = $db->query($sql1); + if (! $resql1) { + $error ++; + setEventMessages($db->lasterror(), null, 'errors'); + } + if (! $error) { + $db->commit(); + setEventMessages($langs->trans('Save'), null, 'mesgs'); + } else { + $db->rollback(); + setEventMessages($db->lasterror(), null, 'errors'); + } + + $account_parent = ''; // Protection to avoid to mass apply it a second time } - if (! $error) { - $db->commit(); - setEventMessages($langs->trans('Save'), null, 'mesgs'); - } else { - $db->rollback(); - setEventMessages($db->lasterror(), null, 'errors'); - } - - $account_parent = ''; // Protection to avoid to mass apply it a second time } @@ -269,7 +278,7 @@ print $langs->trans("DescVentilDoneSupplier") . '
'; print '
' . $langs->trans("ChangeAccount") . '
'; - print $formaccounting->select_account($account_parent, 'account_parent', 1); + print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle'); print '
'; $moreforfilter = ''; diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index aaae010c2fe62..a79f01352e872 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -243,7 +243,7 @@ function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey = '' * * @param string $selectid Preselected id or code of accounting accounts (depends on $select_in) * @param string $htmlname Name of HTML field id. If name start with '.', it is name of HTML css class, so several component with same name in different forms can be used. - * @param int $showempty Add an empty field + * @param int $showempty 1=Add an empty field, 2=Add an empty field+'None' field * @param array $event Event options * @param int $select_in 0=selectid value is a aa.rowid (default) or 1=selectid is aa.account_number * @param int $select_out Set value returned by select. 0=rowid (default), 1=account_number @@ -253,7 +253,7 @@ function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey = '' */ function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss='maxwidth300 maxwidthonsmartphone', $usecache='') { - global $conf; + global $conf, $langs; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; @@ -318,7 +318,12 @@ function select_account($selectid, $htmlname = 'account', $showempty = 0, $event } } - $out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1); + if ($showempty == 2) + { + $options['0'] = $langs->trans("None"); + } + + $out .= Form::selectarray($htmlname, $options, $selected, ($showempty > 0 ? 1 : 0), 0, 0, '', 0, 0, 0, '', $morecss, 1); return $out; } From 2b588b9e43a03c3d2c7c18e27b9a45b4ea67b036 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Mar 2018 13:37:40 +0200 Subject: [PATCH 03/10] FIX Initial month on report income/expense per predefined group --- htdocs/compta/resultat/clientfourn.php | 6 +++--- htdocs/compta/resultat/index.php | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index d78cbabb34f86..f105c11160c49 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -107,13 +107,13 @@ if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } } -// $date_start and $date_end are defined. We force $start_year and $nbofyear +// $date_start and $date_end are defined. We force $year_start and $nbofyear $tmps=dol_getdate($date_start); -$start_year = $tmps['year']; +$year_start = $tmps['year']; $tmpe=dol_getdate($date_end); $year_end = $tmpe['year']; $nbofyear = ($year_end - $start_year) + 1; -//var_dump($start_year." ".$end_year." ".$nbofyear); +//var_dump("year_start=".$year_start." year_end=".$year_end." nbofyear=".$nbofyear." date_start=".dol_print_date($date_start, 'dayhour')." date_end=".dol_print_date($date_end, 'dayhour')); // Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES' or 'BOOKKEEPING') $modecompta = $conf->global->ACCOUNTING_MODE; diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index 26f12e3f7c5d3..c35f084af40fe 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -85,13 +85,14 @@ if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } } -// $date_start and $date_end are defined. We force $start_year and $nbofyear +// $date_start and $date_end are defined. We force $year_start and $nbofyear $tmps=dol_getdate($date_start); -$start_year = $tmps['year']; +$year_start = $tmps['year']; $tmpe=dol_getdate($date_end); $year_end = $tmpe['year']; $nbofyear = ($year_end - $start_year) + 1; -//var_dump($start_year." ".$end_year." ".$nbofyear); +//var_dump("year_start=".$year_start." year_end=".$year_end." nbofyear=".$nbofyear." date_start=".dol_print_date($date_start, 'dayhour')." date_end=".dol_print_date($date_end, 'dayhour')); + // Security check $socid = GETPOST('socid','int'); From 0b13cd17acf2b0f604f2fb386c30adf9b112d091 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Mar 2018 13:55:10 +0200 Subject: [PATCH 04/10] FIX Some report have data when several chart of accounts exists FIX Detail per account not visible when total < 0 --- htdocs/compta/resultat/clientfourn.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index f105c11160c49..2967e31be76ee 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -255,6 +255,7 @@ $sql.= " WHERE f.numero_compte = aa.account_number"; //$sql.= " AND fk_statut in (1,2)"; $sql.= " AND ".$predefinedgroupwhere; + $sql.= " AND fk_pcg_version = '".$db->escape($charofaccountstring)."'"; $sql.= " AND f.entity = ".$conf->entity; if (! empty($date_start) && ! empty($date_end)) $sql.= " AND f.doc_date >= '".$db->idate($date_start)."' AND f.doc_date <= '".$db->idate($date_end)."'"; @@ -295,7 +296,7 @@ if ($showaccountdetail != 'no') { $tmppredefinedgroupwhere="pcg_type = '".$db->escape($objp->pcg_type)."' AND pcg_subtype = '".$db->escape($objp->pcg_subtype)."'"; - $tmppredefinedgroupwhere.= " AND fk_pcg_version = '".$charofaccountstring."'"; + $tmppredefinedgroupwhere.= " AND fk_pcg_version = '".$db->escape($charofaccountstring)."'"; //$tmppredefinedgroupwhere.= " AND thirdparty_code = '".$db->escape($objp->name)."'"; // Get cpts of category/group @@ -312,7 +313,7 @@ } - if ($showaccountdetail == 'all' || $resultN > 0) + if ($showaccountdetail == 'all' || $resultN <> 0) { print ''; print ''; From f9ee2930e2bdd80e052120973c193190da619263 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Mar 2018 14:16:59 +0200 Subject: [PATCH 05/10] FIX Data on income/expense report was always 0 --- htdocs/compta/resultat/clientfourn.php | 1 - htdocs/compta/resultat/index.php | 85 ++++++++++++++++---------- 2 files changed, 52 insertions(+), 34 deletions(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 2967e31be76ee..b717b58edd2e4 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -253,7 +253,6 @@ $sql.= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as f"; $sql.= ", ".MAIN_DB_PREFIX."accounting_account as aa"; $sql.= " WHERE f.numero_compte = aa.account_number"; - //$sql.= " AND fk_statut in (1,2)"; $sql.= " AND ".$predefinedgroupwhere; $sql.= " AND fk_pcg_version = '".$db->escape($charofaccountstring)."'"; $sql.= " AND f.entity = ".$conf->entity; diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index c35f084af40fe..1bbb8eca2cf61 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -377,7 +377,6 @@ $result=$db->query($sql); if ($result) { $num = $db->num_rows($result); - $var=false; $i = 0; if ($num) { while ($i < $num) { @@ -410,7 +409,6 @@ $result=$db->query($sql); if ($result) { $num = $db->num_rows($result); - $var=false; $i = 0; if ($num) { while ($i < $num) { @@ -444,7 +442,6 @@ $result=$db->query($sql); if ($result) { $num = $db->num_rows($result); - $var=false; $i = 0; if ($num) { while ($i < $num) { @@ -475,7 +472,6 @@ $result=$db->query($sql); if ($result) { $num = $db->num_rows($result); - $var=false; $i = 0; if ($num) { while ($i < $num) { @@ -538,7 +534,6 @@ $result=$db->query($sql); if ($result) { $num = $db->num_rows($result); - $var=false; $i = 0; if ($num) { while ($i < $num) { @@ -601,7 +596,6 @@ $result=$db->query($sql); if ($result) { $num = $db->num_rows($result); - $var=false; $i = 0; if ($num) { while ($i < $num) { @@ -648,7 +642,6 @@ $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - $var = false; $i = 0; if ($num) { while ($i < $num) { @@ -776,7 +769,6 @@ if ($result) { $num = $db->num_rows($result); - $var=false; $i = 0; if ($num) { @@ -811,32 +803,35 @@ if (! empty($conf->accounting->enabled) && ($modecompta == 'BOOKKEEPING')) { - $subtotal_ht = 0; - $subtotal_ttc = 0; + $predefinedgroupwhere = "("; + //$predefinedgroupwhere.= " (pcg_type = 'EXPENSE' and pcg_subtype in ('PRODUCT','SERVICE'))"; + $predefinedgroupwhere.= " (pcg_type = 'EXPENSE')"; + $predefinedgroupwhere.= " OR "; + //$predefinedgroupwhere.= " (pcg_type = 'INCOME' and pcg_subtype in ('PRODUCT','SERVICE'))"; + $predefinedgroupwhere.= " (pcg_type = 'INCOME')"; + $predefinedgroupwhere.= ")"; + + $charofaccountstring = $conf->global->CHARTOFACCOUNTS; + $charofaccountstring=dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'accounting_system', 'rowid', 'pcg_version'); $sql = "SELECT b.doc_ref, b.numero_compte, b.subledger_account, b.subledger_label, pcg_type, date_format(b.doc_date,'%Y-%m') as dm, sum(b.debit) as debit, sum(b.credit) as credit, sum(b.montant) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b, ".MAIN_DB_PREFIX."accounting_account as aa"; $sql.= " WHERE b.numero_compte = aa.account_number AND b.entity = ".$conf->entity; - //$sql.= " AND fk_statut in (1,2)"; - $sql.= " AND ("; - //$sql.= " (pcg_type = 'EXPENSE' and pcg_subtype in ('PRODUCT','SERVICE'))"; - $sql.= " (pcg_type = 'EXPENSE')"; - $sql.= " OR "; - //$sql.= " (pcg_type = 'INCOME' and pcg_subtype in ('PRODUCT','SERVICE'))"; - $sql.= " (pcg_type = 'INCOME')"; - $sql.= ")"; - //$sql.= " AND code_journal in ('VT', 'AC')"; + $sql.= " AND ".$predefinedgroupwhere; + $sql.= " AND fk_pcg_version = '".$db->escape($charofaccountstring)."'"; if (! empty($date_start) && ! empty($date_end)) $sql.= " AND b.doc_date >= '".$db->idate($date_start)."' AND b.doc_date <= '".$db->idate($date_end)."'"; $sql.= " GROUP BY b.doc_ref, b.numero_compte, b.subledger_account, b.subledger_label, pcg_type, dm"; //print $sql; + $subtotal_ht = 0; + $subtotal_ttc = 0; + dol_syslog("get bookkeeping record"); $result=$db->query($sql); if ($result) { $num = $db->num_rows($result); - $var=false; $i = 0; if ($num) { @@ -846,9 +841,8 @@ if (! isset($encaiss[$obj->dm])) $encaiss[$obj->dm]=0; $encaiss[$obj->dm] += $obj->debit; - if (! isset($encaiss_ttc[$obj->dm])) $encaiss_ttc[$obj->dm]=0; - $encaiss_ttc[$obj->dm] += $obj->credit; + $encaiss_ttc[$obj->dm] += 0; $i++; } @@ -909,7 +903,6 @@ } print ''; -$var=True; // Loop on each month $nb_mois_decalage = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START-1):0; @@ -927,21 +920,44 @@ $case = strftime("%Y-%m",dol_mktime(12,0,0,$mois_modulo,1,$annee_decalage)); print '"; print '"; } @@ -952,7 +968,10 @@ // Total $nbcols=0; -print ''; +print ''; for ($annee = $year_start ; $annee <= $year_end ; $annee++) { $nbcols+=2; From 51cd793d80ccdb024af6d84c688a81beafb2c817 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Mar 2018 14:37:29 +0200 Subject: [PATCH 06/10] Fix log and duplicate vat_by_date function --- htdocs/compta/localtax/index.php | 20 +++++++------- htdocs/compta/tva/index.php | 4 +-- htdocs/compta/tva/quadri_detail.php | 4 +-- htdocs/compta/tva/quarter_report.php | 4 +-- htdocs/core/lib/tax.lib.php | 40 +++++++--------------------- 5 files changed, 25 insertions(+), 47 deletions(-) diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index 5d17688fc688e..6286bfaa4e4a3 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -45,14 +45,14 @@ // Security check $socid = isset($_GET["socid"])?$_GET["socid"]:''; -if ($user->societe_id) +if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); // Define modetax (0 or 1) // 0=normal, 1=option vat for services is on debit $modetax = $conf->global->TAX_MODE; -if (isset($_GET["modetax"])) +if (isset($_GET["modetax"])) $modetax=$_GET["modetax"]; /** @@ -81,7 +81,7 @@ function pt ($db, $sql, $date) $var=True; while ($i < $num) { $obj = $db->fetch_object($result); - + print ''; print '\n"; $total = $total + $obj->mm; @@ -166,16 +166,16 @@ function pt ($db, $sql, $date) $total=0; $subtotalcoll=0; $subtotalpaye=0; $subtotal=0; $i=0; for ($m = 1 ; $m < 13 ; $m++ ) { - $coll_listsell = vat_by_date($db, $y, 0, 0, 0, $modetax, 'sell', $m); - $coll_listbuy = vat_by_date($db, $y, 0, 0, 0, $modetax, 'buy', $m); - + $coll_listsell = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'sell', $m); + $coll_listbuy = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'buy', $m); + $action = "tva"; $object = array(&$coll_listsell, &$coll_listbuy); $parameters["mode"] = $modetax; $parameters["year"] = $y; $parameters["month"] = $m; $parameters["type"] = 'localtax'.$localTaxType; - + // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('externalbalance')); $reshook=$hookmanager->executeHooks('addVatLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks @@ -190,7 +190,7 @@ function pt ($db, $sql, $date) break; } - + print ''; print ''; if($CalcLT==0) { @@ -221,7 +221,7 @@ function pt ($db, $sql, $date) } $subtotalcoll = $subtotalcoll + $x_coll; print ""; - + } if($CalcLT==0) { @@ -231,7 +231,7 @@ function pt ($db, $sql, $date) } elseif($CalcLT==2) { $diff= $x_coll; } - + $total = $total + $diff; $subtotal = $subtotal + $diff; diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index acbcc86e07d2a..1ac38a93c9630 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -144,8 +144,8 @@ function pt ($db, $sql, $date) $i=0; for ($m = 1 ; $m < 13 ; $m++ ) { - $coll_listsell = vat_by_date($db, $y, 0, 0, 0, $modetax, 'sell', $m); - $coll_listbuy = vat_by_date($db, $y, 0, 0, 0, $modetax, 'buy', $m); + $coll_listsell = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'sell', $m); + $coll_listbuy = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'buy', $m); $action = "tva"; $object = array(&$coll_listsell, &$coll_listbuy); diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index d4ccbf988047e..5a05ef5974f5b 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -224,8 +224,8 @@ $i=0; // Load arrays of datas -$x_coll = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell'); -$x_paye = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'buy'); +$x_coll = tax_by_date('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'sell'); +$x_paye = tax_by_date('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'buy'); if (! is_array($x_coll) || ! is_array($x_paye)) { diff --git a/htdocs/compta/tva/quarter_report.php b/htdocs/compta/tva/quarter_report.php index 4c054923837f2..dd058c6ebc26b 100644 --- a/htdocs/compta/tva/quarter_report.php +++ b/htdocs/compta/tva/quarter_report.php @@ -260,8 +260,8 @@ $columns = 6; // Load arrays of datas -$x_coll = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell'); -$x_paye = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'buy'); +$x_coll = tax_by_date('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'sell'); +$x_paye = tax_by_date('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'buy'); if (!is_array($x_coll) || !is_array($x_paye)) { $langs->load("errors"); diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index 400ed45300436..a0825cf651846 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -32,7 +32,7 @@ * Prepare array with list of tabs * * @param ChargeSociales $object Object related to tabs - * @return array Array of tabs to show + * @return array Array of tabs to show */ function tax_prepare_head(ChargeSociales $object) { @@ -184,7 +184,6 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction * Gets Tax to collect for the given year (and given quarter or month) * The function gets the Tax in split results, as the Tax declaration asks * to report the amounts for different Tax rates as different lines. - * This function also accounts recurrent invoices. * * @param string $type Tax type, either 'vat', 'localtax1' or 'localtax2' * @param DoliDB $db Database handler object @@ -236,7 +235,7 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $total_localtax1='total_localtax1'; $total_localtax2='total_localtax2'; - + // CAS DES BIENS // Define sql request @@ -318,7 +317,7 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if ($sql == 'TODO') return -2; if ($sql != 'TODO') { - dol_syslog("Tax.lib.php::vat_by_date", LOG_DEBUG); + dol_syslog("Tax.lib.php::tax_by_date", LOG_DEBUG); $resql = $db->query($sql); if ($resql) @@ -414,7 +413,7 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql.= " AND (d.product_type = 1"; // Limit to services $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service - $sql.= " ORDER BY d.rowid, d.".$fk_facture; + $sql.= " ORDER BY d.rowid, d.".$fk_facture; } else // Option vat on delivery for goods (payments) and payments for services { @@ -458,13 +457,13 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if (! $sql) { - dol_syslog("Tax.lib.php::vat_by_date no accountancy module enabled".$sql,LOG_ERR); + dol_syslog("Tax.lib.php::tax_by_date no accountancy module enabled".$sql,LOG_ERR); return -1; // -1 = Not accountancy module enabled } if ($sql == 'TODO') return -2; // -2 = Feature not yet available if ($sql != 'TODO') { - dol_syslog("Tax.lib.php::vat_by_date", LOG_DEBUG); + dol_syslog("Tax.lib.php::tax_by_date", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { @@ -550,19 +549,19 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire } if ($q) $sql.= " AND (date_format(p.datep,'%m') > ".(($q-1)*3)." AND date_format(p.datep,'%m') <= ".($q*3).")"; if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; - $sql.= " AND (d.product_type = -1"; + $sql.= " AND (d.product_type = -1"; $sql.= " OR e.date_debut is NOT null OR e.date_fin IS NOT NULL)"; // enhance detection of service $sql.= " ORDER BY e.rowid"; if (! $sql) { - dol_syslog("Tax.lib.php::vat_by_date no accountancy module enabled".$sql,LOG_ERR); + dol_syslog("Tax.lib.php::tax_by_date no accountancy module enabled".$sql,LOG_ERR); return -1; // -1 = Not accountancy module enabled } if ($sql == 'TODO') return -2; // -2 = Feature not yet available if ($sql != 'TODO') { - dol_syslog("Tax.lib.php::vat_by_date", LOG_DEBUG); + dol_syslog("Tax.lib.php::tax_by_date", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { @@ -624,24 +623,3 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire return $list; } -/** - * Gets VAT to collect for the given year (and given quarter or month) - * The function gets the VAT in split results, as the VAT declaration asks - * to report the amounts for different VAT rates as different lines. - * This function also accounts recurrent invoices. - * - * @param DoliDB $db Database handler object - * @param int $y Year - * @param int $q Quarter - * @param string $date_start Start date - * @param string $date_end End date - * @param int $modetax 0 or 1 (option vat on debit) - * @param int $direction 'sell' (customer invoice) or 'buy' (supplier invoices) - * @param int $m Month - * @return array List of quarters with vat - */ -function vat_by_date ($db, $y, $q, $date_start, $date_end, $modetax, $direction, $m=0) -{ - return tax_by_date('vat', $db, $y, $q, $date_start, $date_end, $modetax, $direction, $m); -} - From 460344fbfbe96f7a4377e87d8555755daf778d50 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Mar 2018 16:02:06 +0200 Subject: [PATCH 07/10] Traduction --- htdocs/langs/fr_FR/holiday.lang | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/langs/fr_FR/holiday.lang b/htdocs/langs/fr_FR/holiday.lang index a44463d0d1b32..9412cb5ebeedb 100644 --- a/htdocs/langs/fr_FR/holiday.lang +++ b/htdocs/langs/fr_FR/holiday.lang @@ -81,6 +81,10 @@ EmployeeFirstname=Prénom du salarié TypeWasDisabledOrRemoved=Le type de congés (id %s) a été désactivé ou supprimé LastHolidays=Les %s dernières demandes de congés AllHolidays=Toutes les demandes de congés +LEAVE_PAID=Congé payés +LEAVE_SICK=Arrêt maladie +LEAVE_OTHER=Autre congé +LEAVE_PAID_FR=congé payés ## Configuration du Module ## LastUpdateCP=Dernière mise à jour automatique de l'allocation des congés From 925e0c46dd636193ac454dcb587080af97656885 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20G=C3=A9n=C3=A9r=C3=A9?= Date: Sat, 24 Mar 2018 17:50:40 +0100 Subject: [PATCH 08/10] BUG - Point of sale - buttons for cheque and CB are not displayed properly when one account is not defined I find out in the point of sale module that when you have an account for CB but not for check than you could use check but not CB. It seems quite obvious when you look to the previous code that a mistake was done. This is now fixed I expect. The workaround for now is to define both default accounts (for check and for CB). --- htdocs/cashdesk/tpl/facturation1.tpl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/cashdesk/tpl/facturation1.tpl.php b/htdocs/cashdesk/tpl/facturation1.tpl.php index aed83d641f31b..146ae3d40b65b 100644 --- a/htdocs/cashdesk/tpl/facturation1.tpl.php +++ b/htdocs/cashdesk/tpl/facturation1.tpl.php @@ -183,7 +183,7 @@ else print ''; print ''; print '
'; - if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] < 0) + if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CB']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] < 0) { $langs->load("errors"); print ''; @@ -191,7 +191,7 @@ else print ''; print '
'; print '
'; - if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CB']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] < 0) + if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] < 0) { $langs->load("errors"); print ''; From 299c32d262c4141d19bd784f446c80e5ef3dfdaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 27 Mar 2018 11:17:40 +0200 Subject: [PATCH 09/10] Update actions_sendmails.inc.php --- htdocs/core/actions_sendmails.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 8a29a268e68f6..96a9e4987c3a7 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -384,7 +384,7 @@ if ($mailfile->error) { - setEventMessage($mailfile->error, 'errors'); + setEventMessages($mailfile->error, $mailfile->errors, 'errors'); $action='presend'; } else From 125085acee13580126c284ca669cdcdc25db2d91 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Mar 2018 03:01:05 +0200 Subject: [PATCH 10/10] Fix name of method to avoid ci errors --- htdocs/core/class/commonobject.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 8d08b828fd142..ceaa2f902ae26 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5804,7 +5804,7 @@ function showOptionals($extrafields, $mode='view', $params=null, $keysuffix='', { $labeltoshow = ''.$labeltoshow.''; } - + if (empty($onetrtd)) $out .= '
 '; - if (isset($decaiss_ttc[$case]) && $decaiss_ttc[$case] != 0) + if ($modecompta == 'BOOKKEEPING') { - print ''.price(price2num($decaiss_ttc[$case],'MT')).''; - if (! isset($totsorties[$annee])) $totsorties[$annee]=0; - $totsorties[$annee]+=$decaiss_ttc[$case]; + if (isset($decaiss[$case]) && $decaiss[$case] != 0) + { + print ''.price(price2num($decaiss[$case],'MT')).''; + if (! isset($totsorties[$annee])) $totsorties[$annee]=0; + $totsorties[$annee]+=$decaiss[$case]; + } + } + else + { + if (isset($decaiss_ttc[$case]) && $decaiss_ttc[$case] != 0) + { + print ''.price(price2num($decaiss_ttc[$case],'MT')).''; + if (! isset($totsorties[$annee])) $totsorties[$annee]=0; + $totsorties[$annee]+=$decaiss_ttc[$case]; + } } print " '; - //if (isset($encaiss_ttc[$case]) && $encaiss_ttc[$case] != 0) - if (isset($encaiss_ttc[$case])) + if ($modecompta == 'BOOKKEEPING') { - print ''.price(price2num($encaiss_ttc[$case],'MT')).''; - if (! isset($totentrees[$annee])) $totentrees[$annee]=0; - $totentrees[$annee]+=$encaiss_ttc[$case]; + if (isset($encaiss[$case])) + { + print ''.price(price2num($encaiss[$case],'MT')).''; + if (! isset($totentrees[$annee])) $totentrees[$annee]=0; + $totentrees[$annee]+=$encaiss[$case]; + } + } + else + { + if (isset($encaiss_ttc[$case])) + { + print ''.price(price2num($encaiss_ttc[$case],'MT')).''; + if (! isset($totentrees[$annee])) $totentrees[$annee]=0; + $totentrees[$annee]+=$encaiss_ttc[$case]; + } } print "
'.$langs->trans("TotalTTC").'
'; +if ($modecompta == 'BOOKKEEPING') print $langs->trans("Total"); +else print $langs->trans("TotalTTC"); +print '
'.$obj->dm."
'.dol_print_date(dol_mktime(0,0,0,$m,1,$y),"%b %Y").'".price($x_coll)."'; else $out .= ''; @@ -6111,7 +6111,7 @@ protected function isIndex($info) * * @return array */ - protected function set_save_query() + protected function setSaveQuery() { global $conf; @@ -6210,7 +6210,7 @@ protected function setVarsFromFetchObj(&$obj) * * @return string */ - protected function get_field_list() + protected function getFieldList() { $keys = array_keys($this->fields); return implode(',', $keys); @@ -6245,7 +6245,7 @@ public function createCommon(User $user, $notrigger = false) $now=dol_now(); - $fieldvalues = $this->set_save_query(); + $fieldvalues = $this->setSaveQuery(); if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) $fieldvalues['date_creation']=$this->db->idate($now); if (array_key_exists('fk_user_creat', $fieldvalues) && ! ($fieldvalues['fk_user_creat'] > 0)) $fieldvalues['fk_user_creat']=$user->id; unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into insert. @@ -6337,7 +6337,7 @@ public function fetchCommon($id, $ref = null) { if (empty($id) && empty($ref)) return false; - $sql = 'SELECT '.$this->get_field_list(); + $sql = 'SELECT '.$this->getFieldList(); $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; if(!empty($id)) $sql.= ' WHERE rowid = '.$id; @@ -6380,7 +6380,7 @@ public function updateCommon(User $user, $notrigger = false) $now=dol_now(); - $fieldvalues = $this->set_save_query(); + $fieldvalues = $this->setSaveQuery(); if (array_key_exists('date_modification', $fieldvalues) && empty($fieldvalues['date_modification'])) $fieldvalues['date_modification']=$this->db->idate($now); if (array_key_exists('fk_user_modif', $fieldvalues) && ! ($fieldvalues['fk_user_modif'] > 0)) $fieldvalues['fk_user_modif']=$user->id; unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into update.