From 1ebb018903f974fc77c684cd9b4a300b5cd6a405 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 3 Jan 2021 04:11:25 +0100 Subject: [PATCH 1/8] Add language file --- htdocs/accountancy/bookkeeping/balance.php | 2 +- htdocs/accountancy/bookkeeping/list.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 1547983da0c..d23d826bf42 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -37,7 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page -$langs->loadLangs(array("accountancy")); +$langs->loadLangs(array("accountancy", "compta")); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $sortorder = GETPOST("sortorder", 'alpha'); diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index b3cec7710a4..b66e10c0f71 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("accountancy")); +$langs->loadLangs(array("accountancy", "compta")); $socid = GETPOST('socid', 'int'); From 1d5089e95e2af58ef8c93832dba98a8e263f0846 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 3 Jan 2021 04:42:21 +0100 Subject: [PATCH 2/8] Repare link to create unknown account --- htdocs/accountancy/bookkeeping/balance.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index d23d826bf42..7ac795b784b 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -321,8 +321,8 @@ if ($action != 'export_csv') $root_account_description = $tmparrayforrootaccount['label']; $root_account_number = $tmparrayforrootaccount['account_number']; - if (empty($accountingaccountstatic->label) && $accountingaccountstatic->id > 0) { - $link = ''.img_edit().''; + if (empty($tmparrayforrootaccount['label'])) { + $link = ''.img_edit_add().''; } if (!empty($show_subgroup)) From 691e8580cd732d91610b5373c62555780f3d721b Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 3 Jan 2021 05:44:07 +0100 Subject: [PATCH 3/8] Add date_export on new ledger & subledger to show edit or delete link when is not export yet --- .../accountancy/bookkeeping/listbyaccount.php | 67 +++++++++++++---- .../bookkeeping/listbysubaccount.php | 73 ++++++++++++++----- .../accountancy/class/bookkeeping.class.php | 18 +++-- 3 files changed, 117 insertions(+), 41 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 4847dfd2e9a..6bab55f0f52 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -48,6 +48,14 @@ $search_date_endday = GETPOST('search_date_endday', 'int'); $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); $search_date_end = dol_mktime(0, 0, 0, $search_date_endmonth, $search_date_endday, $search_date_endyear); $search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); +$search_date_export_startyear = GETPOST('search_date_export_startyear', 'int'); +$search_date_export_startmonth = GETPOST('search_date_export_startmonth', 'int'); +$search_date_export_startday = GETPOST('search_date_export_startday', 'int'); +$search_date_export_endyear = GETPOST('search_date_export_endyear', 'int'); +$search_date_export_endmonth = GETPOST('search_date_export_endmonth', 'int'); +$search_date_export_endday = GETPOST('search_date_export_endday', 'int'); +$search_date_export_start = dol_mktime(0, 0, 0, $search_date_export_startmonth, $search_date_export_startday, $search_date_export_startyear); +$search_date_export_end = dol_mktime(0, 0, 0, $search_date_export_endmonth, $search_date_export_endday, $search_date_export_endyear); $search_accountancy_code = GETPOST("search_accountancy_code"); $search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); @@ -128,6 +136,7 @@ $arrayfields = array( 't.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1), 't.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1), 't.lettering_code'=>array('label'=>$langs->trans("LetteringCode"), 'checked'=>1), + 't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1), ); if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) unset($arrayfields['t.lettering_code']); @@ -181,6 +190,14 @@ if (empty($reshook)) $search_date_endyear = ''; $search_date_endmonth = ''; $search_date_endday = ''; + $search_date_export_start = ''; + $search_date_export_end = ''; + $search_date_export_startyear = ''; + $search_date_export_startmonth = ''; + $search_date_export_startday = ''; + $search_date_export_endyear = ''; + $search_date_export_endmonth = ''; + $search_date_export_endday = ''; $search_debit = ''; $search_credit = ''; $search_lettering_code = ''; @@ -251,6 +268,14 @@ if (empty($reshook)) $filter['t.reconciled_option'] = $search_not_reconciled; $param .= '&search_not_reconciled='.urlencode($search_not_reconciled); } + if (!empty($search_date_export_start)) { + $filter['t.date_export>='] = $search_date_export_start; + $param .= '&search_date_export_startmonth='.$search_date_export_startmonth.'&search_date_export_startday='.$search_date_export_startday.'&search_date_export_startyear='.$search_date_export_startyear; + } + if (!empty($search_date_export_end)) { + $filter['t.date_export<='] = $search_date_export_end; + $param .= '&search_date_export_endmonth='.$search_date_export_endmonth.'&search_date_export_endday='.$search_date_export_endday.'&search_date_export_endyear='.$search_date_export_endyear; + } } if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) { @@ -490,6 +515,17 @@ if (!empty($arrayfields['t.lettering_code']['checked'])) print '
'.$langs->trans("NotReconciled").''; print ''; } +// Date export +if (!empty($arrayfields['t.date_export']['checked'])) { + print ''; + print '
'; + print $form->selectDate($search_date_export_start, 'search_date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); + print '
'; + print '
'; + print $form->selectDate($search_date_export_end, 'search_date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); + print '
'; + print ''; +} // Fields from hook $parameters = array('arrayfields'=>$arrayfields); @@ -512,6 +548,7 @@ if (!empty($arrayfields['t.label_operation']['checked'])) print_liste_field_tit if (!empty($arrayfields['t.debit']['checked'])) print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['t.credit']['checked'])) print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['t.lettering_code']['checked'])) print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.date_export']['checked'])) print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center '); // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook @@ -542,13 +579,12 @@ while ($i < min($num, $limit)) // Is it a break ? if ($accountg != $displayed_account_number || !isset($displayed_account_number)) { - if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) { - $colnumber = 3; - $colnumberend = 7; - } else { - $colnumber = 4; - $colnumberend = 7; - } + $colnumber = 5; + $colnumberend = 7; + + if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) $colnumber--; + if (empty($arrayfields['t.date_export']['checked'])) $colnumber--; + $colspan = $totalarray['nbfield'] - $colnumber; $colspanend = $totalarray['nbfield'] - $colnumberend; // Show a subtotal by accounting account @@ -581,7 +617,7 @@ while ($i < min($num, $limit)) // Show the break account print ""; - print ''; + print ''; if ($line->numero_compte != "" && $line->numero_compte != '-1') print length_accountg($line->numero_compte).' : '.$object->get_compte_desc($line->numero_compte); else print ''.$langs->trans("Unknown").''; print ''; @@ -722,6 +758,13 @@ while ($i < min($num, $limit)) if (!$i) $totalarray['nbfield']++; } + // Exported operation date + if (!empty($arrayfields['t.date_export']['checked'])) + { + print ''.dol_print_date($line->date_export, 'dayhour').''; + if (!$i) $totalarray['nbfield']++; + } + // Fields from hook $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook @@ -750,14 +793,6 @@ while ($i < min($num, $limit)) } if ($num > 0) { - // Show sub-total of last shown account - if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) { - $colnumber = 3; - $colnumberend = 7; - } else { - $colnumber = 4; - $colnumberend = 7; - } $colspan = $totalarray['nbfield'] - $colnumber; $colspanend = $totalarray['nbfield'] - $colnumberend; print ''; diff --git a/htdocs/accountancy/bookkeeping/listbysubaccount.php b/htdocs/accountancy/bookkeeping/listbysubaccount.php index abbf5df60e7..f010e9efbcf 100644 --- a/htdocs/accountancy/bookkeeping/listbysubaccount.php +++ b/htdocs/accountancy/bookkeeping/listbysubaccount.php @@ -48,6 +48,14 @@ $search_date_endday = GETPOST('search_date_endday', 'int'); $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); $search_date_end = dol_mktime(0, 0, 0, $search_date_endmonth, $search_date_endday, $search_date_endyear); $search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); +$search_date_export_startyear = GETPOST('search_date_export_startyear', 'int'); +$search_date_export_startmonth = GETPOST('search_date_export_startmonth', 'int'); +$search_date_export_startday = GETPOST('search_date_export_startday', 'int'); +$search_date_export_endyear = GETPOST('search_date_export_endyear', 'int'); +$search_date_export_endmonth = GETPOST('search_date_export_endmonth', 'int'); +$search_date_export_endday = GETPOST('search_date_export_endday', 'int'); +$search_date_export_start = dol_mktime(0, 0, 0, $search_date_export_startmonth, $search_date_export_startday, $search_date_export_startyear); +$search_date_export_end = dol_mktime(0, 0, 0, $search_date_export_endmonth, $search_date_export_endday, $search_date_export_endyear); $search_accountancy_code = GETPOST("search_accountancy_code"); $search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); @@ -128,6 +136,7 @@ $arrayfields = array( 't.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1), 't.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1), 't.lettering_code'=>array('label'=>$langs->trans("LetteringCode"), 'checked'=>1), + 't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1), ); if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) unset($arrayfields['t.lettering_code']); @@ -149,6 +158,7 @@ if ($search_date_end && empty($search_date_endyear)) { /* * Action */ + if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } @@ -180,6 +190,14 @@ if (empty($reshook)) $search_date_endyear = ''; $search_date_endmonth = ''; $search_date_endday = ''; + $search_date_export_start = ''; + $search_date_export_end = ''; + $search_date_export_startyear = ''; + $search_date_export_startmonth = ''; + $search_date_export_startday = ''; + $search_date_export_endyear = ''; + $search_date_export_endmonth = ''; + $search_date_export_endday = ''; $search_debit = ''; $search_credit = ''; $search_lettering_code = ''; @@ -250,6 +268,14 @@ if (empty($reshook)) $filter['t.reconciled_option'] = $search_not_reconciled; $param .= '&search_not_reconciled='.urlencode($search_not_reconciled); } + if (!empty($search_date_export_start)) { + $filter['t.date_export>='] = $search_date_export_start; + $param .= '&search_date_export_startmonth='.$search_date_export_startmonth.'&search_date_export_startday='.$search_date_export_startday.'&search_date_export_startyear='.$search_date_export_startyear; + } + if (!empty($search_date_export_end)) { + $filter['t.date_export<='] = $search_date_export_end; + $param .= '&search_date_export_endmonth='.$search_date_export_endmonth.'&search_date_export_endday='.$search_date_export_endday.'&search_date_export_endyear='.$search_date_export_endyear; + } } if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) { @@ -287,7 +313,7 @@ if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouveme } // Make a redirect to avoid to launch the delete later after a back button - header("Location: listbysubaccount.php".($param ? '?'.$param : '')); + header("Location: ".$_SERVER["PHP_SELF"].($param ? '?'.$param : '')); exit; } else { setEventMessages("NoRecordDeleted", null, 'warnings'); @@ -304,7 +330,7 @@ if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->suppri setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); } - header("Location: listbysubaccount.php?noreset=1".($param ? '&'.$param : '')); + header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : '')); exit; } } @@ -403,7 +429,6 @@ if (empty($reshook)) { $newcardbutton = dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param); $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php', '', 1, array('morecss' => 'marginleftonly')); $newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbysubaccount.php', '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); - $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create'); } @@ -494,6 +519,17 @@ if (!empty($arrayfields['t.lettering_code']['checked'])) print '
'.$langs->trans("NotReconciled").''; print ''; } +// Date export +if (!empty($arrayfields['t.date_export']['checked'])) { + print ''; + print '
'; + print $form->selectDate($search_date_export_start, 'search_date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); + print '
'; + print '
'; + print $form->selectDate($search_date_export_end, 'search_date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); + print '
'; + print ''; +} // Fields from hook $parameters = array('arrayfields'=>$arrayfields); @@ -516,6 +552,7 @@ if (!empty($arrayfields['t.label_operation']['checked'])) print_liste_field_tit if (!empty($arrayfields['t.debit']['checked'])) print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['t.credit']['checked'])) print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['t.lettering_code']['checked'])) print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.date_export']['checked'])) print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center '); // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook @@ -546,13 +583,12 @@ while ($i < min($num, $limit)) // Is it a break ? if ($accountg != $displayed_account_number || !isset($displayed_account_number)) { - if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) { - $colnumber = 3; - $colnumberend = 7; - } else { - $colnumber = 4; - $colnumberend = 7; - } + $colnumber = 5; + $colnumberend = 7; + + if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) $colnumber--; + if (empty($arrayfields['t.date_export']['checked'])) $colnumber--; + $colspan = $totalarray['nbfield'] - $colnumber; $colspanend = $totalarray['nbfield'] - $colnumberend; // Show a subtotal by accounting account @@ -585,7 +621,7 @@ while ($i < min($num, $limit)) // Show the break account print ""; - print ''; + print ''; if ($line->subledger_account != "" && $line->subledger_account != '-1') { print $object->get_compte_desc($line->numero_compte).' : '.length_accounta($line->subledger_account); } else { @@ -734,6 +770,13 @@ while ($i < min($num, $limit)) if (!$i) $totalarray['nbfield']++; } + // Exported operation date + if (!empty($arrayfields['t.date_export']['checked'])) + { + print ''.dol_print_date($line->date_export, 'dayhour').''; + if (!$i) $totalarray['nbfield']++; + } + // Fields from hook $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook @@ -762,14 +805,6 @@ while ($i < min($num, $limit)) } if ($num > 0) { - // Show sub-total of last shown account - if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) { - $colnumber = 3; - $colnumberend = 7; - } else { - $colnumber = 4; - $colnumberend = 7; - } $colspan = $totalarray['nbfield'] - $colnumber; $colspanend = $totalarray['nbfield'] - $colnumberend; print ''; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 72428762459..8261a5f4173 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -795,7 +795,7 @@ class BookKeeping extends CommonObject $sql .= " t.label_operation,"; $sql .= " t.debit,"; $sql .= " t.credit,"; - $sql .= " t.montant,"; + $sql .= " t.montant as amount,"; $sql .= " t.sens,"; $sql .= " t.multicurrency_amount,"; $sql .= " t.multicurrency_code,"; @@ -806,7 +806,8 @@ class BookKeeping extends CommonObject $sql .= " t.code_journal,"; $sql .= " t.journal_label,"; $sql .= " t.piece_num,"; - $sql .= " t.date_creation"; + $sql .= " t.date_creation,"; + $sql .= " t.date_export"; // Manage filter $sqlwhere = array(); if (count($filter) > 0) { @@ -823,6 +824,8 @@ class BookKeeping extends CommonObject $sqlwhere[] = $key.' LIKE \''.$this->db->escape($value).'%\''; } elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') { $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; + } elseif ($key == 't.date_export>=' || $key == 't.date_export<=') { + $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; } elseif ($key == 't.credit' || $key == 't.debit') { $sqlwhere[] = natural_search($key, $value, 1, 1); } elseif ($key == 't.reconciled_option') { @@ -878,7 +881,8 @@ class BookKeeping extends CommonObject $line->label_operation = $obj->label_operation; $line->debit = $obj->debit; $line->credit = $obj->credit; - $line->montant = $obj->montant; + $line->montant = $obj->amount; // deprecated + $line->amount = $obj->amount; $line->sens = $obj->sens; $line->multicurrency_amount = $obj->multicurrency_amount; $line->multicurrency_code = $obj->multicurrency_code; @@ -889,7 +893,8 @@ class BookKeeping extends CommonObject $line->code_journal = $obj->code_journal; $line->journal_label = $obj->journal_label; $line->piece_num = $obj->piece_num; - $line->date_creation = $obj->date_creation; + $line->date_creation = $this->db->jdate($obj->date_creation); + $line->date_export = $this->db->jdate($obj->date_export); $this->lines[] = $line; @@ -941,7 +946,7 @@ class BookKeeping extends CommonObject $sql .= " t.credit,"; $sql .= " t.lettering_code,"; $sql .= " t.date_lettering,"; - $sql .= " t.montant,"; + $sql .= " t.montant as amount,"; $sql .= " t.sens,"; $sql .= " t.fk_user_author,"; $sql .= " t.import_key,"; @@ -1019,7 +1024,8 @@ class BookKeeping extends CommonObject $line->label_operation = $obj->label_operation; $line->debit = $obj->debit; $line->credit = $obj->credit; - $line->montant = $obj->montant; + $line->montant = $obj->amount; // deprecated + $line->amount = $obj->amount; $line->sens = $obj->sens; $line->lettering_code = $obj->lettering_code; $line->date_lettering = $obj->date_lettering; From 9300951c6ed847c4b08d57a21a08069cadbbcc5d Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 3 Jan 2021 14:54:35 +0100 Subject: [PATCH 4/8] Add language file --- htdocs/user/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/list.php b/htdocs/user/list.php index e7a8a31af4e..06910c3da0c 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -36,7 +36,7 @@ if (!$user->rights->user->user->lire && !$user->admin) { } // Load translation files required by page -$langs->loadLangs(array('users', 'companies', 'hrm')); +$langs->loadLangs(array('users', 'companies', 'hrm', 'salaries')); $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) From e18bdfd9f060c5ead73b669f0a06b71c7ba9143c Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 3 Jan 2021 15:01:15 +0100 Subject: [PATCH 5/8] Add missing language key --- htdocs/langs/en_US/main.lang | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 7075df90783..e18d0671662 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1112,4 +1112,5 @@ UpToDate=Up-to-date OutOfDate=Out-of-date EventReminder=Event Reminder UpdateForAllLines=Update for all lines -OnHold=On hold \ No newline at end of file +OnHold=On hold +Civility=Civility From 1f87bbbd01936becf6a646f70aee392f3837cf82 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 7 Jan 2021 06:26:24 +0100 Subject: [PATCH 6/8] Typo --- htdocs/compta/sociales/card.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index bf28ceb0996..ccb413ecf6f 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -182,8 +182,7 @@ if ($action == 'update' && !$_POST["cancel"] && $user->rights->tax->charges->cre if (!$dateech) { - setEventMessages($langs->trans("ErrorFieldReqrequire_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; -uired", $langs->transnoentities("Date")), null, 'errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors'); $action = 'edit'; } elseif (!$dateperiod) { From 74ba7e68daa34d4ecd4f91c7c914822845b51e26 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 7 Jan 2021 06:27:36 +0100 Subject: [PATCH 7/8] Mix two systems for create and edit account from balance --- htdocs/accountancy/bookkeeping/balance.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index b049abb7652..0f77de7d331 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -322,8 +322,10 @@ if ($action != 'export_csv') $root_account_description = $tmparrayforrootaccount['label']; $root_account_number = $tmparrayforrootaccount['account_number']; - if (empty($tmparrayforrootaccount['label'])) { - $link = ''.img_edit_add().''; + if (empty($accountingaccountstatic->label) && $accountingaccountstatic->id > 0) { + $link = '' . img_edit() . ''; + } elseif (empty($tmparrayforrootaccount['label'])) { + $link = '' . img_edit_add() . ''; } if (!empty($show_subgroup)) From 560654222005e4796752dc4c24408788d511dab7 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 7 Jan 2021 06:59:40 +0100 Subject: [PATCH 8/8] FIX: Accountancy - Add control on required fields when we create an account --- htdocs/accountancy/admin/card.php | 188 +++++++++++---------- htdocs/accountancy/bookkeeping/balance.php | 2 +- 2 files changed, 103 insertions(+), 87 deletions(-) diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 029550192f0..c905ad25cd0 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; $error = 0; // Load translation files required by the page -$langs->loadLangs(array("bills", "accountancy")); +$langs->loadLangs(array("bills", "accountancy", "compta")); $mesg = ''; $action = GETPOST('action', 'aZ09'); @@ -41,7 +41,9 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $rowid = GETPOST('rowid', 'int'); $cancel = GETPOST('cancel', 'alpha'); -$accountingaccount = GETPOST('accountingaccount', 'alpha'); + +$account_number = GETPOST('account_number', 'string'); +$label = GETPOST('label', 'alpha'); // Security check if ($user->socid > 0) accessforbidden(); @@ -65,104 +67,118 @@ if (GETPOST('cancel', 'alpha')) if ($action == 'add' && $user->rights->accounting->chartofaccount) { if (!$cancel) { - $sql = 'SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$conf->global->CHARTOFACCOUNTS; - - dol_syslog('accountancy/admin/card.php:: $sql='.$sql); - $result = $db->query($sql); - $obj = $db->fetch_object($result); - - // Clean code - - // To manage zero or not at the end of the accounting account - if ($conf->global->ACCOUNTING_MANAGE_ZERO == 1) + if (!$account_number) { - $account_number = GETPOST('account_number', 'string'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountNumber")), null, 'errors'); + $action = 'create'; + } elseif (!$label) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); + $action = 'create'; } else { - $account_number = clean_account(GETPOST('account_number', 'string')); - } + $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS; - if (GETPOST('account_parent', 'int') <= 0) - { - $account_parent = 0; - } else { - $account_parent = GETPOST('account_parent', 'int'); - } + dol_syslog('accountancy/admin/card.php:: $sql=' . $sql); + $result = $db->query($sql); + $obj = $db->fetch_object($result); - $object->fk_pcg_version = $obj->pcg_version; - $object->pcg_type = GETPOST('pcg_type', 'alpha'); - $object->account_number = $account_number; - $object->account_parent = $account_parent; - $object->account_category = GETPOST('account_category', 'alpha'); - $object->label = GETPOST('label', 'alpha'); - $object->labelshort = GETPOST('labelshort', 'alpha'); - $object->active = 1; + // Clean code - $res = $object->create($user); - if ($res == - 3) { - $error = 1; - $action = "create"; - setEventMessages($object->error, $object->errors, 'errors'); - } elseif ($res == - 4) { - $error = 2; - $action = "create"; - setEventMessages($object->error, $object->errors, 'errors'); - } elseif ($res < 0) - { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - $action = "create"; - } - if (!$error) - { - setEventMessages("RecordCreatedSuccessfully", null, 'mesgs'); - $urltogo = $backtopage ? $backtopage : dol_buildpath('/accountancy/admin/account.php', 1); - header("Location: ".$urltogo); - exit; + // To manage zero or not at the end of the accounting account + if ($conf->global->ACCOUNTING_MANAGE_ZERO == 1) { + $account_number = $account_number; + } else { + $account_number = clean_account($account_number); + } + + if (GETPOST('account_parent', 'int') <= 0) { + $account_parent = 0; + } else { + $account_parent = GETPOST('account_parent', 'int'); + } + + $object->fk_pcg_version = $obj->pcg_version; + $object->pcg_type = GETPOST('pcg_type', 'alpha'); + $object->account_number = $account_number; + $object->account_parent = $account_parent; + $object->account_category = GETPOST('account_category', 'alpha'); + $object->label = $label; + $object->labelshort = GETPOST('labelshort', 'alpha'); + $object->active = 1; + + $res = $object->create($user); + if ($res == -3) { + $error = 1; + $action = "create"; + setEventMessages($object->error, $object->errors, 'errors'); + } elseif ($res == -4) { + $error = 2; + $action = "create"; + setEventMessages($object->error, $object->errors, 'errors'); + } elseif ($res < 0) { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + $action = "create"; + } + if (!$error) { + setEventMessages("RecordCreatedSuccessfully", null, 'mesgs'); + $urltogo = $backtopage ? $backtopage : dol_buildpath('/accountancy/admin/account.php', 1); + header("Location: " . $urltogo); + exit; + } } } } elseif ($action == 'edit' && $user->rights->accounting->chartofaccount) { if (!$cancel) { - $result = $object->fetch($id); - - $sql = 'SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$conf->global->CHARTOFACCOUNTS; - - dol_syslog('accountancy/admin/card.php:: $sql='.$sql); - $result2 = $db->query($sql); - $obj = $db->fetch_object($result2); - - // Clean code - - // To manage zero or not at the end of the accounting account - if ($conf->global->ACCOUNTING_MANAGE_ZERO == 1) + if (!$account_number) { - $account_number = GETPOST('account_number', 'string'); - } else { - $account_number = clean_account(GETPOST('account_number', 'string')); - } - - if (GETPOST('account_parent', 'int') <= 0) + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountNumber")), null, 'errors'); + $action = 'update'; + } elseif (!$label) { - $account_parent = 0; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); + $action = 'update'; } else { - $account_parent = GETPOST('account_parent', 'int'); - } + $result = $object->fetch($id); - $object->fk_pcg_version = $obj->pcg_version; - $object->pcg_type = GETPOST('pcg_type', 'alpha'); - $object->account_number = $account_number; - $object->account_parent = $account_parent; - $object->account_category = GETPOST('account_category', 'alpha'); - $object->label = GETPOST('label', 'alpha'); - $object->labelshort = GETPOST('labelshort', 'alpha'); + $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS; - $result = $object->update($user); + dol_syslog('accountancy/admin/card.php:: $sql=' . $sql); + $result2 = $db->query($sql); + $obj = $db->fetch_object($result2); - if ($result > 0) { - $urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id); - header("Location: ".$urltogo); - exit(); - } else { - $mesg = $object->error; + // Clean code + + // To manage zero or not at the end of the accounting account + if ($conf->global->ACCOUNTING_MANAGE_ZERO == 1) { + $account_number = $account_number; + } else { + $account_number = clean_account($account_number); + } + + if (GETPOST('account_parent', 'int') <= 0) { + $account_parent = 0; + } else { + $account_parent = GETPOST('account_parent', 'int'); + } + + $object->fk_pcg_version = $obj->pcg_version; + $object->pcg_type = GETPOST('pcg_type', 'alpha'); + $object->account_number = $account_number; + $object->account_parent = $account_parent; + $object->account_category = GETPOST('account_category', 'alpha'); + $object->label = $label; + $object->labelshort = GETPOST('labelshort', 'alpha'); + + $result = $object->update($user); + + if ($result > 0) { + $urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"] . "?id=" . $id); + header("Location: " . $urltogo); + exit(); + } else { + $mesg = $object->error; + } } } else { $urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id); @@ -222,7 +238,7 @@ if ($action == 'create') { // Account number print ''.$langs->trans("AccountNumber").''; - print ''; + print ''; // Label print ''.$langs->trans("Label").''; diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 0f77de7d331..fcd7efdab47 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -323,7 +323,7 @@ if ($action != 'export_csv') $root_account_number = $tmparrayforrootaccount['account_number']; if (empty($accountingaccountstatic->label) && $accountingaccountstatic->id > 0) { - $link = '' . img_edit() . ''; + $link = '' . img_edit() . ''; } elseif (empty($tmparrayforrootaccount['label'])) { $link = '' . img_edit_add() . ''; }