diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 2aa6072f2c2..3d73ea531b7 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -27,13 +27,13 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; // Load translation files required by the page -$langs->loadLangs(array("compta","bills","other","main","accountancy")); +$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy")); // Security check if (empty($conf->accounting->enabled)) { @@ -41,16 +41,16 @@ if (empty($conf->accounting->enabled)) { } if ($user->socid > 0) accessforbidden(); -if (! $user->rights->accounting->bind->write) +if (!$user->rights->accounting->bind->write) accessforbidden(); -$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); +$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); else { $year_start = dol_print_date(dol_now(), '%Y'); - if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year + if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year } $year_end = $year_start + 1; $month_end = $month_start - 1; @@ -77,20 +77,20 @@ if ($action == 'clean' || $action == 'validatehistory') { // Clean database $db->begin(); - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd"; + $sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet as fd"; $sql1 .= " SET fk_code_ventilation = 0"; $sql1 .= ' WHERE fd.fk_code_ventilation NOT IN'; $sql1 .= ' (SELECT accnt.rowid '; - $sql1 .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as accnt'; - $sql1 .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'accounting_system as syst'; - $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=' . $conf->global->CHARTOFACCOUNTS . ' AND accnt.entity = '.$conf->entity.')'; - $sql1 .= ' AND fd.fk_facture IN (SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture WHERE entity = '.$conf->entity.')'; + $sql1 .= ' FROM '.MAIN_DB_PREFIX.'accounting_account as accnt'; + $sql1 .= ' INNER JOIN '.MAIN_DB_PREFIX.'accounting_system as syst'; + $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid='.$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity.')'; + $sql1 .= ' AND fd.fk_facture IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'facture WHERE entity = '.$conf->entity.')'; $sql1 .= ' AND fk_code_ventilation <> 0'; dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG); $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; + if (!$resql1) { + $error++; $db->rollback(); setEventMessages($db->lasterror(), null, 'errors'); } else { @@ -121,26 +121,26 @@ if ($action == 'validatehistory') { // Customer Invoice lines (must be same request than into page list.php for manual binding) $sql = "SELECT f.rowid as facid, f.ref as ref, f.datef, f.type as ftype,"; - $sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; - $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,"; - $sql.= " p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,"; - $sql.= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,"; - $sql.= " co.code as country_code, co.label as country_label,"; - $sql.= " s.tva_intra"; - $sql.= " FROM " . MAIN_DB_PREFIX . "facture as f"; - $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; - $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays "; - $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as l ON f.rowid = l.fk_facture"; - $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product"; - $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity; - $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '" . $chartaccountcode."' AND aa2.entity = " . $conf->entity; - $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '" . $chartaccountcode."' AND aa3.entity = " . $conf->entity; - $sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; - $sql.= " AND l.product_type <= 2"; + $sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; + $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,"; + $sql .= " p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,"; + $sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,"; + $sql .= " co.code as country_code, co.label as country_label,"; + $sql .= " s.tva_intra"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as l ON f.rowid = l.fk_facture"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$chartaccountcode."' AND aa2.entity = ".$conf->entity; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$chartaccountcode."' AND aa3.entity = ".$conf->entity; + $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; + $sql .= " AND l.product_type <= 2"; dol_syslog('htdocs/accountancy/customer/index.php'); $result = $db->query($sql); - if (! $result) { + if (!$result) { $error++; setEventMessages($db->lasterror(), null, 'errors'); } else { @@ -172,12 +172,12 @@ if ($action == 'validatehistory') { if ($objp->aarowid_suggest > 0) { - $sqlupdate = "UPDATE " . MAIN_DB_PREFIX . "facturedet"; - $sqlupdate.= " SET fk_code_ventilation = ".$objp->aarowid_suggest; - $sqlupdate.= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid; + $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facturedet"; + $sqlupdate .= " SET fk_code_ventilation = ".$objp->aarowid_suggest; + $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid; $resqlupdate = $db->query($sqlupdate); - if (! $resqlupdate) + if (!$resqlupdate) { $error++; setEventMessages($db->lasterror(), null, 'errors'); @@ -278,11 +278,11 @@ if ($resql) { } else print $row[1]; print ''; - for($i = 2; $i <= 12; $i ++) { - print '' . price($row[$i]) . ''; + for ($i = 2; $i <= 12; $i++) { + print ''.price($row[$i]).''; } - print '' . price($row[13]) . ''; - print '' . price($row[14]) . ''; + print ''.price($row[13]).''; + print ''.price($row[14]).''; print ''; } $db->free($resql); @@ -338,7 +338,7 @@ $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - while ( $row = $db->fetch_row($resql)) { + while ($row = $db->fetch_row($resql)) { print ''; if ($row[0] == 'tobind') { @@ -355,11 +355,11 @@ if ($resql) { else print $row[1]; print ''; - for($i = 2; $i <= 12; $i++) { - print '' . price($row[$i]) . ''; + for ($i = 2; $i <= 12; $i++) { + print ''.price($row[$i]).''; } - print '' . price($row[13]) . ''; - print '' . price($row[14]) . ''; + print ''.price($row[13]).''; + print ''.price($row[14]).''; print ''; } $db->free($resql); @@ -413,11 +413,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. $num = $db->num_rows($resql); while ($row = $db->fetch_row($resql)) { - print '' . $row[0] . ''; - for($i = 1; $i <= 12; $i ++) { - print '' . price($row[$i]) . ''; + print ''.$row[0].''; + for ($i = 1; $i <= 12; $i++) { + print ''.price($row[$i]).''; } - print '' . price($row[13]) . ''; + print ''.price($row[13]).''; print ''; } $db->free($resql); @@ -465,11 +465,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. $num = $db->num_rows($resql); while ($row = $db->fetch_row($resql)) { - print '' . $row[0] . ''; - for($i = 1; $i <= 12; $i ++) { - print '' . price(price2num($row[$i])) . ''; + print ''.$row[0].''; + for ($i = 1; $i <= 12; $i++) { + print ''.price(price2num($row[$i])).''; } - print '' . price(price2num($row[13])) . ''; + print ''.price(price2num($row[13])).''; print ''; } $db->free($resql); diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 9d32bbaebf4..10742b863d2 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -26,16 +26,16 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("bills","compta","accountancy","productbatch")); +$langs->loadLangs(array("bills", "compta", "accountancy", "productbatch")); $account_parent = GETPOST('account_parent'); $changeaccount = GETPOST('changeaccount'); @@ -48,14 +48,14 @@ $search_desc = GETPOST('search_desc', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); $search_account = GETPOST('search_account', 'alpha'); $search_vat = GETPOST('search_vat', 'alpha'); -$search_day=GETPOST("search_day", "int"); -$search_month=GETPOST("search_month", "int"); -$search_year=GETPOST("search_year", "int"); +$search_day = GETPOST("search_day", "int"); +$search_month = GETPOST("search_month", "int"); +$search_year = GETPOST("search_year", "int"); $search_country = GETPOST('search_country', 'alpha'); $search_tvaintra = GETPOST('search_tvaintra', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -63,9 +63,9 @@ if (empty($page) || $page < 0) $page = 0; $pageprev = $page - 1; $pagenext = $page + 1; $offset = $limit * $page; -if (! $sortfield) +if (!$sortfield) $sortfield = "f.datef, f.ref, fd.rowid"; -if (! $sortorder) { +if (!$sortorder) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) { $sortorder = "DESC"; } @@ -74,7 +74,7 @@ if (! $sortorder) { // Security check if ($user->socid > 0) accessforbidden(); -if (! $user->rights->accounting->bind->write) +if (!$user->rights->accounting->bind->write) accessforbidden(); $formaccounting = new FormAccounting($db); @@ -105,27 +105,27 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' if (is_array($changeaccount) && count($changeaccount) > 0) { $error = 0; - if (! (GETPOST('account_parent', 'int') >= 0)) + if (!(GETPOST('account_parent', 'int') >= 0)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors'); } - if (! $error) + if (!$error) { $db->begin(); - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as l"; - $sql1 .= " SET l.fk_code_ventilation=" . (GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0'); - $sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')'; + $sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet as l"; + $sql1 .= " SET l.fk_code_ventilation=".(GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0'); + $sql1 .= ' WHERE l.rowid IN ('.implode(',', $changeaccount).')'; - dol_syslog('accountancy/customer/lines.php::changeaccount sql= ' . $sql1); + dol_syslog('accountancy/customer/lines.php::changeaccount sql= '.$sql1); $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; + if (!$resql1) { + $error++; setEventMessages($db->lasterror(), null, 'errors'); } - if (! $error) { + if (!$error) { $db->commit(); setEventMessages($langs->trans('Save'), null, 'mesgs'); } else { @@ -133,7 +133,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { setEventMessages($db->lasterror(), null, 'errors'); } - $account_parent = ''; // Protection to avoid to mass apply it a second time + $account_parent = ''; // Protection to avoid to mass apply it a second time } } @@ -145,7 +145,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { $form = new Form($db); $formother = new FormOther($db); -llxHeader('', $langs->trans("CustomersVentilation") . ' - ' . $langs->trans("Dispatched")); +llxHeader('', $langs->trans("CustomersVentilation").' - '.$langs->trans("Dispatched")); print '