diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 02098e986ba..67faa375d04 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -25,7 +25,9 @@ */ if ((array_key_exists('action', $_GET) && $_GET['action'] == 'dl') || (array_key_exists('action', $_POST) && $_POST['action'] == 'dl')) { // To not replace token when downloading file - if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); + if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', '1'); + } } require '../main.inc.php'; @@ -70,12 +72,18 @@ $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 = "date,item"; // Set here default search field -if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) { + $sortfield = "date,item"; // Set here default search field +} +if (!$sortorder) { + $sortorder = "DESC"; +} $arrayfields = array( @@ -111,7 +119,9 @@ if (!empty($conf->multicompany->enabled) && is_object($mc)) { $entity = '0,'.join(',', array_keys($arrayofentities)); } } -if (empty($entity)) $entity = $conf->entity; +if (empty($entity)) { + $entity = $conf->entity; +} $error = 0; @@ -129,26 +139,25 @@ $error = 0; $filesarray = array(); $result = false; if (($action == 'searchfiles' || $action == 'dl')) { - if (empty($date_start)) - { + if (empty($date_start)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateStart")), null, 'errors'); $error++; } - if (empty($date_stop)) - { + if (empty($date_stop)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateEnd")), null, 'errors'); $error++; } - if (!$error) - { + if (!$error) { $sql = ''; $wheretail = " '".$db->idate($date_start)."' AND '".$db->idate($date_stop)."'"; // Customer invoices if (GETPOST('selectinvoices')) { - if (!empty($sql)) $sql .= " UNION ALL"; + if (!empty($sql)) { + $sql .= " UNION ALL"; + } $sql .= "SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total as total_ht, t.total_ttc, t.tva as total_vat, t.multicurrency_code as currency, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum, ".PAY_CREDIT." as sens"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; $sql .= " WHERE datef between ".$wheretail; @@ -157,7 +166,9 @@ if (($action == 'searchfiles' || $action == 'dl')) { } // Vendor invoices if (GETPOST('selectsupplierinvoices')) { - if (!empty($sql)) $sql .= " UNION ALL"; + if (!empty($sql)) { + $sql .= " UNION ALL"; + } $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.multicurrency_code as currency, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum, ".PAY_DEBIT." as sens"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; $sql .= " WHERE datef between ".$wheretail; @@ -166,7 +177,9 @@ if (($action == 'searchfiles' || $action == 'dl')) { } // Expense reports if (GETPOST('selectexpensereports')) { - if (!empty($sql)) $sql .= " UNION ALL"; + if (!empty($sql)) { + $sql .= " UNION ALL"; + } $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.multicurrency_code as currency, t.fk_user_author as fk_soc, t.date_fin as date, t.date_fin as date_due, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_DEBIT." as sens"; $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user_author LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; $sql .= " WHERE date_fin between ".$wheretail; @@ -175,7 +188,9 @@ if (($action == 'searchfiles' || $action == 'dl')) { } // Donations if (GETPOST('selectdonations')) { - if (!empty($sql)) $sql .= " UNION ALL"; + if (!empty($sql)) { + $sql .= " UNION ALL"; + } $sql .= " SELECT t.rowid as id, t.entity, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.datedon as date, t.datedon as date_due, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_CREDIT." as sens"; $sql .= " FROM ".MAIN_DB_PREFIX."don as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_country"; $sql .= " WHERE datedon between ".$wheretail; @@ -184,7 +199,9 @@ if (($action == 'searchfiles' || $action == 'dl')) { } // Payments of salaries if (GETPOST('selectpaymentsofsalaries')) { - if (!empty($sql)) $sql .= " UNION ALL"; + if (!empty($sql)) { + $sql .= " UNION ALL"; + } $sql .= " SELECT t.rowid as id, t.entity, t.label as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, t.fk_user as fk_soc, t.datep as date, t.dateep as date_due, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_DEBIT." as sens"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; $sql .= " WHERE datep between ".$wheretail; @@ -193,7 +210,9 @@ if (($action == 'searchfiles' || $action == 'dl')) { } // Social contributions if (GETPOST('selectsocialcontributions')) { - if (!empty($sql)) $sql .= " UNION ALL"; + if (!empty($sql)) { + $sql .= " UNION ALL"; + } $sql .= " SELECT t.rowid as id, t.entity, t.libelle as ref, t.paye as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.date_ech as date, t.periode as date_due, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, ".PAY_DEBIT." as sens"; $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as t"; $sql .= " WHERE t.date_ech between ".$wheretail; @@ -202,7 +221,9 @@ if (($action == 'searchfiles' || $action == 'dl')) { } // Various payments if (GETPOST('selectvariouspayment')) { - if (!empty($sql)) $sql .= " UNION ALL"; + if (!empty($sql)) { + $sql .= " UNION ALL"; + } $sql .= " SELECT t.rowid as id, t.entity, t.ref, 1 as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.datep as date, t.datep as date_due, 'VariousPayment' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, sens"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_various as t"; $sql .= " WHERE datep between ".$wheretail; @@ -210,7 +231,9 @@ if (($action == 'searchfiles' || $action == 'dl')) { } // Loan payments if (GETPOST('selectloanspayment')) { - if (!empty($sql)) $sql .= " UNION ALL"; + if (!empty($sql)) { + $sql .= " UNION ALL"; + } $sql .= " SELECT t.rowid as id, l.entity, l.label as ref, 1 as paid, (t.amount_capital+t.amount_insurance+t.amount_interest) as total_ht, (t.amount_capital+t.amount_insurance+t.amount_interest) as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.datep as date, t.datep as date_due, 'LoanPayment' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, ".PAY_DEBIT." as sens"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_loan as t LEFT JOIN ".MAIN_DB_PREFIX."loan as l ON l.rowid = t.fk_loan"; $sql .= " WHERE datep between ".$wheretail; @@ -225,8 +248,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { $files = array(); $link = ''; - if ($resd) - { + if ($resd) { $numd = $db->num_rows($resd); $tmpinvoice = new Facture($db); @@ -235,12 +257,10 @@ if (($action == 'searchfiles' || $action == 'dl')) { $upload_dir = ''; $i = 0; - while ($i < $numd) - { + while ($i < $numd) { $objd = $db->fetch_object($resd); - switch ($objd->item) - { + switch ($objd->item) { case "Invoice": $subdir = ''; $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); @@ -306,15 +326,13 @@ if (($action == 'searchfiles' || $action == 'dl')) { break; } - if (!empty($upload_dir)) - { + if (!empty($upload_dir)) { $result = true; $files = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', '', SORT_ASC, 1); //var_dump($upload_dir); //var_dump($files); - if (count($files) < 1) - { + if (count($files) < 1) { $nofile = array(); $nofile['id'] = $objd->id; $nofile['entity'] = $objd->entity; @@ -335,8 +353,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { $filesarray[$nofile['item'].'_'.$nofile['id']] = $nofile; } else { - foreach ($files as $key => $file) - { + foreach ($files as $key => $file) { $file['id'] = $objd->id; $file['entity'] = $objd->entity; $file['date'] = $db->idate($objd->date); @@ -399,17 +416,14 @@ if (($action == 'searchfiles' || $action == 'dl')) { */ $dirfortmpfile = ($conf->accounting->dir_temp ? $conf->accounting->dir_temp : $conf->comptabilite->dir_temp); -if (empty($dirfortmpfile)) -{ +if (empty($dirfortmpfile)) { setEventMessages($langs->trans("ErrorNoAccountingModuleEnabled"), null, 'errors'); $error++; } -if ($result && $action == "dl" && !$error) -{ - if (!extension_loaded('zip')) - { +if ($result && $action == "dl" && !$error) { + if (!extension_loaded('zip')) { setEventMessages('PHPZIPExtentionNotLoaded', null, 'errors'); exit; } @@ -417,8 +431,7 @@ if ($result && $action == "dl" && !$error) dol_mkdir($dirfortmpfile); $log = $langs->transnoentitiesnoconv("Type"); - if (!empty($conf->multicompany->enabled) && is_object($mc)) - { + if (!empty($conf->multicompany->enabled) && is_object($mc)) { $log .= ','.$langs->transnoentitiesnoconv("Entity"); } $log .= ','.$langs->transnoentitiesnoconv("Date"); @@ -441,10 +454,8 @@ if ($result && $action == "dl" && !$error) $zip = new ZipArchive; $res = $zip->open($zipname, ZipArchive::OVERWRITE | ZipArchive::CREATE); - if ($res) - { - foreach ($filesarray as $key => $file) - { + if ($res) { + foreach ($filesarray as $key => $file) { if (!empty($file['files'])) { foreach ($file['files'] as $filecursor) { if (file_exists($filecursor["fullname"])) { @@ -454,8 +465,7 @@ if ($result && $action == "dl" && !$error) } $log .= '"'.$langs->trans($file['item']).'"'; - if (!empty($conf->multicompany->enabled) && is_object($mc)) - { + if (!empty($conf->multicompany->enabled) && is_object($mc)) { $log .= ',"'.(empty($arrayofentities[$file['entity']]) ? $file['entity'] : $arrayofentities[$file['entity']]).'"'; } $log .= ','.dol_print_date($file['date'], 'dayrfc'); @@ -532,8 +542,7 @@ print $langs->trans("ReportPeriod").': '.$form->selectDate($date_start, 'date_st print ' - '.$form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0)."\n"; // Export is for current company only -if (!empty($conf->multicompany->enabled) && is_object($mc)) -{ +if (!empty($conf->multicompany->enabled) && is_object($mc)) { $mc->getInfo($conf->entity); print '('.$langs->trans("Entity").' : '; print ""; @@ -559,7 +568,9 @@ $listofchoices = array( 'selectloanspayment'=>array('label'=>'PaymentLoan', 'enabled' => !empty($conf->loan->enabled)), ); foreach ($listofchoices as $choice => $val) { - if (empty($val['enabled'])) continue; // list not qualified + if (empty($val['enabled'])) { + continue; // list not qualified + } $checked = (((!GETPOSTISSET('search') && $action != 'searchfiles') || GETPOST($choice)) ? ' checked="checked"' : ''); print '
'; } @@ -570,8 +581,7 @@ print ''."\n"; print dol_get_fiche_end(); -if (!empty($date_start) && !empty($date_stop)) -{ +if (!empty($date_start) && !empty($date_stop)) { $param = 'action=searchfiles'; $param .= '&date_startday='.GETPOST('date_startday', 'int'); $param .= '&date_startmonth='.GETPOST('date_startmonth', 'int'); @@ -614,14 +624,14 @@ if (!empty($date_start) && !empty($date_stop)) print ''.$langs->trans("Code").''; print ''.$langs->trans("Country").''; print ''.$langs->trans("VATIntra").''; - if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans("Currency").''; + if (!empty($conf->multicurrency->enabled)) { + print ''.$langs->trans("Currency").''; + } print ''; - if ($result) - { + if ($result) { $TData = dol_sort_array($filesarray, $sortfield, $sortorder); - if (empty($TData)) - { + if (empty($TData)) { print ''.$langs->trans("NoItem").''; if (!empty($conf->multicurrency->enabled)) { print ''; @@ -638,8 +648,7 @@ if (!empty($date_start) && !empty($date_stop)) $totalVAT_credit = 0; // Display array - foreach ($TData as $data) - { + foreach ($TData as $data) { $html_class = ''; //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture']; //elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement']; @@ -708,9 +717,8 @@ if (!empty($date_start) && !empty($date_stop)) // File link print ''; - if (!empty($data['files'])) - { - foreach ($data['files'] as $id=>$filecursor) { + if (!empty($data['files'])) { + foreach ($data['files'] as $id => $filecursor) { print ''.($filecursor['name'] ? $filecursor['name'] : $filecursor['ref']).' '.$formfile->showPreview($filecursor, $filecursor['modulepart'], $filecursor['subdir'].'/'.$filecursor['name']).'
'; } } diff --git a/htdocs/compta/ajaxpayment.php b/htdocs/compta/ajaxpayment.php index 0129d1e5f43..d22e1a0182a 100644 --- a/htdocs/compta/ajaxpayment.php +++ b/htdocs/compta/ajaxpayment.php @@ -20,11 +20,21 @@ * \brief File to return Ajax response on payment breakdown process */ -if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); -if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); -if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show -if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +if (!defined('NOREQUIRESOC')) { + define('NOREQUIRESOC', '1'); +} +if (!defined('NOCSRFCHECK')) { + define('NOCSRFCHECK', '1'); +} +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', '1'); +} +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', '1'); // If there is no menu to show +} +if (!defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +} require '../main.inc.php'; @@ -46,18 +56,20 @@ $currentInvId = $_POST['imgClicked']; // from DOM elements : imgId (equals invoi $amountPayment = $amountPayment != '' ? (is_numeric(price2num($amountPayment)) ? price2num($amountPayment) : '') : ''; // keep void if not a valid entry // Clean checkamounts -foreach ($amounts as $key => $value) -{ +foreach ($amounts as $key => $value) { $value = price2num($value); $amounts[$key] = $value; - if (empty($value)) unset($amounts[$key]); + if (empty($value)) { + unset($amounts[$key]); + } } // Clean remains -foreach ($remains as $key => $value) -{ +foreach ($remains as $key => $value) { $value = price2num($value); $remains[$key] = (($invoice_type) == 2 ?-1 : 1) * $value; - if (empty($value)) unset($remains[$key]); + if (empty($value)) { + unset($remains[$key]); + } } // Treatment @@ -65,19 +77,16 @@ $result = ($amountPayment != '') ? ($amountPayment - array_sum($amounts)) : arra $toJsonArray = array(); $totalRemaining = price2num(array_sum($remains)); $toJsonArray['label'] = $amountPayment == '' ? '' : $langs->transnoentities('RemainingAmountPayment'); -if ($currentInvId) // Here to breakdown -{ +if ($currentInvId) { // Here to breakdown // Get the current amount (from form) and the corresponding remainToPay (from invoice) $currentAmount = $amounts['amount_'.$currentInvId]; $currentRemain = $remains['remain_'.$currentInvId]; // If amountPayment isn't filled, breakdown invoice amount, else breakdown from amountPayment - if ($amountPayment == '') - { + if ($amountPayment == '') { // Check if current amount exists in amounts $amountExists = array_key_exists('amount_'.$currentInvId, $amounts); - if ($amountExists) - { + if ($amountExists) { $remainAmount = $currentRemain - $currentAmount; // To keep value between curRemain and curAmount $result += $remainAmount; // result must be deduced by $currentAmount += $remainAmount; // curAmount put to curRemain @@ -90,8 +99,7 @@ if ($currentInvId) // Here to breakdown $result += price2num($currentAmount); $currentAmount = 0; - if ($result >= 0) // then we need to calculate the amount to breakdown - { + if ($result >= 0) { // then we need to calculate the amount to breakdown $amountToBreakdown = ($result - $currentRemain >= 0 ? $currentRemain : // Remain can be fully paid $currentRemain + ($result - $currentRemain)); // Remain can only partially be paid diff --git a/htdocs/compta/bank/account_statement_document.php b/htdocs/compta/bank/account_statement_document.php index b1c5c937f76..929a7a483bb 100644 --- a/htdocs/compta/bank/account_statement_document.php +++ b/htdocs/compta/bank/account_statement_document.php @@ -47,26 +47,30 @@ if ($user->socid) { $action = ''; $socid = $user->socid; } -if ($user->socid) +if ($user->socid) { $socid = $user->socid; +} // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } +if (empty($page) || $page == -1) { + $page = 0; +} $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortorder) +if (!$sortorder) { $sortorder = "ASC"; -if (!$sortfield) +} +if (!$sortfield) { $sortfield = "name"; +} $object = new Account($db); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); $account = $object->id; // Force the search field on id of account } @@ -75,8 +79,7 @@ $result = restrictedArea($user, 'banque', $object->id, 'bank_account', '', ''); // Define number of receipt to show (current, previous or next one ?) $found = false; -if ($_GET["rel"] == 'prev') -{ +if ($_GET["rel"] == 'prev') { // Recherche valeur pour num = numero releve precedent $sql = "SELECT DISTINCT(b.num_releve) as num"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; @@ -86,18 +89,15 @@ if ($_GET["rel"] == 'prev') dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $numrows = $db->num_rows($resql); - if ($numrows > 0) - { + if ($numrows > 0) { $obj = $db->fetch_object($resql); $numref = $obj->num; $found = true; } } -} elseif ($_GET["rel"] == 'next') -{ +} elseif ($_GET["rel"] == 'next') { // Recherche valeur pour num = numero releve precedent $sql = "SELECT DISTINCT(b.num_releve) as num"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; @@ -107,11 +107,9 @@ if ($_GET["rel"] == 'prev') dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $numrows = $db->num_rows($resql); - if ($numrows > 0) - { + if ($numrows > 0) { $obj = $db->fetch_object($resql); $numref = $obj->num; $found = true; @@ -127,8 +125,7 @@ if ($_GET["rel"] == 'prev') * Actions */ -if (!empty($numref)) -{ +if (!empty($numref)) { $object->fetch_thirdparty(); $upload_dir = $conf->bank->dir_output."/".$id."/statement/".dol_sanitizeFileName($numref); } diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index a0650e9ffa4..45ae92480a0 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -41,13 +41,14 @@ $ref = GETPOST('ref'); // Security check $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'banque', $fieldvalue, 'bank_account&bank_account', '', '', $fieldtype); $year_start = GETPOST('year_start'); $year_current = strftime("%Y", time()); -if (!$year_start) -{ +if (!$year_start) { $year_start = $year_current - 2; $year_end = $year_current; } else { @@ -68,13 +69,11 @@ $form = new Form($db); // Get account informations $object = new Account($db); -if ($id > 0 && !preg_match('/,/', $id)) // if for a particular account and not a list -{ +if ($id > 0 && !preg_match('/,/', $id)) { // if for a particular account and not a list $result = $object->fetch($id); $id = $object->id; } -if (!empty($ref)) -{ +if (!empty($ref)) { $result = $object->fetch(0, $ref); $id = $object->id; } @@ -90,17 +89,16 @@ $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql .= " WHERE b.fk_account = ba.rowid"; $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; $sql .= " AND b.amount >= 0"; -if (!empty($id)) +if (!empty($id)) { $sql .= " AND b.fk_account IN (".$db->sanitize($db->escape($id)).")"; +} $sql .= " GROUP BY dm"; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $row = $db->fetch_row($resql); $encaiss[$row[1]] = $row[0]; $i++; @@ -116,17 +114,16 @@ $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql .= " WHERE b.fk_account = ba.rowid"; $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; $sql .= " AND b.amount <= 0"; -if (!empty($id)) +if (!empty($id)) { $sql .= " AND b.fk_account IN (".$db->sanitize($db->escape($id)).")"; +} $sql .= " GROUP BY dm"; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $row = $db->fetch_row($resql); $decaiss[$row[1]] = -$row[0]; $i++; @@ -146,20 +143,19 @@ $link = ($year_start ? "'.$langs->trans("BackToList").''; -if (!empty($id)) -{ - if (!preg_match('/,/', $id)) - { +if (!empty($id)) { + if (!preg_match('/,/', $id)) { dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); } else { $bankaccount = new Account($db); $listid = explode(',', $id); - foreach ($listid as $key => $aId) - { + foreach ($listid as $key => $aId) { $bankaccount->fetch($aId); $bankaccount->label = $bankaccount->ref; print $bankaccount->getNomUrl(1); - if ($key < (count($listid) - 1)) print ', '; + if ($key < (count($listid) - 1)) { + print ', '; + } } } } else { @@ -176,39 +172,33 @@ print '
'; // You can use div-table-responsive- print ''; print ''; -for ($annee = $year_start; $annee <= $year_end; $annee++) -{ +for ($annee = $year_start; $annee <= $year_end; $annee++) { print ''; } print ''; print ''; print ''; -for ($annee = $year_start; $annee <= $year_end; $annee++) -{ +for ($annee = $year_start; $annee <= $year_end; $annee++) { print ''; } print ''; -for ($mois = 1; $mois < 13; $mois++) -{ +for ($mois = 1; $mois < 13; $mois++) { print ''; print ""; - for ($annee = $year_start; $annee <= $year_end; $annee++) - { + for ($annee = $year_start; $annee <= $year_end; $annee++) { $case = sprintf("%04s-%02s", $annee, $mois); print '"; print '"; -for ($annee = $year_start; $annee <= $year_end; $annee++) -{ +for ($annee = $year_start; $annee <= $year_end; $annee++) { print ''; } print "\n"; @@ -239,14 +228,16 @@ $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql .= " WHERE b.fk_account = ba.rowid"; $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; -if (!empty($id)) +if (!empty($id)) { $sql .= " AND b.fk_account IN (".$db->sanitize($db->escape($id)).")"; +} $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) $balance = $obj->total; + if ($obj) { + $balance = $obj->total; + } } else { dol_print_error($db); } @@ -264,8 +255,7 @@ print "
'.$langs->trans("Month").''.$annee.'
 '.$langs->trans("Debit").''.$langs->trans("Credit").'
".dol_print_date(dol_mktime(1, 1, 1, $mois, 1, 2000), "%B")." '; - if ($decaiss[$case] > 0) - { + if ($decaiss[$case] > 0) { print price($decaiss[$case]); $totsorties[$annee] += $decaiss[$case]; } print " '; - if ($encaiss[$case] > 0) - { + if ($encaiss[$case] > 0) { print price($encaiss[$case]); $totentrees[$annee] += $encaiss[$case]; } @@ -219,8 +209,7 @@ for ($mois = 1; $mois < 13; $mois++) // Total debit-credit print '
'.$langs->trans("Total")."'.price($totsorties[$annee]).''.price($totentrees[$annee]).'
"; $year = $year_end; $result = dol_mkdir($conf->bank->dir_temp); -if ($result < 0) -{ +if ($result < 0) { $langs->load("errors"); $error++; setEventMessages($langs->trans("ErrorFailedToCreateDir"), null, 'errors'); @@ -276,11 +266,12 @@ if ($result < 0) $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql .= " WHERE b.fk_account = ba.rowid"; $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; - if ($id && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$id.")"; + if ($id && $_GET["option"] != 'all') { + $sql .= " AND b.fk_account IN (".$id.")"; + } $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $obj = $db->fetch_object($resql); $min = $db->jdate($obj->min); @@ -297,8 +288,7 @@ if ($result < 0) $tblyear[1] = array(); $tblyear[2] = array(); - for ($annee = 0; $annee < 3; $annee++) - { + for ($annee = 0; $annee < 3; $annee++) { $sql = "SELECT date_format(b.datev,'%m')"; $sql .= ", SUM(b.amount)"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; @@ -308,16 +298,16 @@ if ($result < 0) $sql .= " AND b.datev >= '".($year - $annee)."-01-01 00:00:00'"; $sql .= " AND b.datev <= '".($year - $annee)."-12-31 23:59:59'"; $sql .= " AND b.amount > 0"; - if ($id && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$id.")"; + if ($id && $_GET["option"] != 'all') { + $sql .= " AND b.fk_account IN (".$id.")"; + } $sql .= " GROUP BY date_format(b.datev,'%m');"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $row = $db->fetch_row($resql); $tblyear[$annee][$row[0]] = $row[1]; $i++; @@ -333,8 +323,7 @@ if ($result < 0) $data_year_1 = array(); $data_year_2 = array(); - for ($i = 0; $i < 12; $i++) - { + for ($i = 0; $i < 12; $i++) { $data_year_0[$i] = isset($tblyear[0][substr("0".($i + 1), -2)]) ? $tblyear[0][substr("0".($i + 1), -2)] : 0; $data_year_1[$i] = isset($tblyear[1][substr("0".($i + 1), -2)]) ? $tblyear[1][substr("0".($i + 1), -2)] : 0; $data_year_2[$i] = isset($tblyear[2][substr("0".($i + 1), -2)]) ? $tblyear[2][substr("0".($i + 1), -2)] : 0; @@ -347,8 +336,7 @@ if ($result < 0) $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/credmovement".$id."-".$year.".png"; $title = $langs->transnoentities("Credit").' - '.$langs->transnoentities("Year").': '.($year - 2).' - '.($year - 1)." - ".$year; $graph_datas = array(); - for ($i = 0; $i < 12; $i++) - { + for ($i = 0; $i < 12; $i++) { $graph_datas[$i] = array($labels[$i], $data_year_0[$i], $data_year_1[$i], $data_year_2[$i]); } @@ -382,8 +370,7 @@ if ($result < 0) $tblyear[1] = array(); $tblyear[2] = array(); - for ($annee = 0; $annee < 3; $annee++) - { + for ($annee = 0; $annee < 3; $annee++) { $sql = "SELECT date_format(b.datev,'%m')"; $sql .= ", SUM(b.amount)"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; @@ -393,16 +380,16 @@ if ($result < 0) $sql .= " AND b.datev >= '".($year - $annee)."-01-01 00:00:00'"; $sql .= " AND b.datev <= '".($year - $annee)."-12-31 23:59:59'"; $sql .= " AND b.amount < 0"; - if ($id && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$id.")"; + if ($id && $_GET["option"] != 'all') { + $sql .= " AND b.fk_account IN (".$id.")"; + } $sql .= " GROUP BY date_format(b.datev,'%m');"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $row = $db->fetch_row($resql); $tblyear[$annee][$row[0]] = abs($row[1]); $i++; @@ -418,8 +405,7 @@ if ($result < 0) $data_year_1 = array(); $data_year_2 = array(); - for ($i = 0; $i < 12; $i++) - { + for ($i = 0; $i < 12; $i++) { $data_year_0[$i] = isset($tblyear[0][substr("0".($i + 1), -2)]) ? $tblyear[0][substr("0".($i + 1), -2)] : 0; $data_year_1[$i] = isset($tblyear[1][substr("0".($i + 1), -2)]) ? $tblyear[1][substr("0".($i + 1), -2)] : 0; $data_year_2[$i] = isset($tblyear[2][substr("0".($i + 1), -2)]) ? $tblyear[2][substr("0".($i + 1), -2)] : 0; @@ -431,8 +417,7 @@ if ($result < 0) $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/debmovement".$id."-".$year.".png"; $title = $langs->transnoentities("Debit").' - '.$langs->transnoentities("Year").': '.($year - 2).' - '.($year - 1)." - ".$year; $graph_datas = array(); - for ($i = 0; $i < 12; $i++) - { + for ($i = 0; $i < 12; $i++) { $graph_datas[$i] = array($labels[$i], $data_year_0[$i], $data_year_1[$i], $data_year_2[$i]); } diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 3f29ab4d022..390972912c1 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -69,12 +69,15 @@ $contextpage = 'banktransactionlist'.(empty($object->ref) ? '' : '-'.$object->id // Security check $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); -if ($fielvalue) -{ - if ($user->socid) $socid = $user->socid; +if ($fielvalue) { + if ($user->socid) { + $socid = $user->socid; + } $result = restrictedArea($user, 'banque', $fieldvalue, 'bank_account&bank_account', '', '', $fieldtype); } else { - if ($user->socid) $socid = $user->socid; + if ($user->socid) { + $socid = $user->socid; + } $result = restrictedArea($user, 'banque'); } @@ -96,29 +99,37 @@ $search_req_nb = GETPOST("req_nb", 'alpha'); $search_num_releve = GETPOST("search_num_releve", 'alpha'); $search_conciliated = GETPOST("search_conciliated", 'int'); $num_releve = GETPOST("num_releve", "alpha"); -if (empty($dateop)) $dateop = -1; +if (empty($dateop)) { + $dateop = -1; +} $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $pageplusone = GETPOST("pageplusone", 'int'); -if ($pageplusone) $page = $pageplusone - 1; -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if ($pageplusone) { + $page = $pageplusone - 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 (!$sortorder) $sortorder = 'desc,desc,desc'; -if (!$sortfield) $sortfield = 'b.datev,b.dateo,b.rowid'; +if (!$sortorder) { + $sortorder = 'desc,desc,desc'; +} +if (!$sortfield) { + $sortfield = 'b.datev,b.dateo,b.rowid'; +} $object = new Account($db); -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); $search_account = $object->id; // Force the search field on id of account - if (!($object->id > 0)) - { + if (!($object->id > 0)) { $langs->load("errors"); print($langs->trans('ErrorRecordNotFound')); exit; @@ -127,10 +138,11 @@ if ($id > 0 || !empty($ref)) $mode_balance_ok = false; //if (($sortfield == 'b.datev' || $sortfield == 'b.datev,b.dateo,b.rowid')) // TODO Manage balance when account not selected -if (($sortfield == 'b.datev' || $sortfield == 'b.datev,b.dateo,b.rowid')) -{ +if (($sortfield == 'b.datev' || $sortfield == 'b.datev,b.dateo,b.rowid')) { $sortfield = 'b.datev,b.dateo,b.rowid'; - if ($id > 0 || !empty($ref) || $search_account > 0) $mode_balance_ok = true; + if ($id > 0 || !empty($ref) || $search_account > 0) { + $mode_balance_ok = true; + } } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -142,16 +154,16 @@ $extrafields->fetch_name_optionals_label('banktransaction'); $search_array_options = $extrafields->getOptionalsFromPost('banktransaction', '', 'search_'); $arrayfields = array( - 'b.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), - 'b.label'=>array('label'=>$langs->trans("Description"), 'checked'=>1), - 'b.dateo'=>array('label'=>$langs->trans("DateOperationShort"), 'checked'=>1), - 'b.datev'=>array('label'=>$langs->trans("DateValueShort"), 'checked'=>1), - 'type'=>array('label'=>$langs->trans("Type"), 'checked'=>1), - 'b.num_chq'=>array('label'=>$langs->trans("Numero"), 'checked'=>1), - 'bu.label'=>array('label'=>$langs->trans("ThirdParty").'/'.$langs->trans("User"), 'checked'=>1, 'position'=>500), - 'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>(($id > 0 || !empty($ref)) ? 0 : 1), 'position'=>1000), - 'b.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1, 'position'=>600), - 'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605), + 'b.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), + 'b.label'=>array('label'=>$langs->trans("Description"), 'checked'=>1), + 'b.dateo'=>array('label'=>$langs->trans("DateOperationShort"), 'checked'=>1), + 'b.datev'=>array('label'=>$langs->trans("DateValueShort"), 'checked'=>1), + 'type'=>array('label'=>$langs->trans("Type"), 'checked'=>1), + 'b.num_chq'=>array('label'=>$langs->trans("Numero"), 'checked'=>1), + 'bu.label'=>array('label'=>$langs->trans("ThirdParty").'/'.$langs->trans("User"), 'checked'=>1, 'position'=>500), + 'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>(($id > 0 || !empty($ref)) ? 0 : 1), 'position'=>1000), + 'b.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1, 'position'=>600), + 'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605), 'balancebefore'=>array('label'=>$langs->trans("BalanceBefore"), 'checked'=>0, 'position'=>1000), 'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>1001), 'b.num_releve'=>array('label'=>$langs->trans("AccountStatement"), 'checked'=>1, 'position'=>1010), @@ -169,17 +181,22 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $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'); +} 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 tests are required to be compatible with all browsers -{ +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers $search_dt_start = ''; $search_dt_end = ''; $search_dv_start = ''; @@ -197,11 +214,12 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $thirdparty = ''; $search_account = ""; - if ($id > 0 || !empty($ref)) $search_account = $object->id; + if ($id > 0 || !empty($ref)) { + $search_account = $object->id; + } } -if (empty($reshook)) -{ +if (empty($reshook)) { $objectclass = 'Account'; $objectlabel = 'BankTransaction'; $permissiontoread = $user->rights->banque->lire; @@ -212,15 +230,13 @@ if (empty($reshook)) // Conciliation if ((GETPOST('confirm_savestatement', 'alpha') || GETPOST('confirm_reconcile', 'alpha')) && $user->rights->banque->consolidate - && (!GETPOSTISSET('pageplusone') || (GETPOST('pageplusone') == GETPOST('pageplusoneold')))) -{ + && (!GETPOSTISSET('pageplusone') || (GETPOST('pageplusone') == GETPOST('pageplusoneold')))) { $error = 0; // Definition, nettoyage parametres $num_releve = GETPOST("num_releve", "alpha"); - if ($num_releve) - { + if ($num_releve) { $bankline = new AccountLine($db); $rowids = GETPOST('rowid', 'array'); @@ -249,22 +265,45 @@ if ((GETPOST('confirm_savestatement', 'alpha') || GETPOST('confirm_reconcile', ' setEventMessages($langs->trans("ErrorPleaseTypeBankTransactionReportName"), null, 'errors'); } - if (!$error) - { + if (!$error) { $param = 'action=reconcile&contextpage=banktransactionlist&id='.$id.'&search_account='.$id; $param .= '&search_conciliated='.urlencode($search_conciliated); - if ($page) $param .= '&page='.urlencode($page); - if ($offset) $param .= '&offset='.urlencode($offset); - if ($search_thirdparty_user) $param .= '&search_thirdparty='.urlencode($search_thirdparty_user); - if ($search_num_releve) $param .= '&search_num_releve='.urlencode($search_num_releve); - if ($search_description) $param .= '&search_description='.urlencode($search_description); - if ($search_start_dt) $param .= '&search_start_dt='.urlencode($search_start_dt); - if ($search_end_dt) $param .= '&search_end_dt='.urlencode($search_end_dt); - if ($search_start_dv) $param .= '&search_start_dv='.urlencode($search_start_dv); - if ($search_end_dv) $param .= '&search_end_dv='.urlencode($search_end_dv); - if ($search_type) $param .= '&search_type='.urlencode($search_type); - if ($search_debit) $param .= '&search_debit='.urlencode($search_debit); - if ($search_credit) $param .= '&search_credit='.urlencode($search_credit); + if ($page) { + $param .= '&page='.urlencode($page); + } + if ($offset) { + $param .= '&offset='.urlencode($offset); + } + if ($search_thirdparty_user) { + $param .= '&search_thirdparty='.urlencode($search_thirdparty_user); + } + if ($search_num_releve) { + $param .= '&search_num_releve='.urlencode($search_num_releve); + } + if ($search_description) { + $param .= '&search_description='.urlencode($search_description); + } + if ($search_start_dt) { + $param .= '&search_start_dt='.urlencode($search_start_dt); + } + if ($search_end_dt) { + $param .= '&search_end_dt='.urlencode($search_end_dt); + } + if ($search_start_dv) { + $param .= '&search_start_dv='.urlencode($search_start_dv); + } + if ($search_end_dv) { + $param .= '&search_end_dv='.urlencode($search_end_dv); + } + if ($search_type) { + $param .= '&search_type='.urlencode($search_type); + } + if ($search_debit) { + $param .= '&search_debit='.urlencode($search_debit); + } + if ($search_credit) { + $param .= '&search_credit='.urlencode($search_credit); + } $param .= '&sortfield='.urlencode($sortfield).'&sortorder='.urlencode($sortorder); header('Location: '.$_SERVER["PHP_SELF"].'?'.$param); // To avoid to submit twice and allow the back button exit; @@ -272,12 +311,10 @@ if ((GETPOST('confirm_savestatement', 'alpha') || GETPOST('confirm_reconcile', ' } -if (GETPOST('save') && !$cancel && $user->rights->banque->modifier) -{ +if (GETPOST('save') && !$cancel && $user->rights->banque->modifier) { $error = 0; - if (price2num(GETPOST("addcredit")) > 0) - { + if (price2num(GETPOST("addcredit")) > 0) { $amount = price2num(GETPOST("addcredit")); } else { $amount = - price2num(GETPOST("adddebit")); @@ -313,17 +350,16 @@ if (GETPOST('save') && !$cancel && $user->rights->banque->modifier) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors'); } /*if (! empty($conf->accounting->enabled) && (empty($search_accountancy_code) || $search_accountancy_code == '-1')) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountAccounting")), null, 'errors'); - $error++; - }*/ + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountAccounting")), null, 'errors'); + $error++; + }*/ if (!$error && !empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)) { $objecttmp = new Account($db); $objecttmp->fetch($bankaccountid); $insertid = $objecttmp->addline($dateop, $operation, $label, $amount, $num_chq, ($cat1 > 0 ? $cat1 : 0), $user, '', '', $search_accountancy_code); - if ($insertid > 0) - { + if ($insertid > 0) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); header("Location: ".$_SERVER['PHP_SELF'].($id ? "?id=".$id : '')); exit; @@ -335,8 +371,7 @@ if (GETPOST('save') && !$cancel && $user->rights->banque->modifier) } } -if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->modifier) -{ +if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->modifier) { $accline = new AccountLine($db); $result = $accline->fetch(GETPOST("rowid", "int")); $result = $accline->delete($user); @@ -384,28 +419,72 @@ $now = dol_now(); // Must be before button action $param = ''; -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); -if ($id > 0) $param .= '&id='.urlencode($id); -if (!empty($ref)) $param .= '&ref='.urlencode($ref); -if (!empty($search_ref)) $param .= '&search_ref='.urlencode($search_ref); -if (!empty($search_description)) $param .= '&search_description='.urlencode($search_description); -if (!empty($search_type)) $param .= '&type='.urlencode($search_type); -if (!empty($search_thirdparty_user)) $param .= '&search_thirdparty='.urlencode($search_thirdparty_user); -if (!empty($search_debit)) $param .= '&search_debit='.urlencode($search_debit); -if (!empty($search_credit)) $param .= '&search_credit='.urlencode($search_credit); -if (!empty($search_account)) $param .= '&search_account='.urlencode($search_account); -if (!empty($search_num_releve)) $param .= '&search_num_releve='.urlencode($search_num_releve); -if ($search_conciliated != '' && $search_conciliated != '-1') $param .= '&search_conciliated='.urlencode($search_conciliated); -if ($search_bid > 0) $param .= '&search_bid='.urlencode($search_bid); -if (dol_strlen($search_dt_start) > 0) $param .= '&search_start_dtmonth='.GETPOST('search_start_dtmonth', 'int').'&search_start_dtday='.GETPOST('search_start_dtday', 'int').'&search_start_dtyear='.GETPOST('search_start_dtyear', 'int'); -if (dol_strlen($search_dt_end) > 0) $param .= '&search_end_dtmonth='.GETPOST('search_end_dtmonth', 'int').'&search_end_dtday='.GETPOST('search_end_dtday', 'int').'&search_end_dtyear='.GETPOST('search_end_dtyear', 'int'); -if (dol_strlen($search_dv_start) > 0) $param .= '&search_start_dvmonth='.GETPOST('search_start_dvmonth', 'int').'&search_start_dvday='.GETPOST('search_start_dvday', 'int').'&search_start_dvyear='.GETPOST('search_start_dvyear', 'int'); -if (dol_strlen($search_dv_end) > 0) $param .= '&search_end_dvmonth='.GETPOST('search_end_dvmonth', 'int').'&search_end_dvday='.GETPOST('search_end_dvday', 'int').'&search_end_dvyear='.GETPOST('search_end_dvyear', 'int'); -if ($search_req_nb) $param .= '&req_nb='.urlencode($search_req_nb); -if (GETPOST("search_thirdparty", 'int')) $param .= '&thirdparty='.urlencode(GETPOST("search_thirdparty", 'int')); -if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); -if ($action == 'reconcile') $param .= '&action=reconcile'; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); +} +if ($id > 0) { + $param .= '&id='.urlencode($id); +} +if (!empty($ref)) { + $param .= '&ref='.urlencode($ref); +} +if (!empty($search_ref)) { + $param .= '&search_ref='.urlencode($search_ref); +} +if (!empty($search_description)) { + $param .= '&search_description='.urlencode($search_description); +} +if (!empty($search_type)) { + $param .= '&type='.urlencode($search_type); +} +if (!empty($search_thirdparty_user)) { + $param .= '&search_thirdparty='.urlencode($search_thirdparty_user); +} +if (!empty($search_debit)) { + $param .= '&search_debit='.urlencode($search_debit); +} +if (!empty($search_credit)) { + $param .= '&search_credit='.urlencode($search_credit); +} +if (!empty($search_account)) { + $param .= '&search_account='.urlencode($search_account); +} +if (!empty($search_num_releve)) { + $param .= '&search_num_releve='.urlencode($search_num_releve); +} +if ($search_conciliated != '' && $search_conciliated != '-1') { + $param .= '&search_conciliated='.urlencode($search_conciliated); +} +if ($search_bid > 0) { + $param .= '&search_bid='.urlencode($search_bid); +} +if (dol_strlen($search_dt_start) > 0) { + $param .= '&search_start_dtmonth='.GETPOST('search_start_dtmonth', 'int').'&search_start_dtday='.GETPOST('search_start_dtday', 'int').'&search_start_dtyear='.GETPOST('search_start_dtyear', 'int'); +} +if (dol_strlen($search_dt_end) > 0) { + $param .= '&search_end_dtmonth='.GETPOST('search_end_dtmonth', 'int').'&search_end_dtday='.GETPOST('search_end_dtday', 'int').'&search_end_dtyear='.GETPOST('search_end_dtyear', 'int'); +} +if (dol_strlen($search_dv_start) > 0) { + $param .= '&search_start_dvmonth='.GETPOST('search_start_dvmonth', 'int').'&search_start_dvday='.GETPOST('search_start_dvday', 'int').'&search_start_dvyear='.GETPOST('search_start_dvyear', 'int'); +} +if (dol_strlen($search_dv_end) > 0) { + $param .= '&search_end_dvmonth='.GETPOST('search_end_dvmonth', 'int').'&search_end_dvday='.GETPOST('search_end_dvday', 'int').'&search_end_dvyear='.GETPOST('search_end_dvyear', 'int'); +} +if ($search_req_nb) { + $param .= '&req_nb='.urlencode($search_req_nb); +} +if (GETPOST("search_thirdparty", 'int')) { + $param .= '&thirdparty='.urlencode(GETPOST("search_thirdparty", 'int')); +} +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} +if ($action == 'reconcile') { + $param .= '&action=reconcile'; +} // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -414,8 +493,7 @@ $options = array(); $buttonreconcile = ''; $morehtmlref = ''; -if ($id > 0 || !empty($ref)) -{ +if ($id > 0 || !empty($ref)) { $title = $langs->trans("FinancialAccount").' - '.$langs->trans("Transactions"); $helpurl = ""; llxHeader('', $title, $helpurl); @@ -440,13 +518,11 @@ if ($id > 0 || !empty($ref)) /* - * Buttons actions - */ + * Buttons actions + */ - if ($action != 'reconcile') - { - if ($object->canBeConciliated() > 0) - { + if ($action != 'reconcile') { + if ($object->canBeConciliated() > 0) { $allowautomaticconciliation = false; // TODO $titletoconciliatemanual = $langs->trans("Conciliate"); $titletoconciliateauto = $langs->trans("Conciliate"); @@ -485,30 +561,54 @@ $sql .= " b.fk_account, b.fk_type,"; $sql .= " ba.rowid as bankid, ba.ref as bankref"; // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); + } } // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sql .= " FROM "; -if ($search_bid > 0) $sql .= MAIN_DB_PREFIX."bank_class as l,"; +if ($search_bid > 0) { + $sql .= MAIN_DB_PREFIX."bank_class as l,"; +} $sql .= " ".MAIN_DB_PREFIX."bank_account as ba,"; $sql .= " ".MAIN_DB_PREFIX."bank as b"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (b.rowid = ef.fk_object)"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (b.rowid = ef.fk_object)"; +} $sql .= " WHERE b.fk_account = ba.rowid"; $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; -if ($search_account > 0) $sql .= " AND b.fk_account = ".$search_account; +if ($search_account > 0) { + $sql .= " AND b.fk_account = ".$search_account; +} // Search period criteria -if (dol_strlen($search_dt_start) > 0) $sql .= " AND b.dateo >= '".$db->idate($search_dt_start)."'"; -if (dol_strlen($search_dt_end) > 0) $sql .= " AND b.dateo <= '".$db->idate($search_dt_end)."'"; +if (dol_strlen($search_dt_start) > 0) { + $sql .= " AND b.dateo >= '".$db->idate($search_dt_start)."'"; +} +if (dol_strlen($search_dt_end) > 0) { + $sql .= " AND b.dateo <= '".$db->idate($search_dt_end)."'"; +} // Search period criteria -if (dol_strlen($search_dv_start) > 0) $sql .= " AND b.datev >= '".$db->idate($search_dv_start)."'"; -if (dol_strlen($search_dv_end) > 0) $sql .= " AND b.datev <= '".$db->idate($search_dv_end)."'"; -if ($search_ref) $sql .= natural_search("b.rowid", $search_ref, 1); -if ($search_req_nb) $sql .= natural_search("b.num_chq", $search_req_nb); -if ($search_num_releve) $sql .= natural_search("b.num_releve", $search_num_releve); -if ($search_conciliated != '' && $search_conciliated != '-1') $sql .= " AND b.rappro = ".urlencode($search_conciliated); +if (dol_strlen($search_dv_start) > 0) { + $sql .= " AND b.datev >= '".$db->idate($search_dv_start)."'"; +} +if (dol_strlen($search_dv_end) > 0) { + $sql .= " AND b.datev <= '".$db->idate($search_dv_end)."'"; +} +if ($search_ref) { + $sql .= natural_search("b.rowid", $search_ref, 1); +} +if ($search_req_nb) { + $sql .= natural_search("b.num_chq", $search_req_nb); +} +if ($search_num_releve) { + $sql .= natural_search("b.num_releve", $search_num_releve); +} +if ($search_conciliated != '' && $search_conciliated != '-1') { + $sql .= " AND b.rappro = ".urlencode($search_conciliated); +} if ($search_thirdparty_user) { $sql.= " AND (b.rowid IN "; $sql.= " ( SELECT bu.fk_bank FROM ".MAIN_DB_PREFIX."bank_url AS bu"; @@ -523,8 +623,7 @@ if ($search_thirdparty_user) { $sql.= " WHERE ". natural_search(array("subSoc.nom"), $search_thirdparty_user, '', 1); $sql.= ")"; } -if ($search_description) -{ +if ($search_description) { $search_description_to_use = $search_description; $arrayoffixedlabels = array( 'payment_salary', @@ -536,23 +635,29 @@ if ($search_description) 'SubscriptionPayment', 'WithdrawalPayment' ); - foreach ($arrayoffixedlabels as $keyforlabel) - { + foreach ($arrayoffixedlabels as $keyforlabel) { $translatedlabel = $langs->transnoentitiesnoconv($keyforlabel); - if (preg_match('/'.$search_description.'/i', $translatedlabel)) - { + if (preg_match('/'.$search_description.'/i', $translatedlabel)) { $search_description_to_use .= "|".$keyforlabel; } } $sql .= natural_search("b.label", $search_description_to_use); // Warning some text are just translation keys, not translated strings } -if ($search_bid > 0) $sql .= " AND b.rowid=l.lineid AND l.fk_categ=".$search_bid; -if (!empty($search_type)) $sql .= " AND b.fk_type = '".$db->escape($search_type)."' "; +if ($search_bid > 0) { + $sql .= " AND b.rowid=l.lineid AND l.fk_categ=".$search_bid; +} +if (!empty($search_type)) { + $sql .= " AND b.fk_type = '".$db->escape($search_type)."' "; +} // Search criteria amount $search_debit = price2num(str_replace('-', '', $search_debit)); $search_credit = price2num(str_replace('-', '', $search_credit)); -if ($search_debit) $sql .= natural_search('- b.amount', $search_debit, 1); -if ($search_credit) $sql .= natural_search('b.amount', $search_credit, 1); +if ($search_debit) { + $sql .= natural_search('- b.amount', $search_debit, 1); +} +if ($search_credit) { + $sql .= natural_search('b.amount', $search_credit, 1); +} // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -565,48 +670,66 @@ $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; $nbtotalofpages = 0; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); $nbtotalofpages = ceil($nbtotalofrecords / $limit); } -if (($id > 0 || !empty($ref)) && ((string) $page == '')) -{ +if (($id > 0 || !empty($ref)) && ((string) $page == '')) { // We open a list of transaction of a dedicated account and no page was set by defaut // We force on last page. $page = ($nbtotalofpages - 1); $offset = $limit * $page; - if ($page < 0) $page = 0; + if ($page < 0) { + $page = 0; + } } -if ($page >= $nbtotalofpages) -{ +if ($page >= $nbtotalofpages) { // If we made a search and result has low page than the page number we were on $page = ($nbtotalofpages - 1); $offset = $limit * $page; - if ($page < 0) $page = 0; + if ($page < 0) { + $page = 0; + } } // If not account defined $mode_balance_ok=false -if (empty($search_account)) $mode_balance_ok = false; +if (empty($search_account)) { + $mode_balance_ok = false; +} // If a search is done $mode_balance_ok=false -if (!empty($search_ref)) $mode_balance_ok = false; -if (!empty($search_description)) $mode_balance_ok = false; -if (!empty($search_type)) $mode_balance_ok = false; -if (!empty($search_debit)) $mode_balance_ok = false; -if (!empty($search_credit)) $mode_balance_ok = false; -if (!empty($search_thirdparty_user)) $mode_balance_ok = false; -if ($search_conciliated != '' && $search_conciliated != '-1') $mode_balance_ok = false; -if (!empty($search_num_releve)) $mode_balance_ok = false; +if (!empty($search_ref)) { + $mode_balance_ok = false; +} +if (!empty($search_description)) { + $mode_balance_ok = false; +} +if (!empty($search_type)) { + $mode_balance_ok = false; +} +if (!empty($search_debit)) { + $mode_balance_ok = false; +} +if (!empty($search_credit)) { + $mode_balance_ok = false; +} +if (!empty($search_thirdparty_user)) { + $mode_balance_ok = false; +} +if ($search_conciliated != '' && $search_conciliated != '-1') { + $mode_balance_ok = false; +} +if (!empty($search_num_releve)) { + $mode_balance_ok = false; +} $sql .= $db->plimit($limit + 1, $offset); //print $sql; dol_syslog('compta/bank/bankentries_list.php', LOG_DEBUG); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $arrayofselected = is_array($toselect) ? $toselect : array(); @@ -617,19 +740,22 @@ if ($resql) //'builddoc'=>$langs->trans("PDFMerge"), ); //if ($user->rights->bank->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); - if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + if (in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); + } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); // Confirmation delete - if ($action == 'delete') - { + if ($action == 'delete') { $text = $langs->trans('ConfirmDeleteTransaction'); print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&rowid='.GETPOST("rowid"), $langs->trans('DeleteTransaction'), $text, 'confirm_delete', null, '', 1); } // Lines of title fields print '
'."\n"; - if ($optioncss != '') print ''; + if ($optioncss != '') { + print ''; + } print ''; print ''; print ''; @@ -639,17 +765,17 @@ if ($resql) print ''; print ''; print ''; - if (GETPOST('bid')) print ''; + if (GETPOST('bid')) { + print ''; + } // Form to reconcile - if ($user->rights->banque->consolidate && $action == 'reconcile') - { + if ($user->rights->banque->consolidate && $action == 'reconcile') { print '
'; print ''.$langs->trans("InputReceiptNumber").': '; print ''; // The only default value is value we just entered print '
'; - if (is_array($options) && count($options)) - { + if (is_array($options) && count($options)) { print $langs->trans("EventualyAddCategory").': '; print Form::selectarray('cat', $options, GETPOST('cat'), 1); } @@ -671,13 +797,11 @@ if ($resql) print '
'; print $langs->trans("LastAccountStatements").' : '; $resqlr = $db->query($sql); - if ($resqlr) - { + if ($resqlr) { $numr = $db->num_rows($resqlr); $i = 0; $last_ok = 0; - while (($i < $numr) && ($i < $nbmax)) - { + while (($i < $numr) && ($i < $nbmax)) { $objr = $db->fetch_object($resqlr); if (!$last_ok) { $last_releve = $objr->num_releve; @@ -686,16 +810,19 @@ if ($resql) $i++; $liste = ''.$objr->num_releve.'   '.$liste; } - if ($numr >= $nbmax) $liste = "...   ".$liste; + if ($numr >= $nbmax) { + $liste = "...   ".$liste; + } print $liste; - if ($numr <= 0) print ''.$langs->trans("None").''; + if ($numr <= 0) { + print ''.$langs->trans("None").''; + } } else { dol_print_error($db); } // Using BANK_REPORT_LAST_NUM_RELEVE to automatically report last num (or not) - if (!empty($conf->global->BANK_REPORT_LAST_NUM_RELEVE)) - { + if (!empty($conf->global->BANK_REPORT_LAST_NUM_RELEVE)) { print ' '; } - if (!GETPOST('fac_rec', 'int')) print ' '; + if (!GETPOST('fac_rec', 'int')) { + print ' '; + } print ''; print ''."\n"; } @@ -2958,15 +3072,21 @@ if ($action == 'create') $invoice_predefined->fetch(GETPOST('fac_rec', 'int')); $dateinvoice = $invoice_predefined->date_when; // To use next gen date by default later - if (empty($projectid)) $projectid = $invoice_predefined->fk_project; + if (empty($projectid)) { + $projectid = $invoice_predefined->fk_project; + } $cond_reglement_id = $invoice_predefined->cond_reglement_id; $mode_reglement_id = $invoice_predefined->mode_reglement_id; $fk_account = $invoice_predefined->fk_account; $note_public = $invoice_predefined->note_public; $note_private = $invoice_predefined->note_private; - if (!empty($invoice_predefined->multicurrency_code)) $currency_code = $invoice_predefined->multicurrency_code; - if (!empty($invoice_predefined->multicurrency_tx)) $currency_tx = $invoice_predefined->multicurrency_tx; + if (!empty($invoice_predefined->multicurrency_code)) { + $currency_code = $invoice_predefined->multicurrency_code; + } + if (!empty($invoice_predefined->multicurrency_tx)) { + $currency_tx = $invoice_predefined->multicurrency_tx; + } $sql = 'SELECT r.rowid, r.titre as title, r.total_ttc'; $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_rec as r'; @@ -2985,8 +3105,7 @@ if ($action == 'create') while ($i < $num) { $objp = $db->fetch_object($resql); print '
'; - } + } } if ($socid > 0) { @@ -3124,8 +3243,9 @@ if ($action == 'create') $tmp .= '> '; $text = ' '; $text .= ''; @@ -3146,8 +3266,9 @@ if ($action == 'create') if (is_array($facids)) { foreach ($facids as $facparam) { $options .= ''; @@ -3234,8 +3355,9 @@ if ($action == 'create') $newinvoice_static->paye = $valarray ['paye']; $optionsav .= '