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 1547983da0c..fcd7efdab47 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'); @@ -88,6 +88,7 @@ if (empty($search_date_start) && !GETPOSTISSET('formfilteraction')) } else { $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); $year_start = dol_print_date(dol_now(), '%Y'); + if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year $year_end = $year_start + 1; $month_end = $month_start - 1; if ($month_end < 1) @@ -322,7 +323,9 @@ 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() . ''; } if (!empty($show_subgroup)) 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'); 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; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 05149030f9e..62e95b2c001 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -621,6 +621,7 @@ if ($id == 11) // 'contract' => $langs->trans('Contract'), 'project' => $langs->trans('Project'), 'project_task' => $langs->trans('Task'), + 'ticket' => $langs->trans('Ticket'), 'agenda' => $langs->trans('Agenda'), 'dolresource' => $langs->trans('Resource'), // old deprecated @@ -1492,11 +1493,9 @@ if ($id) continue; } - if ($value == 'element') - { + if ($value == 'element') { $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow; - } elseif ($value == 'source') - { + } elseif ($value == 'source') { $valuetoshow = isset($sourceList[$valuetoshow]) ? $sourceList[$valuetoshow] : $valuetoshow; } elseif ($valuetoshow == 'all') { $valuetoshow = $langs->trans('All'); diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 5c170d0aa72..38e8b601cf6 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -181,8 +181,10 @@ if (empty($reshook)) unset($_POST['qty_frozen']); unset($_POST['disable_stock_change']); - $object->fetchLines(); - } + $object->fetchLines(); + + $object->calculateCosts(); + } } } @@ -221,7 +223,9 @@ if (empty($reshook)) unset($_POST['qty_frozen']); unset($_POST['disable_stock_change']); - $object->fetchLines(); + $object->fetchLines(); + + $object->calculateCosts(); } } } diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index d29cdb7c6bb..1f0a00cb4b8 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -113,7 +113,6 @@ if (!empty($conf->global->PRODUCT_USE_UNITS)) { $coldisplay++; print ''; - // print $form->selectUnits(empty($line->fk_unit) ? $conf->global->PRODUCT_USE_UNITS : $line->fk_unit, "units"); print ''; } diff --git a/htdocs/bom/tpl/objectline_edit.tpl.php b/htdocs/bom/tpl/objectline_edit.tpl.php index 77638b875ff..f31db94403b 100644 --- a/htdocs/bom/tpl/objectline_edit.tpl.php +++ b/htdocs/bom/tpl/objectline_edit.tpl.php @@ -112,7 +112,6 @@ if (!empty($conf->global->PRODUCT_USE_UNITS)) { $coldisplay++; print ''; - // print $form->selectUnits($line->fk_unit, "units"); print ''; } diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index 33f7f3a0352..467f6b7b78b 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -58,11 +58,15 @@ if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'banque', $fieldvalue, 'bank_account', '', '', $fieldtype); if (!$user->rights->banque->lire && !$user->rights->banque->consolidate) accessforbidden(); +$hookmanager->initHooks(array('bankline')); + /* * Actions */ - +$parameters = array('socid' => $socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($cancel) { if ($backtopage) diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php index 7e1b7fd0567..5aeec4f444c 100644 --- a/htdocs/compta/bank/transfer.php +++ b/htdocs/compta/bank/transfer.php @@ -40,11 +40,14 @@ if (!$user->rights->banque->transfer) $action = GETPOST('action', 'aZ09'); $error = 0; +$hookmanager->initHooks(array('banktransfer')); /* * Actions */ - +$parameters = array('socid' => $socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($action == 'add') { $langs->load("errors"); 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) { diff --git a/htdocs/core/boxes/box_birthdays.php b/htdocs/core/boxes/box_birthdays.php index 9a2ccd33cf7..ea83e022079 100644 --- a/htdocs/core/boxes/box_birthdays.php +++ b/htdocs/core/boxes/box_birthdays.php @@ -91,7 +91,7 @@ class box_birthdays extends ModeleBoxes $sql .= " WHERE u.entity IN (".getEntity('user').")"; $sql .= " AND u.statut = 1"; $sql .= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], 0); - $sql .= " ORDER BY u.birth ASC"; + $sql .= " ORDER BY DAY(u.birth) ASC"; $sql .= $this->db->plimit($max, 0); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); diff --git a/htdocs/core/boxes/box_birthdays_members.php b/htdocs/core/boxes/box_birthdays_members.php index 02a315ea836..56619fac581 100644 --- a/htdocs/core/boxes/box_birthdays_members.php +++ b/htdocs/core/boxes/box_birthdays_members.php @@ -91,7 +91,7 @@ class box_birthdays_members extends ModeleBoxes $sql .= " WHERE u.entity IN (".getEntity('adherent').")"; $sql .= " AND u.statut = 1"; $sql .= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], 0); - $sql .= " ORDER BY u.birth ASC"; + $sql .= " ORDER BY DAY(u.birth) ASC"; $sql .= $this->db->plimit($max, 0); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); diff --git a/htdocs/core/boxes/box_shipments.php b/htdocs/core/boxes/box_shipments.php index 5a1f093ce87..22b28d42761 100644 --- a/htdocs/core/boxes/box_shipments.php +++ b/htdocs/core/boxes/box_shipments.php @@ -105,6 +105,7 @@ class box_shipments extends ModeleBoxes if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; if (!empty($conf->global->ORDER_BOX_LAST_SHIPMENTS_VALIDATED_ONLY)) $sql .= " AND e.fk_statut = 1"; + if ($user->socid > 0) $sql.= " AND s.rowid = ".$user->socid; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND sc.fk_user = ".$user->id; else $sql .= " ORDER BY e.date_delivery, e.ref DESC "; $sql .= $this->db->plimit($max, 0); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 3bf47b7da7a..4ded311f7ed 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -680,7 +680,8 @@ function checkVal($out = '', $check = 'alphanohtml', $filter = null, $options = if (!is_array($out)) { // '"' is dangerous because param in url can close the href= or src= and add javascript functions. // '../' is dangerous because it allows dir transversals - $out = str_replace(array('"', '"', '../'), '', trim($out)); + $out = str_replace(array('"', '"'), "''", trim($out)); + $out = str_replace(array('../'), '', $out); // keep lines feed $out = dol_string_nohtmltag($out, 0); } diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 6698495f983..f3cffecdd9c 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -365,14 +365,15 @@ class pdf_rouget extends ModelePdfExpedition $tab_top_alt = $tab_top; $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, 0, 1, false, true, 'L'); - $tab_top_alt = $pdf->GetY(); //$tab_top_alt += 1; // Tracking number if (!empty($object->tracking_number)) { + $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, 0, 1, false, true, 'L'); + $tab_top_alt = $pdf->GetY(); + $object->getUrlTrackingStatus($object->tracking_number); if (!empty($object->tracking_url)) { diff --git a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php index 7bb8988e18e..55c128c2f0f 100644 --- a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php +++ b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php @@ -198,11 +198,21 @@ class InterfaceTicketEmail extends DolibarrTriggers if (empty($conf->global->TICKET_DISABLE_CUSTOMER_MAILS) && empty($object->context['disableticketemail']) && $object->notify_tiers_at_create) { $sendto = ''; - if (empty($user->socid) && empty($user->email)) { - $object->fetch_thirdparty(); - $sendto = $object->thirdparty->email; - } else { - $sendto = $user->email; + + //if contact selected send to email's contact else send to email's thirdparty + + $contactid = GETPOST('contactid', 'alpha'); + + if (!empty($contactid)) { + $contact = new Contact($this->db); + $res = $contact->fetch($contactid); + } + + if ($res > 0 && !empty($contact->email) && !empty($contact->statut)) { + $sendto = $contact->email; + } elseif (!empty($object->fk_soc)) { + $object->fetch_thirdparty(); + $sendto = $object->thirdparty->email; } if ($sendto) { diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 998ef884766..ab13801319f 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1079,7 +1079,7 @@ if (empty($reshook)) $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); - if (GETPOST('price_ht') != '') + if (GETPOST('price_ht') != '' || GETPOST('multicurrency_subprice') != '') { $up = price2num(GETPOST('price_ht')); $price_base_type = 'HT'; 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 diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 63e0fea2b36..b3381ea7ebe 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5428,7 +5428,6 @@ class Product extends CommonObject $langs->load('products'); $label_type = 'label'; - if ($type == 'short') { $label_type = 'short_label'; } diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 26b0eca9ee5..b2f7489cbfe 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -486,7 +486,11 @@ if ($resql) } } - llxHeader('', $title, $helpurl, ''); + foreach ($searchCategoryProductList as $searchCategoryProduct) { + $paramsCat .= "&search_category_product_list[]=".urlencode($searchCategoryProduct); + } + llxHeader('', $title, $helpurl, '', 0, 0, "", "", $paramsCat); + // Displays product removal confirmation if (GETPOST('delprod')) { diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index b1951affe7f..0e2b10bcb19 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1550,12 +1550,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } // Supplier - //if ($object->fournisseur) { - print ''.$form->editfieldkey('SuppliersCategoriesShort', 'suppcats', '', $object, 0).''; - $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, 'parent', null, null, 1); - print img_picto('', 'category').$form->multiselectarray('suppcats', $cate_arbo, GETPOST('suppcats', 'array'), null, null, 'quatrevingtpercent widthcentpercentminusx', 0, 0); - print ""; - //} + if (!empty($conf->fournisseur->enabled)) { + print ''.$form->editfieldkey('SuppliersCategoriesShort', 'suppcats', '', $object, 0).''; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, 'parent', null, null, 1); + print img_picto('', 'category').$form->multiselectarray('suppcats', $cate_arbo, GETPOST('suppcats', 'array'), null, null, 'quatrevingtpercent widthcentpercentminusx', 0, 0); + print ""; + } } // Multicurrency @@ -2170,17 +2170,19 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print ""; // Supplier - print ''.$form->editfieldkey('SuppliersCategoriesShort', 'suppcats', '', $object, 0).''; - print ''; - $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, null, null, null, 1); - $c = new Categorie($db); - $cats = $c->containing($object->id, Categorie::TYPE_SUPPLIER); - $arrayselected = array(); - foreach ($cats as $cat) { - $arrayselected[] = $cat->id; + if (!empty($conf->fournisseur->enabled)) { + print ''.$form->editfieldkey('SuppliersCategoriesShort', 'suppcats', '', $object, 0).''; + print ''; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, null, null, null, 1); + $c = new Categorie($db); + $cats = $c->containing($object->id, Categorie::TYPE_SUPPLIER); + $arrayselected = array(); + foreach ($cats as $cat) { + $arrayselected[] = $cat->id; + } + print img_picto('', 'category').$form->multiselectarray('suppcats', $cate_arbo, $arrayselected, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); + print ""; } - print img_picto('', 'category').$form->multiselectarray('suppcats', $cate_arbo, $arrayselected, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); - print ""; } // Multicurrency @@ -2546,7 +2548,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) } // Supplier - if ($object->fournisseur) { + if (!empty($conf->fournisseur->enabled) && $object->fournisseur) { print ''.$langs->trans("SuppliersCategoriesShort").''; print ''; print $form->showCategories($object->id, Categorie::TYPE_SUPPLIER, 1); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 91cc0cb1e13..38676044ca3 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3658,8 +3658,8 @@ class Societe extends CommonObject */ public function create_from_member(Adherent $member, $socname = '', $socalias = '', $customercode = '') { - // phpcs:enable - global $user, $langs; + // phpcs:enable + global $conf, $user, $langs; dol_syslog(get_class($this)."::create_from_member", LOG_DEBUG); @@ -3693,6 +3693,23 @@ class Societe extends CommonObject // Cree et positionne $this->id $result = $this->create($user); if ($result >= 0) { + // Auto-create contact on thirdparty creation + if (!empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT)) { + // Fill fields needed by contact + $this->name_bis = $member->lastname; + $this->firstname = $member->firstname; + $this->civility_id = $member->civility_id; + + dol_syslog("We ask to create a contact/address too", LOG_DEBUG); + $result = $this->create_individual($user); + if ($result < 0) + { + setEventMessages($this->error, $this->errors, 'errors'); + $this->db->rollback(); + return -1; + } + } + $sql = "UPDATE ".MAIN_DB_PREFIX."adherent"; $sql .= " SET fk_soc=".$this->id; $sql .= " WHERE rowid=".$member->id; diff --git a/htdocs/user/list.php b/htdocs/user/list.php index 9a1a06f5a17..9c63dc3e664 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) diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index 3eda8354113..d2405e9609d 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -294,20 +294,20 @@ class SecurityTest extends PHPUnit\Framework\TestCase $result=GETPOST("param1", 'int'); print __METHOD__." result=".$result."\n"; - $this->assertEquals($result, 222); + $this->assertEquals($result, 222, 'Test on param1 with no 3rd param'); $result=GETPOST("param1", 'int', 2); print __METHOD__." result=".$result."\n"; - $this->assertEquals($result, 333); + $this->assertEquals($result, 333, 'Test on param1 with 3rd param = 2'); // Test alpha $result=GETPOST("param2", 'alpha'); print __METHOD__." result=".$result."\n"; - $this->assertEquals($result, $_GET["param2"]); + $this->assertEquals($result, $_GET["param2"], 'Test on param2'); $result=GETPOST("param3", 'alpha'); // Must return string sanitized from char " print __METHOD__." result=".$result."\n"; - $this->assertEquals($result, 'na/b#e(pr)qq-rr\cc'); + $this->assertEquals($result, '\'\'na/b#e(pr)qq-rr\cc', 'Test on param3'); $result=GETPOST("param4", 'alpha'); // Must return string sanitized from ../ print __METHOD__." result=".$result."\n"; @@ -346,7 +346,7 @@ class SecurityTest extends PHPUnit\Framework\TestCase // With alphanohtml, we must convert the html entities like n $result=GETPOST("param8", 'alphanohtml'); print __METHOD__." result=".$result."\n"; - $this->assertEquals("HackerassertEquals("Hacker