From 337689d5d2268ad63ad503179194ca7bcca8990c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 22 Feb 2021 21:36:42 +0100 Subject: [PATCH] code syntax --- htdocs/accountancy/admin/account.php | 262 ++++++++---- htdocs/accountancy/admin/accountmodel.php | 376 +++++++++------- htdocs/accountancy/admin/card.php | 29 +- htdocs/accountancy/admin/categories.php | 16 +- htdocs/accountancy/admin/categories_list.php | 404 ++++++++++-------- htdocs/accountancy/admin/closure.php | 1 - htdocs/accountancy/admin/defaultaccounts.php | 3 +- htdocs/accountancy/admin/export.php | 3 +- htdocs/accountancy/admin/fiscalyear.php | 30 +- htdocs/accountancy/admin/fiscalyear_card.php | 25 +- htdocs/accountancy/admin/fiscalyear_info.php | 6 +- htdocs/accountancy/admin/index.php | 1 + htdocs/accountancy/admin/journals_list.php | 321 ++++++++------ htdocs/accountancy/admin/productaccount.php | 243 +++++++---- htdocs/accountancy/admin/subaccount.php | 220 ++++++---- htdocs/accountancy/bookkeeping/balance.php | 78 ++-- .../bookkeeping/balancebymonth.php | 3 +- htdocs/accountancy/bookkeeping/card.php | 98 ++--- htdocs/accountancy/bookkeeping/list.php | 348 ++++++++------- .../accountancy/bookkeeping/listbyaccount.php | 228 ++++++---- .../bookkeeping/listbysubaccount.php | 22 +- .../thirdparty_lettering_customer.php | 1 - .../thirdparty_lettering_supplier.php | 1 - .../class/accountancycategory.class.php | 181 +++++--- .../class/accountancyexport.class.php | 137 +++--- .../class/accountancysystem.class.php | 3 +- .../class/accountingaccount.class.php | 134 +++--- .../class/accountingjournal.class.php | 88 ++-- .../accountancy/class/bookkeeping.class.php | 107 +++-- htdocs/accountancy/class/lettering.class.php | 18 +- htdocs/accountancy/closure/index.php | 43 +- htdocs/accountancy/customer/card.php | 16 +- htdocs/accountancy/customer/index.php | 93 ++-- htdocs/accountancy/customer/lines.php | 130 ++++-- htdocs/accountancy/customer/list.php | 190 +++++--- htdocs/accountancy/expensereport/card.php | 16 +- htdocs/accountancy/expensereport/index.php | 76 ++-- htdocs/accountancy/expensereport/lines.php | 84 ++-- htdocs/accountancy/expensereport/list.php | 104 +++-- htdocs/accountancy/index.php | 30 +- .../journal/expensereportsjournal.php | 139 +++--- .../accountancy/journal/purchasesjournal.php | 222 +++++----- htdocs/accountancy/journal/sellsjournal.php | 214 +++++----- htdocs/accountancy/supplier/card.php | 16 +- htdocs/accountancy/supplier/index.php | 85 ++-- htdocs/accountancy/supplier/lines.php | 137 ++++-- htdocs/accountancy/supplier/list.php | 187 +++++--- htdocs/accountancy/tpl/export_journal.tpl.php | 14 +- 48 files changed, 3052 insertions(+), 2131 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 47a984cd467..d84f546fb01 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -49,20 +49,30 @@ $search_pcgtype = GETPOST('search_pcgtype', 'alpha'); $chartofaccounts = GETPOST('chartofaccounts', 'int'); // Security check -if ($user->socid > 0) accessforbidden(); -if (!$user->rights->accounting->chartofaccount) accessforbidden(); +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 +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 = "aa.account_number"; -if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) { + $sortfield = "aa.account_number"; +} +if (!$sortorder) { + $sortorder = "ASC"; +} $arrayfields = array( 'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1), @@ -74,7 +84,9 @@ $arrayfields = array( 'aa.active'=>array('label'=>$langs->trans("Activated"), 'checked'=>1) ); -if ($conf->global->MAIN_FEATURES_LEVEL < 2) unset($arrayfields['aa.reconcilable']); +if ($conf->global->MAIN_FEATURES_LEVEL < 2) { + unset($arrayfields['aa.reconcilable']); +} $accounting = new AccountingAccount($db); @@ -84,21 +96,27 @@ $accounting = new AccountingAccount($db); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha')) { $massaction = ''; } +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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ - if (!empty($cancel)) $action = ''; +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 - { + 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_account = ""; $search_label = ""; $search_labelshort = ""; @@ -107,23 +125,21 @@ if (empty($reshook)) $search_array_options = array(); } if ((GETPOST('valid_change_chart', 'alpha') && GETPOST('chartofaccounts', 'int') > 0) // explicit click on button 'Change and load' with js on - || (GETPOST('chartofaccounts', 'int') > 0 && GETPOST('chartofaccounts', 'int') != $conf->global->CHARTOFACCOUNTS)) // a submit of form is done and chartofaccounts combo has been modified - { - if ($chartofaccounts > 0) - { + || (GETPOST('chartofaccounts', 'int') > 0 && GETPOST('chartofaccounts', 'int') != $conf->global->CHARTOFACCOUNTS)) { // a submit of form is done and chartofaccounts combo has been modified + if ($chartofaccounts > 0) { // Get language code for this $chartofaccounts $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_country as c, '.MAIN_DB_PREFIX.'accounting_system as a'; $sql .= ' WHERE c.rowid = a.fk_country AND a.rowid = '.(int) $chartofaccounts; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); $country_code = $obj->code; - } else dol_print_error($db); + } else { + dol_print_error($db); + } // Try to load sql file - if ($country_code) - { + if ($country_code) { $sqlfile = DOL_DOCUMENT_ROOT.'/install/mysql/data/llx_accounting_account_'.strtolower($country_code).'.sql'; $offsetforchartofaccount = 0; @@ -131,16 +147,14 @@ if (empty($reshook)) // and pass CCCNNNNN + (num of company * 100 000 000) as offset to the run_sql as a new parameter to say to update sql on the fly to add offset to rowid and account_parent value. // This is to be sure there is no conflict for each chart of account, whatever is country, whatever is company when multicompany is used. $tmp = file_get_contents($sqlfile); - if (preg_match('/-- ADD (\d+) to rowid/ims', $tmp, $reg)) - { + if (preg_match('/-- ADD (\d+) to rowid/ims', $tmp, $reg)) { $offsetforchartofaccount += $reg[1]; } $offsetforchartofaccount += ($conf->entity * 100000000); $result = run_sql($sqlfile, 1, $conf->entity, 1, '', 'default', 32768, 0, $offsetforchartofaccount); - if ($result > 0) - { + if ($result > 0) { setEventMessages($langs->trans("ChartLoaded"), null, 'mesgs'); } else { setEventMessages($langs->trans("ErrorDuringChartLoad"), null, 'warnings'); @@ -198,8 +212,11 @@ $sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.account_number, aa.a $sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = ".$conf->entity; -if ($db->type == 'pgsql') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity; -else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity; +if ($db->type == 'pgsql') { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity; +} else { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity; +} $sql .= " WHERE asy.rowid = ".$pcgver; //print $sql; if (strlen(trim($search_account))) { @@ -224,31 +241,38 @@ if (strlen(trim($search_account))) { $search_account_tmp_clean = $search_account_tmp; $search_account_clean = $search_account; $startchar = '%'; - if (strpos($search_account_tmp, '^') === 0) - { + if (strpos($search_account_tmp, '^') === 0) { $startchar = ''; $search_account_tmp_clean = preg_replace('/^\^/', '', $search_account_tmp); $search_account_clean = preg_replace('/^\^/', '', $search_account); } $sql .= " AND (aa.account_number LIKE '".$db->escape($startchar.$search_account_tmp_clean)."'"; $sql .= " OR aa.account_number LIKE '".$db->escape($startchar.$search_account_clean)."%')"; - } else $sql .= natural_search("aa.account_number", $search_account_tmp); + } else { + $sql .= natural_search("aa.account_number", $search_account_tmp); + } } } -if (strlen(trim($search_label))) $sql .= natural_search("aa.label", $search_label); -if (strlen(trim($search_labelshort))) $sql .= natural_search("aa.labelshort", $search_labelshort); -if (strlen(trim($search_accountparent)) && $search_accountparent != '-1') $sql .= natural_search("aa.account_parent", $search_accountparent, 2); -if (strlen(trim($search_pcgtype))) $sql .= natural_search("aa.pcg_type", $search_pcgtype); +if (strlen(trim($search_label))) { + $sql .= natural_search("aa.label", $search_label); +} +if (strlen(trim($search_labelshort))) { + $sql .= natural_search("aa.labelshort", $search_labelshort); +} +if (strlen(trim($search_accountparent)) && $search_accountparent != '-1') { + $sql .= natural_search("aa.account_parent", $search_accountparent, 2); +} +if (strlen(trim($search_pcgtype))) { + $sql .= natural_search("aa.pcg_type", $search_pcgtype); +} $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +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 - { + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -259,22 +283,36 @@ $sql .= $db->plimit($limit + 1, $offset); dol_syslog('accountancy/admin/account.php:: $sql='.$sql); $resql = $db->query($sql); -if ($resql) -{ +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_account) $param .= '&search_account='.urlencode($search_account); - if ($search_label) $param .= '&search_label='.urlencode($search_label); - if ($search_labelshort) $param .= '&search_labelshort='.urlencode($search_labelshort); - if ($search_accountparent > 0 || $search_accountparent == '0') $param .= '&search_accountparent='.urlencode($search_accountparent); - if ($search_pcgtype) $param .= '&search_pcgtype='.urlencode($search_pcgtype); - if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($search_account) { + $param .= '&search_account='.urlencode($search_account); + } + if ($search_label) { + $param .= '&search_label='.urlencode($search_label); + } + if ($search_labelshort) { + $param .= '&search_labelshort='.urlencode($search_labelshort); + } + if ($search_accountparent > 0 || $search_accountparent == '0') { + $param .= '&search_accountparent='.urlencode($search_accountparent); + } + if ($search_pcgtype) { + $param .= '&search_pcgtype='.urlencode($search_pcgtype); + } + if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); + } - if (!empty($conf->use_javascript_ajax)) - { + if (!empty($conf->use_javascript_ajax)) { print '