diff --git a/htdocs/accountancy/admin/subaccount.php b/htdocs/accountancy/admin/subaccount.php new file mode 100644 index 00000000000..fd6e33b6d00 --- /dev/null +++ b/htdocs/accountancy/admin/subaccount.php @@ -0,0 +1,417 @@ + + * Copyright (C) 2013-2020 Alexandre Spangaro + * Copyright (C) 2016-2018 Laurent Destailleur + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/accountancy/admin/subaccount.php + * \ingroup Accountancy (Double entries) + * \brief List of accounting sub-account (auxiliary accounts) + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; + +// Load translation files required by the page +$langs->loadLangs(array("compta", "bills", "admin", "accountancy", "salaries", "hrm", "errors")); + +$mesg = ''; +$action = GETPOST('action', 'aZ09'); +$cancel = GETPOST('cancel', 'alpha'); +$id = GETPOST('id', 'int'); +$rowid = GETPOST('rowid', 'int'); +$massaction = GETPOST('massaction', 'aZ09'); +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'accountingsubaccountlist'; // To manage different context of search + +$search_subaccount = GETPOST('search_subaccount', 'alpha'); +$search_label = GETPOST('search_label', 'alpha'); +$search_type = GETPOST('search_type', 'int'); + +// Security check +if ($user->socid > 0) accessforbidden(); +if (!$user->rights->accounting->chartofaccount) accessforbidden(); + +// Load variable for pagination +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (!$sortfield) $sortfield = "label"; +if (!$sortorder) $sortorder = "ASC"; + +$arrayfields = array( + 'subaccount'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1), + 'label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), + 'type'=>array('label'=>$langs->trans("Type"), 'checked'=>1), + 'reconcilable'=>array('label'=>$langs->trans("Reconcilable"), 'checked'=>1) +); + +if ($conf->global->MAIN_FEATURES_LEVEL < 2) unset($arrayfields['reconcilable']); + +/* + * Actions + */ + +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha')) { $massaction = ''; } + +$parameters = array(); +$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 (empty($reshook)) +{ + if (!empty($cancel)) $action = ''; + + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers + { + $search_subaccount = ""; + $search_label = ""; + $search_type = ""; + $search_array_options = array(); + } +} + + +/* + * View + */ + +$form = new Form($db); + +llxHeader('', $langs->trans("ReportThirdParty")); + +// Customer +$sql = "SELECT sa.rowid, sa.nom as label, sa.code_compta as subaccount, '0' as type, sa.entity"; +$sql .= " FROM ".MAIN_DB_PREFIX."societe sa"; +$sql .= " WHERE sa.entity IN (".getEntity('societe').")"; +$sql .= " AND sa.code_compta <> ''"; +//print $sql; +if (strlen(trim($search_subaccount))) { + $lengthpaddingaccount = 0; + if ($conf->global->ACCOUNTING_LENGTH_AACCOUNT) { + $lengthpaddingaccount = max($conf->global->ACCOUNTING_LENGTH_AACCOUNT); + } + $search_subaccount_tmp = $search_subaccount; + $weremovedsomezero = 0; + if (strlen($search_subaccount_tmp) <= $lengthpaddingaccount) { + for ($i = 0; $i < $lengthpaddingaccount; $i++) { + if (preg_match('/0$/', $search_subaccount_tmp)) { + $weremovedsomezero++; + $search_subaccount_tmp = preg_replace('/0$/', '', $search_subaccount_tmp); + } + } + } + + //var_dump($search_subaccount); exit; + if ($search_subaccount_tmp) { + if ($weremovedsomezero) { + $search_subaccount_tmp_clean = $search_subaccount_tmp; + $search_subaccount_clean = $search_subaccount; + $startchar = '%'; + if (strpos($search_subaccount_tmp, '^') === 0) + { + $startchar = ''; + $search_subaccount_tmp_clean = preg_replace('/^\^/', '', $search_subaccount_tmp); + $search_subaccount_clean = preg_replace('/^\^/', '', $search_subaccount); + } + $sql .= " AND (sa.code_compta LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean)."'"; + $sql .= " OR sa.code_compta LIKE '".$db->escape($startchar.$search_subaccount_clean)."%')"; + } else $sql .= natural_search("sa.code_compta", $search_subaccount_tmp); + } +} +if (strlen(trim($search_label))) $sql .= natural_search("sa.nom", $search_label); +if (!empty($search_type) && $search_type >= 0) $sql .= " HAVING type LIKE '".$db->escape($search_type)."'"; + +// Supplier +$sql .= " UNION "; +$sql .= " SELECT sa.rowid, sa.nom as label, sa.code_compta_fournisseur as subaccount, '1' as type, sa.entity FROM ".MAIN_DB_PREFIX."societe sa"; +$sql .= " WHERE sa.entity IN (".getEntity('societe').")"; +$sql .= " AND sa.code_compta_fournisseur <> ''"; +//print $sql; +if (strlen(trim($search_subaccount))) { + $lengthpaddingaccount = 0; + if ($conf->global->ACCOUNTING_LENGTH_AACCOUNT) { + $lengthpaddingaccount = max($conf->global->ACCOUNTING_LENGTH_AACCOUNT); + } + $search_subaccount_tmp = $search_subaccount; + $weremovedsomezero = 0; + if (strlen($search_subaccount_tmp) <= $lengthpaddingaccount) { + for ($i = 0; $i < $lengthpaddingaccount; $i++) { + if (preg_match('/0$/', $search_subaccount_tmp)) { + $weremovedsomezero++; + $search_subaccount_tmp = preg_replace('/0$/', '', $search_subaccount_tmp); + } + } + } + + //var_dump($search_subaccount); exit; + if ($search_subaccount_tmp) { + if ($weremovedsomezero) { + $search_subaccount_tmp_clean = $search_subaccount_tmp; + $search_subaccount_clean = $search_subaccount; + $startchar = '%'; + if (strpos($search_subaccount_tmp, '^') === 0) + { + $startchar = ''; + $search_subaccount_tmp_clean = preg_replace('/^\^/', '', $search_subaccount_tmp); + $search_subaccount_clean = preg_replace('/^\^/', '', $search_subaccount); + } + $sql .= " AND (sa.code_compta_fournisseur LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean)."'"; + $sql .= " OR sa.code_compta_fournisseur LIKE '".$db->escape($startchar.$search_subaccount_clean)."%')"; + } else $sql .= natural_search("sa.code_compta_fournisseur", $search_subaccount_tmp); + } +} +if (strlen(trim($search_label))) $sql .= natural_search("sa.nom", $search_label); +if (!empty($search_type) && $search_type >= 0) $sql .= " HAVING type LIKE '".$db->escape($search_type)."'"; + +// User +$sql .= " UNION "; +$sql .= " SELECT u.rowid, u.lastname as label, u.accountancy_code as subaccount, '2' as type, u.entity FROM ".MAIN_DB_PREFIX."user u"; +$sql .= " WHERE u.entity IN (".getEntity('user').")"; +$sql .= " AND u.accountancy_code <> ''"; +//print $sql; +if (strlen(trim($search_subaccount))) { + $lengthpaddingaccount = 0; + if ($conf->global->ACCOUNTING_LENGTH_AACCOUNT) { + $lengthpaddingaccount = max($conf->global->ACCOUNTING_LENGTH_AACCOUNT); + } + $search_subaccount_tmp = $search_subaccount; + $weremovedsomezero = 0; + if (strlen($search_subaccount_tmp) <= $lengthpaddingaccount) { + for ($i = 0; $i < $lengthpaddingaccount; $i++) { + if (preg_match('/0$/', $search_subaccount_tmp)) { + $weremovedsomezero++; + $search_subaccount_tmp = preg_replace('/0$/', '', $search_subaccount_tmp); + } + } + } + + //var_dump($search_subaccount); exit; + if ($search_subaccount_tmp) { + if ($weremovedsomezero) { + $search_subaccount_tmp_clean = $search_subaccount_tmp; + $search_subaccount_clean = $search_subaccount; + $startchar = '%'; + if (strpos($search_subaccount_tmp, '^') === 0) + { + $startchar = ''; + $search_subaccount_tmp_clean = preg_replace('/^\^/', '', $search_subaccount_tmp); + $search_subaccount_clean = preg_replace('/^\^/', '', $search_subaccount); + } + $sql .= " AND (u.accountancy_code LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean)."'"; + $sql .= " OR u.accountancy_code LIKE '".$db->escape($startchar.$search_subaccount_clean)."%')"; + } else $sql .= natural_search("u.accountancy_code", $search_subaccount_tmp); + } +} +if (strlen(trim($search_label))) $sql .= natural_search("u.lastname", $search_label); +if (!empty($search_type) && $search_type >= 0) $sql .= " HAVING type LIKE '".$db->escape($search_type)."'"; + +$sql .= $db->order($sortfield, $sortorder); + +// Count total nb of records +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } +} + +$sql .= $db->plimit($limit + 1, $offset); + +dol_syslog('accountancy/admin/subaccount.php:: $sql='.$sql); +$resql = $db->query($sql); + +if ($resql) +{ + $num = $db->num_rows($resql); + + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($search_subaccount) $param .= '&search_subaccount='.urlencode($search_subaccount); + if ($search_label) $param .= '&search_label='.urlencode($search_label); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + + print '
'; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print_barre_liste($langs->trans('ReportThirdParty'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit, 0, 0, 1); + + print '
'.$langs->trans("WarningCreateSubAccounts").'
'; + + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + + $moreforfilter = ''; + $massactionbutton = ''; + + print '
'; + print ''."\n"; + + // Line for search fields + print ''; + if (!empty($arrayfields['subaccount']['checked'])) print ''; + if (!empty($arrayfields['label']['checked'])) print ''; + if (!empty($arrayfields['type']['checked'])) print ''; + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['reconcilable']['checked'])) print ''; } + print ''; + print ''; + + print ''; + if (!empty($arrayfields['subaccount']['checked'])) print_liste_field_titre($arrayfields['subaccount']['label'], $_SERVER["PHP_SELF"], "subaccount", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['label']['checked'])) print_liste_field_titre($arrayfields['label']['label'], $_SERVER["PHP_SELF"], "label", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['type']['checked'])) print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "type", "", $param, '', $sortfield, $sortorder, 'center '); + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['reconcilable']['checked'])) print_liste_field_titre($arrayfields['reconcilable']['label'], $_SERVER["PHP_SELF"], 'reconcilable', '', $param, '', $sortfield, $sortorder, 'center '); } + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); + print "\n"; + + $totalarray = array(); + $i = 0; + while ($i < min($num, $limit)) + { + $obj = $db->fetch_object($resql); + + print ''; + + // Account number + if (!empty($arrayfields['subaccount']['checked'])) + { + print "\n"; + if (!$i) $totalarray['nbfield']++; + } + + // Subaccount label + if (!empty($arrayfields['label']['checked'])) + { + print "\n"; + if (!$i) $totalarray['nbfield']++; + } + + // Type + if (!empty($arrayfields['type']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { + // Activated or not reconciliation on accounting account + if (!empty($arrayfields['reconcilable']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + } + + // Action + print ''."\n"; + if (!$i) $totalarray['nbfield']++; + + print ''."\n"; + $i++; + } + + $db->free($resql); + + $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); + $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + print "
'.$form->selectarray('search_type', array('0'=>$langs->trans('Customer'), '1'=>$langs->trans('Supplier'), '2'=>$langs->trans('Employee')), $search_type, 1).' '; + $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); + print $searchpicto; + print '
"; + print length_accounta($obj->subaccount); + print ""; + print $obj->label; + print "'; + $s = ''; + // Customer + if ($obj->type == 0) + { + $s .= ''.$langs->trans("Customer").''; + } + // Supplier + elseif ($obj->type == 1) + { + $s .= ''.$langs->trans("Supplier").''; + } + // User + elseif ($obj->type == 2) + { + $s .= ''.$langs->trans("Employee").''; + } + print $s; + print ''; + if (empty($obj->reconcilable)) { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; + } else { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; + } + print ''; + $e = ''; + // Customer + if ($obj->type == 0) + { + $e .= ''.img_edit().''; + } + // Supplier + elseif ($obj->type == 1) + { + $e .= ''.img_edit().''; + } + // User + elseif ($obj->type == 2) + { + $e .= ''.img_edit().''; + } + print $e; + print '
"; + print "
"; + + print '
'; +} else { + dol_print_error($db); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index ef105b6709a..8ca880de25f 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -328,7 +328,7 @@ llxHeader('', $langs->trans("CreateMvts")); // Confirmation to delete the command if ($action == 'delete') { - $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"].'?id='.$id.'&mode='.$mode, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'confirm_delete', '', 0, 1); + $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"].'?id='.$id.'&mode='.$mode, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'confirm_delete', '', 0, 1); print $formconfirm; } diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 813dbd4a37f..642d47b09e4 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -108,7 +108,7 @@ $hookmanager->initHooks(array('bookkeepinglist')); $formaccounting = new FormAccounting($db); $form = new Form($db); -if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !isset($_POST['begin']) && !isset($_GET['begin']) && !isset($_POST['formfilteraction']) && GETPOST('page', 'int') == '' && !GETPOST('noreset', 'int') && $user->rights->accounting->mouvements->export) +if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !GETPOSTISSET('begin') && !isset($_POST['formfilteraction']) && GETPOST('page', 'int') == '' && !GETPOST('noreset', 'int') && $user->rights->accounting->mouvements->export) { if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values')) { @@ -529,7 +529,7 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) { $formother = new FormOther($db); $formfile = new FormFile($db); -$title_page = $langs->trans("Bookkeeping"); +$title_page = $langs->trans("Operations").' - '.$langs->trans("Journals"); // Count total nb of records $nbtotalofrecords = ''; @@ -608,22 +608,22 @@ if ($action == 'delbookkeepingyear') { 'default' => $deljournal ); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, '', 1, 300); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'delbookkeepingyearconfirm', $form_question, '', 1, 300); print $formconfirm; } //$param=''; param started before -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); print '
'; print ''; print ''; -if ($optioncss != '') print ''; +if ($optioncss != '') print ''; print ''; -print ''; -print ''; -print ''; +print ''; +print ''; +print ''; if (count($filter)) $buttonLabel = $langs->trans("ExportFilteredList"); else $buttonLabel = $langs->trans("ExportList"); @@ -638,7 +638,8 @@ $newcardbutton .= ''.$langs->trans("I $newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param ? '&'.$param : ''), $user->rights->accounting->mouvements->export); -$newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param, '', 1, array('morecss'=>'btnTitleSelected')); +$newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss'=>'marginleftonly')); $url = './card.php?action=create'; if (!empty($socid)) $url .= '&socid='.$socid; @@ -670,12 +671,10 @@ if (!empty($arrayfields['t.doc_date']['checked'])) { print ''; print '
'; - print $langs->trans('From').' '; - print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1); + print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); print '
'; print '
'; - print $langs->trans('to').' '; - print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1); + print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); print '
'; print ''; } @@ -703,25 +702,25 @@ if (!empty($arrayfields['t.subledger_account']['checked'])) { print ''; print '
'; - print $langs->trans('From').' '; // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not // use setup of keypress to select thirdparty and this hang browser on large database. if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { + print $langs->trans('From').' '; print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1); } else { - print ''; + print ''; } print '
'; print '
'; - print $langs->trans('to').' '; // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not // use setup of keypress to select thirdparty and this hang browser on large database. if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { + print $langs->trans('to').' '; print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); } else { - print ''; + print ''; } print '
'; print ''; @@ -771,12 +770,10 @@ if (!empty($arrayfields['t.date_creation']['checked'])) { print ''; print '
'; - print $langs->trans('From').' '; - print $form->selectDate($search_date_creation_start, 'date_creation_start', 0, 0, 1); + print $form->selectDate($search_date_creation_start, 'date_creation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); print '
'; print '
'; - print $langs->trans('to').' '; - print $form->selectDate($search_date_creation_end, 'date_creation_end', 0, 0, 1); + print $form->selectDate($search_date_creation_end, 'date_creation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); print '
'; print ''; } @@ -785,12 +782,10 @@ if (!empty($arrayfields['t.tms']['checked'])) { print ''; print '
'; - print $langs->trans('From').' '; - print $form->selectDate($search_date_modification_start, 'date_modification_start', 0, 0, 1); + print $form->selectDate($search_date_modification_start, 'date_modification_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); print '
'; print '
'; - print $langs->trans('to').' '; - print $form->selectDate($search_date_modification_end, 'date_modification_end', 0, 0, 1); + print $form->selectDate($search_date_modification_end, 'date_modification_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); print '
'; print ''; } @@ -799,12 +794,10 @@ if (!empty($arrayfields['t.date_export']['checked'])) { print ''; print '
'; - print $langs->trans('From').' '; - print $form->selectDate($search_date_export_start, 'date_export_start', 0, 0, 1); + print $form->selectDate($search_date_export_start, 'date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); print '
'; print '
'; - print $langs->trans('to').' '; - print $form->selectDate($search_date_export_end, 'date_export_end', 0, 0, 1); + print $form->selectDate($search_date_export_end, 'date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); print '
'; print ''; } diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index e0e16e00d12..4ed055be0b1 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -33,7 +33,6 @@ require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; // Load translation files required by the page @@ -55,6 +54,7 @@ if ($search_accountancy_code_end == - 1) { } $search_doc_ref = GETPOST('search_doc_ref', 'alpha'); $search_label_operation = GETPOST('search_label_operation', 'alpha'); +$search_mvt_num = GETPOST('search_mvt_num', 'int'); $search_direction = GETPOST('search_direction', 'alpha'); $search_ledger_code = GETPOST('search_ledger_code', 'alpha'); $search_debit = GETPOST('search_debit', 'alpha'); @@ -86,7 +86,7 @@ $hookmanager->initHooks(array('bookkeepingbyaccountlist')); $formaccounting = new FormAccounting($db); $form = new Form($db); -if (empty($search_date_start) && empty($search_date_end) && GETPOSTISSET('search_date_startday') && GETPOSTISSET('search_date_startmonth') && GETPOSTISSET('search_date_starthour')) { +if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('search_date_startday') && !GETPOSTISSET('search_date_startmonth') && !GETPOSTISSET('search_date_starthour')) { $sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; $sql .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'"; $sql .= $db->plimit(1); @@ -149,6 +149,7 @@ if (empty($reshook)) $search_label_account = ''; $search_doc_ref = ''; $search_label_operation = ''; + $search_mvt_num = ''; $search_direction = ''; $search_ledger_code = ''; $search_date_start = ''; @@ -193,6 +194,10 @@ if (empty($reshook)) $filter['t.label_compte'] = $search_label_account; $param .= '&search_label_compte=' . urlencode($search_label_account); } + if (!empty($search_mvt_num)) { + $filter['t.piece_num'] = $search_mvt_num; + $param .= '&search_mvt_num=' . urlencode($search_mvt_num); + } if (!empty($search_doc_ref)) { $filter['t.doc_ref'] = $search_doc_ref; $param .= '&search_doc_ref=' . urlencode($search_doc_ref); @@ -294,7 +299,7 @@ $formfile = new FormFile($db); $formother = new FormOther($db); $form = new Form($db); -$title_page = $langs->trans("Bookkeeping").' '.strtolower($langs->trans("By")).' '.strtolower($langs->trans("AccountAccounting")); +$title_page = $langs->trans("Operations").' - '.$langs->trans("VueByAccountAccounting").' ('.$langs->trans("Bookkeeping").')'; llxHeader('', $title_page); @@ -358,7 +363,7 @@ if ($action == 'delbookkeepingyear') { 'default' => $deljournal ); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, '', 1, 300); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'delbookkeepingyearconfirm', $form_question, '', 1, 300); print $formconfirm; } @@ -370,16 +375,19 @@ if ($optioncss != '') print ''; print ''; print ''; -print ''; -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param); +$newcardbutton .= dolGetButtonTitle($langs->trans('VueByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss'=>'marginleftonly btnTitleSelected')); + +$newcardbutton .= '   '; + $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create'); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); -print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $viewflat.$newcardbutton, '', $limit); +print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $viewflat.$newcardbutton, '', $limit, 0, 0, 1); $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields @@ -394,10 +402,10 @@ $moreforfilter = ''; // Accountancy account $moreforfilter .= '
'; $moreforfilter .= $langs->trans('AccountAccounting').': '; -$moreforfilter .= '
'; +$moreforfilter .= '
'; $moreforfilter .= $langs->trans('From').' '; $moreforfilter .= $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, 'maxwidth200'); -$moreforfilter .= $langs->trans('to').' '; +$moreforfilter .= ' '.$langs->trans('to').' '; $moreforfilter .= $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, 'maxwidth200'); $moreforfilter .= '
'; $moreforfilter .= '
'; @@ -425,12 +433,10 @@ if (!empty($arrayfields['t.code_journal']['checked'])) { if (!empty($arrayfields['t.doc_date']['checked'])) { print ''; print '
'; - print $langs->trans('From') . ': '; - print $form->selectDate($search_date_start, 'search_date_start', 0, 0, 1); + print $form->selectDate($search_date_start, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); print '
'; print '
'; - print $langs->trans('to') . ': '; - print $form->selectDate($search_date_end, 'search_date_end', 0, 0, 1); + print $form->selectDate($search_date_end, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); print '
'; print ''; } @@ -697,10 +703,10 @@ while ($i < min($num, $limit)) print ''; if (empty($line->date_export)) { if ($user->rights->accounting->mouvements->creer) { - print ''.img_edit().''; + print ''.img_edit().''; } if ($user->rights->accounting->mouvements->supprimer) { - print ' '.img_delete().''; + print '   '.img_delete().''; } } print ''; diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 24f14d2ebd2..199899f89d5 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -448,7 +448,7 @@ class AccountingAccount extends CommonObject * @param int $notooltip 1=Disable tooltip * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @param int $withcompletelabel 0=Short label (field short label), 1=Complete label (field label) - * @param string $option 'bookkeeping', 'bookkeepinglistbyaccount', 'accountcard' + * @param string $option 'ledger', 'journals', 'accountcard' * @return string String with URL */ public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1, $withcompletelabel = 0, $option = '') @@ -460,12 +460,12 @@ class AccountingAccount extends CommonObject $result = ''; - if (empty($option) || $option == 'bookkeeping') { - $url = DOL_URL_ROOT . '/accountancy/bookkeeping/list.php?search_accountancy_code_start=' . $this->account_number . '&search_accountancy_code_end=' . $this->account_number; - $labelurl = $langs->trans("ShowAccountingAccountInBookKeeping"); - } elseif ($option == 'bookkeepinglistbyaccount') { + if (empty($option) || $option == 'ledger') { $url = DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?search_accountancy_code_start=' . $this->account_number . '&search_accountancy_code_end=' . $this->account_number; - $labelurl = $langs->trans("ShowAccountingAccountInBookKeepingByAccount"); + $labelurl = $langs->trans("ShowAccountingAccountInLedger"); + } elseif ($option == 'journals') { + $url = DOL_URL_ROOT . '/accountancy/bookkeeping/list.php?search_accountancy_code_start=' . $this->account_number . '&search_accountancy_code_end=' . $this->account_number; + $labelurl = $langs->trans("ShowAccountingAccountInJournals"); } elseif ($option == 'accountcard') { $url = DOL_URL_ROOT . '/accountancy/admin/card.php?id=' . $this->id; $labelurl = $langs->trans("ShowAccountingAccount"); diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 1e1e42a6047..790aba68203 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2014-2017 Olivier Geffroy * Copyright (C) 2015-2017 Alexandre Spangaro * Copyright (C) 2015-2017 Florian Henry - * Copyright (C) 2018-2019 Frédéric France + * Copyright (C) 2018-2020 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -2006,8 +2006,22 @@ class BookKeepingLine public $label_operation; public $debit; public $credit; + + /** + * @var float Amount + * @deprecated see $amount + */ public $montant; - public $sens; + + /** + * @var float Amount + */ + public $amount; + + /** + * @var string Sens + */ + public $sens; public $lettering_code; /** diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 9396b02d518..ef4639e4b5e 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -436,7 +436,7 @@ if ($sall) { // Filter on categories $moreforfilter = ''; -if (!empty($conf->categorie->enabled)) { +if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; $moreforfilter .= $langs->trans('Categories').': '; diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 724a978996b..5909e4b5d5b 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -472,22 +472,22 @@ print '