diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index e3f1415c6f1..867c79099a6 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -27,22 +27,22 @@ */ require '../../main.inc.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/class/html.formaccounting.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.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.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.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","other","productbatch")); +$langs->loadLangs(array("bills", "compta", "accountancy", "other", "productbatch")); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); // Select Box @@ -57,16 +57,16 @@ $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'); $btn_ventil = GETPOST('ventil', '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'); @@ -74,9 +74,9 @@ if (empty($page) || $page < 0) { $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) +if (!$sortfield) $sortfield = "f.datef, f.ref, l.rowid"; -if (! $sortorder) { +if (!$sortorder) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) { $sortorder = "DESC"; } @@ -85,7 +85,7 @@ if (! $sortorder) { // Security check if ($user->socid > 0) accessforbidden(); -if (! $user->rights->accounting->bind->write) +if (!$user->rights->accounting->bind->write) accessforbidden(); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -100,11 +100,11 @@ $chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'acco * 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 +$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)) @@ -128,7 +128,7 @@ if (empty($reshook)) } // Mass actions - $objectclass='AccountingAccount'; + $objectclass = 'AccountingAccount'; $permissiontoread = $user->rights->accounting->read; $permissiontodelete = $user->rights->accounting->delete; $uploaddir = $conf->accounting->dir_output; @@ -137,15 +137,15 @@ if (empty($reshook)) if ($massaction == 'ventil') { - $msg=''; + $msg = ''; //print '
' . $langs->trans("Processing") . '...
'; - if (! empty($mesCasesCochees)) { - $msg = '
' . $langs->trans("SelectedLines") . ': '.count($mesCasesCochees).'
'; - $msg.='
'; + if (!empty($mesCasesCochees)) { + $msg = '
'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'
'; + $msg .= '
'; $cpt = 0; - $ok=0; - $ko=0; + $ok = 0; + $ko = 0; foreach ($mesCasesCochees as $maLigneCochee) { $maLigneCourante = explode("_", $maLigneCochee); @@ -154,32 +154,32 @@ if ($massaction == 'ventil') { if ($monCompte <= 0) { - $msg.= '
' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NoAccountSelected") . '
'; + $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'
'; $ko++; } else { - $sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet"; - $sql .= " SET fk_code_ventilation = " . $monCompte; - $sql .= " WHERE rowid = " . $monId; + $sql = " UPDATE ".MAIN_DB_PREFIX."facturedet"; + $sql .= " SET fk_code_ventilation = ".$monCompte; + $sql .= " WHERE rowid = ".$monId; $accountventilated = new AccountingAccount($db); $accountventilated->fetch($monCompte, ''); - dol_syslog("accountancy/customer/list.php sql=" . $sql, LOG_DEBUG); + dol_syslog("accountancy/customer/list.php sql=".$sql, LOG_DEBUG); if ($db->query($sql)) { - $msg.= '
' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '
'; + $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'; $ok++; } else { - $msg.= '
' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '
' . $sql . '
'; + $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'.$sql.'
'; $ko++; } } $cpt++; } - $msg.='
'; - $msg.= '
' . $langs->trans("EndProcessing") . '
'; + $msg .= '
'; + $msg .= '
'.$langs->trans("EndProcessing").'
'; } } @@ -205,25 +205,25 @@ if (empty($chartaccountcode)) // Customer Invoice lines $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"; -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$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"; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$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"; // Add search filter like if ($search_lineid) { $sql .= natural_search("l.rowid", $search_lineid, 1); @@ -249,35 +249,35 @@ if (strlen(trim($search_account))) { if (strlen(trim($search_vat))) { $sql .= natural_search("l.tva_tx", price2num($search_vat), 1); } -$sql.=dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year); +$sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year); if (strlen(trim($search_country))) { $arrayofcode = getCountriesInEEC(); $country_code_in_EEC = $country_code_in_EEC_without_me = ''; foreach ($arrayofcode as $key => $value) { - $country_code_in_EEC.=($country_code_in_EEC ? "," : "")."'".$value."'"; - if ($value != $mysoc->country_code) $country_code_in_EEC_without_me.=($country_code_in_EEC_without_me ? "," : "")."'".$value."'"; + $country_code_in_EEC .= ($country_code_in_EEC ? "," : "")."'".$value."'"; + if ($value != $mysoc->country_code) $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ? "," : "")."'".$value."'"; } if ($search_country == 'special_allnotme') $sql .= " AND co.code <> '".$db->escape($mysoc->country_code)."'"; elseif ($search_country == 'special_eec') $sql .= " AND co.code IN (".$country_code_in_EEC.")"; elseif ($search_country == 'special_eecnotme') $sql .= " AND co.code IN (".$country_code_in_EEC_without_me.")"; elseif ($search_country == 'special_noteec') $sql .= " AND co.code NOT IN (".$country_code_in_EEC.")"; - else $sql .= natural_search(array("co.code","co.label"), $search_country); + else $sql .= natural_search(array("co.code", "co.label"), $search_country); } if (strlen(trim($search_tvaintra))) { $sql .= natural_search("s.tva_intra", $search_tvaintra); } -if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; +if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")"; } else { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; + $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")"; } -$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy +$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; $sql .= $db->order($sortfield, $sortorder); @@ -307,33 +307,33 @@ if ($result) { $num_lines = $db->num_rows($result); $i = 0; - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); - $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_lineid) $param.='&search_lineid='.urlencode($search_lineid); - if ($search_day) $param.='&search_day='.urlencode($search_day); - if ($search_month) $param.='&search_month='.urlencode($search_month); - if ($search_year) $param.='&search_year='.urlencode($search_year); - if ($search_invoice) $param.='&search_invoice='.urlencode($search_invoice); - if ($search_ref) $param.='&search_ref='.urlencode($search_ref); - if ($search_desc) $param.='&search_desc='.urlencode($search_desc); - if ($search_amount) $param.='&search_amount='.urlencode($search_amount); - if ($search_vat) $param.='&search_vat='.urlencode($search_vat); - if ($search_country) $param.= "&search_country=".urlencode($search_country); - if ($search_tvaintra) $param.= "&search_tvaintra=".urlencode($search_tvaintra); + $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_lineid) $param .= '&search_lineid='.urlencode($search_lineid); + if ($search_day) $param .= '&search_day='.urlencode($search_day); + if ($search_month) $param .= '&search_month='.urlencode($search_month); + if ($search_year) $param .= '&search_year='.urlencode($search_year); + if ($search_invoice) $param .= '&search_invoice='.urlencode($search_invoice); + if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); + if ($search_desc) $param .= '&search_desc='.urlencode($search_desc); + if ($search_amount) $param .= '&search_amount='.urlencode($search_amount); + if ($search_vat) $param .= '&search_vat='.urlencode($search_vat); + if ($search_country) $param .= "&search_country=".urlencode($search_country); + if ($search_tvaintra) $param .= "&search_tvaintra=".urlencode($search_tvaintra); - $arrayofmassactions = array( + $arrayofmassactions = array( 'ventil'=>$langs->trans("Ventilate") //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); //if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); //if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1); + $massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1); - print '
' . "\n"; + print ''."\n"; print ''; if ($optioncss != '') print ''; print ''; @@ -344,7 +344,7 @@ if ($result) { print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); - print ''.$langs->trans("DescVentilTodoCustomer") . '

'; + print ''.$langs->trans("DescVentilTodoCustomer").'

'; /*$topicmail="Information"; $modelmail="project"; @@ -357,33 +357,33 @@ if ($result) { $moreforfilter = ''; print '
'; - print ''."\n"; + print '
'."\n"; // We add search filter print ''; - print ''; - print ''; + print ''; + print ''; print ''; - print ''; + print ''; //print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; print ''; @@ -401,8 +401,8 @@ if ($result) { print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'center '); print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', 'center '); - $checkpicto=''; - if ($massactionbutton) $checkpicto=$form->showCheckAddButtons('checkforselect', 1); + $checkpicto = ''; + if ($massactionbutton) $checkpicto = $form->showCheckAddButtons('checkforselect', 1); print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print "\n"; @@ -429,39 +429,39 @@ if ($result) { $facture_static->type = $objp->ftype; $code_sell_p_notset = ''; - $objp->aarowid_suggest = ''; // Will be set later + $objp->aarowid_suggest = ''; // Will be set later $isBuyerInEEC = isInEEC($objp); $suggestedaccountingaccountbydefaultfor = ''; if ($objp->type_l == 1) { if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) - $objp->code_sell_l = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : ''); + $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : ''); $suggestedaccountingaccountbydefaultfor = ''; } else { if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale - $objp->code_sell_l = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : ''); + $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : ''); $suggestedaccountingaccountbydefaultfor = 'eec'; } else { // Foreign sale - $objp->code_sell_l = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : ''); + $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : ''); $suggestedaccountingaccountbydefaultfor = 'export'; } } } elseif ($objp->type_l == 0) { if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) - $objp->code_sell_l = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : ''); + $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : ''); $suggestedaccountingaccountbydefaultfor = ''; } else { if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale - $objp->code_sell_l = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : ''); + $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : ''); $suggestedaccountingaccountbydefaultfor = 'eec'; } else { - $objp->code_sell_l = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : ''); + $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : ''); $suggestedaccountingaccountbydefaultfor = 'export'; } } } - if ($objp->code_sell_l == -1) $objp->code_sell_l=''; + if ($objp->code_sell_l == -1) $objp->code_sell_l = ''; // Search suggested account for product/service $suggestedaccountingaccountfor = ''; @@ -494,12 +494,12 @@ if ($result) { print ''; // Line id - print ''; + print ''; // Ref Invoice - print ''; + print ''; - print ''; + print ''; // Ref Product print ''; // Country print ''; - print ''; + print ''; // Current account - print ''; @@ -582,11 +582,11 @@ if ($result) { print ''; print ''; - $i ++; + $i++; } print '
'; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { print ''; } print ''; $formother->select_year($search_year, 'search_year', 1, 20, 5); print ''; print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth150', 'code2', 1, 0, 1); //print ''; print ''; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
' . $objp->rowid . ''.$objp->rowid.'' . $facture_static->getNomUrl(1) . ''.$facture_static->getNomUrl(1).'' . dol_print_date($db->jdate($objp->datef), 'day') . ''.dol_print_date($db->jdate($objp->datef), 'day').''; @@ -521,34 +521,34 @@ if ($result) { // Vat rate if ($objp->vat_tx_l != $objp->vat_tx_p) $code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red'; - print ''; - print vatrate($objp->tva_tx_line.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')); + print ''; + print vatrate($objp->tva_tx_line.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')); print ''; - $labelcountry=($objp->country_code && ($langs->trans("Country".$objp->country_code)!="Country".$objp->country_code))?$langs->trans("Country".$objp->country_code):$objp->country_label; + $labelcountry = ($objp->country_code && ($langs->trans("Country".$objp->country_code) != "Country".$objp->country_code)) ? $langs->trans("Country".$objp->country_code) : $objp->country_label; print $labelcountry; print '' . $objp->tva_intra . ''.$objp->tva_intra.''; - $s = (($objp->type_l == 1)?$langs->trans("DefaultForService"):$langs->trans("DefaultForProduct")).': '; + print ''; + $s = (($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': '; $shelp = ''; - if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp.= $langs->trans("SaleEEC"); - elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp.= $langs->trans("SaleExport"); - $s.= ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : $langs->trans("NotDefined")); + if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp .= $langs->trans("SaleEEC"); + elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp .= $langs->trans("SaleExport"); + $s .= ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : $langs->trans("NotDefined")); print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); if ($objp->product_id > 0) { print '
'; - $s = (($objp->type_l == 1)?$langs->trans("ThisService"):$langs->trans("ThisProduct")).': '; + $s = (($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': '; $shelp = ''; if ($suggestedaccountingaccountfor == 'eec') $shelp = $langs->trans("SaleEEC"); elseif ($suggestedaccountingaccountfor == 'export') $shelp = $langs->trans("SaleExport"); - $s.= (empty($objp->code_sell_p) ? $langs->trans("NotDefined") : length_accountg($objp->code_sell_p)); + $s .= (empty($objp->code_sell_p) ? $langs->trans("NotDefined") : length_accountg($objp->code_sell_p)); print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); } print '
'; //var_dump($objp->aarowid);var_dump($objp->aarowid_intra);var_dump($objp->aarowid_export);var_dump($objp->aarowid_suggest); $ischecked = $objp->aarowid_suggest; - print ''; + print ''; print '
'; print "
"; diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index a1c354f010b..29b58d76c78 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -27,20 +27,20 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.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.'/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.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'; // Load translation files required by the page -$langs->loadLangs(array("bills","compta","accountancy","other","trips","productbatch")); +$langs->loadLangs(array("bills", "compta", "accountancy", "other", "trips", "productbatch")); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); // Select Box @@ -53,14 +53,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"); $btn_ventil = GETPOST('ventil', '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'); @@ -68,9 +68,9 @@ if (empty($page) || $page < 0) { $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) +if (!$sortfield) $sortfield = "erd.date, erd.rowid"; -if (! $sortorder) { +if (!$sortorder) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) { $sortorder = "DESC"; } @@ -79,7 +79,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); @@ -92,8 +92,8 @@ $chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'acco * Action */ -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 = ''; } // Purge search criteria 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 @@ -110,23 +110,23 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' } // Mass actions -$objectclass='ExpenseReport'; -$objectlabel='ExpenseReport'; +$objectclass = 'ExpenseReport'; +$objectlabel = 'ExpenseReport'; $permissiontoread = $user->rights->expensereport->read; $permissiontodelete = $user->rights->expensereport->delete; $uploaddir = $conf->expensereport->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; if ($massaction == 'ventil') { - $msg=''; + $msg = ''; //print '
' . $langs->trans("Processing") . '...
'; - if (! empty($mesCasesCochees)) { - $msg = '
' . $langs->trans("SelectedLines") . ': '.count($mesCasesCochees).'
'; - $msg.='
'; + if (!empty($mesCasesCochees)) { + $msg = '
'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'
'; + $msg .= '
'; $mesCodesVentilChoisis = $codeventil; $cpt = 0; - $ok=0; - $ko=0; + $ok = 0; + $ko = 0; foreach ($mesCasesCochees as $maLigneCochee) { $maLigneCourante = explode("_", $maLigneCochee); @@ -135,32 +135,32 @@ if ($massaction == 'ventil') { if ($monCompte <= 0) { - $msg.= '
' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NoAccountSelected") . '
'; + $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'
'; $ko++; } else { - $sql = " UPDATE " . MAIN_DB_PREFIX . "expensereport_det"; - $sql .= " SET fk_code_ventilation = " . $monCompte; - $sql .= " WHERE rowid = " . $monId; + $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det"; + $sql .= " SET fk_code_ventilation = ".$monCompte; + $sql .= " WHERE rowid = ".$monId; $accountventilated = new AccountingAccount($db); $accountventilated->fetch($monCompte, ''); - dol_syslog('accountancy/expensereport/list.php:: sql=' . $sql, LOG_DEBUG); + dol_syslog('accountancy/expensereport/list.php:: sql='.$sql, LOG_DEBUG); if ($db->query($sql)) { - $msg.= '
' . $langs->trans("LineOfExpenseReport") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '
'; + $msg .= '
'.$langs->trans("LineOfExpenseReport").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'; $ok++; } else { - $msg.= '
' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '
' . $sql . '
'; + $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'.$sql.'
'; $ko++; } } $cpt++; } - $msg.='
'; - $msg.= '
' . $langs->trans("EndProcessing") . '
'; + $msg .= '
'; + $msg .= '
'.$langs->trans("EndProcessing").'
'; } } @@ -186,14 +186,14 @@ if (empty($chartaccountcode)) // Expense report lines $sql = "SELECT er.ref, er.rowid as erid, er.date_debut,"; -$sql.= " erd.rowid, erd.fk_c_type_fees, erd.comments, erd.total_ht as price, erd.fk_code_ventilation, erd.tva_tx as tva_tx_line, erd.vat_src_code, erd.date,"; -$sql.= " f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label, f.accountancy_code as code_buy,"; -$sql.= " aa.rowid as aarowid"; -$sql.= " FROM " . MAIN_DB_PREFIX . "expensereport as er"; -$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "expensereport_det as erd ON er.rowid = erd.fk_expensereport"; -$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "c_type_fees as f ON f.id = erd.fk_c_type_fees"; -$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON f.accountancy_code = aa.account_number AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.entity = " . $conf->entity; -$sql.= " WHERE er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.") AND erd.fk_code_ventilation <= 0"; +$sql .= " erd.rowid, erd.fk_c_type_fees, erd.comments, erd.total_ht as price, erd.fk_code_ventilation, erd.tva_tx as tva_tx_line, erd.vat_src_code, erd.date,"; +$sql .= " f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label, f.accountancy_code as code_buy,"; +$sql .= " aa.rowid as aarowid"; +$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as er"; +$sql .= " INNER JOIN ".MAIN_DB_PREFIX."expensereport_det as erd ON er.rowid = erd.fk_expensereport"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as f ON f.id = erd.fk_c_type_fees"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON f.accountancy_code = aa.account_number AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity; +$sql .= " WHERE er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.") AND erd.fk_code_ventilation <= 0"; // Add search filter like if (strlen(trim($search_expensereport))) { $sql .= natural_search("er.ref", $search_expensereport); @@ -213,8 +213,8 @@ if (strlen(trim($search_account))) { if (strlen(trim($search_vat))) { $sql .= natural_search("erd.tva_tx", $search_vat, 1); } -$sql.=dolSqlDateFilter('erd.date', $search_day, $search_month, $search_year); -$sql.= " AND er.entity IN (" . getEntity('expensereport', 0) . ")"; // We don't share object for accountancy +$sql .= dolSqlDateFilter('erd.date', $search_day, $search_month, $search_year); +$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy $sql .= $db->order($sortfield, $sortorder); @@ -239,32 +239,32 @@ if ($result) { $num_lines = $db->num_rows($result); $i = 0; - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_lineid) $param.='&search_lineid='.urlencode($search_lineid); - if ($search_day) $param.='&search_day='.urlencode($search_day); - if ($search_month) $param.='&search_month='.urlencode($search_month); - if ($search_year) $param.='&search_year='.urlencode($search_year); - if ($search_expensereport) $param.='&search_expensereport='.urlencode($search_expensereport); - if ($search_label) $param.='&search_label='.urlencode($search_label); - if ($search_desc) $param.='&search_desc='.urlencode($search_desc); - if ($search_amount) $param.='&search_amount='.urlencode($search_amount); - if ($search_vat) $param.='&search_vat='.urlencode($search_vat); + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + if ($search_lineid) $param .= '&search_lineid='.urlencode($search_lineid); + if ($search_day) $param .= '&search_day='.urlencode($search_day); + if ($search_month) $param .= '&search_month='.urlencode($search_month); + if ($search_year) $param .= '&search_year='.urlencode($search_year); + if ($search_expensereport) $param .= '&search_expensereport='.urlencode($search_expensereport); + if ($search_label) $param .= '&search_label='.urlencode($search_label); + if ($search_desc) $param .= '&search_desc='.urlencode($search_desc); + if ($search_amount) $param .= '&search_amount='.urlencode($search_amount); + if ($search_vat) $param .= '&search_vat='.urlencode($search_vat); - $arrayofmassactions = array( + $arrayofmassactions = array( 'ventil'=>$langs->trans("Ventilate") //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); //if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); //if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1); + $massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1); - print '' . "\n"; + print ''."\n"; print ''; if ($optioncss != '') print ''; print ''; @@ -275,7 +275,7 @@ if ($result) { print_barre_liste($langs->trans("ExpenseReportLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); - print ''.$langs->trans("DescVentilTodoExpenseReport") . '

'; + print ''.$langs->trans("DescVentilTodoExpenseReport").'

'; /*$topicmail="Information"; $modelmail="project"; @@ -288,25 +288,25 @@ if ($result) { $moreforfilter = ''; print '
'; - print ''."\n"; + print '
'."\n"; // We add search filter print ''; print ''; - print ''; + print ''; print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print ''; print ''; print ''; print ''; @@ -321,8 +321,8 @@ if ($result) { print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "erd.tva_tx", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', $sortfield, $sortorder, 'center '); print_liste_field_titre("IntoAccount", '', '', '', '', '', $sortfield, $sortorder, 'center '); - $checkpicto=''; - if ($massactionbutton) $checkpicto=$form->showCheckAddButtons('checkforselect', 1); + $checkpicto = ''; + if ($massactionbutton) $checkpicto = $form->showCheckAddButtons('checkforselect', 1); print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print "\n"; @@ -330,7 +330,7 @@ if ($result) { $expensereport_static = new ExpenseReport($db); $form = new Form($db); - while ( $i < min($num_lines, $limit) ) { + while ($i < min($num_lines, $limit)) { $objp = $db->fetch_object($result); $objp->aarowid_suggest = ''; @@ -342,13 +342,13 @@ if ($result) { print ''; // Line id - print ''; + print ''; // Ref Expense report - print ''; + print ''; // Date - print ''; + print ''; // Fees label print ''; // Current account @@ -382,11 +382,11 @@ if ($result) { print ''; print ''; print ""; - $i ++; + $i++; } print '
'; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; $formother->select_year($search_year, 'search_year', 1, 20, 5); print ''; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
' . $objp->rowid . ''.$objp->rowid.'' . $expensereport_static->getNomUrl(1) . ''.$expensereport_static->getNomUrl(1).'' . dol_print_date($db->jdate($objp->date), 'day') . ''.dol_print_date($db->jdate($objp->date), 'day').''; @@ -368,7 +368,7 @@ if ($result) { // Vat rate print ''; - print vatrate($objp->tva_tx_line.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')); + print vatrate($objp->tva_tx_line.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')); print ''; - print 'aarowid ? "checked" : "") . '/>'; + print 'aarowid ? "checked" : "").'/>'; print '
'; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 249cb920c47..bf27dcf650d 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -27,22 +27,22 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; -require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.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.'/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.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","other","productbatch")); +$langs->loadLangs(array("bills", "compta", "accountancy", "other", "productbatch")); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); // Select Box @@ -57,16 +57,16 @@ $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'); $btn_ventil = GETPOST('ventil', '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'); @@ -74,9 +74,9 @@ if (empty($page) || $page < 0) { $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) +if (!$sortfield) $sortfield = "f.datef, f.ref, l.rowid"; -if (! $sortorder) { +if (!$sortorder) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) { $sortorder = "DESC"; } @@ -85,7 +85,7 @@ if (! $sortorder) { // Security check if ($user->socid > 0) accessforbidden(); -if (! $user->rights->accounting->bind->write) +if (!$user->rights->accounting->bind->write) accessforbidden(); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -104,11 +104,11 @@ $chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'acco * 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 +$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)) @@ -132,7 +132,7 @@ if (empty($reshook)) } // Mass actions - $objectclass='AccountingAccount'; + $objectclass = 'AccountingAccount'; $permissiontoread = $user->rights->accounting->read; $permissiontodelete = $user->rights->accounting->delete; $uploaddir = $conf->accounting->dir_output; @@ -141,15 +141,15 @@ if (empty($reshook)) if ($massaction == 'ventil') { - $msg=''; + $msg = ''; //print '
' . $langs->trans("Processing") . '...
'; - if (! empty($mesCasesCochees)) { - $msg = '
' . $langs->trans("SelectedLines") . ': '.count($mesCasesCochees).'
'; - $msg.='
'; + if (!empty($mesCasesCochees)) { + $msg = '
'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'
'; + $msg .= '
'; $cpt = 0; - $ok=0; - $ko=0; + $ok = 0; + $ko = 0; foreach ($mesCasesCochees as $maLigneCochee) { $maLigneCourante = explode("_", $maLigneCochee); @@ -158,32 +158,32 @@ if ($massaction == 'ventil') { if ($monCompte <= 0) { - $msg.= '
' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NoAccountSelected") . '
'; + $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'
'; $ko++; } else { - $sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; - $sql .= " SET fk_code_ventilation = " . $monCompte; - $sql .= " WHERE rowid = " . $monId; + $sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det"; + $sql .= " SET fk_code_ventilation = ".$monCompte; + $sql .= " WHERE rowid = ".$monId; $accountventilated = new AccountingAccount($db); $accountventilated->fetch($monCompte, ''); - dol_syslog('accountancy/supplier/list.php:: sql=' . $sql, LOG_DEBUG); + dol_syslog('accountancy/supplier/list.php:: sql='.$sql, LOG_DEBUG); if ($db->query($sql)) { - $msg.= '
' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '
'; + $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'; $ok++; } else { - $msg.= '
' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '
' . $sql . '
'; + $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'.$sql.'
'; $ko++; } } $cpt++; } - $msg.='
'; - $msg.= '
' . $langs->trans("EndProcessing") . '
'; + $msg .= '
'; + $msg .= '
'.$langs->trans("EndProcessing").'
'; } } @@ -209,22 +209,22 @@ if (empty($chartaccountcode)) // Supplier Invoice Lines $sql = "SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_label, 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_buy as code_buy, p.tva_tx as tva_tx_prod,"; -$sql.= " aa.rowid as aarowid,"; -$sql.= " co.code as country_code, co.label as country_label,"; -$sql.= " s.tva_intra"; -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql.= " FROM " . MAIN_DB_PREFIX . "facture_fourn 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 . "facture_fourn_det as l ON f.rowid = l.fk_facture_fourn"; -$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_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '" . $chartaccountcode."' AND aa.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_buy as code_buy, p.tva_tx as tva_tx_prod,"; +$sql .= " aa.rowid as aarowid,"; +$sql .= " co.code as country_code, co.label as country_label,"; +$sql .= " s.tva_intra"; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn 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."facture_fourn_det as l ON f.rowid = l.fk_facture_fourn"; +$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_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity; +$sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; +$sql .= " AND l.product_type <= 2"; // Add search filter like if ($search_lineid) { $sql .= natural_search("l.rowid", $search_lineid, 1); @@ -250,35 +250,35 @@ if (strlen(trim($search_account))) { if (strlen(trim($search_vat))) { $sql .= natural_search("l.tva_tx", price2num($search_vat), 1); } -$sql.=dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year); +$sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year); if (strlen(trim($search_country))) { $arrayofcode = getCountriesInEEC(); $country_code_in_EEC = $country_code_in_EEC_without_me = ''; foreach ($arrayofcode as $key => $value) { - $country_code_in_EEC.=($country_code_in_EEC ? "," : "")."'".$value."'"; - if ($value != $mysoc->country_code) $country_code_in_EEC_without_me.=($country_code_in_EEC_without_me ? "," : "")."'".$value."'"; + $country_code_in_EEC .= ($country_code_in_EEC ? "," : "")."'".$value."'"; + if ($value != $mysoc->country_code) $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ? "," : "")."'".$value."'"; } if ($search_country == 'special_allnotme') $sql .= " AND co.code <> '".$db->escape($mysoc->country_code)."'"; elseif ($search_country == 'special_eec') $sql .= " AND co.code IN (".$country_code_in_EEC.")"; elseif ($search_country == 'special_eecnotme') $sql .= " AND co.code IN (".$country_code_in_EEC_without_me.")"; elseif ($search_country == 'special_noteec') $sql .= " AND co.code NOT IN (".$country_code_in_EEC.")"; - else $sql .= natural_search(array("co.code","co.label"), $search_country); + else $sql .= natural_search(array("co.code", "co.label"), $search_country); } if (strlen(trim($search_tvaintra))) { $sql .= natural_search("s.tva_intra", $search_tvaintra); } -if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_SITUATION . ")"; +if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql .= " AND f.type IN (".FactureFournisseur::TYPE_STANDARD.",".FactureFournisseur::TYPE_REPLACEMENT.",".FactureFournisseur::TYPE_CREDIT_NOTE.",".FactureFournisseur::TYPE_SITUATION.")"; } else { - $sql .= " AND f.type IN (" . FactureFournisseur::TYPE_STANDARD . "," . FactureFournisseur::TYPE_REPLACEMENT . "," . FactureFournisseur::TYPE_CREDIT_NOTE . "," . FactureFournisseur::TYPE_DEPOSIT . "," . FactureFournisseur::TYPE_SITUATION . ")"; + $sql .= " AND f.type IN (".FactureFournisseur::TYPE_STANDARD.",".FactureFournisseur::TYPE_REPLACEMENT.",".FactureFournisseur::TYPE_CREDIT_NOTE.",".FactureFournisseur::TYPE_DEPOSIT.",".FactureFournisseur::TYPE_SITUATION.")"; } -$sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy +$sql .= " AND f.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; $sql .= $db->order($sortfield, $sortorder); @@ -304,34 +304,34 @@ if ($result) { $num_lines = $db->num_rows($result); $i = 0; - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); - $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_lineid) $param.='&search_lineid='.urlencode($search_lineid); - if ($search_day) $param.='&search_day='.urlencode($search_day); - if ($search_month) $param.='&search_month='.urlencode($search_month); - if ($search_year) $param.='&search_year='.urlencode($search_year); - if ($search_invoice) $param.='&search_invoice='.urlencode($search_invoice); - if ($search_ref) $param.='&search_ref='.urlencode($search_ref); - if ($search_label) $param.='&search_label='.urlencode($search_label); - if ($search_desc) $param.='&search_desc='.urlencode($search_desc); - if ($search_amount) $param.='&search_amount='.urlencode($search_amount); - if ($search_vat) $param.='&search_vat='.urlencode($search_vat); - if ($search_country) $param.="&search_country=".urlencode($search_country); - if ($search_tvaintra) $param.="&search_tvaintra=".urlencode($search_tvaintra); + $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_lineid) $param .= '&search_lineid='.urlencode($search_lineid); + if ($search_day) $param .= '&search_day='.urlencode($search_day); + if ($search_month) $param .= '&search_month='.urlencode($search_month); + if ($search_year) $param .= '&search_year='.urlencode($search_year); + if ($search_invoice) $param .= '&search_invoice='.urlencode($search_invoice); + if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); + if ($search_label) $param .= '&search_label='.urlencode($search_label); + if ($search_desc) $param .= '&search_desc='.urlencode($search_desc); + if ($search_amount) $param .= '&search_amount='.urlencode($search_amount); + if ($search_vat) $param .= '&search_vat='.urlencode($search_vat); + if ($search_country) $param .= "&search_country=".urlencode($search_country); + if ($search_tvaintra) $param .= "&search_tvaintra=".urlencode($search_tvaintra); - $arrayofmassactions = array( + $arrayofmassactions = array( 'ventil'=>$langs->trans("Ventilate") //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); //if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); //if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1); + $massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1); - print '' . "\n"; + print ''."\n"; print ''; if ($optioncss != '') print ''; print ''; @@ -342,7 +342,7 @@ if ($result) { print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); - print ''.$langs->trans("DescVentilTodoCustomer") . '

'; + print ''.$langs->trans("DescVentilTodoCustomer").'

'; /*$topicmail="Information"; $modelmail="project"; @@ -355,31 +355,31 @@ if ($result) { $moreforfilter = ''; print '
'; - print ''."\n"; + print '
'."\n"; // We add search filter print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; print "\n"; @@ -398,8 +398,8 @@ if ($result) { print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'center '); print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', 'center '); - $checkpicto=''; - if ($massactionbutton) $checkpicto=$form->showCheckAddButtons('checkforselect', 1); + $checkpicto = ''; + if ($massactionbutton) $checkpicto = $form->showCheckAddButtons('checkforselect', 1); print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print "\n"; @@ -429,18 +429,18 @@ if ($result) { $objp->aarowid_suggest = $objp->aarowid; if ($objp->type_l == 1) { - $objp->code_buy_l = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : ''); + $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : ''); if ($objp->aarowid == '') $objp->aarowid_suggest = $aarowid_s; } elseif ($objp->type_l == 0) { - $objp->code_buy_l = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : ''); + $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : ''); if ($objp->aarowid == '') $objp->aarowid_suggest = $aarowid_p; } - if ($objp->code_buy_l == -1) $objp->code_buy_l=''; + if ($objp->code_buy_l == -1) $objp->code_buy_l = ''; - if (! empty($objp->code_buy)) { - $objp->code_buy_p = $objp->code_buy; // Code on product + if (!empty($objp->code_buy)) { + $objp->code_buy_p = $objp->code_buy; // Code on product } else { $code_buy_p_notset = 'color:orange'; } @@ -452,16 +452,16 @@ if ($result) { print ''; // Line id - print ''; + print ''; // Ref Invoice - print ''; + print ''; print ''; - print ''; + print ''; // Ref Product print ''; // Country print ''; // VAT Num - print ''; + print ''; // Current account - print ''; @@ -526,11 +526,11 @@ if ($result) { // Column with checkbox print ''; print ''; - $i ++; + $i++; } print '
'; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; $formother->select_year($search_year, 'search_year', 1, 20, 5); print ''; print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth150', 'code2', 1, 0, 1); //print ''; print ''; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
' . $objp->rowid . ''.$objp->rowid.'' . $facturefourn_static->getNomUrl(1) . ''.$facturefourn_static->getNomUrl(1).''; print $objp->invoice_label; print '' . dol_print_date($db->jdate($objp->datef), 'day') . ''.dol_print_date($db->jdate($objp->datef), 'day').''; @@ -484,35 +484,35 @@ if ($result) { // Vat rate if ($objp->vat_tx_l != $objp->vat_tx_p) $code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red'; - print ''; - print vatrate($objp->tva_tx_line.($objp->vat_src_code?' ('.$objp->vat_src_code.')':'')); + print ''; + print vatrate($objp->tva_tx_line.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')); print ''; - $labelcountry=($objp->country_code && ($langs->trans("Country".$objp->country_code)!="Country".$objp->country_code))?$langs->trans("Country".$objp->country_code):$objp->country_label; + $labelcountry = ($objp->country_code && ($langs->trans("Country".$objp->country_code) != "Country".$objp->country_code)) ? $langs->trans("Country".$objp->country_code) : $objp->country_label; print $labelcountry; print '' . $objp->tva_intra . ''.$objp->tva_intra.''; - $s = (($objp->type_l == 1)?$langs->trans("DefaultForService"):$langs->trans("DefaultForProduct")).': '; + print ''; + $s = (($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': '; $shelp = ''; - if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp.= $langs->trans("SaleEEC"); - elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp.= $langs->trans("SaleExport"); - $s.= ($objp->code_buy_l > 0 ? length_accountg($objp->code_buy_l) : $langs->trans("NotDefined")); + if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp .= $langs->trans("SaleEEC"); + elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp .= $langs->trans("SaleExport"); + $s .= ($objp->code_buy_l > 0 ? length_accountg($objp->code_buy_l) : $langs->trans("NotDefined")); print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); if ($objp->product_id > 0) { print '
'; - $s = (($objp->type_l == 1)?$langs->trans("ThisService"):$langs->trans("ThisProduct")).': '; + $s = (($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': '; $shelp = ''; if ($suggestedaccountingaccountfor == 'eec') $shelp = $langs->trans("SaleEEC"); elseif ($suggestedaccountingaccountfor == 'export') $shelp = $langs->trans("SaleExport"); - $s.= (empty($objp->code_buy_p) ? $langs->trans("NotDefined") : length_accountg($objp->code_buy_p)); + $s .= (empty($objp->code_buy_p) ? $langs->trans("NotDefined") : length_accountg($objp->code_buy_p)); print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); } print '
'; $ischecked = $objp->aarowid_suggest; - print ''; + print ''; print '
'; diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 81d6b7625b7..1cf99284074 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -32,55 +32,55 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -$langs->loadLangs(array("members","companies")); +$langs->loadLangs(array("members", "companies")); -$action=GETPOST('action', 'aZ09'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'memberslist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'memberslist'; // To manage different context of search // Security check -$result=restrictedArea($user, 'adherent'); +$result = restrictedArea($user, 'adherent'); -$filter=GETPOST("filter", 'alpha'); -$statut=GETPOST("statut", 'intcomma'); -$search=GETPOST("search", 'alpha'); -$search_ref=GETPOST("search_ref", 'alpha'); -$search_lastname=GETPOST("search_lastname", 'alpha'); -$search_firstname=GETPOST("search_firstname", 'alpha'); -$search_gender=GETPOST("search_gender", 'alpha'); -$search_civility=GETPOST("search_civility", 'alpha'); -$search_login=GETPOST("search_login", 'alpha'); -$search_address=GETPOST("search_address", 'alpha'); -$search_zip=GETPOST("search_zip", 'alpha'); -$search_town=GETPOST("search_town", 'alpha'); -$search_state=GETPOST("search_state", 'alpha'); -$search_country=GETPOST("search_country", 'alpha'); -$search_phone=GETPOST("search_phone", 'alpha'); -$search_phone_perso=GETPOST("search_phone_perso", 'alpha'); -$search_phone_mobile=GETPOST("search_phone_mobile", 'alpha'); -$search_type=GETPOST("search_type", 'alpha'); -$search_email=GETPOST("search_email", 'alpha'); +$filter = GETPOST("filter", 'alpha'); +$statut = GETPOST("statut", 'intcomma'); +$search = GETPOST("search", 'alpha'); +$search_ref = GETPOST("search_ref", 'alpha'); +$search_lastname = GETPOST("search_lastname", 'alpha'); +$search_firstname = GETPOST("search_firstname", 'alpha'); +$search_gender = GETPOST("search_gender", 'alpha'); +$search_civility = GETPOST("search_civility", 'alpha'); +$search_login = GETPOST("search_login", 'alpha'); +$search_address = GETPOST("search_address", 'alpha'); +$search_zip = GETPOST("search_zip", 'alpha'); +$search_town = GETPOST("search_town", 'alpha'); +$search_state = GETPOST("search_state", 'alpha'); +$search_country = GETPOST("search_country", 'alpha'); +$search_phone = GETPOST("search_phone", 'alpha'); +$search_phone_perso = GETPOST("search_phone_perso", 'alpha'); +$search_phone_mobile = GETPOST("search_phone_mobile", 'alpha'); +$search_type = GETPOST("search_type", 'alpha'); +$search_email = GETPOST("search_email", 'alpha'); $search_categ = GETPOST("search_categ", 'int'); $catid = GETPOST("catid", 'int'); $optioncss = GETPOST('optioncss', 'alpha'); -$sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); if ($statut < -1) $statut = ''; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $limit * $page ; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) { $sortorder=($filter=='outofdate'?"DESC":"ASC"); } -if (! $sortfield) { $sortfield=($filter=='outofdate'?"d.datefin":"d.lastname"); } +if (!$sortorder) { $sortorder = ($filter == 'outofdate' ? "DESC" : "ASC"); } +if (!$sortfield) { $sortfield = ($filter == 'outofdate' ? "d.datefin" : "d.lastname"); } $object = new Adherent($db); @@ -91,7 +91,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -108,8 +108,8 @@ $fieldstosearchall = array( 'd.note_public'=>'NotePublic', 'd.note_private'=>'NotePrivate', ); -if($db->type == 'pgsql') unset($fieldstosearchall['d.rowid']); -$arrayfields=array( +if ($db->type == 'pgsql') unset($fieldstosearchall['d.rowid']); +$arrayfields = array( 'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'd.civility'=>array('label'=>$langs->trans("Civility"), 'checked'=>0), 'd.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1), @@ -139,10 +139,10 @@ $arrayfields=array( // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } @@ -151,11 +151,11 @@ if (is_array($extrafields->attributes[$object->table_element]['label']) && count * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; } -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) @@ -166,48 +166,48 @@ if (empty($reshook)) // Purge search criteria 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=""; - $search_ref=""; - $search_lastname=""; - $search_firstname=""; - $search_gender=""; - $search_civility=""; - $search_login=""; - $search_company=""; - $search_type=""; - $search_email=""; - $search_address=""; - $search_zip=""; - $search_town=""; - $search_state=""; - $search_country=''; - $search_phone=''; - $search_phone_perso=''; - $search_phone_mobile=''; - $search_morphy=""; - $search_categ=""; - $catid=""; - $sall=""; - $statut=''; - $toselect=''; - $search_array_options=array(); + $search = ""; + $search_ref = ""; + $search_lastname = ""; + $search_firstname = ""; + $search_gender = ""; + $search_civility = ""; + $search_login = ""; + $search_company = ""; + $search_type = ""; + $search_email = ""; + $search_address = ""; + $search_zip = ""; + $search_town = ""; + $search_state = ""; + $search_country = ''; + $search_phone = ''; + $search_phone_perso = ''; + $search_phone_mobile = ''; + $search_morphy = ""; + $search_categ = ""; + $catid = ""; + $sall = ""; + $statut = ''; + $toselect = ''; + $search_array_options = array(); } // Close if ($massaction == 'close' && $user->rights->adherent->creer) { $tmpmember = new Adherent($db); - $error=0; - $nbclose=0; + $error = 0; + $nbclose = 0; $db->begin(); - foreach($toselect as $idtoclose) + foreach ($toselect as $idtoclose) { $tmpmember->fetch($idtoclose); - $result=$tmpmember->resiliate($user); + $result = $tmpmember->resiliate($user); - if ($result < 0 && ! count($tmpmember->errors)) + if ($result < 0 && !count($tmpmember->errors)) { setEventMessages($tmpmember->error, $tmpmember->errors, 'errors'); } @@ -217,7 +217,7 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { setEventMessages($langs->trans("XMembersClosed", $nbclose), null, 'mesgs'); @@ -230,8 +230,8 @@ if (empty($reshook)) } // Mass actions - $objectclass='Adherent'; - $objectlabel='Members'; + $objectclass = 'Adherent'; + $objectlabel = 'Members'; $permissiontoread = $user->rights->adherent->lire; $permissiontodelete = $user->rights->adherent->supprimer; $uploaddir = $conf->adherent->dir_output; @@ -243,69 +243,69 @@ if (empty($reshook)) * View */ -$form=new Form($db); -$formother=new FormOther($db); -$membertypestatic=new AdherentType($db); -$memberstatic=new Adherent($db); +$form = new Form($db); +$formother = new FormOther($db); +$membertypestatic = new AdherentType($db); +$memberstatic = new Adherent($db); -$now=dol_now(); +$now = dol_now(); $sql = "SELECT d.rowid, d.login, d.lastname, d.firstname, d.gender, d.societe as company, d.fk_soc,"; -$sql.= " d.civility, d.datefin, d.address, d.zip, d.town, d.state_id, d.country,"; -$sql.= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.skype, d.birth, d.public, d.photo,"; -$sql.= " d.fk_adherent_type as type_id, d.morphy, d.statut, d.datec as date_creation, d.tms as date_update,"; -$sql.= " t.libelle as type, t.subscription,"; -$sql.= " state.code_departement as state_code, state.nom as state_name,"; +$sql .= " d.civility, d.datefin, d.address, d.zip, d.town, d.state_id, d.country,"; +$sql .= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.skype, d.birth, d.public, d.photo,"; +$sql .= " d.fk_adherent_type as type_id, d.morphy, d.statut, d.datec as date_creation, d.tms as date_update,"; +$sql .= " t.libelle as type, t.subscription,"; +$sql .= " state.code_departement as state_code, state.nom as state_name,"; // 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.', ' : ''); +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.', ' : ''); // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook -$sql.=preg_replace('/^,/', '', $hookmanager->resPrint); -$sql =preg_replace('/,\s*$/', '', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d"; -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 (d.rowid = ef.fk_object)"; -if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_member as cm ON d.rowid = cm.fk_member"; // We need this table joined to the select in order to filter by categ -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = d.country)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = d.state_id)"; -$sql.= ", ".MAIN_DB_PREFIX."adherent_type as t"; -$sql.= " WHERE d.fk_adherent_type = t.rowid "; -if ($catid > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($catid); -if ($catid == -2) $sql.= " AND cm.fk_categorie IS NULL"; -if ($search_categ > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($search_categ); -if ($search_categ == -2) $sql.= " AND cm.fk_categorie IS NULL"; -$sql.= " AND d.entity IN (".getEntity('adherent').")"; -if ($sall) $sql.=natural_search(array_keys($fieldstosearchall), $sall); -if ($search_type > 0) $sql.=" AND t.rowid=".$db->escape($search_type); -if ($statut != '') $sql.=" AND d.statut in (".$db->escape($statut).")"; // Peut valoir un nombre ou liste de nombre separes par virgules +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql = preg_replace('/,\s*$/', '', $sql); +$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; +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 (d.rowid = ef.fk_object)"; +if (!empty($search_categ) || !empty($catid)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_member as cm ON d.rowid = cm.fk_member"; // We need this table joined to the select in order to filter by categ +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = d.country)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = d.state_id)"; +$sql .= ", ".MAIN_DB_PREFIX."adherent_type as t"; +$sql .= " WHERE d.fk_adherent_type = t.rowid "; +if ($catid > 0) $sql .= " AND cm.fk_categorie = ".$db->escape($catid); +if ($catid == -2) $sql .= " AND cm.fk_categorie IS NULL"; +if ($search_categ > 0) $sql .= " AND cm.fk_categorie = ".$db->escape($search_categ); +if ($search_categ == -2) $sql .= " AND cm.fk_categorie IS NULL"; +$sql .= " AND d.entity IN (".getEntity('adherent').")"; +if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); +if ($search_type > 0) $sql .= " AND t.rowid=".$db->escape($search_type); +if ($statut != '') $sql .= " AND d.statut in (".$db->escape($statut).")"; // Peut valoir un nombre ou liste de nombre separes par virgules if ($search_ref) { - if (is_numeric($search_ref)) $sql.= " AND (d.rowid = ".$db->escape($search_ref).")"; - else $sql.=" AND 1 = 2"; // Always wrong + if (is_numeric($search_ref)) $sql .= " AND (d.rowid = ".$db->escape($search_ref).")"; + else $sql .= " AND 1 = 2"; // Always wrong } -if ($search_civility) $sql.= natural_search("d.civility", $search_civility); -if ($search_firstname) $sql.= natural_search("d.firstname", $search_firstname); -if ($search_lastname) $sql.= natural_search(array("d.firstname", "d.lastname", "d.societe"), $search_lastname); -if ($search_gender != '' && $search_gender != '-1') $sql.= " AND d.gender = '".$search_gender."'"; -if ($search_login) $sql.= natural_search("d.login", $search_login); -if ($search_email) $sql.= natural_search("d.email", $search_email); -if ($search_town) $sql.= natural_search("d.town", $search_town); -if ($search_zip) $sql.= natural_search("d.zip", $search_zip); -if ($search_state) $sql.= natural_search("state.nom", $search_state); +if ($search_civility) $sql .= natural_search("d.civility", $search_civility); +if ($search_firstname) $sql .= natural_search("d.firstname", $search_firstname); +if ($search_lastname) $sql .= natural_search(array("d.firstname", "d.lastname", "d.societe"), $search_lastname); +if ($search_gender != '' && $search_gender != '-1') $sql .= " AND d.gender = '".$search_gender."'"; +if ($search_login) $sql .= natural_search("d.login", $search_login); +if ($search_email) $sql .= natural_search("d.email", $search_email); +if ($search_town) $sql .= natural_search("d.town", $search_town); +if ($search_zip) $sql .= natural_search("d.zip", $search_zip); +if ($search_state) $sql .= natural_search("state.nom", $search_state); if ($search_country) $sql .= " AND d.country IN (".$search_country.')'; -if ($filter == 'uptodate') $sql.=" AND (datefin >= '".$db->idate($now)."' OR t.subscription = 0)"; -if ($filter == 'outofdate') $sql.=" AND ((datefin IS NULL OR datefin < '".$db->idate($now)."') AND t.subscription = 1)"; +if ($filter == 'uptodate') $sql .= " AND (datefin >= '".$db->idate($now)."' OR t.subscription = 0)"; +if ($filter == 'outofdate') $sql .= " AND ((datefin IS NULL OR datefin < '".$db->idate($now)."') AND t.subscription = 1)"; // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records with no order and no limits $nbtotalofrecords = ''; @@ -321,11 +321,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } // Add limit -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); dol_syslog("get list", LOG_DEBUG); $resql = $db->query($sql); -if (! $resql) +if (!$resql) { dol_print_error($db); exit; @@ -333,9 +333,9 @@ if (! $resql) $num = $db->num_rows($resql); -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -345,69 +345,69 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && llxHeader('', $langs->trans("Member"), 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); -$titre=$langs->trans("MembersList"); +$titre = $langs->trans("MembersList"); if (GETPOSTISSET("statut")) { - if ($statut == '-1,1') { $titre=$langs->trans("MembersListQualified"); } - if ($statut == '-1') { $titre=$langs->trans("MembersListToValid"); } - if ($statut == '1' && ! $filter) { $titre=$langs->trans("MembersListValid"); } - if ($statut == '1' && $filter=='uptodate') { $titre=$langs->trans("MembersListUpToDate"); } - if ($statut == '1' && $filter=='outofdate') { $titre=$langs->trans("MembersListNotUpToDate"); } - if ($statut == '0') { $titre=$langs->trans("MembersListResiliated"); } + if ($statut == '-1,1') { $titre = $langs->trans("MembersListQualified"); } + if ($statut == '-1') { $titre = $langs->trans("MembersListToValid"); } + if ($statut == '1' && !$filter) { $titre = $langs->trans("MembersListValid"); } + if ($statut == '1' && $filter == 'uptodate') { $titre = $langs->trans("MembersListUpToDate"); } + if ($statut == '1' && $filter == 'outofdate') { $titre = $langs->trans("MembersListNotUpToDate"); } + if ($statut == '0') { $titre = $langs->trans("MembersListResiliated"); } } elseif ($action == 'search') { - $titre=$langs->trans("MembersListQualified"); + $titre = $langs->trans("MembersListQualified"); } if ($search_type > 0) { - $membertype=new AdherentType($db); - $result=$membertype->fetch(GETPOST("type", 'int')); - $titre.=" (".$membertype->label.")"; + $membertype = new AdherentType($db); + $result = $membertype->fetch(GETPOST("type", 'int')); + $titre .= " (".$membertype->label.")"; } -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); -if ($sall != "") $param.="&sall=".urlencode($sall); -if ($statut != "") $param.="&statut=".urlencode($statut); -if ($search_ref) $param.="&search_ref=".urlencode($search_ref); -if ($search_civility) $param.="&search_civility=".urlencode($search_civility); -if ($search_firstname) $param.="&search_firstname=".urlencode($search_firstname); -if ($search_lastname) $param.="&search_lastname=".urlencode($search_lastname); -if ($search_gender) $param.="&search_gender=".urlencode($search_gender); -if ($search_login) $param.="&search_login=".urlencode($search_login); -if ($search_email) $param.="&search_email=".urlencode($search_email); -if ($search_company) $param.="&search_company=".urlencode($search_company); -if ($search_address != '') $param.= "&search_address=".urlencode($search_address); -if ($search_town != '') $param.= "&search_town=".urlencode($search_town); -if ($search_zip != '') $param.= "&search_zip=".urlencode($search_zip); -if ($search_state != '') $param.= "&search_state=".urlencode($search_state); -if ($search_country != '') $param.= "&search_country=".urlencode($search_country); -if ($search_phone != '') $param.= "&search_phone=".urlencode($search_phone); -if ($search_phone_perso != '') $param.= "&search_phone_perso=".urlencode($search_phone_perso); -if ($search_phone_mobile != '') $param.= "&search_phone_mobile=".urlencode($search_phone_mobile); -if ($filter) $param.="&filter=".urlencode($filter); -if ($search_type > 0) $param.="&search_type=".urlencode($search_type); -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +if ($sall != "") $param .= "&sall=".urlencode($sall); +if ($statut != "") $param .= "&statut=".urlencode($statut); +if ($search_ref) $param .= "&search_ref=".urlencode($search_ref); +if ($search_civility) $param .= "&search_civility=".urlencode($search_civility); +if ($search_firstname) $param .= "&search_firstname=".urlencode($search_firstname); +if ($search_lastname) $param .= "&search_lastname=".urlencode($search_lastname); +if ($search_gender) $param .= "&search_gender=".urlencode($search_gender); +if ($search_login) $param .= "&search_login=".urlencode($search_login); +if ($search_email) $param .= "&search_email=".urlencode($search_email); +if ($search_company) $param .= "&search_company=".urlencode($search_company); +if ($search_address != '') $param .= "&search_address=".urlencode($search_address); +if ($search_town != '') $param .= "&search_town=".urlencode($search_town); +if ($search_zip != '') $param .= "&search_zip=".urlencode($search_zip); +if ($search_state != '') $param .= "&search_state=".urlencode($search_state); +if ($search_country != '') $param .= "&search_country=".urlencode($search_country); +if ($search_phone != '') $param .= "&search_phone=".urlencode($search_phone); +if ($search_phone_perso != '') $param .= "&search_phone_perso=".urlencode($search_phone_perso); +if ($search_phone_mobile != '') $param .= "&search_phone_mobile=".urlencode($search_phone_mobile); +if ($filter) $param .= "&filter=".urlencode($filter); +if ($search_type > 0) $param .= "&search_type=".urlencode($search_type); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); -if ($user->rights->adherent->creer) $arrayofmassactions['close']=$langs->trans("Resiliate"); -if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); -if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($user->rights->adherent->creer) $arrayofmassactions['close'] = $langs->trans("Resiliate"); +if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); -$newcardbutton=''; +$newcardbutton = ''; if ($user->rights->adherent->creer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewMember'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewMember'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create'); } print ''; @@ -422,164 +422,164 @@ print ''; print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'members', 0, $newcardbutton, '', $limit); -$topicmail="Information"; -$modelmail="member"; -$objecttmp=new Adherent($db); -$trackid='mem'.$object->id; +$topicmail = "Information"; +$modelmail = "member"; +$objecttmp = new Adherent($db); +$trackid = 'mem'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } // Filter on categories -$moreforfilter=''; -if (! empty($conf->categorie->enabled)) +$moreforfilter = ''; +if (!empty($conf->categorie->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('Categories'). ': '; - $moreforfilter.=$formother->select_categories(Categorie::TYPE_MEMBER, $search_categ, 'search_categ', 1); - $moreforfilter.='
'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('Categories').': '; + $moreforfilter .= $formother->select_categories(Categorie::TYPE_MEMBER, $search_categ, 'search_categ', 1); + $moreforfilter .= '
'; } -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '
'; print $moreforfilter; print '
'; } -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); print '
'; -print ''."\n"; +print '
'."\n"; // Line for filters fields print ''; // Line numbering -if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) +if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { print ''; } // Ref -if (! empty($arrayfields['d.ref']['checked'])) +if (!empty($arrayfields['d.ref']['checked'])) { print ''; } -if (! empty($arrayfields['d.civility']['checked'])) +if (!empty($arrayfields['d.civility']['checked'])) { print ''; } -if (! empty($arrayfields['d.firstname']['checked'])) +if (!empty($arrayfields['d.firstname']['checked'])) { print ''; } -if (! empty($arrayfields['d.lastname']['checked'])) +if (!empty($arrayfields['d.lastname']['checked'])) { print ''; } -if (! empty($arrayfields['d.gender']['checked'])) +if (!empty($arrayfields['d.gender']['checked'])) { print ''; } -if (! empty($arrayfields['d.company']['checked'])) +if (!empty($arrayfields['d.company']['checked'])) { print ''; } -if (! empty($arrayfields['d.login']['checked'])) +if (!empty($arrayfields['d.login']['checked'])) { print ''; } -if (! empty($arrayfields['d.morphy']['checked'])) +if (!empty($arrayfields['d.morphy']['checked'])) { print ''; } -if (! empty($arrayfields['t.libelle']['checked'])) +if (!empty($arrayfields['t.libelle']['checked'])) { print ''; } -if (! empty($arrayfields['d.address']['checked'])) +if (!empty($arrayfields['d.address']['checked'])) { print ''; } -if (! empty($arrayfields['d.zip']['checked'])) +if (!empty($arrayfields['d.zip']['checked'])) { print ''; } -if (! empty($arrayfields['d.town']['checked'])) +if (!empty($arrayfields['d.town']['checked'])) { print ''; } // State -if (! empty($arrayfields['state.nom']['checked'])) +if (!empty($arrayfields['state.nom']['checked'])) { print ''; } // Country -if (! empty($arrayfields['country.code_iso']['checked'])) +if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; } // Phone pro -if (! empty($arrayfields['d.phone']['checked'])) +if (!empty($arrayfields['d.phone']['checked'])) { print ''; } // Phone perso -if (! empty($arrayfields['d.phone_perso']['checked'])) +if (!empty($arrayfields['d.phone_perso']['checked'])) { print ''; } // Phone mobile -if (! empty($arrayfields['d.phone_mobile']['checked'])) +if (!empty($arrayfields['d.phone_mobile']['checked'])) { print ''; } // Email -if (! empty($arrayfields['d.email']['checked'])) +if (!empty($arrayfields['d.email']['checked'])) { print ''; } -if (! empty($arrayfields['d.datefin']['checked'])) +if (!empty($arrayfields['d.datefin']['checked'])) { print ''; @@ -588,32 +588,32 @@ if (! empty($arrayfields['d.datefin']['checked'])) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation -if (! empty($arrayfields['d.datec']['checked'])) +if (!empty($arrayfields['d.datec']['checked'])) { print ''; } //Birthday -if (! empty($arrayfields['d.birth']['checked'])) +if (!empty($arrayfields['d.birth']['checked'])) { print ''; } // Date modification -if (! empty($arrayfields['d.tms']['checked'])) +if (!empty($arrayfields['d.tms']['checked'])) { print ''; } // Status -if (! empty($arrayfields['d.statut']['checked'])) +if (!empty($arrayfields['d.statut']['checked'])) { print ''; print "\n"; print ''; -if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) print_liste_field_titre("ID", $_SERVER["PHP_SELF"], '', '', $param, 'align="center"', $sortfield, $sortorder); -if (! empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], 'd.rowid', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['d.civility']['checked'])) print_liste_field_titre($arrayfields['d.civility']['label'], $_SERVER["PHP_SELF"], 'd.civility', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['d.firstname']['checked'])) print_liste_field_titre($arrayfields['d.firstname']['label'], $_SERVER["PHP_SELF"], 'd.firstname', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['d.lastname']['checked'])) print_liste_field_titre($arrayfields['d.lastname']['label'], $_SERVER["PHP_SELF"], 'd.lastname', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['d.gender']['checked'])) print_liste_field_titre($arrayfields['d.gender']['label'], $_SERVER['PHP_SELF'], 'd.gender', $param, "", "", $sortfield, $sortorder); -if (! empty($arrayfields['d.company']['checked'])) print_liste_field_titre($arrayfields['d.company']['label'], $_SERVER["PHP_SELF"], 'd.societe', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['d.login']['checked'])) print_liste_field_titre($arrayfields['d.login']['label'], $_SERVER["PHP_SELF"], 'd.login', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['d.morphy']['checked'])) print_liste_field_titre($arrayfields['d.morphy']['label'], $_SERVER["PHP_SELF"], 'd.morphy', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['t.libelle']['checked'])) print_liste_field_titre($arrayfields['t.libelle']['label'], $_SERVER["PHP_SELF"], 't.libelle', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['d.address']['checked'])) print_liste_field_titre($arrayfields['d.address']['label'], $_SERVER["PHP_SELF"], 'd.address', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['d.zip']['checked'])) print_liste_field_titre($arrayfields['d.zip']['label'], $_SERVER["PHP_SELF"], 'd.zip', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['d.town']['checked'])) print_liste_field_titre($arrayfields['d.town']['label'], $_SERVER["PHP_SELF"], 'd.town', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder); -if (! empty($arrayfields['d.phone']['checked'])) print_liste_field_titre($arrayfields['d.phone']['label'], $_SERVER["PHP_SELF"], 'd.phone', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['d.phone_perso']['checked'])) print_liste_field_titre($arrayfields['d.phone_perso']['label'], $_SERVER["PHP_SELF"], 'd.phone_perso', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['d.phone_mobile']['checked'])) print_liste_field_titre($arrayfields['d.phone_mobile']['label'], $_SERVER["PHP_SELF"], 'd.phone_mobile', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['d.email']['checked'])) print_liste_field_titre($arrayfields['d.email']['label'], $_SERVER["PHP_SELF"], 'd.email', '', $param, '', $sortfield, $sortorder); -if (! empty($arrayfields['d.datefin']['checked'])) print_liste_field_titre($arrayfields['d.datefin']['label'], $_SERVER["PHP_SELF"], 'd.datefin', '', $param, 'align="center"', $sortfield, $sortorder); +if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) print_liste_field_titre("ID", $_SERVER["PHP_SELF"], '', '', $param, 'align="center"', $sortfield, $sortorder); +if (!empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], 'd.rowid', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['d.civility']['checked'])) print_liste_field_titre($arrayfields['d.civility']['label'], $_SERVER["PHP_SELF"], 'd.civility', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['d.firstname']['checked'])) print_liste_field_titre($arrayfields['d.firstname']['label'], $_SERVER["PHP_SELF"], 'd.firstname', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['d.lastname']['checked'])) print_liste_field_titre($arrayfields['d.lastname']['label'], $_SERVER["PHP_SELF"], 'd.lastname', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['d.gender']['checked'])) print_liste_field_titre($arrayfields['d.gender']['label'], $_SERVER['PHP_SELF'], 'd.gender', $param, "", "", $sortfield, $sortorder); +if (!empty($arrayfields['d.company']['checked'])) print_liste_field_titre($arrayfields['d.company']['label'], $_SERVER["PHP_SELF"], 'd.societe', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['d.login']['checked'])) print_liste_field_titre($arrayfields['d.login']['label'], $_SERVER["PHP_SELF"], 'd.login', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['d.morphy']['checked'])) print_liste_field_titre($arrayfields['d.morphy']['label'], $_SERVER["PHP_SELF"], 'd.morphy', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['t.libelle']['checked'])) print_liste_field_titre($arrayfields['t.libelle']['label'], $_SERVER["PHP_SELF"], 't.libelle', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['d.address']['checked'])) print_liste_field_titre($arrayfields['d.address']['label'], $_SERVER["PHP_SELF"], 'd.address', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['d.zip']['checked'])) print_liste_field_titre($arrayfields['d.zip']['label'], $_SERVER["PHP_SELF"], 'd.zip', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['d.town']['checked'])) print_liste_field_titre($arrayfields['d.town']['label'], $_SERVER["PHP_SELF"], 'd.town', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder); +if (!empty($arrayfields['d.phone']['checked'])) print_liste_field_titre($arrayfields['d.phone']['label'], $_SERVER["PHP_SELF"], 'd.phone', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['d.phone_perso']['checked'])) print_liste_field_titre($arrayfields['d.phone_perso']['label'], $_SERVER["PHP_SELF"], 'd.phone_perso', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['d.phone_mobile']['checked'])) print_liste_field_titre($arrayfields['d.phone_mobile']['label'], $_SERVER["PHP_SELF"], 'd.phone_mobile', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['d.email']['checked'])) print_liste_field_titre($arrayfields['d.email']['label'], $_SERVER["PHP_SELF"], 'd.email', '', $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['d.datefin']['checked'])) print_liste_field_titre($arrayfields['d.datefin']['label'], $_SERVER["PHP_SELF"], 'd.datefin', '', $param, 'align="center"', $sortfield, $sortorder); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (! empty($arrayfields['d.datec']['checked'])) print_liste_field_titre($arrayfields['d.datec']['label'], $_SERVER["PHP_SELF"], "d.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); -if (! empty($arrayfields['d.birth']['checked'])) print_liste_field_titre($arrayfields['d.birth']['label'], $_SERVER["PHP_SELF"], "d.birth", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); -if (! empty($arrayfields['d.tms']['checked'])) print_liste_field_titre($arrayfields['d.tms']['label'], $_SERVER["PHP_SELF"], "d.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); -if (! empty($arrayfields['d.statut']['checked'])) print_liste_field_titre($arrayfields['d.statut']['label'], $_SERVER["PHP_SELF"], "d.statut", "", $param, 'class="right"', $sortfield, $sortorder); +if (!empty($arrayfields['d.datec']['checked'])) print_liste_field_titre($arrayfields['d.datec']['label'], $_SERVER["PHP_SELF"], "d.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); +if (!empty($arrayfields['d.birth']['checked'])) print_liste_field_titre($arrayfields['d.birth']['label'], $_SERVER["PHP_SELF"], "d.birth", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); +if (!empty($arrayfields['d.tms']['checked'])) print_liste_field_titre($arrayfields['d.tms']['label'], $_SERVER["PHP_SELF"], "d.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); +if (!empty($arrayfields['d.statut']['checked'])) print_liste_field_titre($arrayfields['d.statut']['label'], $_SERVER["PHP_SELF"], "d.statut", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; $i = 0; -$totalarray=array(); +$totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - $datefin=$db->jdate($obj->datefin); - $memberstatic->id=$obj->rowid; - $memberstatic->ref=$obj->rowid; - $memberstatic->civility_id=$obj->civility; - $memberstatic->lastname=$obj->lastname; - $memberstatic->firstname=$obj->firstname; - $memberstatic->gender=$obj->gender; - $memberstatic->statut=$obj->statut; - $memberstatic->datefin= $datefin; + $datefin = $db->jdate($obj->datefin); + $memberstatic->id = $obj->rowid; + $memberstatic->ref = $obj->rowid; + $memberstatic->civility_id = $obj->civility; + $memberstatic->lastname = $obj->lastname; + $memberstatic->firstname = $obj->firstname; + $memberstatic->gender = $obj->gender; + $memberstatic->statut = $obj->statut; + $memberstatic->datefin = $datefin; $memberstatic->socid = $obj->fk_soc; $memberstatic->photo = $obj->photo; $memberstatic->morphy = $obj->morphy; - if (! empty($obj->fk_soc)) { + if (!empty($obj->fk_soc)) { $memberstatic->fetch_thirdparty(); - $companyname=$memberstatic->thirdparty->name; + $companyname = $memberstatic->thirdparty->name; } else { - $companyname=$obj->company; + $companyname = $obj->company; } $memberstatic->company = $companyname; print ''; - if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) + if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Ref - if (! empty($arrayfields['d.ref']['checked'])) + if (!empty($arrayfields['d.ref']['checked'])) { print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Civility - if (! empty($arrayfields['d.civility']['checked'])) + if (!empty($arrayfields['d.civility']['checked'])) { print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Firstname - if (! empty($arrayfields['d.firstname']['checked'])) + if (!empty($arrayfields['d.firstname']['checked'])) { print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Lastname - if (! empty($arrayfields['d.lastname']['checked'])) + if (!empty($arrayfields['d.lastname']['checked'])) { print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Gender - if (! empty($arrayfields['d.gender']['checked'])) + if (!empty($arrayfields['d.gender']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Company - if (! empty($arrayfields['d.company']['checked'])) + if (!empty($arrayfields['d.company']['checked'])) { print "\n"; } // Login - if (! empty($arrayfields['d.login']['checked'])) + if (!empty($arrayfields['d.login']['checked'])) { print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Moral/Physique - if (! empty($arrayfields['d.morphy']['checked'])) + if (!empty($arrayfields['d.morphy']['checked'])) { print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Type label - if (! empty($arrayfields['t.libelle']['checked'])) + if (!empty($arrayfields['t.libelle']['checked'])) { - $membertypestatic->id=$obj->type_id; - $membertypestatic->label=$obj->type; + $membertypestatic->id = $obj->type_id; + $membertypestatic->label = $obj->type; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Address - if (! empty($arrayfields['d.address']['checked'])) + if (!empty($arrayfields['d.address']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Zip - if (! empty($arrayfields['d.zip']['checked'])) + if (!empty($arrayfields['d.zip']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Town - if (! empty($arrayfields['d.town']['checked'])) + if (!empty($arrayfields['d.town']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // State - if (! empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Country - if (! empty($arrayfields['country.code_iso']['checked'])) + if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Phone pro - if (! empty($arrayfields['d.phone']['checked'])) + if (!empty($arrayfields['d.phone']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Phone perso - if (! empty($arrayfields['d.phone_perso']['checked'])) + if (!empty($arrayfields['d.phone_perso']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Phone mobile - if (! empty($arrayfields['d.phone_mobile']['checked'])) + if (!empty($arrayfields['d.phone_mobile']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // EMail - if (! empty($arrayfields['d.email']['checked'])) + if (!empty($arrayfields['d.email']['checked'])) { print "\n"; } // End of subscription date - $datefin=$db->jdate($obj->datefin); - if (! empty($arrayfields['d.datefin']['checked'])) + $datefin = $db->jdate($obj->datefin); + if (!empty($arrayfields['d.datefin']['checked'])) { if ($datefin) { print ''; @@ -868,51 +868,51 @@ while ($i < min($num, $limit)) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['d.datec']['checked'])) + if (!empty($arrayfields['d.datec']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Birth - if (! empty($arrayfields['d.birth']['checked'])) + if (!empty($arrayfields['d.birth']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date modification - if (! empty($arrayfields['d.tms']['checked'])) + if (!empty($arrayfields['d.tms']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Status - if (! empty($arrayfields['d.statut']['checked'])) + if (!empty($arrayfields['d.statut']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Action column print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "\n"; $i++; @@ -925,15 +925,15 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found if ($num == 0) { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print ''; } $db->free($resql); -$parameters=array('sql' => $sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('sql' => $sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print "
 '; print ''; print ''; print ''; print ''; print ''; - $arraygender=array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman")); + $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman")); print $form->selectarray('search_gender', $arraygender, $search_gender, 1); print ''; print ''; print ''; print ''; - $listetype=$membertypestatic->liste_array(); + $listetype = $membertypestatic->liste_array(); print $form->selectarray("search_type", $listetype, $type, 1, 0, 0, '', 0, 32); print ''; print ''; print ''; print ''; print ''; print ''; print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; - $liststatus=array( + $liststatus = array( '-1'=>$langs->trans("Draft"), '1'=>$langs->trans("Validated"), '0'=>$langs->trans("Resiliated") @@ -623,229 +623,229 @@ if (! empty($arrayfields['d.statut']['checked'])) } // Action column print ''; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'.$obj->rowid.'"; print $memberstatic->getNomUrl(-1, 0, 'card', 'ref'); print ""; print $obj->civility; print ""; print $obj->firstname; print ""; print $obj->lastname; print "'; if ($obj->gender) print $langs->trans("Gender".$obj->gender); print '"; print $companyname; print "".$obj->login."".$memberstatic->getmorphylib($obj->morphy)."'; print $membertypestatic->getNomUrl(1, 32); print ''; print $obj->address; print ''; print $obj->zip; print ''; print $obj->town; print '".$obj->state_name."'; - $tmparray=getCountry($obj->country, 'all'); + $tmparray = getCountry($obj->country, 'all'); print $tmparray['label']; print ''; print $obj->phone; print ''; print $obj->phone_perso; print ''; print $obj->phone_mobile; print '".dol_print_email($obj->email, 0, 0, 1)."'; print dol_print_date($datefin, 'day'); if ($memberstatic->hasDelay()) { - $textlate .= ' ('.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($conf->adherent->subscription->warning_delay/60/60/24) >= 0 ? '+' : '').ceil($conf->adherent->subscription->warning_delay/60/60/24).' '.$langs->trans("days").')'; + $textlate .= ' ('.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24) >= 0 ? '+' : '').ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24).' '.$langs->trans("days").')'; print " ".img_warning($langs->trans("SubscriptionLate").$textlate); } print ''; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; print dol_print_date($db->jdate($obj->birth), 'day', 'tzuser'); print ''; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; print $memberstatic->LibStatut($obj->statut, $obj->subscription, $datefin, 5); print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; } print '
'.$langs->trans("NoRecordFound").'
\n"; diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php index 9cb83e3784b..add400b6aef 100644 --- a/htdocs/admin/emailcollector_list.php +++ b/htdocs/admin/emailcollector_list.php @@ -26,9 +26,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.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.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; dol_include_once('/emailcollector/class/emailcollector.class.php'); if (!$user->admin) accessforbidden(); @@ -37,20 +37,20 @@ if (empty($conf->emailcollector->enabled)) accessforbidden(); // Load traductions files required by page $langs->loadLangs(array("admin", "other")); -$action = GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... -$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) -$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? -$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation -$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button -$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'emailcollectorlist'; // To manage different context of search -$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'emailcollectorlist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -64,7 +64,7 @@ $pagenext = $page + 1; // Initialize technical objects $object = new EmailCollector($db); $extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->emailcollector->dir_output . '/temp/massgeneration/' . $user->id; +$diroutputmassaction = $conf->emailcollector->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('emailcollectorlist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels @@ -73,11 +73,11 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. +if (!$sortorder) $sortorder = "ASC"; // Security check -$socid=0; +$socid = 0; if ($user->socid > 0) // Protection if external user { //$socid = $user->socid; @@ -86,34 +86,34 @@ if ($user->socid > 0) // Protection if external user //$result = restrictedArea($user, 'emailcollector', $id, ''); // Initialize array of search criterias -$search_all=trim(GETPOST("search_all", 'alpha')); -$search=array(); -foreach($object->fields as $key => $val) +$search_all = trim(GETPOST("search_all", 'alpha')); +$search = array(); +foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; + if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; } // Definition of fields for list -$arrayfields=array(); -foreach($object->fields as $key => $val) +$arrayfields = array(); +foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); } // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -125,11 +125,11 @@ $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 +$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)) @@ -138,24 +138,24 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - 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 { - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $search[$key]=''; + $search[$key] = ''; } - $toselect=''; - $search_array_options=array(); + $toselect = ''; + $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { - $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='EmailCollector'; - $objectlabel='EmailCollector'; + $objectclass = 'EmailCollector'; + $objectlabel = 'EmailCollector'; $permissiontoread = $user->rights->emailcollector->read; $permissiontodelete = $user->rights->emailcollector->delete; $uploaddir = $conf->emailcollector->dir_output; @@ -168,47 +168,47 @@ if (empty($reshook)) * View */ -$form=new Form($db); +$form = new Form($db); -$now=dol_now(); +$now = dol_now(); //$help_url="EN:Module_EmailCollector|FR:Module_EmailCollector_FR|ES:Módulo_EmailCollector"; -$help_url=''; +$help_url = ''; $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("EmailCollector")); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $sql.='t.'.$key.', '; + $sql .= 't.'.$key.', '; } // 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.', ' : ''); +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.', ' : ''); // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/, $/', '', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -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 (t.rowid = ef.fk_object)"; -if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity($object->element).")"; -else $sql.=" WHERE 1 = 1"; -foreach($search as $key => $val) +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql = preg_replace('/, $/', '', $sql); +$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +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 (t.rowid = ef.fk_object)"; +if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; +else $sql .= " WHERE 1 = 1"; +foreach ($search as $key => $val) { if ($key == 'status' && $search[$key] == -1) continue; - $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0); - if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); } -if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; /* If a group by is required $sql.= " GROUP BY " @@ -226,7 +226,7 @@ $sql.=$hookmanager->resPrint; $sql=preg_replace('/, $/','', $sql); */ -$sql.=$db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -247,10 +247,10 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) } else { - $sql.= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); - $resql=$db->query($sql); - if (! $resql) + $resql = $db->query($sql); + if (!$resql) { dol_print_error($db); exit; @@ -260,7 +260,7 @@ else } // Direct jump if only one record found -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -289,27 +289,27 @@ jQuery(document).ready(function() { }); '; -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); -foreach($search as $key => $val) +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +foreach ($search as $key => $val) { - $param.= '&search_'.$key.'='.urlencode($search[$key]); + $param .= '&search_'.$key.'='.urlencode($search[$key]); } -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); -if ($user->rights->emailcollector->delete) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($user->rights->emailcollector->delete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); print ''; if ($optioncss != '') print ''; @@ -321,10 +321,10 @@ print ''; print ''; print ''; -$newcardbutton=''; +$newcardbutton = ''; //if ($user->rights->emailcollector->creer) //{ -$newcardbutton.= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', 'emailcollector_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF'])); +$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', 'emailcollector_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF'])); //} print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit); @@ -338,8 +338,8 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } $moreforfilter = ''; @@ -347,47 +347,47 @@ $moreforfilter = ''; $moreforfilter.= $langs->trans('MyFilter') . ': '; $moreforfilter.= '
';*/ -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '
'; print $moreforfilter; print '
'; } -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); -print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print ''."\n"; +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '
'."\n"; // Fields title search // -------------------------------------------------------------------- print ''; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $cssforfield=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) print ''; + $cssforfield = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + if (!empty($arrayfields['t.'.$key]['checked'])) print ''; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; print ''."\n"; @@ -396,66 +396,66 @@ print ''."\n"; // Fields title label // -------------------------------------------------------------------- print ''; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $cssforfield=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $cssforfield = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + if (!empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n"; + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; print ''."\n"; // Detect if we need a fetch on each output line -$needToFetchEachLine=0; +$needToFetchEachLine = 0; if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object + if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object } } // Loop on record // -------------------------------------------------------------------- -$i=0; -$totalarray=array(); +$i = 0; +$totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) break; // Should not happen // Store properties in $object $object->id = $obj->rowid; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { if (property_exists($obj, $key)) $object->$key = $obj->$key; } // Show here line of result print ''; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $cssforfield=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + $cssforfield = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; + if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - if (! empty($arrayfields['t.'.$key]['checked'])) + if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print ''; @@ -503,16 +503,16 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found if ($num == 0) { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print ''; } $db->free($resql); -$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'.$langs->trans("NoRecordFound").'
'."\n"; @@ -522,19 +522,19 @@ print ''."\n"; if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->emailcollector->read; - $delallowed=$user->rights->emailcollector->create; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->emailcollector->read; + $delallowed = $user->rights->emailcollector->create; print $formfile->showdocuments('massfilesarea_emailcollector', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index 028de9a32a5..4d5eed40ff0 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -30,22 +30,22 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/emailsenderprofile.class.php'; // Load translation files required by the page -$langs->loadLangs(array("errors","admin","mails","languages")); +$langs->loadLangs(array("errors", "admin", "mails", "languages")); -$action = GETPOST('action', 'alpha')?GETPOST('action', 'alpha'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... -$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) -$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? -$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation -$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button -$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'emailsenderprofilelist'; // To manage different context of search -$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$action = GETPOST('action', 'alpha') ?GETPOST('action', 'alpha') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'emailsenderprofilelist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -55,22 +55,22 @@ $pageprev = $page - 1; $pagenext = $page + 1; // Initialize technical objects -$object=new EmailSenderProfile($db); +$object = new EmailSenderProfile($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->admin->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('emailsenderprofilelist')); // Note that conf->hooks_modules contains array +$diroutputmassaction = $conf->admin->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('emailsenderprofilelist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. +if (!$sortorder) $sortorder = "ASC"; // Protection if external user -$socid=0; +$socid = 0; if ($user->socid > 0) { //$socid = $user->socid; @@ -78,34 +78,34 @@ if ($user->socid > 0) } // Initialize array of search criterias -$search_all=trim(GETPOST("search_all", 'alpha')); -$search=array(); -foreach($object->fields as $key => $val) +$search_all = trim(GETPOST("search_all", 'alpha')); +$search = array(); +foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; + if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; } // Definition of fields for list -$arrayfields=array(); -foreach($object->fields as $key => $val) +$arrayfields = array(); +foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled']); + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled']); } // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -117,11 +117,11 @@ $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 +$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)) @@ -130,24 +130,24 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - 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 { - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $search[$key]=''; + $search[$key] = ''; } - $toselect=''; - $search_array_options=array(); + $toselect = ''; + $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { - $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='EmailSenderProfile'; - $objectlabel='EmailSenderProfile'; + $objectclass = 'EmailSenderProfile'; + $objectlabel = 'EmailSenderProfile'; $permissiontoread = $user->admin; $permissiontodelete = $user->admin; $uploaddir = $conf->admin->dir_output.'/senderprofiles'; @@ -160,20 +160,20 @@ if (empty($reshook)) * View */ -$form=new Form($db); +$form = new Form($db); -$now=dol_now(); +$now = dol_now(); //$help_url="EN:Module_EmailSenderProfile|FR:Module_EmailSenderProfile_FR|ES:Módulo_EmailSenderProfile"; -$help_url=''; +$help_url = ''; $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("EmailSenderProfiles")); llxHeader(); -$titre=$langs->trans("EMailsSetup"); -$linkback=''; -$titlepicto='title_setup'; +$titre = $langs->trans("EMailsSetup"); +$linkback = ''; +$titlepicto = 'title_setup'; print load_fiche_titre($titre, $linkback, $titlepicto); @@ -184,34 +184,34 @@ dol_fiche_head($head, 'senderprofiles', '', -1); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $sql.='t.'.$key.', '; + $sql .= 't.'.$key.', '; } // 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.', ' : ''); +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.', ' : ''); // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/,\s*$/', '', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -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 (t.rowid = ef.fk_object)"; -if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity('emailsenderprofile').")"; -else $sql.=" WHERE 1 = 1"; -foreach($search as $key => $val) +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql = preg_replace('/,\s*$/', '', $sql); +$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +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 (t.rowid = ef.fk_object)"; +if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity('emailsenderprofile').")"; +else $sql .= " WHERE 1 = 1"; +foreach ($search as $key => $val) { - $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0); - if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); } -if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; /* If a group by is required $sql.= " GROUP BY " @@ -228,7 +228,7 @@ $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // $sql.=$hookmanager->resPrint; */ -$sql.=$db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -243,10 +243,10 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); -$resql=$db->query($sql); -if (! $resql) +$resql = $db->query($sql); +if (!$resql) { dol_print_error($db); exit; @@ -255,7 +255,7 @@ if (! $resql) $num = $db->num_rows($resql); // Direct jump if only one record found -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -279,27 +279,27 @@ jQuery(document).ready(function() { }); '; -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); -foreach($search as $key => $val) +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +foreach ($search as $key => $val) { - $param.= '&search_'.$key.'='.urlencode($search[$key]); + $param .= '&search_'.$key.'='.urlencode($search[$key]); } -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); -if ($user->rights->monmodule->delete) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); -if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($user->rights->monmodule->delete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '
'; if ($optioncss != '') print ''; @@ -313,9 +313,9 @@ print ''; //print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit); -$topicmail="Information"; +$topicmail = "Information"; //$modelmail="subscription"; -$objecttmp=new EmailSenderProfile($db); +$objecttmp = new EmailSenderProfile($db); //$trackid='sub'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; @@ -324,46 +324,46 @@ $moreforfilter = ''; $moreforfilter.= $langs->trans('MyFilter') . ': '; $moreforfilter.= '
';*/ -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '
'; print $moreforfilter; print '
'; } -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); -print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print ''."\n"; +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '
'."\n"; // Fields title search // -------------------------------------------------------------------- print ''; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) print ''; + $align = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center'; + if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap'; + if ($key == 'status') $align .= ($align ? ' ' : '').'center'; + if (!empty($arrayfields['t.'.$key]['checked'])) print ''; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; print ''."\n"; @@ -372,68 +372,68 @@ print ''."\n"; // Fields title label // -------------------------------------------------------------------- print ''; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; + $align = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center'; + if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap'; + if ($key == 'status') $align .= ($align ? ' ' : '').'center'; + if (!empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n"; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n"; print ''."\n"; // Detect if we need a fetch on each output line -$needToFetchEachLine=0; +$needToFetchEachLine = 0; foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object + if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object } // Loop on record // -------------------------------------------------------------------- -$i=0; -$totalarray=array(); +$i = 0; +$totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) break; // Should not happen // Store properties in $object $object->id = $obj->rowid; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { if (property_exists($obj, $key)) $object->$key = $obj->$key; } // Show here line of result print ''; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $align = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center'; + if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap'; + if ($key == 'status') $align .= ($align ? ' ' : '').'center'; + if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; print $object->showOutputField($val, $key, $obj->$key, ''); print ''; - if (! $i) $totalarray['nbfield']++; - if (! empty($val['isameasure'])) + if (!$i) $totalarray['nbfield']++; + if (!empty($val['isameasure'])) { - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; $totalarray['val']['t.'.$key] += $obj->$key; } } @@ -441,19 +441,19 @@ while ($i < min($num, $limit)) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print ''; @@ -467,16 +467,16 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found if ($num == 0) { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print ''; } $db->free($resql); -$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; } print '
'.$langs->trans("NoRecordFound").'
'."\n"; @@ -489,16 +489,16 @@ if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $n require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->monmodule->read; - $delallowed=$user->rights->monmodule->create; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->monmodule->read; + $delallowed = $user->rights->monmodule->create; print $formfile->showdocuments('massfilesarea_monmodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index b0da228e7a8..7f2ae92851b 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -33,7 +33,7 @@ $langs->load("admin"); if (!$user->admin) accessforbidden(); -$error=0; +$error = 0; /* @@ -75,19 +75,19 @@ print '
'; $file_list = array('missing' => array(), 'updated' => array()); // Local file to compare to -$xmlshortfile = GETPOST('xmlshortfile', 'alpha')?GETPOST('xmlshortfile', 'alpha'):'/install/filelist-'.DOL_VERSION.(empty($conf->global->MAIN_FILECHECK_LOCAL_SUFFIX)?'':$conf->global->MAIN_FILECHECK_LOCAL_SUFFIX).'.xml'; +$xmlshortfile = GETPOST('xmlshortfile', 'alpha') ?GETPOST('xmlshortfile', 'alpha') : '/install/filelist-'.DOL_VERSION.(empty($conf->global->MAIN_FILECHECK_LOCAL_SUFFIX) ? '' : $conf->global->MAIN_FILECHECK_LOCAL_SUFFIX).'.xml'; $xmlfile = DOL_DOCUMENT_ROOT.$xmlshortfile; // Remote file to compare to $xmlremote = GETPOST('xmlremote'); -if (empty($xmlremote) && ! empty($conf->global->MAIN_FILECHECK_URL)) $xmlremote = $conf->global->MAIN_FILECHECK_URL; -$param='MAIN_FILECHECK_URL_'.DOL_VERSION; -if (empty($xmlremote) && ! empty($conf->global->$param)) $xmlremote = $conf->global->$param; +if (empty($xmlremote) && !empty($conf->global->MAIN_FILECHECK_URL)) $xmlremote = $conf->global->MAIN_FILECHECK_URL; +$param = 'MAIN_FILECHECK_URL_'.DOL_VERSION; +if (empty($xmlremote) && !empty($conf->global->$param)) $xmlremote = $conf->global->$param; if (empty($xmlremote)) $xmlremote = 'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.'.xml'; // Test if remote test is ok $enableremotecheck = true; -if (preg_match('/beta|alpha|rc/i', DOL_VERSION) || ! empty($conf->global->MAIN_ALLOW_INTEGRITY_CHECK_ON_UNSTABLE)) $enableremotecheck=false; +if (preg_match('/beta|alpha|rc/i', DOL_VERSION) || !empty($conf->global->MAIN_ALLOW_INTEGRITY_CHECK_ON_UNSTABLE)) $enableremotecheck = false; $enableremotecheck = true; print ''; @@ -95,7 +95,7 @@ print $langs->trans("MakeIntegrityAnalysisFrom").':
'; print ''."\n"; if (dol_is_file($xmlfile)) { - print ' '.$langs->trans("LocalSignature").' = '; + print ' '.$langs->trans("LocalSignature").' = '; print ''; print '
'; } @@ -109,13 +109,13 @@ else print ''."\n"; if ($enableremotecheck) { - print ' '.$langs->trans("RemoteSignature").' = '; + print ' '.$langs->trans("RemoteSignature").' = '; print '
'; } else { print ' '.$langs->trans("RemoteSignature").' = '.$xmlremote; - if (! GETPOST('xmlremote')) print ' ('.$langs->trans("FeatureAvailableOnlyOnStable").')'; + if (!GETPOST('xmlremote')) print ' ('.$langs->trans("FeatureAvailableOnlyOnStable").')'; print '
'; } print '
'; @@ -131,7 +131,7 @@ if (GETPOST('target') == 'local') } else { - print $langs->trans('XmlNotFound') . ': ' . $xmlfile; + print $langs->trans('XmlNotFound').': '.$xmlfile; $error++; } } @@ -140,7 +140,7 @@ if (GETPOST('target') == 'remote') $xmlarray = getURLContent($xmlremote); // Return array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...) - if (! $xmlarray['curl_error_no'] && $xmlarray['http_code'] != '404') + if (!$xmlarray['curl_error_no'] && $xmlarray['http_code'] != '404') { $xmlfile = $xmlarray['content']; //print "xmlfilestart".$xmlfile."xmlfileend"; @@ -148,14 +148,14 @@ if (GETPOST('target') == 'remote') } else { - $errormsg=$langs->trans('XmlNotFound') . ': ' . $xmlremote.' - '.$xmlarray['http_code'].' '.$xmlarray['curl_error_no'].' '.$xmlarray['curl_error_msg']; + $errormsg = $langs->trans('XmlNotFound').': '.$xmlremote.' - '.$xmlarray['http_code'].' '.$xmlarray['curl_error_no'].' '.$xmlarray['curl_error_msg']; setEventMessages($errormsg, null, 'errors'); $error++; } } -if (! $error && $xml) +if (!$error && $xml) { $checksumconcat = array(); $file_list = array(); @@ -164,84 +164,84 @@ if (! $error && $xml) // Forced constants if (is_object($xml->dolibarr_constants[0])) { - $out.=load_fiche_titre($langs->trans("ForcedConstants")); + $out .= load_fiche_titre($langs->trans("ForcedConstants")); - $out.='
'; - $out.=''; - $out.=''; - $out.=''; - $out.=''; - $out.=''; - $out.=''; - $out.=''."\n"; + $out .= '
'; + $out .= '
#' . $langs->trans("Constant") . '' . $langs->trans("ExpectedValue") . '' . $langs->trans("Value") . '
'; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''."\n"; $i = 0; foreach ($xml->dolibarr_constants[0]->constant as $constant) // $constant is a simpleXMLElement { - $constname=$constant['name']; - $constvalue=(string) $constant; - $constvalue = (empty($constvalue)?'0':$constvalue); + $constname = $constant['name']; + $constvalue = (string) $constant; + $constvalue = (empty($constvalue) ? '0' : $constvalue); // Value found - $value=''; - if ($constname && $conf->global->$constname != '') $value=$conf->global->$constname; - $valueforchecksum=(empty($value)?'0':$value); + $value = ''; + if ($constname && $conf->global->$constname != '') $value = $conf->global->$constname; + $valueforchecksum = (empty($value) ? '0' : $value); - $checksumconcat[]=$valueforchecksum; + $checksumconcat[] = $valueforchecksum; $i++; - $out.=''; - $out.='' . "\n"; - $out.='' . "\n"; - $out.='' . "\n"; - $out.='' . "\n"; - $out.="\n"; + $out .= ''; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= "\n"; } - if ($i==0) + if ($i == 0) { - $out.=''; + $out .= ''; } - $out.='
#'.$langs->trans("Constant").''.$langs->trans("ExpectedValue").''.$langs->trans("Value").'
'.$i.''.$constname.''.$constvalue.''.$valueforchecksum.'
'.$i.''.$constname.''.$constvalue.''.$valueforchecksum.'
'.$langs->trans("None").'
'.$langs->trans("None").'
'; - $out.='
'; + $out .= ''; + $out .= '
'; - $out.='
'; + $out .= '
'; } // Scan htdocs if (is_object($xml->dolibarr_htdocs_dir[0])) { //var_dump($xml->dolibarr_htdocs_dir[0]['includecustom']);exit; - $includecustom=(empty($xml->dolibarr_htdocs_dir[0]['includecustom'])?0:$xml->dolibarr_htdocs_dir[0]['includecustom']); + $includecustom = (empty($xml->dolibarr_htdocs_dir[0]['includecustom']) ? 0 : $xml->dolibarr_htdocs_dir[0]['includecustom']); // Defined qualified files (must be same than into generate_filelist_xml.php) - $regextoinclude='\.(php|css|html|js|json|tpl|jpg|png|gif|sql|lang)$'; - $regextoexclude='('.($includecustom?'':'custom|').'documents|conf|install|public\/test|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs + $regextoinclude = '\.(php|css|html|js|json|tpl|jpg|png|gif|sql|lang)$'; + $regextoexclude = '('.($includecustom ? '' : 'custom|').'documents|conf|install|public\/test|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs $scanfiles = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude); // Fill file_list with files in signature, new files, modified files - $ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', DOL_DOCUMENT_ROOT, $checksumconcat); // Fill array $file_list + $ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', DOL_DOCUMENT_ROOT, $checksumconcat); // Fill array $file_list // Complete with list of new files foreach ($scanfiles as $keyfile => $valfile) { - $tmprelativefilename=preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', $valfile['fullname']); - if (! in_array($tmprelativefilename, $file_list['insignature'])) + $tmprelativefilename = preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', $valfile['fullname']); + if (!in_array($tmprelativefilename, $file_list['insignature'])) { - $md5newfile=@md5_file($valfile['fullname']); // Can fails if we don't have permission to open/read file - $file_list['added'][]=array('filename'=>$tmprelativefilename, 'md5'=>$md5newfile); + $md5newfile = @md5_file($valfile['fullname']); // Can fails if we don't have permission to open/read file + $file_list['added'][] = array('filename'=>$tmprelativefilename, 'md5'=>$md5newfile); } } // Files missings - $out.=load_fiche_titre($langs->trans("FilesMissing")); + $out .= load_fiche_titre($langs->trans("FilesMissing")); - $out.='
'; - $out.=''; - $out.=''; - $out.=''; - $out.=''; - $out.=''; - $out.=''; - $out.=''."\n"; + $out .= '
'; + $out .= '
#' . $langs->trans("Filename") . '' . $langs->trans("ExpectedSize") . '' . $langs->trans("ExpectedChecksum") . '
'; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''."\n"; $tmpfilelist = dol_sort_array($file_list['missing'], 'filename'); if (is_array($tmpfilelist) && count($tmpfilelist)) { @@ -249,40 +249,40 @@ if (! $error && $xml) foreach ($tmpfilelist as $file) { $i++; - $out.=''; - $out.='' . "\n"; - $out.='' . "\n"; - $out.='' . "\n"; - $out.='' . "\n"; - $out.="\n"; + $out .= ''; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= "\n"; } } else { - $out.=''; + $out .= ''; } - $out.='
#'.$langs->trans("Filename").''.$langs->trans("ExpectedSize").''.$langs->trans("ExpectedChecksum").'
'.$i.''.$file['filename'].''; - if (! empty($file['expectedsize'])) $out.=dol_print_size($file['expectedsize']); - $out.=''.$file['expectedmd5'].'
'.$i.''.$file['filename'].''; + if (!empty($file['expectedsize'])) $out .= dol_print_size($file['expectedsize']); + $out .= ''.$file['expectedmd5'].'
'.$langs->trans("None").'
'.$langs->trans("None").'
'; - $out.='
'; + $out .= ''; + $out .= '
'; - $out.='
'; + $out .= '
'; // Files modified - $out.=load_fiche_titre($langs->trans("FilesModified")); + $out .= load_fiche_titre($langs->trans("FilesModified")); - $totalsize=0; - $out.='
'; - $out.=''; - $out.=''; - $out.=''; - $out.=''; - $out.=''; - $out.=''; - $out.=''; - $out.=''; - $out.=''; - $out.=''."\n"; + $totalsize = 0; + $out .= '
'; + $out .= '
#' . $langs->trans("Filename") . '' . $langs->trans("ExpectedChecksum") . '' . $langs->trans("CurrentChecksum") . '' . $langs->trans("ExpectedSize") . '' . $langs->trans("CurrentSize") . '' . $langs->trans("DateModification") . '
'; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''."\n"; $tmpfilelist2 = dol_sort_array($file_list['updated'], 'filename'); if (is_array($tmpfilelist2) && count($tmpfilelist2)) { @@ -290,53 +290,53 @@ if (! $error && $xml) foreach ($tmpfilelist2 as $file) { $i++; - $out.=''; - $out.='' . "\n"; - $out.='' . "\n"; - $out.='' . "\n"; - $out.='' . "\n"; - $out.='' . "\n"; + $out .= ''; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; $size = dol_filesize(DOL_DOCUMENT_ROOT.'/'.$file['filename']); $totalsize += $size; - $out.='' . "\n"; - $out.='' . "\n"; - $out.="\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= "\n"; } - $out.=''; - $out.='' . "\n"; - $out.='' . "\n"; - $out.='' . "\n"; - $out.='' . "\n"; - $out.='' . "\n"; - $out.='' . "\n"; - $out.='' . "\n"; - $out.="\n"; + $out .= ''; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= "\n"; } else { - $out.=''; + $out .= ''; } - $out.='
#'.$langs->trans("Filename").''.$langs->trans("ExpectedChecksum").''.$langs->trans("CurrentChecksum").''.$langs->trans("ExpectedSize").''.$langs->trans("CurrentSize").''.$langs->trans("DateModification").'
'.$i.''.$file['filename'].''.$file['expectedmd5'].''.$file['md5'].''; - if ($file['expectedsize']) $out.=dol_print_size($file['expectedsize']); - $out.='
'.$i.''.$file['filename'].''.$file['expectedmd5'].''.$file['md5'].''; + if ($file['expectedsize']) $out .= dol_print_size($file['expectedsize']); + $out .= ''.dol_print_size($size).''.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']), 'dayhour').'
'.dol_print_size($size).''.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']), 'dayhour').'
'.$langs->trans("Total").''.dol_print_size($totalsize).'
'.$langs->trans("Total").''.dol_print_size($totalsize).'
'.$langs->trans("None").'
'.$langs->trans("None").'
'; - $out.='
'; + $out .= ''; + $out .= '
'; - $out.='
'; + $out .= '
'; // Files added - $out.=load_fiche_titre($langs->trans("FilesAdded")); + $out .= load_fiche_titre($langs->trans("FilesAdded")); $totalsize = 0; - $out.='
'; - $out.=''; - $out.=''; - $out.=''; - $out.=''; - $out.=''; - $out.=''; - $out.=''; - $out.=''; - $out.=''."\n"; + $out .= '
'; + $out .= '
#' . $langs->trans("Filename") . '' . $langs->trans("ExpectedChecksum") . '' . $langs->trans("CurrentChecksum") . '' . $langs->trans("Size") . '' . $langs->trans("DateModification") . '
'; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''."\n"; $tmpfilelist3 = dol_sort_array($file_list['added'], 'filename'); if (is_array($tmpfilelist3) && count($tmpfilelist3)) { @@ -344,37 +344,37 @@ if (! $error && $xml) foreach ($tmpfilelist3 as $file) { $i++; - $out.=''; - $out.='' . "\n"; - $out.=''; + $out .= ''."\n"; + $out .= '' . "\n"; - $out.='' . "\n"; - $out.='' . "\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; $size = dol_filesize(DOL_DOCUMENT_ROOT.'/'.$file['filename']); $totalsize += $size; - $out.='' . "\n"; - $out.='' . "\n"; - $out.="\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= "\n"; } - $out.=''; - $out.='' . "\n"; - $out.='' . "\n"; - $out.='' . "\n"; - $out.='' . "\n"; - $out.='' . "\n"; - $out.='' . "\n"; - $out.="\n"; + $out .= ''; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= "\n"; } else { - $out.=''; + $out .= ''; } - $out.='
#'.$langs->trans("Filename").''.$langs->trans("ExpectedChecksum").''.$langs->trans("CurrentChecksum").''.$langs->trans("Size").''.$langs->trans("DateModification").'
'.$i.''.$file['filename']; - if (! preg_match('/^win/i', PHP_OS)) { - $htmltext=$langs->trans("YouCanDeleteFileOnServerWith", 'rm '.DOL_DOCUMENT_ROOT.$file['filename']); // The slash is included int file['filename'] - $out.=' '.$form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helprm'.$i); + $out .= '
'.$i.''.$file['filename']; + if (!preg_match('/^win/i', PHP_OS)) { + $htmltext = $langs->trans("YouCanDeleteFileOnServerWith", 'rm '.DOL_DOCUMENT_ROOT.$file['filename']); // The slash is included int file['filename'] + $out .= ' '.$form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helprm'.$i); } - $out.=''.$file['expectedmd5'].''.$file['md5'].''.$file['expectedmd5'].''.$file['md5'].''.dol_print_size($size).''.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']), 'dayhour').'
'.dol_print_size($size).''.dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT.'/'.$file['filename']), 'dayhour').'
'.$langs->trans("Total").''.dol_print_size($totalsize).'
'.$langs->trans("Total").''.dol_print_size($totalsize).'
'.$langs->trans("None").'
'.$langs->trans("None").'
'; - $out.='
'; + $out .= ''; + $out .= ''; // Show warning @@ -419,26 +419,26 @@ if (! $error && $xml) if (count($file_list['added'])) { $resultcode = 'warning'; - $resultcomment='FileIntegrityIsOkButFilesWereAdded'; - $outcurrentchecksum = $checksumget.' - '.$langs->trans("FileIntegrityIsOkButFilesWereAdded").''; + $resultcomment = 'FileIntegrityIsOkButFilesWereAdded'; + $outcurrentchecksum = $checksumget.' - '.$langs->trans("FileIntegrityIsOkButFilesWereAdded").''; } else { $resultcode = 'ok'; - $resultcomment='Success'; + $resultcomment = 'Success'; $outcurrentchecksum = ''.$checksumget.''; } } else { $resultcode = 'error'; - $resultcomment='Error'; + $resultcomment = 'Error'; $outcurrentchecksum = ''.$checksumget.''; } print load_fiche_titre($langs->trans("GlobalChecksum")).'
'; - print $langs->trans("ExpectedChecksum").' = '. $outexpectedchecksum .'
'; - print $langs->trans("CurrentChecksum").' = '. $outcurrentchecksum; + print $langs->trans("ExpectedChecksum").' = '.$outexpectedchecksum.'
'; + print $langs->trans("CurrentChecksum").' = '.$outcurrentchecksum; print '
'; print '
'; diff --git a/htdocs/admin/triggers.php b/htdocs/admin/triggers.php index bdc5ee5961d..ce7f525e8b3 100644 --- a/htdocs/admin/triggers.php +++ b/htdocs/admin/triggers.php @@ -28,8 +28,8 @@ $langs->load("admin"); if (!$user->admin) accessforbidden(); -$sortfield='file'; -$sortorder='ASC'; +$sortfield = 'file'; +$sortorder = 'ASC'; /* @@ -61,9 +61,9 @@ print '
'; print ''; print ''; print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], 'none', "", $param, '', $sortfield, $sortorder, '', 1)."\n"; -print getTitleFieldOfList($langs->trans("File"), 0, $_SERVER["PHP_SELF"], 'file', "", $param, ($align?'align="'.$align.'"':''), $sortfield, $sortorder, '', 1)."\n"; +print getTitleFieldOfList($langs->trans("File"), 0, $_SERVER["PHP_SELF"], 'file', "", $param, ($align ? 'align="'.$align.'"' : ''), $sortfield, $sortorder, '', 1)."\n"; print getTitleFieldOfList($langs->trans("Active"), 0, $_SERVER["PHP_SELF"], 'active', "", $param, 'align="center"', $sortfield, $sortorder, '', 1)."\n"; -print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], 'none', "", $param, ($align?'align="'.$align.'"':''), $sortfield, $sortorder, '', 1)."\n"; +print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], 'none', "", $param, ($align ? 'align="'.$align.'"' : ''), $sortfield, $sortorder, '', 1)."\n"; print ''; foreach ($triggers as $trigger) @@ -73,8 +73,8 @@ foreach ($triggers as $trigger) print ''; print ''; print ''; diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php index c43bd73eae8..9d480eccebe 100644 --- a/htdocs/asset/list.php +++ b/htdocs/asset/list.php @@ -33,20 +33,20 @@ require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php'; // Load translation files required by the page $langs->loadLangs(array("assets")); -$action = GETPOST('action', 'alpha')?GETPOST('action', 'alpha'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... -$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) -$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? -$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation -$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button -$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'assetslist'; // To manage different context of search -$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$action = GETPOST('action', 'alpha') ?GETPOST('action', 'alpha') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'assetslist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -56,22 +56,22 @@ $pageprev = $page - 1; $pagenext = $page + 1; // Initialize technical objects -$object=new Asset($db); +$object = new Asset($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->asset->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('assetlist')); // Note that conf->hooks_modules contains array +$diroutputmassaction = $conf->asset->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('assetlist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. +if (!$sortorder) $sortorder = "ASC"; // Protection if external user -$socid=0; +$socid = 0; if ($user->socid > 0) { //$socid = $user->socid; @@ -80,34 +80,34 @@ if ($user->socid > 0) //$result = restrictedArea($user, 'asset', $id,''); // Initialize array of search criterias -$search_all=trim(GETPOST("search_all", 'alpha')); -$search=array(); -foreach($object->fields as $key => $val) +$search_all = trim(GETPOST("search_all", 'alpha')); +$search = array(); +foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; + if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; } // Definition of fields for list -$arrayfields=array(); -foreach($object->fields as $key => $val) +$arrayfields = array(); +foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); } // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -121,11 +121,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Put here all code to do according to value of "$action" parameter */ -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 +$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)) @@ -134,24 +134,24 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - 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 { - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $search[$key]=''; + $search[$key] = ''; } - $toselect=''; - $search_array_options=array(); + $toselect = ''; + $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { - $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='Asset'; - $objectlabel='Asset'; + $objectclass = 'Asset'; + $objectlabel = 'Asset'; $permissiontoread = $user->rights->asset->read; $permissiontodelete = $user->rights->asset->delete; $uploaddir = $conf->asset->dir_output; @@ -166,46 +166,46 @@ if (empty($reshook)) * Put here all code to render page */ -$form=new Form($db); +$form = new Form($db); -$now=dol_now(); +$now = dol_now(); //$help_url="EN:Module_Asset|FR:Module_Asset_FR|ES:Módulo_Asset"; -$help_url=''; +$help_url = ''; $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("Assets")); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $sql.='t.'.$key.', '; + $sql .= 't.'.$key.', '; } // 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.', ' : ''); +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.', ' : ''); // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/,\s*$/', '', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -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 (t.rowid = ef.fk_object)"; -if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity('assets').")"; -else $sql.=" WHERE 1 = 1"; -foreach($search as $key => $val) +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql = preg_replace('/,\s*$/', '', $sql); +$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +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 (t.rowid = ef.fk_object)"; +if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity('assets').")"; +else $sql .= " WHERE 1 = 1"; +foreach ($search as $key => $val) { - $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0); - if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); } -if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; /* If a group by is required $sql.= " GROUP BY " @@ -222,7 +222,7 @@ $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // $sql.=$hookmanager->resPrint; */ -$sql.=$db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -237,10 +237,10 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); -$resql=$db->query($sql); -if (! $resql) +$resql = $db->query($sql); +if (!$resql) { dol_print_error($db); exit; @@ -249,7 +249,7 @@ if (! $resql) $num = $db->num_rows($resql); // Direct jump if only one record found -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -278,34 +278,34 @@ jQuery(document).ready(function() { }); '; -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); -foreach($search as $key => $val) +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +foreach ($search as $key => $val) { - $param.= '&search_'.$key.'='.urlencode($search[$key]); + $param .= '&search_'.$key.'='.urlencode($search[$key]); } -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); -if ($user->rights->asset->delete) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); -if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($user->rights->asset->delete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); -$newcardbutton=''; +$newcardbutton = ''; if ($user->rights->asset->write) { - $newcardbutton=''.$langs->trans('NewAsset').''; - $newcardbutton.= ''; - $newcardbutton.= ''; + $newcardbutton = ''.$langs->trans('NewAsset').''; + $newcardbutton .= ''; + $newcardbutton .= ''; } print ''; @@ -321,16 +321,16 @@ print ''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'accountancy', 0, $newcardbutton, '', $limit); // Add code for pre mass action (confirmation or email presend form) -$topicmail="SendAssetsRef"; -$modelmail="asset"; -$objecttmp=new Asset($db); -$trackid='xxxx'.$object->id; +$topicmail = "SendAssetsRef"; +$modelmail = "asset"; +$objecttmp = new Asset($db); +$trackid = 'xxxx'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } $moreforfilter = ''; @@ -338,47 +338,47 @@ $moreforfilter = ''; $moreforfilter.= $langs->trans('MyFilter') . ': '; $moreforfilter.= '';*/ -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '
'; print $moreforfilter; print '
'; } -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); -print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print '
'.$trigger['file'].''.$trigger['status'].''; - $text=$trigger['info']; - $text.="
\n".$langs->trans("File").":
\n".$trigger['relpath']; + $text = $trigger['info']; + $text .= "
\n".$langs->trans("File").":
\n".$trigger['relpath']; //$text.="\n".$langs->trans("ExternalModule",$trigger['isocreorexternal']); print $form->textwithpicto('', $text); print '
'."\n"; +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '
'."\n"; // Fields title search // -------------------------------------------------------------------- print ''; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) print ''; + $align = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center'; + if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap'; + if ($key == 'status') $align .= ($align ? ' ' : '').'center'; + if (!empty($arrayfields['t.'.$key]['checked'])) print ''; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; print ''."\n"; @@ -459,19 +459,19 @@ while ($i < min($num, $limit)) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print ''; @@ -482,11 +482,11 @@ while ($i < min($num, $limit)) if (isset($totalarray['pos'])) { print ''; - $i=0; + $i = 0; while ($i < $totalarray['nbfield']) { $i++; - if (! empty($totalarray['pos'][$i])) print ''; + if (!empty($totalarray['pos'][$i])) print ''; else { if ($i == 1) @@ -503,16 +503,16 @@ if (isset($totalarray['pos'])) // If no record found if ($num == 0) { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print ''; } $db->free($resql); -$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; } print '
'.price($totalarray['val'][$totalarray['pos'][$i]]).''.price($totalarray['val'][$totalarray['pos'][$i]]).'
'.$langs->trans("NoRecordFound").'
'."\n"; @@ -528,12 +528,12 @@ if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $n $formfile = new FormFile($db); // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->asset->read; - $delallowed=$user->rights->asset->create; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->asset->read; + $delallowed = $user->rights->asset->create; print $formfile->showdocuments('massfilesarea_asset', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, ''); } diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index c61efc84591..0ff7ed8c672 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -31,20 +31,20 @@ require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; // Load translation files required by the page $langs->loadLangs(array("mrp", "other")); -$action = GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... -$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) -$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? -$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation -$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button -$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'bomlist'; // To manage different context of search -$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'bomlist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -58,8 +58,8 @@ $pagenext = $page + 1; // Initialize technical objects $object = new BOM($db); $extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->bom->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('bomlist')); // Note that conf->hooks_modules contains array +$diroutputmassaction = $conf->bom->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('bomlist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); @@ -67,11 +67,11 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. +if (!$sortorder) $sortorder = "ASC"; // Security check -$socid=0; +$socid = 0; if ($user->socid > 0) // Protection if external user { //$socid = $user->socid; @@ -80,34 +80,34 @@ if ($user->socid > 0) // Protection if external user //$result = restrictedArea($user, 'bom', $id, ''); // Initialize array of search criterias -$search_all=trim(GETPOST("search_all", 'alpha')); -$search=array(); -foreach($object->fields as $key => $val) +$search_all = trim(GETPOST("search_all", 'alpha')); +$search = array(); +foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; + if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; } // Definition of fields for list -$arrayfields=array(); -foreach($object->fields as $key => $val) +$arrayfields = array(); +foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); } // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -122,11 +122,11 @@ $permissiontodelete = $user->rights->bom->delete; * 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 +$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)) @@ -135,24 +135,24 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - 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 { - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $search[$key]=''; + $search[$key] = ''; } - $toselect=''; - $search_array_options=array(); + $toselect = ''; + $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { - $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='BOM'; - $objectlabel='BillOfMaterials'; + $objectclass = 'BOM'; + $objectlabel = 'BillOfMaterials'; $permissiontoread = $user->rights->bom->read; $permissiontodelete = $user->rights->bom->delete; $uploaddir = $conf->bom->dir_output; @@ -160,18 +160,18 @@ if (empty($reshook)) // Validate records - if (! $error && $massaction == 'disable' && $permissiontoadd) + if (!$error && $massaction == 'disable' && $permissiontoadd) { - $objecttmp=new $objectclass($db); + $objecttmp = new $objectclass($db); - if (! $error) + if (!$error) { $db->begin(); $nbok = 0; - foreach($toselect as $toselectid) + foreach ($toselect as $toselectid) { - $result=$objecttmp->fetch($toselectid); + $result = $objecttmp->fetch($toselectid); if ($result > 0) { if ($objecttmp->status != $objecttmp::STATUS_VALIDATED) @@ -200,7 +200,7 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); @@ -275,48 +275,48 @@ if (empty($reshook)) * View */ -$form=new Form($db); +$form = new Form($db); -$now=dol_now(); +$now = dol_now(); //$help_url="EN:Module_BillOfMaterials|FR:Module_BillOfMaterials_FR|ES:Módulo_BillOfMaterials"; -$help_url=''; +$help_url = ''; $title = $langs->trans('ListOfBOMs'); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $sql.='t.'.$key.', '; + $sql .= 't.'.$key.', '; } // 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.', ' : ''); +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.', ' : ''); } // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/, $/', '', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -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 (t.rowid = ef.fk_object)"; -if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity($object->element).")"; -else $sql.=" WHERE 1 = 1"; -foreach($search as $key => $val) +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql = preg_replace('/, $/', '', $sql); +$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +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 (t.rowid = ef.fk_object)"; +if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; +else $sql .= " WHERE 1 = 1"; +foreach ($search as $key => $val) { if ($key == 'status' && $search[$key] == -1) continue; - $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0); - if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); } -if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; /* If a group by is required $sql.= " GROUP BY " @@ -335,7 +335,7 @@ $sql.=$hookmanager->resPrint; $sql=preg_replace('/, $/','', $sql); */ -$sql.=$db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -356,10 +356,10 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) } else { - $sql.= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); - $resql=$db->query($sql); - if (! $resql) + $resql = $db->query($sql); + if (!$resql) { dol_print_error($db); exit; @@ -369,7 +369,7 @@ else } // Direct jump if only one record found -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -437,16 +437,16 @@ $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle' print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'cubes', 0, $newcardbutton, '', $limit); // Add code for pre mass action (confirmation or email presend form) -$topicmail="SendBillOfMaterialsRef"; -$modelmail="bom"; -$objecttmp=new BOM($db); -$trackid='xxxx'.$object->id; +$topicmail = "SendBillOfMaterialsRef"; +$modelmail = "bom"; +$objecttmp = new BOM($db); +$trackid = 'xxxx'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; } $moreforfilter = ''; @@ -454,39 +454,39 @@ $moreforfilter = ''; $moreforfilter.= $langs->trans('MyFilter') . ': '; $moreforfilter.= '
';*/ -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '
'; print $moreforfilter; print '
'; } -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); -print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print ''."\n"; +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '
'."\n"; // Fields title search // -------------------------------------------------------------------- print ''; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; @@ -496,12 +496,12 @@ foreach($object->fields as $key => $val) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; print ''."\n"; @@ -510,23 +510,23 @@ print ''."\n"; // Fields title label // -------------------------------------------------------------------- print ''; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n"; + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; @@ -534,56 +534,56 @@ print ''."\n"; // Detect if we need a fetch on each output line -$needToFetchEachLine=0; +$needToFetchEachLine = 0; if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object + if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object } } // Loop on record // -------------------------------------------------------------------- -$i=0; -$totalarray=array(); +$i = 0; +$totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) break; // Should not happen // Store properties in $object $object->id = $obj->rowid; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { if (property_exists($obj, $key)) $object->$key = $obj->$key; } // Show here line of result print ''; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; + if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield.=($cssforfield?' ':'').'right'; + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; if ($key == 'status') print $object->getLibStatut(5); - elseif (in_array($val['type'], array('date','datetime','timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); else print $object->showOutputField($val, $key, $obj->$key, ''); print ''; - if (! $i) $totalarray['nbfield']++; - if (! empty($val['isameasure'])) + if (!$i) $totalarray['nbfield']++; + if (!empty($val['isameasure'])) { - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; $totalarray['val']['t.'.$key] += $obj->$key; } } @@ -591,19 +591,19 @@ while ($i < min($num, $limit)) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print ''; @@ -617,16 +617,16 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found if ($num == 0) { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print ''; } $db->free($resql); -$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; + print ''; if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75'); else print ''; print ''; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; } print '
'.$langs->trans("NoRecordFound").'
'."\n"; @@ -637,19 +637,19 @@ print ''."\n"; if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->bom->read; - $delallowed=$user->rights->bom->create; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->bom->read; + $delallowed = $user->rights->bom->create; print $formfile->showdocuments('massfilesarea_bom', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 48faa5ca2c0..fdaac89eda0 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -26,7 +26,7 @@ * \brief Page to list actions */ -if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); +if (!defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; @@ -37,43 +37,43 @@ include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load translation files required by the page -$langs->loadLangs(array("users","companies","agenda","commercial")); +$langs->loadLangs(array("users", "companies", "agenda", "commercial")); -$action=GETPOST('action', 'alpha'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'actioncommlist'; // To manage different context of search -$resourceid=GETPOST("search_resourceid", "int")?GETPOST("search_resourceid", "int"):GETPOST("resourceid", "int"); -$pid=GETPOST("search_projectid", 'int', 3)?GETPOST("search_projectid", 'int', 3):GETPOST("projectid", 'int', 3); -$status=(GETPOST("search_status", 'alpha') != '')?GETPOST("search_status", 'alpha'):GETPOST("status", 'alpha'); -$type=GETPOST('search_type', 'alphanohtml')?GETPOST('search_type', 'alphanohtml'):GETPOST('type', 'alphanohtml'); +$action = GETPOST('action', 'alpha'); +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'actioncommlist'; // To manage different context of search +$resourceid = GETPOST("search_resourceid", "int") ?GETPOST("search_resourceid", "int") : GETPOST("resourceid", "int"); +$pid = GETPOST("search_projectid", 'int', 3) ?GETPOST("search_projectid", 'int', 3) : GETPOST("projectid", 'int', 3); +$status = (GETPOST("search_status", 'alpha') != '') ?GETPOST("search_status", 'alpha') : GETPOST("status", 'alpha'); +$type = GETPOST('search_type', 'alphanohtml') ?GETPOST('search_type', 'alphanohtml') : GETPOST('type', 'alphanohtml'); $optioncss = GETPOST('optioncss', 'alpha'); -$year=GETPOST("year", 'int'); -$month=GETPOST("month", 'int'); -$day=GETPOST("day", 'int'); +$year = GETPOST("year", 'int'); +$month = GETPOST("month", 'int'); +$day = GETPOST("day", 'int'); // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) if (GETPOST('search_actioncode', 'array')) { - $actioncode=GETPOST('search_actioncode', 'array', 3); - if (! count($actioncode)) $actioncode='0'; + $actioncode = GETPOST('search_actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; } else { - $actioncode=GETPOST("search_actioncode", "alpha", 3)?GETPOST("search_actioncode", "alpha", 3):(GETPOST("search_actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE)); + $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } -if ($actioncode == '' && empty($actioncodearray)) $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE); -$search_id=GETPOST('search_id', 'alpha'); -$search_title=GETPOST('search_title', 'alpha'); -$search_note=GETPOST('search_note', 'alpha'); +if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); +$search_id = GETPOST('search_id', 'alpha'); +$search_title = GETPOST('search_title', 'alpha'); +$search_note = GETPOST('search_note', 'alpha'); -$dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int')); -$datestart=dol_mktime(0, 0, 0, GETPOST('datestartmonth', 'int'), GETPOST('datestartday', 'int'), GETPOST('datestartyear', 'int')); -$dateend=dol_mktime(0, 0, 0, GETPOST('dateendmonth', 'int'), GETPOST('dateendday', 'int'), GETPOST('dateendyear', 'int')); -if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS); -if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) $action=(empty($conf->global->AGENDA_DEFAULT_VIEW)?'show_month':$conf->global->AGENDA_DEFAULT_VIEW); +$dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int')); +$datestart = dol_mktime(0, 0, 0, GETPOST('datestartmonth', 'int'), GETPOST('datestartday', 'int'), GETPOST('datestartyear', 'int')); +$dateend = dol_mktime(0, 0, 0, GETPOST('dateendmonth', 'int'), GETPOST('dateendday', 'int'), GETPOST('dateendyear', 'int')); +if ($status == '' && !isset($_GET['status']) && !isset($_POST['status'])) $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); +if (empty($action) && !isset($_GET['action']) && !isset($_POST['action'])) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); -$filter = GETPOST("search_filter", 'alpha', 3)?GETPOST("search_filter", 'alpha', 3):GETPOST("filter", 'alpha', 3); -$filtert = GETPOST("search_filtert", "int", 3)?GETPOST("search_filtert", "int", 3):GETPOST("filtert", "int", 3); -$usergroup = GETPOST("search_usergroup", "int", 3)?GETPOST("search_usergroup", "int", 3):GETPOST("usergroup", "int", 3); -$showbirthday = empty($conf->use_javascript_ajax)?(GETPOST("search_showbirthday", "int")?GETPOST("search_showbirthday", "int"):GETPOST("showbirthday", "int")):1; +$filter = GETPOST("search_filter", 'alpha', 3) ?GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3); +$filtert = GETPOST("search_filtert", "int", 3) ?GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3); +$usergroup = GETPOST("search_usergroup", "int", 3) ?GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3); +$showbirthday = empty($conf->use_javascript_ajax) ? (GETPOST("search_showbirthday", "int") ?GETPOST("search_showbirthday", "int") : GETPOST("showbirthday", "int")) : 1; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new ActionComm($db); @@ -84,45 +84,45 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // If not choice done on calendar owner, we filter on user. if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) { - $filtert=$user->id; + $filtert = $user->id; } -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); -if ($page == -1 || $page == null) { $page = 0 ; } -$offset = $limit * $page ; -if (! $sortorder) +if ($page == -1 || $page == null) { $page = 0; } +$offset = $limit * $page; +if (!$sortorder) { - $sortorder="DESC,DESC"; - if ($status == 'todo') $sortorder="DESC,DESC"; + $sortorder = "DESC,DESC"; + if ($status == 'todo') $sortorder = "DESC,DESC"; } -if (! $sortfield) +if (!$sortfield) { - $sortfield="a.datep,a.id"; - if ($status == 'todo') $sortfield="a.datep,a.id"; + $sortfield = "a.datep,a.id"; + if ($status == 'todo') $sortfield = "a.datep,a.id"; } // Security check -$socid = GETPOST("search_socid", 'int')?GETPOST("search_socid", 'int'):GETPOST("socid", 'int'); -if ($user->socid) $socid=$user->socid; +$socid = GETPOST("search_socid", 'int') ?GETPOST("search_socid", 'int') : GETPOST("socid", 'int'); +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'agenda', 0, '', 'myactions'); -if ($socid < 0) $socid=''; +if ($socid < 0) $socid = ''; -$canedit=1; -if (! $user->rights->agenda->myactions->read) accessforbidden(); -if (! $user->rights->agenda->allactions->read) $canedit=0; -if (! $user->rights->agenda->allactions->read || $filter=='mine') // If no permission to see all, we show only affected to me +$canedit = 1; +if (!$user->rights->agenda->myactions->read) accessforbidden(); +if (!$user->rights->agenda->allactions->read) $canedit = 0; +if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no permission to see all, we show only affected to me { - $filtert=$user->id; + $filtert = $user->id; } -$arrayfields=array( +$arrayfields = array( 'a.id'=>array('label'=>"Ref", 'checked'=>1), 'owner'=>array('label'=>"Owner", 'checked'=>1), 'c.libelle'=>array('label'=>"Type", 'checked'=>1), @@ -132,7 +132,7 @@ $arrayfields=array( 'a.datep2'=>array('label'=>"DateEnd", 'checked'=>1), 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1), 'a.fk_contact'=>array('label'=>"Contact", 'checked'=>1), - 'a.fk_element'=>array('label'=>"LinkedObject", 'checked'=>0, 'enabled'=>(! empty($conf->global->AGENDA_SHOW_LINKED_OBJECT))), + 'a.fk_element'=>array('label'=>"LinkedObject", 'checked'=>0, 'enabled'=>(!empty($conf->global->AGENDA_SHOW_LINKED_OBJECT))), 'a.percent'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), 'a.datec'=>array('label'=>'DateCreation', 'checked'=>0), 'a.tms'=>array('label'=>'DateModification', 'checked'=>0) @@ -140,10 +140,10 @@ $arrayfields=array( // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -156,12 +156,12 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday")) { - $param=''; + $param = ''; if (is_array($_POST)) { - foreach($_POST as $key => $val) + foreach ($_POST as $key => $val) { - $param.='&'.$key.'='.urlencode($val); + $param .= '&'.$key.'='.urlencode($val); } } //print $param; @@ -169,8 +169,8 @@ if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday")) exit; } -$parameters=array('id'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); // Selection of new fields @@ -179,13 +179,13 @@ 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 { //$actioncode=''; - $search_id=''; - $search_title=''; - $search_note=''; - $datestart=''; - $dateend=''; - $status=''; - $search_array_options=array(); + $search_id = ''; + $search_title = ''; + $search_note = ''; + $datestart = ''; + $dateend = ''; + $status = ''; + $search_array_options = array(); } @@ -193,154 +193,154 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' * View */ -$form=new Form($db); -$userstatic=new User($db); -$formactions=new FormActions($db); +$form = new Form($db); +$userstatic = new User($db); +$formactions = new FormActions($db); $nav = ''; $nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); -$nav .=' '; +$nav .= ' '; -$now=dol_now(); +$now = dol_now(); -$help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; +$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; llxHeader('', $langs->trans("Agenda"), $help_url); // Define list of all external calendars -$listofextcals=array(); +$listofextcals = array(); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($actioncode != '') { - if(is_array($actioncode)) { - foreach($actioncode as $str_action) $param.="&search_actioncode[]=".urlencode($str_action); - } else $param.="&search_actioncode=".urlencode($actioncode); + if (is_array($actioncode)) { + foreach ($actioncode as $str_action) $param .= "&search_actioncode[]=".urlencode($str_action); + } else $param .= "&search_actioncode=".urlencode($actioncode); } -if ($resourceid > 0) $param.="&search_resourceid=".urlencode($resourceid); -if ($status != '' && $status > -1) $param.="&search_status=".urlencode($status); -if ($filter) $param.="&search_filter=".urlencode($filter); -if ($filtert) $param.="&search_filtert=".urlencode($filtert); -if ($socid) $param.="&search_socid=".urlencode($socid); -if ($showbirthday) $param.="&search_showbirthday=1"; -if ($pid) $param.="&search_projectid=".urlencode($pid); -if ($type) $param.="&search_type=".urlencode($type); -if ($usergroup) $param.="&search_usergroup=".urlencode($usergroup); -if ($search_id != '') $param.='&search_title='.urlencode($search_id); -if ($search_title != '') $param.='&search_title='.urlencode($search_title); -if ($search_note != '') $param.='&search_note='.$search_note; -if (GETPOST('datestartday', 'int')) $param.='&datestartday='.GETPOST('datestartday', 'int'); -if (GETPOST('datestartmonth', 'int')) $param.='&datestartmonth='.GETPOST('datestartmonth', 'int'); -if (GETPOST('datestartyear', 'int')) $param.='&datestartyear='.GETPOST('datestartyear', 'int'); -if (GETPOST('dateendday', 'int')) $param.='&dateendday='.GETPOST('dateendday', 'int'); -if (GETPOST('dateendmonth', 'int')) $param.='&dateendmonth='.GETPOST('dateendmonth', 'int'); -if (GETPOST('dateendyear', 'int')) $param.='&dateendyear='.GETPOST('dateendyear', 'int'); -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($resourceid > 0) $param .= "&search_resourceid=".urlencode($resourceid); +if ($status != '' && $status > -1) $param .= "&search_status=".urlencode($status); +if ($filter) $param .= "&search_filter=".urlencode($filter); +if ($filtert) $param .= "&search_filtert=".urlencode($filtert); +if ($socid) $param .= "&search_socid=".urlencode($socid); +if ($showbirthday) $param .= "&search_showbirthday=1"; +if ($pid) $param .= "&search_projectid=".urlencode($pid); +if ($type) $param .= "&search_type=".urlencode($type); +if ($usergroup) $param .= "&search_usergroup=".urlencode($usergroup); +if ($search_id != '') $param .= '&search_title='.urlencode($search_id); +if ($search_title != '') $param .= '&search_title='.urlencode($search_title); +if ($search_note != '') $param .= '&search_note='.$search_note; +if (GETPOST('datestartday', 'int')) $param .= '&datestartday='.GETPOST('datestartday', 'int'); +if (GETPOST('datestartmonth', 'int')) $param .= '&datestartmonth='.GETPOST('datestartmonth', 'int'); +if (GETPOST('datestartyear', 'int')) $param .= '&datestartyear='.GETPOST('datestartyear', 'int'); +if (GETPOST('dateendday', 'int')) $param .= '&dateendday='.GETPOST('dateendday', 'int'); +if (GETPOST('dateendmonth', 'int')) $param .= '&dateendmonth='.GETPOST('dateendmonth', 'int'); +if (GETPOST('dateendyear', 'int')) $param .= '&dateendyear='.GETPOST('dateendyear', 'int'); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; $sql = "SELECT"; -if ($usergroup > 0) $sql.=" DISTINCT"; -$sql.= " s.nom as societe, s.rowid as socid, s.client, s.email as socemail,"; -$sql.= " a.id, a.label, a.note, a.datep as dp, a.datep2 as dp2, a.fulldayevent, a.location,"; -$sql.= ' a.fk_user_author,a.fk_user_action,'; -$sql.= " a.fk_contact, a.note, a.percent as percent,"; -$sql.= " a.fk_element, a.elementtype, a.datec, a.tms as datem,"; -$sql.= " c.code as type_code, c.libelle as type_label,"; -$sql.= " sp.lastname, sp.firstname, sp.email, sp.phone, sp.address, sp.phone as phone_pro, sp.phone_mobile, sp.phone_perso, sp.fk_pays as country_id"; +if ($usergroup > 0) $sql .= " DISTINCT"; +$sql .= " s.nom as societe, s.rowid as socid, s.client, s.email as socemail,"; +$sql .= " a.id, a.label, a.note, a.datep as dp, a.datep2 as dp2, a.fulldayevent, a.location,"; +$sql .= ' a.fk_user_author,a.fk_user_action,'; +$sql .= " a.fk_contact, a.note, a.percent as percent,"; +$sql .= " a.fk_element, a.elementtype, a.datec, a.tms as datem,"; +$sql .= " c.code as type_code, c.libelle as type_label,"; +$sql .= " sp.lastname, sp.firstname, sp.email, sp.phone, sp.address, sp.phone as phone_pro, sp.phone_mobile, sp.phone_perso, sp.fk_pays as country_id"; // 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 : ''); +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 : ''); } // 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; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; -$sql.=" LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_extrafields as ef ON (a.id = ef.fk_object) "; -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; -$sql.=" ,".MAIN_DB_PREFIX."c_actioncomm as c"; +$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_extrafields as ef ON (a.id = ef.fk_object) "; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; +$sql .= " ,".MAIN_DB_PREFIX."c_actioncomm as c"; // We must filter on resource table -if ($resourceid > 0) $sql.=", ".MAIN_DB_PREFIX."element_resources as r"; +if ($resourceid > 0) $sql .= ", ".MAIN_DB_PREFIX."element_resources as r"; // We must filter on assignement table -if ($filtert > 0 || $usergroup > 0) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; -if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; -$sql.= " WHERE c.id = a.fk_action"; -$sql.= ' AND a.entity IN ('.getEntity('agenda').')'; +if ($filtert > 0 || $usergroup > 0) $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; +if ($usergroup > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; +$sql .= " WHERE c.id = a.fk_action"; +$sql .= ' AND a.entity IN ('.getEntity('agenda').')'; // Condition on actioncode -if (! empty($actioncode)) +if (!empty($actioncode)) { if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - if ($actioncode == 'AC_NON_AUTO') $sql.= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND c.type = 'systemauto'"; + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; else { - if ($actioncode == 'AC_OTH') $sql.= " AND c.type != 'systemauto'"; - if ($actioncode == 'AC_OTH_AUTO') $sql.= " AND c.type = 'systemauto'"; + if ($actioncode == 'AC_OTH') $sql .= " AND c.type != 'systemauto'"; + if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND c.type = 'systemauto'"; } } else { - if ($actioncode == 'AC_NON_AUTO') $sql.= " AND c.type != 'systemauto'"; - elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND c.type = 'systemauto'"; + if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; + elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; else { if (is_array($actioncode)) { - $sql.=" AND c.code IN ('".implode("','", $actioncode)."')"; + $sql .= " AND c.code IN ('".implode("','", $actioncode)."')"; } else { - $sql.=" AND c.code IN ('".implode("','", explode(',', $actioncode))."')"; + $sql .= " AND c.code IN ('".implode("','", explode(',', $actioncode))."')"; } } } } -if ($resourceid > 0) $sql.=" AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); -if ($pid) $sql.=" AND a.fk_project=".$db->escape($pid); -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; -if ($socid > 0) $sql.= " AND s.rowid = ".$socid; +if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); +if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid); +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; +if ($socid > 0) $sql .= " AND s.rowid = ".$socid; // We must filter on assignement table -if ($filtert > 0 || $usergroup > 0) $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; -if ($type) $sql.= " AND c.id = ".$type; -if ($status == '0') { $sql.= " AND a.percent = 0"; } -if ($status == '-1') { $sql.= " AND a.percent = -1"; } // Not applicable -if ($status == '50') { $sql.= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started -if ($status == '100') { $sql.= " AND a.percent = 100"; } -if ($status == 'done') { $sql.= " AND (a.percent = 100)"; } -if ($status == 'todo') { $sql.= " AND (a.percent >= 0 AND a.percent < 100)"; } -if ($search_id) $sql.=natural_search("a.id", $search_id, 1); -if ($search_title) $sql.=natural_search("a.label", $search_title); -if ($search_note) $sql.=natural_search('a.note', $search_note); +if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; +if ($type) $sql .= " AND c.id = ".$type; +if ($status == '0') { $sql .= " AND a.percent = 0"; } +if ($status == '-1') { $sql .= " AND a.percent = -1"; } // Not applicable +if ($status == '50') { $sql .= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started +if ($status == '100') { $sql .= " AND a.percent = 100"; } +if ($status == 'done') { $sql .= " AND (a.percent = 100)"; } +if ($status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; } +if ($search_id) $sql .= natural_search("a.id", $search_id, 1); +if ($search_title) $sql .= natural_search("a.label", $search_title); +if ($search_note) $sql .= natural_search('a.note', $search_note); // We must filter on assignement table if ($filtert > 0 || $usergroup > 0) { - $sql.= " AND ("; - if ($filtert > 0) $sql.= "(ar.fk_element = ".$filtert." OR (ar.fk_element IS NULL AND a.fk_user_action=".$filtert."))"; // The OR is for backward compatibility - if ($usergroup > 0) $sql.= ($filtert>0?" OR ":"")." ugu.fk_usergroup = ".$usergroup; - $sql.= ")"; + $sql .= " AND ("; + if ($filtert > 0) $sql .= "(ar.fk_element = ".$filtert." OR (ar.fk_element IS NULL AND a.fk_user_action=".$filtert."))"; // The OR is for backward compatibility + if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; + $sql .= ")"; } // The second or of next test is to take event with no end date (we suppose duration is 1 hour in such case) -if ($dateselect > 0) $sql.= " AND ((a.datep2 >= '".$db->idate($dateselect)."' AND a.datep <= '".$db->idate($dateselect+3600*24-1)."') OR (a.datep2 IS NULL AND a.datep > '".$db->idate($dateselect-3600)."' AND a.datep <= '".$db->idate($dateselect+3600*24-1)."'))"; -if ($datestart > 0) $sql.= " AND a.datep BETWEEN '".$db->idate($datestart)."' AND '".$db->idate($datestart+3600*24-1)."'"; -if ($dateend > 0) $sql.= " AND a.datep2 BETWEEN '".$db->idate($dateend)."' AND '".$db->idate($dateend+3600*24-1)."'"; +if ($dateselect > 0) $sql .= " AND ((a.datep2 >= '".$db->idate($dateselect)."' AND a.datep <= '".$db->idate($dateselect + 3600 * 24 - 1)."') OR (a.datep2 IS NULL AND a.datep > '".$db->idate($dateselect - 3600)."' AND a.datep <= '".$db->idate($dateselect + 3600 * 24 - 1)."'))"; +if ($datestart > 0) $sql .= " AND a.datep BETWEEN '".$db->idate($datestart)."' AND '".$db->idate($datestart + 3600 * 24 - 1)."'"; +if ($dateend > 0) $sql .= " AND a.datep2 BETWEEN '".$db->idate($dateend)."' AND '".$db->idate($dateend + 3600 * 24 - 1)."'"; // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -354,23 +354,23 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit + 1, $offset); +$sql .= $db->plimit($limit + 1, $offset); //print $sql; dol_syslog("comm/action/list.php", LOG_DEBUG); -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { - $actionstatic=new ActionComm($db); - $societestatic=new Societe($db); + $actionstatic = new ActionComm($db); + $societestatic = new Societe($db); $num = $db->num_rows($resql); // Local calendar - $newtitle ='
' . $langs->trans("LocalAgenda").'  
'; + $newtitle = '
'.$langs->trans("LocalAgenda").'  
'; //$newtitle=$langs->trans($title); - $tabactive='cardlist'; + $tabactive = 'cardlist'; $head = calendars_prepare_head($param); @@ -384,14 +384,14 @@ if ($resql) print ''; print ''; print ''; - $nav=''; + $nav = ''; //if ($actioncode) $nav.=''; //if ($resourceid) $nav.=''; - if ($filter) $nav.=''; + if ($filter) $nav .= ''; //if ($filtert) $nav.=''; //if ($socid) $nav.=''; - if ($showbirthday) $nav.=''; + if ($showbirthday) $nav .= ''; //if ($pid) $nav.=''; //if ($usergroup) $nav.=''; print $nav; @@ -401,7 +401,7 @@ if ($resql) dol_fiche_end(); // Add link to show birthdays - $link=''; + $link = ''; /* if (empty($conf->use_javascript_ajax)) { @@ -417,76 +417,76 @@ if ($resql) } */ - $s=$newtitle; + $s = $newtitle; // Calendars from hooks - $parameters=array(); $object=null; - $reshook=$hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); + $parameters = array(); $object = null; + $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); if (empty($reshook)) { - $s.= $hookmanager->resPrint; + $s .= $hookmanager->resPrint; } elseif ($reshook > 1) { $s = $hookmanager->resPrint; } - $newcardbutton=''; + $newcardbutton = ''; if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { - $tmpforcreatebutton=dol_getdate(dol_now(), true); + $tmpforcreatebutton = dol_getdate(dol_now(), true); - $newparam.='&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year']; + $newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year']; //$param='month='.$monthshown.'&year='.$year; - $hourminsec='100000'; - $newcardbutton.= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam?'?'.$newparam:''))); + $hourminsec = '100000'; + $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : ''))); } print_barre_liste($s, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, -1 * $nbtotalofrecords, '', 0, $nav.$newcardbutton, '', $limit); - $moreforfilter=''; + $moreforfilter = ''; - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); $i = 0; print '
'; - print ''."\n"; + print '
'."\n"; print ''; - if (! empty($arrayfields['a.id']['checked'])) print ''; - if (! empty($arrayfields['owner']['checked'])) print ''; - if (! empty($arrayfields['c.libelle']['checked'])) print ''; - if (! empty($arrayfields['a.label']['checked'])) print ''; - if (! empty($arrayfields['a.note']['checked'])) print ''; - if (! empty($arrayfields['a.datep']['checked'])) { + if (!empty($arrayfields['a.id']['checked'])) print ''; + if (!empty($arrayfields['owner']['checked'])) print ''; + if (!empty($arrayfields['c.libelle']['checked'])) print ''; + if (!empty($arrayfields['a.label']['checked'])) print ''; + if (!empty($arrayfields['a.note']['checked'])) print ''; + if (!empty($arrayfields['a.datep']['checked'])) { print ''; } - if (! empty($arrayfields['a.datep2']['checked'])) { + if (!empty($arrayfields['a.datep2']['checked'])) { print ''; } - if (! empty($arrayfields['s.nom']['checked'])) { + if (!empty($arrayfields['s.nom']['checked'])) { print ''; } - if (! empty($arrayfields['a.fk_contact']['checked'])) print ''; - if (! empty($arrayfields['a.fk_element']['checked'])) print ''; + if (!empty($arrayfields['a.fk_contact']['checked'])) print ''; + if (!empty($arrayfields['a.fk_element']['checked'])) print ''; // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['a.datec']['checked'])) print ''; - if (! empty($arrayfields['a.tms']['checked'])) print ''; - if (! empty($arrayfields['a.percent']['checked'])) { + if (!empty($arrayfields['a.datec']['checked'])) print ''; + if (!empty($arrayfields['a.tms']['checked'])) print ''; + if (!empty($arrayfields['a.percent']['checked'])) { print ''; print "\n"; print ''; - if (! empty($arrayfields['a.id']['checked'])) print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $param, "", "", $sortfield, $sortorder); - if (! empty($arrayfields['owner']['checked'])) print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); - if (! empty($arrayfields['c.libelle']['checked'])) print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", $param, "", "", $sortfield, $sortorder); - if (! empty($arrayfields['a.label']['checked'])) print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder); - if (! empty($arrayfields['a.note']['checked'])) print_liste_field_titre($arrayfields['a.note']['label'], $_SERVER["PHP_SELF"], "a.note", $param, "", "", $sortfield, $sortorder); + if (!empty($arrayfields['a.id']['checked'])) print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $param, "", "", $sortfield, $sortorder); + if (!empty($arrayfields['owner']['checked'])) print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); + if (!empty($arrayfields['c.libelle']['checked'])) print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", $param, "", "", $sortfield, $sortorder); + if (!empty($arrayfields['a.label']['checked'])) print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder); + if (!empty($arrayfields['a.note']['checked'])) print_liste_field_titre($arrayfields['a.note']['label'], $_SERVER["PHP_SELF"], "a.note", $param, "", "", $sortfield, $sortorder); //if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) - if (! empty($arrayfields['a.datep']['checked'])) print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep,a.id", $param, '', 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['a.datep2']['checked'])) print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder); - if (! empty($arrayfields['a.fk_contact']['checked'])) print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); - if (! empty($arrayfields['a.fk_element']['checked'])) print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); + if (!empty($arrayfields['a.datep']['checked'])) print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep,a.id", $param, '', 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['a.datep2']['checked'])) print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder); + if (!empty($arrayfields['a.fk_contact']['checked'])) print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); + if (!empty($arrayfields['a.fk_element']['checked'])) print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['a.datec']['checked'])) print_liste_field_titre($arrayfields['a.datec']['label'], $_SERVER["PHP_SELF"], "a.datec,a.id", $param, "", 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['a.tms']['checked'])) print_liste_field_titre($arrayfields['a.tms']['label'], $_SERVER["PHP_SELF"], "a.tms,a.id", $param, "", 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['a.datec']['checked'])) print_liste_field_titre($arrayfields['a.datec']['label'], $_SERVER["PHP_SELF"], "a.datec,a.id", $param, "", 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['a.tms']['checked'])) print_liste_field_titre($arrayfields['a.tms']['label'], $_SERVER["PHP_SELF"], "a.tms,a.id", $param, "", 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['a.percent']['checked']))print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "a.percent", $param, "", 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['a.percent']['checked']))print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "a.percent", $param, "", 'align="center"', $sortfield, $sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; $contactstatic = new Contact($db); - $now=dol_now(); - $delay_warning=$conf->global->MAIN_DELAY_ACTIONS_TODO*24*60*60; + $now = dol_now(); + $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; - $caction=new CActionComm($db); - $arraylist=$caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE)?1:0), '', 1); + $caction = new CActionComm($db); + $arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1); $contactListCache = array(); while ($i < min($num, $limit)) @@ -541,34 +541,34 @@ if ($resql) $obj = $db->fetch_object($resql); // Discard auto action if option is on - if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') { $i++; continue; } - $actionstatic->id=$obj->id; - $actionstatic->ref=$obj->id; - $actionstatic->type_code=$obj->type_code; - $actionstatic->type_label=$obj->type_label; - $actionstatic->type_picto=$obj->type_picto; - $actionstatic->label=$obj->label; + $actionstatic->id = $obj->id; + $actionstatic->ref = $obj->id; + $actionstatic->type_code = $obj->type_code; + $actionstatic->type_label = $obj->type_label; + $actionstatic->type_picto = $obj->type_picto; + $actionstatic->label = $obj->label; $actionstatic->location = $obj->location; - $actionstatic->note=dol_htmlentitiesbr($obj->note); + $actionstatic->note = dol_htmlentitiesbr($obj->note); print ''; // Ref - if (! empty($arrayfields['a.id']['checked'])) { + if (!empty($arrayfields['a.id']['checked'])) { print ''; } // User owner - if (! empty($arrayfields['owner']['checked'])) + if (!empty($arrayfields['owner']['checked'])) { - print ''; } // Label - if (! empty($arrayfields['a.label']['checked'])) { + if (!empty($arrayfields['a.label']['checked'])) { print ''; } // Description - if (! empty($arrayfields['a.note']['checked'])) { + if (!empty($arrayfields['a.note']['checked'])) { print ''; } - $formatToUse = $obj->fulldayevent?'day':'dayhour'; + $formatToUse = $obj->fulldayevent ? 'day' : 'dayhour'; // Start date - if (! empty($arrayfields['a.datep']['checked'])) { + if (!empty($arrayfields['a.datep']['checked'])) { print ''; } // End date - if (! empty($arrayfields['a.datep2']['checked'])) { + if (!empty($arrayfields['a.datep2']['checked'])) { print ''; } // Third party - if (! empty($arrayfields['s.nom']['checked'])) { + if (!empty($arrayfields['s.nom']['checked'])) { print ''; } // Date update - if (! empty($arrayfields['a.tms']['checked'])) { + if (!empty($arrayfields['a.tms']['checked'])) { print ''; } - if (! empty($arrayfields['a.percent']['checked'])) { + if (!empty($arrayfields['a.percent']['checked'])) { // Status/Percent - $datep=$db->jdate($obj->datep); + $datep = $db->jdate($obj->datep); print ''; } print ''; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 11d57eabbfc..b3d8360e39a 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -36,21 +36,21 @@ */ require '../../main.inc.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/class/html.formpropal.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formmargin.class.php'; -require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; -require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/modules/propale/modules_propale.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/propal.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/signature.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; -if (! empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; - require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.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/class/html.formpropal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } if (!empty($conf->variants->enabled)) { @@ -60,7 +60,7 @@ if (!empty($conf->variants->enabled)) { // Load translation files required by the page $langs->loadLangs(array('companies', 'propal', 'compta', 'bills', 'orders', 'products', 'deliveries', 'sendings', 'other')); if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); -if (! empty($conf->margin->enabled)) +if (!empty($conf->margin->enabled)) $langs->load('margins'); $error = 0; @@ -78,15 +78,15 @@ $contactid = GETPOST('contactid', 'int'); $projectid = GETPOST('projectid', 'int'); // PDF -$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); -$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); -$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); +$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); +$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); +$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); // Nombre de ligne pour choix de produit/service predefinis $NBLINES = 4; // Security check -if (! empty($user->socid)) $socid = $user->socid; +if (!empty($user->socid)) $socid = $user->socid; $result = restrictedArea($user, 'propal', $id); $object = new Propal($db); @@ -96,7 +96,7 @@ $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); // Load object -if ($id > 0 || ! empty($ref)) { +if ($id > 0 || !empty($ref)) { $ret = $object->fetch($id, $ref); if ($ret > 0) $ret = $object->fetch_thirdparty(); @@ -108,13 +108,13 @@ if ($id > 0 || ! empty($ref)) { } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('propalcard','globalcard')); +$hookmanager->initHooks(array('propalcard', 'globalcard')); $usercanread = $user->rights->propal->lire; $usercancreate = $user->rights->propal->creer; $usercanclose = $user->rights->propal->cloturer; $usercandelete = $user->rights->propal->supprimer; -$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->propal_advance->validate))); +$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->validate))); $usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->propal->propal_advance->send); $usercancreateorder = $user->rights->commande->creer; @@ -124,7 +124,7 @@ $usercancreateintervention = $user->rights->ficheinter->creer; $usercancreatepurchaseorder = $user->rights->fournisseur->commande->creer; $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php +$permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php $permissiontoedit = $usercancreate; // Used by the include of actions_lineupdown.inc.php @@ -140,24 +140,24 @@ if (empty($reshook)) { if ($cancel) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } - $action=''; + $action = ''; } include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once - include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once - include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes' && $usercancreate) { - if (! GETPOST('socid', 3)) + if (!GETPOST('socid', 3)) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } @@ -195,7 +195,7 @@ if (empty($reshook)) $result = $object->createFromClone($user, $socid); if ($result > 0) { - header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); + header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); exit(); } else { if (count($object->errors) > 0) setEventMessages($object->error, $object->errors, 'errors'); @@ -210,7 +210,7 @@ if (empty($reshook)) { $result = $object->delete($user); if ($result > 0) { - header('Location: ' . DOL_URL_ROOT . '/comm/propal/list.php?restore_lastsearch_values=1'); + header('Location: '.DOL_URL_ROOT.'/comm/propal/list.php?restore_lastsearch_values=1'); exit(); } else { $langs->load("errors"); @@ -229,7 +229,7 @@ if (empty($reshook)) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) { + if (!empty($conf->global->MAIN_MULTILANGS)) { $outputlangs = new Translate("", $conf); $newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $object->thirdparty->default_lang); $outputlangs->setDefaultLang($newlang); @@ -238,7 +238,7 @@ if (empty($reshook)) $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit(); } @@ -254,11 +254,11 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -275,11 +275,11 @@ if (empty($reshook)) $datep = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); if (empty($datep)) { - $error ++; + $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); } - if (! $error) { + if (!$error) { $result = $object->set_date($user, $datep); if ($result < 0) dol_print_error($db, $object->error); @@ -327,22 +327,22 @@ if (empty($reshook)) if (empty($datep)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); $action = 'create'; - $error ++; + $error++; } if (empty($duration)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ValidityDuration")), null, 'errors'); $action = 'create'; - $error ++; + $error++; } if ($socid < 1) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), null, 'errors'); $action = 'create'; - $error ++; + $error++; } - if (! $error) + if (!$error) { $db->begin(); @@ -413,12 +413,12 @@ if (empty($reshook)) // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) { - $error ++; + $error++; $action = 'create'; } } - if (! $error) + if (!$error) { if ($origin && $originid) { @@ -452,19 +452,19 @@ if (empty($reshook)) // Possibility to add external linked objects with hooks $object->linked_objects [$object->origin] = $object->origin_id; - if (is_array($_POST['other_linked_objects']) && ! empty($_POST['other_linked_objects'])) { + if (is_array($_POST['other_linked_objects']) && !empty($_POST['other_linked_objects'])) { $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); } $id = $object->create($user); if ($id > 0) { - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); $srcobject = new $classname($db); - dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); + dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); $result = $srcobject->fetch($object->origin_id); if ($result > 0) @@ -476,12 +476,12 @@ if (empty($reshook)) $lines = $srcobject->lines; } - $fk_parent_line=0; - $num=count($lines); - for ($i=0;$i<$num;$i++) + $fk_parent_line = 0; + $num = count($lines); + for ($i = 0; $i < $num; $i++) { - $label=(! empty($lines[$i]->label)?$lines[$i]->label:''); - $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle); + $label = (!empty($lines[$i]->label) ? $lines[$i]->label : ''); + $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc : $lines[$i]->libelle); // Positive line $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); @@ -516,7 +516,7 @@ if (empty($reshook)) } $tva_tx = $lines[$i]->tva_tx; - if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; + if (!empty($lines[$i]->vat_src_code) && !preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, 'HT', 0, $lines[$i]->info_bits, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $date_start, $date_end, $array_options, $lines[$i]->fk_unit); @@ -524,7 +524,7 @@ if (empty($reshook)) $lineid = $result; } else { $lineid = 0; - $error ++; + $error++; break; } @@ -539,14 +539,14 @@ if (empty($reshook)) $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if ($reshook < 0) - $error ++; + $error++; } else { setEventMessages($srcobject->error, $srcobject->errors, 'errors'); - $error ++; + $error++; } } else { setEventMessages($object->error, $object->errors, 'errors'); - $error ++; + $error++; } } // Standard creation else @@ -567,7 +567,7 @@ if (empty($reshook)) } } - if (! empty($conf->global->PROPOSAL_AUTO_ADD_AUTHOR_AS_CONTACT)) + if (!empty($conf->global->PROPOSAL_AUTO_ADD_AUTHOR_AS_CONTACT)) { $result = $object->add_contact($user->id, 'SALESREPFOLL', 'internal'); if ($result < 0) @@ -577,7 +577,7 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { $db->commit(); @@ -588,31 +588,31 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) dol_print_error($db, $result); } - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); exit(); } else { $db->rollback(); - $action='create'; + $action = 'create'; } } else { setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); - $action='create'; + $action = 'create'; } } } @@ -623,14 +623,14 @@ if (empty($reshook)) { $db->begin(); - $result=$object->cloture($user, Propal::STATUS_BILLED, ''); + $result = $object->cloture($user, Propal::STATUS_BILLED, ''); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; } - if (! $error) + if (!$error) { $db->commit(); } @@ -641,8 +641,8 @@ if (empty($reshook)) } // Close proposal - elseif ($action == 'setstatut' && $usercanclose && ! GETPOST('cancel', 'alpha')) { - if (! (GETPOST('statut', 'int') > 0)) { + elseif ($action == 'setstatut' && $usercanclose && !GETPOST('cancel', 'alpha')) { + if (!(GETPOST('statut', 'int') > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CloseAs")), null, 'errors'); $action = 'statut'; } else { @@ -651,14 +651,14 @@ if (empty($reshook)) { $db->begin(); - $result=$object->cloture($user, GETPOST('statut', 'int'), GETPOST('note_private', 'none')); + $result = $object->cloture($user, GETPOST('statut', 'int'), GETPOST('note_private', 'none')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; } - if (! $error) + if (!$error) { $db->commit(); } @@ -671,20 +671,20 @@ if (empty($reshook)) } // Reopen proposal - elseif ($action == 'confirm_reopen' && $usercanclose && ! GETPOST('cancel', 'alpha')) { + elseif ($action == 'confirm_reopen' && $usercanclose && !GETPOST('cancel', 'alpha')) { // prevent browser refresh from reopening proposal several times if ($object->statut == Propal::STATUS_SIGNED || $object->statut == Propal::STATUS_NOTSIGNED || $object->statut == Propal::STATUS_BILLED) { $db->begin(); - $result=$object->reopen($user, 1); + $result = $object->reopen($user, 1); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; } - if (! $error) + if (!$error) { $db->commit(); } @@ -696,7 +696,7 @@ if (empty($reshook)) } // add lines from objectlinked - elseif($action == 'import_lines_from_object' + elseif ($action == 'import_lines_from_object' && $user->rights->propal->creer && $object->statut == Propal::STATUS_DRAFT ) @@ -705,14 +705,14 @@ if (empty($reshook)) $fromElementid = GETPOST('fromelementid'); $importLines = GETPOST('line_checkbox'); - if(!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) + if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) { - if($fromElement == 'commande') + if ($fromElement == 'commande') { dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class.php'); $lineClassName = 'OrderLine'; } - elseif($fromElement == 'propal') + elseif ($fromElement == 'propal') { dol_include_once('/comm/'.$fromElement.'/class/'.$fromElement.'.class.php'); $lineClassName = 'PropaleLigne'; @@ -720,11 +720,11 @@ if (empty($reshook)) $nextRang = count($object->lines) + 1; $importCount = 0; $error = 0; - foreach($importLines as $lineId) + foreach ($importLines as $lineId) { $lineId = intval($lineId); $originLine = new $lineClassName($db); - if(intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) + if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) { $originLine->fetch_optionals($lineId); $desc = $originLine->desc; @@ -740,15 +740,15 @@ if (empty($reshook)) $ventil = 0; $info_bits = $originLine->info_bits; $fk_remise_except = $originLine->fk_remise_except; - $price_base_type='HT'; - $pu_ttc=0; + $price_base_type = 'HT'; + $pu_ttc = 0; $type = $originLine->product_type; - $rang=$nextRang++; + $rang = $nextRang++; $special_code = $originLine->special_code; $origin = $originLine->element; $origin_id = $originLine->id; - $fk_parent_line=0; - $fk_fournprice=$originLine->fk_fournprice; + $fk_parent_line = 0; + $fk_fournprice = $originLine->fk_fournprice; $pa_ht = $originLine->pa_ht; $label = $originLine->label; $array_options = $originLine->array_options; @@ -759,18 +759,18 @@ if (empty($reshook)) $res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, $rang, $special_code, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $date_start, $date_end, $array_options, $fk_unit, $origin, $origin_id, $pu_ht_devise, $fk_remise_except); - if($res > 0){ + if ($res > 0) { $importCount++; - }else{ + } else { $error++; } } - else{ + else { $error++; } } - if($error) + if ($error) { setEventMessages($langs->trans('ErrorsOnXLines', $error), null, 'errors'); } @@ -780,10 +780,10 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - $actiontypecode='AC_OTH_AUTO'; - $trigger_name='PROPAL_SENTBYMAIL'; - $autocopy='MAIN_MAIL_AUTOCOPY_PROPOSAL_TO'; - $trackid='pro'.$object->id; + $actiontypecode = 'AC_OTH_AUTO'; + $trigger_name = 'PROPAL_SENTBYMAIL'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_PROPOSAL_TO'; + $trackid = 'pro'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; @@ -796,7 +796,7 @@ if (empty($reshook)) { // Define output language $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) { + if (!empty($conf->global->MAIN_MULTILANGS)) { $outputlangs = new Translate("", $conf); $newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $object->thirdparty->default_lang); $outputlangs->setDefaultLang($newlang); @@ -820,25 +820,25 @@ if (empty($reshook)) // Add line elseif ($action == 'addline' && $usercancreate) { // Set if we used free entry or predefined product - $predef=''; - $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); + $predef = ''; + $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); $price_ht = GETPOST('price_ht'); $price_ht_devise = GETPOST('multicurrency_price_ht'); $prod_entry_mode = GETPOST('prod_entry_mode'); if ($prod_entry_mode == 'free') { - $idprod=0; + $idprod = 0; $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); } else { - $idprod=GETPOST('idprod', 'int'); + $idprod = GETPOST('idprod', 'int'); $tva_tx = ''; } - $qty = GETPOST('qty' . $predef); - $remise_percent = GETPOST('remise_percent' . $predef); - if (empty($remise_percent)) $remise_percent=0; + $qty = GETPOST('qty'.$predef); + $remise_percent = GETPOST('remise_percent'.$predef); + if (empty($remise_percent)) $remise_percent = 0; // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -847,23 +847,23 @@ if (empty($reshook)) if (is_array($extralabelsline)) { // Get extra fields foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); + unset($_POST["options_".$key]); } } if ($prod_entry_mode == 'free' && empty($idprod) && GETPOST('type') < 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); - $error ++; + $error++; } if ($prod_entry_mode == 'free' && empty($idprod) && $price_ht == '' && $price_ht_devise == '') // Unit price can be 0 but not ''. Also price can be negative for proposal. { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); - $error ++; + $error++; } if ($prod_entry_mode == 'free' && empty($idprod) && empty($product_desc)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), null, 'errors'); - $error ++; + $error++; } if (!$error && !empty($conf->variants->enabled) && $prod_entry_mode != 'free') { @@ -875,12 +875,12 @@ if (empty($reshook)) $idprod = $res->fk_product_child; } else { setEventMessages($langs->trans('ErrorProductCombinationNotFound'), null, 'errors'); - $error ++; + $error++; } } } - if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { + if (!$error && ($qty >= 0) && (!empty($product_desc) || !empty($idprod))) { $pu_ht = 0; $pu_ttc = 0; $price_min = 0; @@ -894,7 +894,7 @@ if (empty($reshook)) // Ecrase $desc par celui du produit // Ecrase $tva_tx par celui du produit // Replaces $fk_unit with the product unit - if (! empty($idprod)) { + if (!empty($idprod)) { $prod = new Product($db); $prod->fetch($idprod); @@ -903,7 +903,7 @@ if (empty($reshook)) // Update if prices fields are defined $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); - if (empty($tva_tx)) $tva_npr=0; + if (empty($tva_tx)) $tva_npr = 0; // Price unique per product $pu_ht = $prod->price; @@ -912,22 +912,22 @@ if (empty($reshook)) $price_base_type = $prod->price_base_type; // If price per segment - if (! empty($conf->global->PRODUIT_MULTIPRICES) && $object->thirdparty->price_level) + if (!empty($conf->global->PRODUIT_MULTIPRICES) && $object->thirdparty->price_level) { $pu_ht = $prod->multiprices[$object->thirdparty->price_level]; $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level]; $price_min = $prod->multiprices_min[$object->thirdparty->price_level]; $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; - if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility + if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility { - if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level]; - if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level]; + if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level]; + if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level]; } } // If price per customer - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { - require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; $prodcustprice = new Productcustomerprice($db); @@ -940,15 +940,15 @@ if (empty($reshook)) $pu_ht = price($prodcustprice->lines[0]->price); $pu_ttc = price($prodcustprice->lines[0]->price_ttc); $price_base_type = $prodcustprice->lines[0]->price_base_type; - $tva_tx = ($prodcustprice->lines[0]->default_vat_code ? $prodcustprice->lines[0]->tva_tx . ' ('.$prodcustprice->lines[0]->default_vat_code.' )' : $prodcustprice->lines[0]->tva_tx); - if ($prodcustprice->lines[0]->default_vat_code && ! preg_match('/\(.*\)/', $tva_tx)) $tva_tx.= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + $tva_tx = ($prodcustprice->lines[0]->default_vat_code ? $prodcustprice->lines[0]->tva_tx.' ('.$prodcustprice->lines[0]->default_vat_code.' )' : $prodcustprice->lines[0]->tva_tx); + if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; $tva_npr = $prodcustprice->lines[0]->recuperableonly; - if (empty($tva_tx)) $tva_npr=0; + if (empty($tva_tx)) $tva_npr = 0; } } } // If price per quantity - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) { if ($prod->prices_by_qty[0]) // yes, this product has some prices per quantity { @@ -956,7 +956,7 @@ if (empty($reshook)) $pqp = GETPOST('pbq', 'int'); // Search price into product_price_by_qty from $prod->id - foreach($prod->prices_by_qty_list[0] as $priceforthequantityarray) + foreach ($prod->prices_by_qty_list[0] as $priceforthequantityarray) { if ($priceforthequantityarray['rowid'] != $pqp) continue; // We found the price @@ -974,7 +974,7 @@ if (empty($reshook)) } } // If price per quantity and customer - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { if ($prod->prices_by_qty[$object->thirdparty->price_level]) // yes, this product has some prices per quantity { @@ -982,7 +982,7 @@ if (empty($reshook)) $pqp = GETPOST('pbq', 'int'); // Search price into product_price_by_qty from $prod->id - foreach($prod->prices_by_qty_list[$object->thirdparty->price_level] as $priceforthequantityarray) + foreach ($prod->prices_by_qty_list[$object->thirdparty->price_level] as $priceforthequantityarray) { if ($priceforthequantityarray['rowid'] != $pqp) continue; // We found the price @@ -1004,7 +1004,7 @@ if (empty($reshook)) $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); // if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ? - if (! empty($price_ht)) { + if (!empty($price_ht)) { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); } @@ -1021,24 +1021,24 @@ if (empty($reshook)) $desc = ''; // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; $newlang = ''; if (empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if (empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; + $desc = (!empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; } else { $desc = $prod->description; } - if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) $desc= $product_desc; + if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) $desc = $product_desc; else $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); // Add dimensions into product description @@ -1054,35 +1054,35 @@ if (empty($reshook)) }*/ // Add custom code and origin country into description - if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) + if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (!empty($prod->customcode) || !empty($prod->country_code))) { $tmptxt = '('; // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; $newlang = ''; if (empty($newlang) && GETPOST('lang_id', 'alpha')) $newlang = GETPOST('lang_id', 'alpha'); if (empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); $outputlangs->load('products'); } - if (! empty($prod->customcode)) - $tmptxt .= $outputlangs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; - if (! empty($prod->customcode) && ! empty($prod->country_code)) + if (!empty($prod->customcode)) + $tmptxt .= $outputlangs->transnoentitiesnoconv("CustomCode").': '.$prod->customcode; + if (!empty($prod->customcode) && !empty($prod->country_code)) $tmptxt .= ' - '; - if (! empty($prod->country_code)) - $tmptxt .= $outputlangs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $outputlangs, 0); + if (!empty($prod->country_code)) + $tmptxt .= $outputlangs->transnoentitiesnoconv("CountryOrigin").': '.getCountry($prod->country_code, 0, $db, $outputlangs, 0); } else { - if (! empty($prod->customcode)) - $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; - if (! empty($prod->customcode) && ! empty($prod->country_code)) + if (!empty($prod->customcode)) + $tmptxt .= $langs->transnoentitiesnoconv("CustomCode").': '.$prod->customcode; + if (!empty($prod->customcode) && !empty($prod->country_code)) $tmptxt .= ' - '; - if (! empty($prod->country_code)) - $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); + if (!empty($prod->country_code)) + $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin").': '.getCountry($prod->country_code, 0, $db, $langs, 0); } $tmptxt .= ')'; $desc = dol_concatdesc($desc, $tmptxt); @@ -1104,11 +1104,11 @@ if (empty($reshook)) } // Margin - $fournprice = price2num(GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); - $buyingprice = price2num(GETPOST('buying_price' . $predef) != '' ? GETPOST('buying_price' . $predef) : ''); // If buying_price is '0', we muste keep this value + $fournprice = price2num(GETPOST('fournprice'.$predef) ? GETPOST('fournprice'.$predef) : ''); + $buyingprice = price2num(GETPOST('buying_price'.$predef) != '' ? GETPOST('buying_price'.$predef) : ''); // If buying_price is '0', we muste keep this value - $date_start = dol_mktime(GETPOST('date_start' . $predef . 'hour'), GETPOST('date_start' . $predef . 'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year')); - $date_end = dol_mktime(GETPOST('date_end' . $predef . 'hour'), GETPOST('date_end' . $predef . 'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year')); + $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); + $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); // Local Taxes $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $tva_npr); @@ -1118,7 +1118,7 @@ if (empty($reshook)) if ($tva_npr) $info_bits |= 0x01; - if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) ) && (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) { + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && (!empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); setEventMessages($mesg, null, 'errors'); } else { @@ -1131,7 +1131,7 @@ if (empty($reshook)) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) { + if (!empty($conf->global->MAIN_MULTILANGS)) { $outputlangs = new Translate("", $conf); $newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $object->thirdparty->default_lang); $outputlangs->setDefaultLang($newlang); @@ -1201,7 +1201,7 @@ if (empty($reshook)) // Add buying price $fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : ''); - $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value + $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value $pu_ht_devise = GETPOST('multicurrency_subprice'); @@ -1215,30 +1215,30 @@ if (empty($reshook)) if (is_array($extralabelsline)) { // Get extra fields foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); + unset($_POST["options_".$key]); } } // Define special_code for special lines - $special_code=GETPOST('special_code'); - if (! GETPOST('qty')) $special_code=3; + $special_code = GETPOST('special_code'); + if (!GETPOST('qty')) $special_code = 3; // Check minimum price $productid = GETPOST('productid', 'int'); - if (! empty($productid)) { + if (!empty($productid)) { $product = new Product($db); $res = $product->fetch($productid); $type = $product->type; $price_min = $product->price_min; - if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level)) + if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) $price_min = $product->multiprices_min [$object->thirdparty->price_level]; $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); - if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)))) { + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)))) { setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors'); - $error ++; + $error++; } } else { $type = GETPOST('type'); @@ -1247,11 +1247,11 @@ if (empty($reshook)) // Check parameters if (GETPOST('type') < 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); - $error ++; + $error++; } } - if (! $error) { + if (!$error) { $db->begin(); if (empty($user->rights->margins->creer)) @@ -1274,7 +1274,7 @@ if (empty($reshook)) if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) { + if (!empty($conf->global->MAIN_MULTILANGS)) { $outputlangs = new Translate("", $conf); $newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $object->thirdparty->default_lang); $outputlangs->setDefaultLang($newlang); @@ -1316,7 +1316,7 @@ if (empty($reshook)) } } } elseif ($action == 'updateline' && $usercancreate && GETPOST('cancel', 'alpha')) { - header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition + header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // Pour reaffichage de la fiche en cours d'edition exit(); } @@ -1365,12 +1365,12 @@ if (empty($reshook)) // bank account elseif ($action == 'setbankaccount' && $usercancreate) { - $result=$object->setBankAccount(GETPOST('fk_account', 'int')); + $result = $object->setBankAccount(GETPOST('fk_account', 'int')); } // shipping method elseif ($action == 'setshippingmethod' && $usercancreate) { - $result=$object->setShippingMethod(GETPOST('shipping_method_id', 'int')); + $result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int')); } elseif ($action == 'update_extras') { @@ -1379,7 +1379,7 @@ if (empty($reshook)) // Fill array 'array_options' with data from update form $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; - if (! $error) + if (!$error) { $result = $object->insertExtraFields('PROPAL_MODIFY'); if ($result < 0) @@ -1391,7 +1391,7 @@ if (empty($reshook)) if ($error) $action = 'edit_extras'; } - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate) + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate) { if ($action == 'addcontact') { @@ -1401,7 +1401,7 @@ if (empty($reshook)) } if ($result >= 0) { - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit(); } else { if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { @@ -1428,7 +1428,7 @@ if (empty($reshook)) $result = $object->delete_contact($lineid); if ($result >= 0) { - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit(); } else { dol_print_error($db); @@ -1455,7 +1455,7 @@ $formfile = new FormFile($db); $formpropal = new FormPropal($db); $formmargin = new FormMargin($db); $companystatic = new Societe($db); -if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } $now = dol_now(); @@ -1471,7 +1471,7 @@ if ($action == 'create') $res = $soc->fetch($socid); // Load objectsrc - if (! empty($origin) && ! empty($originid)) + if (!empty($origin) && !empty($originid)) { // Parse element/subelement (ex: project_task) $element = $subelement = $origin; @@ -1498,7 +1498,7 @@ if ($action == 'create') $element = $subelement = 'expedition'; } - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); $objectsrc = new $classname($db); @@ -1509,17 +1509,17 @@ if ($action == 'create') } $objectsrc->fetch_thirdparty(); - $projectid = (! empty($objectsrc->fk_project) ? $objectsrc->fk_project : 0); - $ref_client = (! empty($objectsrc->ref_client) ? $objectsrc->ref_client : ''); - $ref_int = (! empty($objectsrc->ref_int) ? $objectsrc->ref_int : ''); + $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project : 0); + $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client : ''); + $ref_int = (!empty($objectsrc->ref_int) ? $objectsrc->ref_int : ''); $soc = $objectsrc->thirdparty; - $cond_reglement_id = (! empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(! empty($soc->cond_reglement_id)?$soc->cond_reglement_id:0)); // TODO maybe add default value option - $mode_reglement_id = (! empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(! empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); - $remise_percent = (! empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(! empty($soc->remise_percent)?$soc->remise_percent:0)); - $remise_absolue = (! empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(! empty($soc->remise_absolue)?$soc->remise_absolue:0)); - $dateinvoice = (empty($dateinvoice)?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$dateinvoice); + $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0)); // TODO maybe add default value option + $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0)); + $remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_percent) ? $soc->remise_percent : 0)); + $remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); + $dateinvoice = (empty($dateinvoice) ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $dateinvoice); // Replicate extrafields $objectsrc->fetch_optionals($originid); @@ -1539,14 +1539,14 @@ if ($action == 'create') $object = new Propal($db); - print ''; - print ''; + print ''; + print ''; print ''; if ($origin != 'project' && $originid) { - print ''; - print ''; + print ''; + print ''; } elseif ($origin == 'project' && !empty($projectid)) { - print ''; + print ''; } dol_fiche_head(); @@ -1554,22 +1554,22 @@ if ($action == 'create') print '
'; print $form->selectDate($datestart, 'datestart', 0, 0, 1, '', 1, 0); print ''; print $form->selectDate($dateend, 'dateend', 0, 0, 1, '', 1, 0); print ''; $formactions->form_select_status_action('formaction', $status, 1, 'status', 1, 2, 'minwidth100imp maxwidth125'); print ajax_combobox('selectstatus'); @@ -494,46 +494,46 @@ if ($resql) } // Action column print ''; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; print $actionstatic->getNomUrl(1, -1); print ''; // With edge and chrome the td overflow is not supported correctly when content is not full text. + print ''; // With edge and chrome the td overflow is not supported correctly when content is not full text. if ($obj->fk_user_action > 0) { $userstatic->fetch($obj->fk_user_action); @@ -579,10 +579,10 @@ if ($resql) } // Type - if (! empty($arrayfields['c.libelle']['checked'])) + if (!empty($arrayfields['c.libelle']['checked'])) { print ''; - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { if ($actionstatic->type_picto) print img_picto('', $actionstatic->type_picto); else { @@ -591,60 +591,60 @@ if ($resql) elseif ($actionstatic->type_code == 'AC_FAX') print img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; elseif ($actionstatic->type_code == 'AC_EMAIL') print img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; elseif ($actionstatic->type_code == 'AC_INT') print img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; - elseif (! preg_match('/_AUTO/', $actionstatic->type_code)) print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; + elseif (!preg_match('/_AUTO/', $actionstatic->type_code)) print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; } } - $labeltype=$obj->type_code; - if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) $labeltype='AC_OTH'; - if (! empty($arraylist[$labeltype])) $labeltype=$arraylist[$labeltype]; + $labeltype = $obj->type_code; + if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) $labeltype = 'AC_OTH'; + if (!empty($arraylist[$labeltype])) $labeltype = $arraylist[$labeltype]; print dol_trunc($labeltype, 28); print ''; print $actionstatic->label; print ''; $text = dolGetFirstLineOfText(dol_string_nohtmltag($actionstatic->note, 0)); print $form->textwithtooltip(dol_trunc($text, 40), $actionstatic->note); print ''; print dol_print_date($db->jdate($obj->dp), $formatToUse); - $late=0; - if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late=1; - if ($obj->percent == 0 && ! $obj->dp && $obj->dp2 && $db->jdate($obj->dp) < ($now - $delay_warning)) $late=1; - if ($obj->percent > 0 && $obj->percent < 100 && $obj->dp2 && $db->jdate($obj->dp2) < ($now - $delay_warning)) $late=1; - if ($obj->percent > 0 && $obj->percent < 100 && ! $obj->dp2 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late=1; + $late = 0; + if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1; + if ($obj->percent == 0 && !$obj->dp && $obj->dp2 && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1; + if ($obj->percent > 0 && $obj->percent < 100 && $obj->dp2 && $db->jdate($obj->dp2) < ($now - $delay_warning)) $late = 1; + if ($obj->percent > 0 && $obj->percent < 100 && !$obj->dp2 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1; if ($late) print img_warning($langs->trans("Late")).' '; print ''; print dol_print_date($db->jdate($obj->dp2), $formatToUse); print ''; if ($obj->socid > 0) { - $societestatic->id=$obj->socid; - $societestatic->client=$obj->client; - $societestatic->name=$obj->societe; - $societestatic->email=$obj->socemail; + $societestatic->id = $obj->socid; + $societestatic->client = $obj->client; + $societestatic->name = $obj->societe; + $societestatic->email = $obj->socemail; print $societestatic->getNomUrl(1, '', 28); } @@ -653,44 +653,44 @@ if ($resql) } // Contact - if (! empty($arrayfields['a.fk_contact']['checked'])) { + if (!empty($arrayfields['a.fk_contact']['checked'])) { print ''; $actionstatic->fetchResources(); - if(!empty($actionstatic->socpeopleassigned)) + if (!empty($actionstatic->socpeopleassigned)) { $contactList = array(); foreach ($actionstatic->socpeopleassigned as $socpeopleassigned) { - if(!isset($contactListCache[$socpeopleassigned['id']])) + if (!isset($contactListCache[$socpeopleassigned['id']])) { // if no cache found we fetch it $contact = new Contact($db); - if($contact->fetch($socpeopleassigned['id'])>0) + if ($contact->fetch($socpeopleassigned['id']) > 0) { $contactListCache[$socpeopleassigned['id']] = $contact->getNomUrl(1, '', 0); $contactList[] = $contact->getNomUrl(1, '', 0); } } - else{ + else { // use cache $contactList[] = $contactListCache[$socpeopleassigned['id']]; } } - if(!empty($contactList)){ + if (!empty($contactList)) { print implode(', ', $contactList); } } elseif ($obj->fk_contact > 0) //keep for retrocompatibility with faraway event { - $contactstatic->id=$obj->fk_contact; - $contactstatic->email=$obj->email; - $contactstatic->lastname=$obj->lastname; - $contactstatic->firstname=$obj->firstname; - $contactstatic->phone_pro=$obj->phone_pro; - $contactstatic->phone_mobile=$obj->phone_mobile; - $contactstatic->phone_perso=$obj->phone_perso; - $contactstatic->country_id=$obj->country_id; + $contactstatic->id = $obj->fk_contact; + $contactstatic->email = $obj->email; + $contactstatic->lastname = $obj->lastname; + $contactstatic->firstname = $obj->firstname; + $contactstatic->phone_pro = $obj->phone_pro; + $contactstatic->phone_mobile = $obj->phone_mobile; + $contactstatic->phone_perso = $obj->phone_perso; + $contactstatic->country_id = $obj->country_id; print $contactstatic->getNomUrl(1, '', 0); } else @@ -701,10 +701,10 @@ if ($resql) } // Linked object - if (! empty($arrayfields['a.fk_element']['checked'])) { + if (!empty($arrayfields['a.fk_element']['checked'])) { print ''; //var_dump($obj->fkelement.' '.$obj->elementtype); - if ($obj->fk_element > 0 && ! empty($obj->elementtype)) { + if ($obj->fk_element > 0 && !empty($obj->elementtype)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; print dolGetElementUrl($obj->fk_element, $obj->elementtype, 1); } else { @@ -716,22 +716,22 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['a.datec']['checked'])) { + if (!empty($arrayfields['a.datec']['checked'])) { // Status/Percent print ''.dol_print_date($db->jdate($obj->datec), 'dayhour').''.dol_print_date($db->jdate($obj->datem), 'dayhour').''.$actionstatic->LibStatut($obj->percent, 3, 0, $datep).'
'; // Reference - print ''; + print ''; // Ref customer - print ''; print ''; // Third party print ''; - print ''; + print ''; if ($socid > 0) { print ''; - if (! empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD) && ! empty($soc->shipping_method_id)) { + if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD) && !empty($soc->shipping_method_id)) { $shipping_method_id = $soc->shipping_method_id; } } else { @@ -1591,71 +1591,71 @@ if ($action == 'create') print ' '.$langs->trans("AddThirdParty").''; print ''; } - print '' . "\n"; + print ''."\n"; if ($socid > 0) { // Contacts (ask contact only if thirdparty already defined). - print "'; // Third party discounts info line - print ''; } // Date - print ''; // Validaty duration - print ''; + print ''; // Terms of payment - print ''; // Mode of payment - print ''; // Bank Account - if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && ! empty($conf->banque->enabled)) { - print ''; } // What trigger creation - print ''; // Delivery delay - print ''; // Shipping Method - if (! empty($conf->expedition->enabled)) { - print ''; } // Delivery date (or manufacturing) - print ''; + print ''; print ''; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); print ''; - print ''; print ''; } @@ -1686,20 +1686,20 @@ if ($action == 'create') print ''; print ''; print ''; } // Template to use by default print ''; - print ''; + print ''; print '"; // Multicurrency - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; print ''; @@ -1710,9 +1710,9 @@ if ($action == 'create') // Public note print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; - print '"; - if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0 ) // Localtax1 + print ''; + print ''; + print '"; + if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 { - print '"; + print '"; } if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 { - print '"; + print '"; } - print '"; + print '"; if (!empty($conf->multicurrency->enabled)) { - print ''; - print '"; - print '"; + print ''; + print '"; + print '"; } } @@ -1792,21 +1792,21 @@ if ($action == 'create') if (empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) print ''; - if (! empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) + if (!empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) { print '
' . $langs->trans('Ref') . '' . $langs->trans("Draft") . '
'.$langs->trans('Ref').''.$langs->trans("Draft").'
' . $langs->trans('RefCustomer') . ''; + print '
'.$langs->trans('RefCustomer').''; print '
' . $langs->trans('Customer') . ''.$langs->trans('Customer').''; print $soc->getNomUrl(1); - print ''; + print ''; print '
" . $langs->trans("DefaultContact") . ''; + print "
".$langs->trans("DefaultContact").''; $form->select_contacts($soc->id, $contactid, 'contactid', 1, $srccontactslist); print '
' . $langs->trans('Discounts') . ''; + print '
'.$langs->trans('Discounts').''; $absolute_discount = $soc->getAvailableDiscounts(); $thirdparty = $soc; $discount_type = 0; - $backtopage = urlencode($_SERVER["PHP_SELF"] . '?socid=' . $thirdparty->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')); + $backtopage = urlencode($_SERVER["PHP_SELF"].'?socid='.$thirdparty->id.'&action='.$action.'&origin='.GETPOST('origin').'&originid='.GETPOST('originid')); include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; print '
' . $langs->trans('Date') . ''; + print '
'.$langs->trans('Date').''; print $form->selectDate('', '', '', '', '', "addprop", 1, 1); print '
' . $langs->trans("ValidityDuration") . ' ' . $langs->trans("days") . '
'.$langs->trans("ValidityDuration").' '.$langs->trans("days").'
' . $langs->trans('PaymentConditionsShort') . ''; + print '
'.$langs->trans('PaymentConditionsShort').''; $form->select_conditions_paiements($soc->cond_reglement_id, 'cond_reglement_id', -1, 1); print '
' . $langs->trans('PaymentMode') . ''; + print '
'.$langs->trans('PaymentMode').''; $form->select_types_paiements($soc->mode_reglement_id, 'mode_reglement_id'); print '
' . $langs->trans('BankAccount') . ''; + if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && !empty($conf->banque->enabled)) { + print '
'.$langs->trans('BankAccount').''; $form->select_comptes($soc->fk_account, 'fk_account', 0, '', 1); print '
' . $langs->trans('Source') . ''; + print '
'.$langs->trans('Source').''; $form->selectInputReason('', 'demand_reason_id', "SRC_PROP", 1); print '
' . $langs->trans('AvailabilityPeriod') . ''; + print '
'.$langs->trans('AvailabilityPeriod').''; $form->selectAvailabilityDelay('', 'availability_id', '', 1); print '
' . $langs->trans('SendingMethod') . ''; + if (!empty($conf->expedition->enabled)) { + print '
'.$langs->trans('SendingMethod').''; print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1); print '
' . $langs->trans("DeliveryDate") . '
'.$langs->trans("DeliveryDate").''; if ($conf->global->DATE_LIVRAISON_WEEK_DELAY != "") { $tmpdte = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); @@ -1669,13 +1669,13 @@ if ($action == 'create') print '
' . $langs->trans("Project") . ''; + print ''.$langs->trans("Project").''; $numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 1); - print '   id).'">' . $langs->trans("AddProject") . ''; + print '   id).'">'.$langs->trans("AddProject").''; print '
'; - print $form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms : ''), (!empty($soc->location_incoterms)?$soc->location_incoterms:'')); + print $form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms : ''), (!empty($soc->location_incoterms) ? $soc->location_incoterms : '')); print '
' . $langs->trans("DefaultModel") . ''.$langs->trans("DefaultModel").''; $liste = ModelePDFPropales::liste_modeles($db); print $form->selectarray('model', $liste, ($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT ? $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT : $conf->global->PROPALE_ADDON_PDF)); print "
'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).'
' . $langs->trans('NotePublic') . ''.$langs->trans('NotePublic').''; - $note_public = $object->getDefaultCreateValueFor('note_public', (is_object($objectsrc)?$objectsrc->note_public:null)); + $note_public = $object->getDefaultCreateValueFor('note_public', (is_object($objectsrc) ? $objectsrc->note_public : null)); $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); @@ -1720,9 +1720,9 @@ if ($action == 'create') if (empty($user->socid)) { print '
' . $langs->trans('NotePrivate') . ''.$langs->trans('NotePrivate').''; - $note_private = $object->getDefaultCreateValueFor('note_private', ((! empty($origin) && ! empty($originid) && is_object($objectsrc))?$objectsrc->note_private:null)); + $note_private = $object->getDefaultCreateValueFor('note_private', ((!empty($origin) && !empty($originid) && is_object($objectsrc)) ? $objectsrc->note_private : null)); $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); // print ' @@ -1730,10 +1730,10 @@ if ($action == 'create') } // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; // Lines from source - if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) + if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { // TODO for compatibility if ($origin == 'contrat') { @@ -1743,13 +1743,13 @@ if ($action == 'create') $objectsrc->update_price(1, - 1, 1); } - print "\n"; + print "\n"; print "\n"; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - print ''; - print ''; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''; + print ''; $newclassname = $classname; if ($newclassname == 'Propal') @@ -1761,25 +1761,25 @@ if ($action == 'create') elseif ($newclassname == 'Fichinter') $newclassname = 'Intervention'; - print '
' . $langs->trans($newclassname) . '' . $objectsrc->getNomUrl(1) . '
' . $langs->trans('AmountHT') . '' . price($objectsrc->total_ht, 0, $langs, 1, -1, -1, $conf->currency) . '
' . $langs->trans('AmountVAT') . '' . price($objectsrc->total_tva, 0, $langs, 1, -1, -1, $conf->currency) . "
'.$langs->trans($newclassname).''.$objectsrc->getNomUrl(1).'
'.$langs->trans('AmountHT').''.price($objectsrc->total_ht, 0, $langs, 1, -1, -1, $conf->currency).'
'.$langs->trans('AmountVAT').''.price($objectsrc->total_tva, 0, $langs, 1, -1, -1, $conf->currency)."
' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($objectsrc->total_localtax1, 0, $langs, 1, -1, -1, $conf->currency) . "
'.$langs->transcountry("AmountLT1", $mysoc->country_code).''.price($objectsrc->total_localtax1, 0, $langs, 1, -1, -1, $conf->currency)."
' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($objectsrc->total_localtax2, 0, $langs, 1, -1, -1, $conf->currency) . "
'.$langs->transcountry("AmountLT2", $mysoc->country_code).''.price($objectsrc->total_localtax2, 0, $langs, 1, -1, -1, $conf->currency)."
' . $langs->trans('AmountTTC') . '' . price($objectsrc->total_ttc, 0, $langs, 1, -1, -1, $conf->currency) . "
'.$langs->trans('AmountTTC').''.price($objectsrc->total_ttc, 0, $langs, 1, -1, -1, $conf->currency)."
' . $langs->trans('MulticurrencyAmountHT') . '' . price($objectsrc->multicurrency_total_ht) . '
' . $langs->trans('MulticurrencyAmountVAT') . '' . price($objectsrc->multicurrency_total_tva) . "
' . $langs->trans('MulticurrencyAmountTTC') . '' . price($objectsrc->multicurrency_total_ttc) . "
'.$langs->trans('MulticurrencyAmountHT').''.price($objectsrc->multicurrency_total_ht).'
'.$langs->trans('MulticurrencyAmountVAT').''.price($objectsrc->multicurrency_total_tva)."
'.$langs->trans('MulticurrencyAmountTTC').''.price($objectsrc->multicurrency_total_ttc)."
'; // For backward compatibility print ''; print ''; - print ''; + print ''; print ''; print ''; - print ''; + print ''; } - if (! empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) print '
' . $langs->trans("CopyPropalFrom") . ' '.$langs->trans("CopyPropalFrom").' '; $liste_propal = array(); $liste_propal [0] = ''; $sql = "SELECT p.rowid as id, p.ref, s.nom"; - $sql .= " FROM " . MAIN_DB_PREFIX . "propal p"; - $sql .= ", " . MAIN_DB_PREFIX . "societe s"; + $sql .= " FROM ".MAIN_DB_PREFIX."propal p"; + $sql .= ", ".MAIN_DB_PREFIX."societe s"; $sql .= " WHERE s.rowid = p.fk_soc"; $sql .= " AND p.entity IN (".getEntity('propal').")"; $sql .= " AND p.fk_statut <> 0"; @@ -1818,9 +1818,9 @@ if ($action == 'create') $i = 0; while ($i < $num) { $row = $db->fetch_row($resql); - $propalRefAndSocName = $row [1] . " - " . $row [2]; + $propalRefAndSocName = $row [1]." - ".$row [2]; $liste_propal [$row [0]] = $propalRefAndSocName; - $i ++; + $i++; } print $form->selectarray("copie_propal", $liste_propal, 0); } else { @@ -1829,25 +1829,25 @@ if ($action == 'create') print '
' . $langs->trans("CreateEmptyPropal") . '
'.$langs->trans("CreateEmptyPropal").'
'; + if (!empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) print ''; dol_fiche_end(); $langs->load("bills"); print '
'; - print ''; + print ''; print '     '; - print ''; + print ''; print '
'; print ""; // Show origin lines - if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) { + if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { print '
'; $title = $langs->trans('ProductsAndServices'); @@ -1880,47 +1880,47 @@ if ($action == 'create') // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => // 1), - array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)'))); + array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)'))); if (!empty($conf->global->PROPAL_CLONE_DATE_DELIVERY) && !empty($object->date_livraison)) { - $formquestion[] = array('type' => 'date','name' => 'date_delivery','label' => $langs->trans("DeliveryDate"),'value' => $object->date_livraison); + $formquestion[] = array('type' => 'date', 'name' => 'date_delivery', 'label' => $langs->trans("DeliveryDate"), 'value' => $object->date_livraison); } // Incomplete payment. We ask if reason = discount or other - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmClonePropal', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmClonePropal', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } if ($action == 'statut') { //Form to close proposal (signed or not) $formquestion = array( - array('type' => 'select','name' => 'statut','label' => $langs->trans("CloseAs"),'values' => array(2=>$object->LibStatut(Propal::STATUS_SIGNED), 3=>$object->LibStatut(Propal::STATUS_NOTSIGNED))), - array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"),'value' => '') // Field to complete private note (not replace) + array('type' => 'select', 'name' => 'statut', 'label' => $langs->trans("CloseAs"), 'values' => array(2=>$object->LibStatut(Propal::STATUS_SIGNED), 3=>$object->LibStatut(Propal::STATUS_NOTSIGNED))), + array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"), 'value' => '') // Field to complete private note (not replace) ); - if (! empty($conf->notification->enabled)) + if (!empty($conf->notification->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; $notify = new Notify($db); $formquestion = array_merge($formquestion, array( array('type' => 'onecolumn', 'value' => $notify->confirmMessage('PROPAL_CLOSE_SIGNED', $object->socid, $object)), )); } - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('SetAcceptedRefused'), $text, 'setstatut', $formquestion, '', 1, 250); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetAcceptedRefused'), $text, 'setstatut', $formquestion, '', 1, 250); } // Confirm delete elseif ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp', $object->ref), 'confirm_delete', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp', $object->ref), 'confirm_delete', '', 0, 1); } // Confirm reopen elseif ($action == 'reopen') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ReOpen'), $langs->trans('ConfirmReOpenProp', $object->ref), 'confirm_reopen', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReOpen'), $langs->trans('ConfirmReOpenProp', $object->ref), 'confirm_reopen', '', 0, 1); } // Confirmation delete product/service line elseif ($action == 'ask_deleteline') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); } // Confirm validate proposal @@ -1932,7 +1932,7 @@ if ($action == 'create') if ($ref == 'PROV') { $numref = $object->getNextNumRef($soc); if (empty($numref)) { - $error ++; + $error++; setEventMessages($object->error, $object->errors, 'errors'); } } else { @@ -1940,22 +1940,22 @@ if ($action == 'create') } $text = $langs->trans('ConfirmValidateProp', $numref); - if (! empty($conf->notification->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; + if (!empty($conf->notification->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; $notify = new Notify($db); $text .= '
'; $text .= $notify->confirmMessage('PROPAL_VALIDATE', $object->socid, $object); } - if (! $error) - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ValidateProp'), $text, 'confirm_validate', '', 0, 1); + if (!$error) + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateProp'), $text, 'confirm_validate', '', 0, 1); } // Call Hook formConfirm $parameters = array('lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; // Print form confirm print $formconfirm; @@ -1963,48 +1963,48 @@ if ($action == 'create') // Proposal card - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
'; + $morehtmlref = '
'; // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', null, null, '', 1); + $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'customer'); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' ('.$langs->trans("OtherProposals").')'; + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' ('.$langs->trans("OtherProposals").')'; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; + $morehtmlref .= '
'.$langs->trans('Project').' '; if ($usercancreate) { if ($action != 'classify') - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='
'; + $morehtmlref .= '
'; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -2017,7 +2017,7 @@ if ($action == 'create') print ''; // Link for thirdparty discounts - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice } else { @@ -2025,7 +2025,7 @@ if ($action == 'create') $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')"; } - print ''; @@ -2046,15 +2046,15 @@ if ($action == 'create') print $langs->trans('Date'); print ''; if ($action != 'editdate' && $object->statut == Propal::STATUS_DRAFT && $usercancreate) - print ''; + print ''; print '
' . $langs->trans('Discounts') . ''; + print '
'.$langs->trans('Discounts').''; $absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount); $absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote); @@ -2034,7 +2034,7 @@ if ($action == 'create') $thirdparty = $soc; $discount_type = 0; - $backtopage = urlencode($_SERVER["PHP_SELF"] . '?id=' . $object->id); + $backtopage = urlencode($_SERVER["PHP_SELF"].'?id='.$object->id); include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; print '
id . '">' . img_edit($langs->trans('SetDate'), 1) . 'id.'">'.img_edit($langs->trans('SetDate'), 1).'
'; print ''; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editdate' && $usercancreate) { - print '
'; - print ''; + print ''; + print ''; print ''; print $form->selectDate($object->date, 're', '', '', 0, "editdate"); - print ''; + print ''; print '
'; } else { if ($object->date) { @@ -2072,18 +2072,18 @@ if ($action == 'create') print $langs->trans('DateEndPropal'); print ''; if ($action != 'editecheance' && $object->statut == Propal::STATUS_DRAFT && $usercancreate) - print 'id . '">' . img_edit($langs->trans('SetConditions'), 1) . ''; + print 'id.'">'.img_edit($langs->trans('SetConditions'), 1).''; print ''; print ''; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editecheance' && $usercancreate) { - print '
'; - print ''; + print ''; + print ''; print ''; print $form->selectDate($object->fin_validite, 'ech', '', '', '', "editecheance"); - print ''; + print ''; print '
'; } else { - if (! empty($object->fin_validite)) { + if (!empty($object->fin_validite)) { print dol_print_date($object->fin_validite, 'day'); if ($object->statut == Propal::STATUS_VALIDATED && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); @@ -2100,13 +2100,13 @@ if ($action == 'create') print $langs->trans('PaymentConditionsShort'); print ''; if ($action != 'editconditions' && $object->statut == Propal::STATUS_DRAFT && $usercancreate) - print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetConditions'), 1) . ''; + print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetConditions'), 1).''; print ''; print ''; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editconditions' && $usercancreate) { - $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->cond_reglement_id, 'cond_reglement_id'); + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id'); } else { - $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->cond_reglement_id, 'none'); + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none'); } print ''; print ''; @@ -2124,24 +2124,24 @@ if ($action == 'create') print ''; print ''; if ($action != 'editavailability' && $object->statut == Propal::STATUS_DRAFT && $usercancreate) - print ''; + print ''; print '
'; print $langs->trans('AvailabilityPeriod'); - if (! empty($conf->commande->enabled)) - print ' (' . $langs->trans('AfterOrder') . ')'; + if (!empty($conf->commande->enabled)) + print ' ('.$langs->trans('AfterOrder').')'; print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetAvailability'), 1) . 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetAvailability'), 1).'
'; print ''; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editavailability' && $usercancreate) { - $form->form_availability($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->availability_id, 'availability_id', 1); + $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, $object->availability_id, 'availability_id', 1); } else { - $form->form_availability($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->availability_id, 'none', 1); + $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, $object->availability_id, 'none', 1); } print ''; print ''; // Shipping Method - if (! empty($conf->expedition->enabled)) { + if (!empty($conf->expedition->enabled)) { print ''; print ''; if ($action != 'editdemandreason' && $object->statut == Propal::STATUS_DRAFT && $usercancreate) - print ''; + print ''; print '
'; print $langs->trans('SendingMethod'); @@ -2165,13 +2165,13 @@ if ($action == 'create') print $langs->trans('Source'); print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetDemandReason'), 1) . 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetDemandReason'), 1).'
'; print ''; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editdemandreason' && $usercancreate) { - $form->formInputReason($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->demand_reason_id, 'demand_reason_id', 1); + $form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, $object->demand_reason_id, 'demand_reason_id', 1); } else { - $form->formInputReason($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->demand_reason_id, 'none'); + $form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, $object->demand_reason_id, 'none'); } print ''; print ''; @@ -2183,18 +2183,18 @@ if ($action == 'create') print $langs->trans('PaymentMode'); print ''; if ($action != 'editmode' && $object->statut == Propal::STATUS_DRAFT && $usercancreate) - print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMode'), 1) . ''; + print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMode'), 1).''; print ''; print ''; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editmode' && $usercancreate) { - $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); } else { - $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'none'); + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none'); } print ''; // Multicurrency - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { // Multicurrency code print ''; @@ -2203,13 +2203,13 @@ if ($action == 'create') print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); print ''; if ($action != 'editmulticurrencycode' && $object->statut == $object::STATUS_DRAFT && $usercancreate) - print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . ''; + print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).''; print ''; print ''; if ($object->statut == $object::STATUS_DRAFT && $action == 'editmulticurrencycode' && $usercancreate) { - $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code'); + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'multicurrency_code'); } else { - $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none'); + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'none'); } print ''; @@ -2223,16 +2223,16 @@ if ($action == 'create') print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); print ''; if ($action != 'editmulticurrencyrate' && $object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency && $usercancreate) - print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . ''; + print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).''; print ''; print ''; - if ($object->statut ==$object::STATUS_DRAFT && ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') && $usercancreate) { - if($action == 'actualizemulticurrencyrate') { + if ($object->statut == $object::STATUS_DRAFT && ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') && $usercancreate) { + if ($action == 'actualizemulticurrencyrate') { list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); } - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { print '
        '; print ''.$langs->trans("ActualizeCurrency").''; @@ -2250,13 +2250,13 @@ if ($action == 'create') print $langs->trans('OutstandingBill'); print ''; $arrayoutstandingbills = $soc->getOutstandingBills(); - print price($arrayoutstandingbills['opened']) . ' / '; + print price($arrayoutstandingbills['opened']).' / '; print price($soc->outstanding_limit, 0, $langs, 1, - 1, - 1, $conf->currency); print ''; print ''; } - if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && ! empty($conf->banque->enabled)) + if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && !empty($conf->banque->enabled)) { // Bank Account print ''; @@ -2276,19 +2276,19 @@ if ($action == 'create') print ''; } - $tmparray=$object->getTotalWeightVolume(); - $totalWeight=$tmparray['weight']; - $totalVolume=$tmparray['volume']; + $tmparray = $object->getTotalWeightVolume(); + $totalWeight = $tmparray['weight']; + $totalVolume = $tmparray['volume']; if ($totalWeight) { - print '' . $langs->trans("CalculatedWeight") . ''; + print ''.$langs->trans("CalculatedWeight").''; print ''; - print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND)?$conf->global->MAIN_WEIGHT_DEFAULT_ROUND:-1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?$conf->global->MAIN_WEIGHT_DEFAULT_UNIT:'no'); + print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); print ''; } if ($totalVolume) { - print '' . $langs->trans("CalculatedVolume") . ''; + print ''.$langs->trans("CalculatedVolume").''; print ''; - print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no'); + print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); print ''; } @@ -2310,13 +2310,13 @@ if ($action == 'create') } else { - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?id='.$object->id); + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); } print ''; } // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print ''; @@ -2330,48 +2330,48 @@ if ($action == 'create') if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) { // Multicurrency Amount HT - print '' . $form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0) . ''; - print '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; + print ''.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).''; + print ''.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).''; print ''; // Multicurrency Amount VAT - print '' . $form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0) . ''; - print '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; + print ''.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).''; + print ''.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).''; print ''; // Multicurrency Amount TTC - print '' . $form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0) . ''; - print '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; + print ''.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).''; + print ''.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).''; print ''; } // Amount HT - print '' . $langs->trans('AmountHT') . ''; - print '' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . ''; + print ''.$langs->trans('AmountHT').''; + print ''.price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency).''; print ''; // Amount VAT - print '' . $langs->trans('AmountVAT') . ''; - print '' . price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency) . ''; + print ''.$langs->trans('AmountVAT').''; + print ''.price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency).''; print ''; // Amount Local Taxes if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) // Localtax1 { - print '' . $langs->transcountry("AmountLT1", $mysoc->country_code) . ''; - print '' . price($object->total_localtax1, '', $langs, 0, - 1, - 1, $conf->currency) . ''; + print ''.$langs->transcountry("AmountLT1", $mysoc->country_code).''; + print ''.price($object->total_localtax1, '', $langs, 0, - 1, - 1, $conf->currency).''; print ''; } if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) // Localtax2 { - print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . ''; - print '' . price($object->total_localtax2, '', $langs, 0, - 1, - 1, $conf->currency) . ''; + print ''.$langs->transcountry("AmountLT2", $mysoc->country_code).''; + print ''.price($object->total_localtax2, '', $langs, 0, - 1, - 1, $conf->currency).''; print ''; } // Amount TTC - print '' . $langs->trans('AmountTTC') . ''; - print '' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . ''; + print ''.$langs->trans('AmountTTC').''; + print ''.price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency).''; print ''; // Statut @@ -2380,7 +2380,7 @@ if ($action == 'create') print ''; // Margin Infos - if (! empty($conf->margin->enabled)) + if (!empty($conf->margin->enabled)) { $formmargin->displayMarginInfos($object); } @@ -2391,16 +2391,16 @@ if ($action == 'create') print '

'; - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; $title = $langs->trans('ContactsAddresses'); - include DOL_DOCUMENT_ROOT . '/core/tpl/bloc_showhide.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; } - if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { + if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $blocname = 'notes'; $title = $langs->trans('Notes'); - include DOL_DOCUMENT_ROOT . '/core/tpl/bloc_showhide.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; } /* @@ -2410,24 +2410,24 @@ if ($action == 'create') // Show object lines $result = $object->getLinesArray(); - print '
- - + print ' + + - + '; - if (! empty($conf->use_javascript_ajax) && $object->statut == Propal::STATUS_DRAFT) { - include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + if (!empty($conf->use_javascript_ajax) && $object->statut == Propal::STATUS_DRAFT) { + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } print '
'; - if (! empty($object->lines) || ($object->statut == Propal::STATUS_DRAFT && $usercancreate && $action != 'selectlines' && $action != 'editline')) + if (!empty($object->lines) || ($object->statut == Propal::STATUS_DRAFT && $usercancreate && $action != 'selectlines' && $action != 'editline')) { print ''; } - if (! empty($object->lines)) + if (!empty($object->lines)) { $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); } @@ -2445,7 +2445,7 @@ if ($action == 'create') } } - if (! empty($object->lines) || ($object->statut == Propal::STATUS_DRAFT && $usercancreate && $action != 'selectlines' && $action != 'editline')) + if (!empty($object->lines) || ($object->statut == Propal::STATUS_DRAFT && $usercancreate && $action != 'selectlines' && $action != 'editline')) { print '
'; } @@ -2475,10 +2475,10 @@ if ($action == 'create') { if ($usercanvalidate) { - print '' . $langs->trans('Validate') . ''; + print ''.$langs->trans('Validate').''; } else - print '' . $langs->trans('Validate') . ''; + print ''.$langs->trans('Validate').''; } // Create event /*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. @@ -2487,45 +2487,45 @@ if ($action == 'create') }*/ // Edit if ($object->statut == Propal::STATUS_VALIDATED && $usercancreate) { - print '' . $langs->trans('Modify') . ''; + print ''.$langs->trans('Modify').''; } // ReOpen if (($object->statut == Propal::STATUS_SIGNED || $object->statut == Propal::STATUS_NOTSIGNED || $object->statut == Propal::STATUS_BILLED) && $usercanclose) { - print 'global->MAIN_JUMP_TAG) ? '' : '#reopen') . '"'; - print '>' . $langs->trans('ReOpen') . ''; + print 'global->MAIN_JUMP_TAG) ? '' : '#reopen').'"'; + print '>'.$langs->trans('ReOpen').''; } // Send if ($object->statut == Propal::STATUS_VALIDATED || $object->statut == Propal::STATUS_SIGNED || !empty($conf->global->PROPOSAL_SENDBYEMAIL_FOR_ALL_STATUS)) { if ($usercansend) { - print '' . $langs->trans('SendMail') . ''; + print ''.$langs->trans('SendMail').''; } else - print '' . $langs->trans('SendMail') . ''; + print ''.$langs->trans('SendMail').''; } // Create a sale order - if (! empty($conf->commande->enabled) && $object->statut == Propal::STATUS_SIGNED) { + if (!empty($conf->commande->enabled) && $object->statut == Propal::STATUS_SIGNED) { if ($usercancreateorder) { - print '' . $langs->trans("AddOrder") . ''; + print ''.$langs->trans("AddOrder").''; } } // Create a purchase order - if (! empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_PROPOSAL)) + if (!empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_PROPOSAL)) { - if (! empty($conf->fournisseur->enabled) && $object->statut == Propal::STATUS_SIGNED) { + if (!empty($conf->fournisseur->enabled) && $object->statut == Propal::STATUS_SIGNED) { if ($usercancreatepurchaseorder) { - print '' . $langs->trans("AddPurchaseOrder") . ''; + print ''.$langs->trans("AddPurchaseOrder").''; } } } // Create an intervention - if (! empty($conf->service->enabled) && ! empty($conf->ficheinter->enabled) && $object->statut == Propal::STATUS_SIGNED) { + if (!empty($conf->service->enabled) && !empty($conf->ficheinter->enabled) && $object->statut == Propal::STATUS_SIGNED) { if ($usercancreateintervention) { $langs->load("interventions"); - print '' . $langs->trans("AddIntervention") . ''; + print ''.$langs->trans("AddIntervention").''; } } @@ -2534,16 +2534,16 @@ if ($action == 'create') $langs->load("contracts"); if ($usercancreatecontract) { - print '' . $langs->trans('AddContract') . ''; + print ''.$langs->trans('AddContract').''; } } // Create an invoice and classify billed if ($object->statut == Propal::STATUS_SIGNED) { - if (! empty($conf->facture->enabled) && $usercancreateinvoice) + if (!empty($conf->facture->enabled) && $usercancreateinvoice) { - print '' . $langs->trans("AddBill") . ''; + print ''.$langs->trans("AddBill").''; } $arrayofinvoiceforpropal = $object->getInvoiceArrayList(); @@ -2551,30 +2551,30 @@ if ($action == 'create') { if ($usercanclose) { - print 'socid . '">' . $langs->trans("ClassifyBilled") . ''; + print 'socid.'">'.$langs->trans("ClassifyBilled").''; } else { - print '' . $langs->trans("ClassifyBilled") . ''; + print ''.$langs->trans("ClassifyBilled").''; } } } // Set accepted/refused if ($object->statut == Propal::STATUS_VALIDATED && $usercanclose) { - print 'global->MAIN_JUMP_TAG) ? '' : '#close') . '"'; - print '>' . $langs->trans('SetAcceptedRefused') . ''; + print 'global->MAIN_JUMP_TAG) ? '' : '#close').'"'; + print '>'.$langs->trans('SetAcceptedRefused').''; } // Clone if ($usercancreate) { - print '' . $langs->trans("ToClone") . ''; + print ''.$langs->trans("ToClone").''; } // Delete if ($usercandelete) { - print '' . $langs->trans('Delete') . ''; + print ''.$langs->trans('Delete').''; } } } @@ -2593,8 +2593,8 @@ if ($action == 'create') * Documents generes */ $filename = dol_sanitizeFileName($object->ref); - $filedir = $conf->propal->multidir_output[$object->entity] . "/" . dol_sanitizeFileName($object->ref); - $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; + $filedir = $conf->propal->multidir_output[$object->entity]."/".dol_sanitizeFileName($object->ref); + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed = $usercanread; $delallowed = $usercancreate; @@ -2604,14 +2604,14 @@ if ($action == 'create') $linktoelem = $form->showLinkToObjectBlock($object, null, array('propal')); $compatibleImportElementsList = false; - if($user->rights->propal->creer && $object->statut == Propal::STATUS_DRAFT) + if ($user->rights->propal->creer && $object->statut == Propal::STATUS_DRAFT) { - $compatibleImportElementsList = array('commande','propal'); // import from linked elements + $compatibleImportElementsList = array('commande', 'propal'); // import from linked elements } $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, $compatibleImportElementsList); // Show online signature link - $useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok + $useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok if ($object->statut != Propal::STATUS_DRAFT && $useonlinesignature) { @@ -2621,7 +2621,7 @@ if ($action == 'create') } // Show direct download link - if ($object->statut != Propal::STATUS_DRAFT && ! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) + if ($object->statut != Propal::STATUS_DRAFT && !empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) { print '
'."\n"; print showDirectDownloadLink($object).'
'; @@ -2630,7 +2630,7 @@ if ($action == 'create') print '
'; // List of actions on element - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'propal', $socid, 1); @@ -2638,8 +2638,8 @@ if ($action == 'create') } // Presend form - $modelmail='propal_send'; - $defaulttopic='SendPropalRef'; + $modelmail = 'propal_send'; + $defaulttopic = 'SendPropalRef'; $diroutput = $conf->propal->multidir_output[$object->entity]; $trackid = 'pro'.$object->id; diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index bccc742aa8e..4a38ff4096a 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -47,57 +47,57 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; // Load translation files required by the page $langs->loadLangs(array('companies', 'propal', 'compta', 'bills', 'orders', 'products', 'deliveries', 'categories')); -$socid=GETPOST('socid', 'int'); +$socid = GETPOST('socid', 'int'); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'proposallist'; +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'proposallist'; -$search_user=GETPOST('search_user', 'int'); -$search_sale=GETPOST('search_sale', 'int'); -$search_ref=GETPOST('sf_ref')?GETPOST('sf_ref', 'alpha'):GETPOST('search_ref', 'alpha'); -$search_refcustomer=GETPOST('search_refcustomer', 'alpha'); +$search_user = GETPOST('search_user', 'int'); +$search_sale = GETPOST('search_sale', 'int'); +$search_ref = GETPOST('sf_ref') ?GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha'); +$search_refcustomer = GETPOST('search_refcustomer', 'alpha'); -$search_refproject=GETPOST('search_refproject', 'alpha'); -$search_project=GETPOST('search_project', 'alpha'); +$search_refproject = GETPOST('search_refproject', 'alpha'); +$search_project = GETPOST('search_project', 'alpha'); -$search_societe=GETPOST('search_societe', 'alpha'); -$search_montant_ht=GETPOST('search_montant_ht', 'alpha'); -$search_montant_vat=GETPOST('search_montant_vat', 'alpha'); -$search_montant_ttc=GETPOST('search_montant_ttc', 'alpha'); -$search_login=GETPOST('search_login', 'alpha'); -$search_product_category=GETPOST('search_product_category', 'int'); -$search_town=GETPOST('search_town', 'alpha'); -$search_zip=GETPOST('search_zip', 'alpha'); -$search_state=trim(GETPOST("search_state")); -$search_country=GETPOST("search_country", 'int'); -$search_type_thirdparty=GETPOST("search_type_thirdparty", 'int'); -$search_day=GETPOST("search_day", "int"); -$search_month=GETPOST("search_month", "int"); -$search_year=GETPOST("search_year", "int"); -$search_dayfin=GETPOST("search_dayfin", "int"); -$search_month_end=GETPOST("search_month_end", "int"); -$search_yearfin=GETPOST("search_yearfin", "int"); -$search_daydelivery=GETPOST("search_daydelivery", "int"); -$search_monthdelivery=GETPOST("search_monthdelivery", "int"); -$search_yeardelivery=GETPOST("search_yeardelivery", "int"); -$search_availability=GETPOST('search_availability', 'int'); -$search_categ_cus=trim(GETPOST("search_categ_cus", 'int')); -$search_btn=GETPOST('button_search', 'alpha'); -$search_remove_btn=GETPOST('button_removefilter', 'alpha'); +$search_societe = GETPOST('search_societe', 'alpha'); +$search_montant_ht = GETPOST('search_montant_ht', 'alpha'); +$search_montant_vat = GETPOST('search_montant_vat', 'alpha'); +$search_montant_ttc = GETPOST('search_montant_ttc', 'alpha'); +$search_login = GETPOST('search_login', 'alpha'); +$search_product_category = GETPOST('search_product_category', 'int'); +$search_town = GETPOST('search_town', 'alpha'); +$search_zip = GETPOST('search_zip', 'alpha'); +$search_state = trim(GETPOST("search_state")); +$search_country = GETPOST("search_country", 'int'); +$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); +$search_day = GETPOST("search_day", "int"); +$search_month = GETPOST("search_month", "int"); +$search_year = GETPOST("search_year", "int"); +$search_dayfin = GETPOST("search_dayfin", "int"); +$search_month_end = GETPOST("search_month_end", "int"); +$search_yearfin = GETPOST("search_yearfin", "int"); +$search_daydelivery = GETPOST("search_daydelivery", "int"); +$search_monthdelivery = GETPOST("search_monthdelivery", "int"); +$search_yeardelivery = GETPOST("search_yeardelivery", "int"); +$search_availability = GETPOST('search_availability', 'int'); +$search_categ_cus = trim(GETPOST("search_categ_cus", 'int')); +$search_btn = GETPOST('button_search', 'alpha'); +$search_remove_btn = GETPOST('button_removefilter', 'alpha'); -$viewstatut=GETPOST('viewstatut', 'alpha'); +$viewstatut = GETPOST('viewstatut', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); -$object_statut=GETPOST('search_statut', 'alpha'); +$object_statut = GETPOST('search_statut', 'alpha'); -$sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$mesg=(GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg")); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$mesg = (GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg")); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -105,23 +105,23 @@ if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='p.ref'; -if (! $sortorder) $sortorder='DESC'; +if (!$sortfield) $sortfield = 'p.ref'; +if (!$sortorder) $sortorder = 'DESC'; // Security check -$module='propal'; -$dbtable=''; -$objectid=''; -if (! empty($user->socid)) $socid=$user->socid; -if (! empty($socid)) +$module = 'propal'; +$dbtable = ''; +$objectid = ''; +if (!empty($user->socid)) $socid = $user->socid; +if (!empty($socid)) { - $objectid=$socid; - $module='societe'; - $dbtable='&societe'; + $objectid = $socid; + $module = 'societe'; + $dbtable = '&societe'; } $result = restrictedArea($user, $module, $objectid, $dbtable); -$diroutputmassaction=$conf->propal->multidir_output[$conf->entity] . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->propal->multidir_output[$conf->entity].'/temp/massgeneration/'.$user->id; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Propal($db); @@ -131,7 +131,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -142,15 +142,15 @@ $fieldstosearchall = array( 's.name_alias'=>"AliasNameShort", 'p.note_public'=>'NotePublic', ); -if (empty($user->socid)) $fieldstosearchall["p.note_private"]="NotePrivate"; +if (empty($user->socid)) $fieldstosearchall["p.note_private"] = "NotePrivate"; -$checkedtypetiers=0; -$arrayfields=array( +$checkedtypetiers = 0; +$arrayfields = array( 'p.ref'=>array('label'=>"Ref", 'checked'=>1), 'p.ref_client'=>array('label'=>"RefCustomer", 'checked'=>1), - 'pr.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled)?0:1)), - 'pr.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled)?0:1)), + 'pr.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)), + 'pr.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)), 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1), 's.town'=>array('label'=>"Town", 'checked'=>1), 's.zip'=>array('label'=>"Zip", 'checked'=>1), @@ -176,10 +176,10 @@ $arrayfields=array( // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } @@ -188,11 +188,11 @@ if (is_array($extrafields->attributes[$object->table_element]['label']) && count * 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('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; @@ -200,47 +200,47 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Do we click on purge search criteria ? 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_categ=''; - $search_user=''; - $search_sale=''; - $search_ref=''; - $search_refcustomer=''; - $search_refproject=''; - $search_project=''; - $search_societe=''; - $search_montant_ht=''; - $search_montant_vat=''; - $search_montant_ttc=''; - $search_login=''; - $search_product_category=''; - $search_town=''; - $search_zip=""; - $search_state=""; - $search_type=''; - $search_country=''; - $search_type_thirdparty=''; - $search_year=''; - $search_month=''; - $search_day=''; - $search_yearfin=''; - $search_month_end=''; - $search_dayfin=''; - $search_yeardelivery=''; - $search_monthdelivery=''; - $search_daydelivery=''; - $search_availability=''; - $viewstatut=''; - $object_statut=''; - $toselect=''; - $search_array_options=array(); - $search_categ_cus=0; + $search_categ = ''; + $search_user = ''; + $search_sale = ''; + $search_ref = ''; + $search_refcustomer = ''; + $search_refproject = ''; + $search_project = ''; + $search_societe = ''; + $search_montant_ht = ''; + $search_montant_vat = ''; + $search_montant_ttc = ''; + $search_login = ''; + $search_product_category = ''; + $search_town = ''; + $search_zip = ""; + $search_state = ""; + $search_type = ''; + $search_country = ''; + $search_type_thirdparty = ''; + $search_year = ''; + $search_month = ''; + $search_day = ''; + $search_yearfin = ''; + $search_month_end = ''; + $search_dayfin = ''; + $search_yeardelivery = ''; + $search_monthdelivery = ''; + $search_daydelivery = ''; + $search_availability = ''; + $viewstatut = ''; + $object_statut = ''; + $toselect = ''; + $search_array_options = array(); + $search_categ_cus = 0; } -if ($object_statut != '') $viewstatut=$object_statut; +if ($object_statut != '') $viewstatut = $object_statut; if (empty($reshook)) { - $objectclass='Propal'; - $objectlabel='Proposals'; + $objectclass = 'Propal'; + $objectlabel = 'Proposals'; $permissiontoread = $user->rights->propal->lire; $permissiontodelete = $user->rights->propal->supprimer; $permissiontoclose = $user->rights->propal->cloturer; @@ -254,68 +254,68 @@ if (empty($reshook)) * View */ -$now=dol_now(); +$now = dol_now(); $form = new Form($db); $formother = new FormOther($db); $formfile = new FormFile($db); $formpropal = new FormPropal($db); -$companystatic=new Societe($db); -$projectstatic=new Project($db); -$formcompany=new FormCompany($db); +$companystatic = new Societe($db); +$projectstatic = new Project($db); +$formcompany = new FormCompany($db); -$help_url='EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'; +$help_url = 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'; //llxHeader('',$langs->trans('Proposal'),$help_url); $sql = 'SELECT'; if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; -$sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; -$sql.= " typent.code as typent_code,"; -$sql.= " ava.rowid as availability,"; -$sql.= " state.code_departement as state_code, state.nom as state_name,"; -$sql.= ' p.rowid, p.entity, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,p.date_livraison as ddelivery,'; -$sql.= ' p.datec as date_creation, p.tms as date_update, p.date_cloture as date_cloture,'; -$sql.= " pr.rowid as project_id, pr.ref as project_ref, pr.title as project_label,"; -$sql.= ' u.login'; -if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user"; +$sql .= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; +$sql .= " typent.code as typent_code,"; +$sql .= " ava.rowid as availability,"; +$sql .= " state.code_departement as state_code, state.nom as state_name,"; +$sql .= ' p.rowid, p.entity, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,p.date_livraison as ddelivery,'; +$sql .= ' p.datec as date_creation, p.tms as date_update, p.date_cloture as date_cloture,'; +$sql .= " pr.rowid as project_id, pr.ref as project_ref, pr.title as project_label,"; +$sql .= ' u.login'; +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user"; if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; // 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 : ''); +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 : ''); } // 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=preg_replace('/, $/', '', $sql); -$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s'; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; -if (! empty($search_categ_cus)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ -$sql.= ', '.MAIN_DB_PREFIX.'propal as p'; -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 (p.rowid = ef.fk_object)"; -if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet as pd ON p.rowid=pd.fk_propal'; -if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; -$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON p.fk_user_author = u.rowid'; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr ON pr.rowid = p.fk_projet"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_availability as ava on (ava.rowid = p.fk_availability)"; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql = preg_replace('/, $/', '', $sql); +$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s'; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +if (!empty($search_categ_cus)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ +$sql .= ', '.MAIN_DB_PREFIX.'propal as p'; +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 (p.rowid = ef.fk_object)"; +if ($sall || $search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet as pd ON p.rowid=pd.fk_propal'; +if ($search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON p.fk_user_author = u.rowid'; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr ON pr.rowid = p.fk_projet"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_availability as ava on (ava.rowid = p.fk_availability)"; // We'll need this table joined to the select in order to filter by sale -if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if ($search_user > 0) { - $sql.=", ".MAIN_DB_PREFIX."element_contact as c"; - $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact as c"; + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; } -$sql.= ' WHERE p.fk_soc = s.rowid'; -$sql.= ' AND p.entity IN ('.getEntity('propal').')'; -if (! $user->rights->societe->client->voir && ! $socid) //restriction +$sql .= ' WHERE p.fk_soc = s.rowid'; +$sql .= ' AND p.entity IN ('.getEntity('propal').')'; +if (!$user->rights->societe->client->voir && !$socid) //restriction { - $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } -if ($search_town) $sql.= natural_search('s.town', $search_town); -if ($search_zip) $sql.= natural_search("s.zip", $search_zip); -if ($search_state) $sql.= natural_search("state.nom", $search_state); +if ($search_town) $sql .= natural_search('s.town', $search_town); +if ($search_zip) $sql .= natural_search("s.zip", $search_zip); +if ($search_state) $sql .= natural_search("state.nom", $search_state); if ($search_country) $sql .= " AND s.fk_pays IN (".$db->escape($search_country).')'; if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->escape($search_type_thirdparty).')'; if ($search_ref) $sql .= natural_search('p.ref', $search_ref); @@ -326,39 +326,39 @@ if ($search_availability) $sql .= " AND p.fk_availability IN (".$db->escape($sea if ($search_societe) $sql .= natural_search('s.nom', $search_societe); if ($search_login) $sql .= natural_search("u.login", $search_login); -if ($search_montant_ht != '') $sql.= natural_search("p.total_ht", $search_montant_ht, 1); -if ($search_montant_vat != '') $sql.= natural_search("p.tva", $search_montant_vat, 1); -if ($search_montant_ttc != '') $sql.= natural_search("p.total", $search_montant_ttc, 1); +if ($search_montant_ht != '') $sql .= natural_search("p.total_ht", $search_montant_ht, 1); +if ($search_montant_vat != '') $sql .= natural_search("p.tva", $search_montant_vat, 1); +if ($search_montant_ttc != '') $sql .= natural_search("p.total", $search_montant_ttc, 1); if ($sall) { $sql .= natural_search(array_keys($fieldstosearchall), $sall); } -if ($search_categ_cus > 0) $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); -if ($search_categ_cus == -2) $sql.= " AND cc.fk_categorie IS NULL"; +if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); +if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL"; -if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$db->escape($search_product_category); -if ($socid > 0) $sql.= ' AND s.rowid = '.$socid; +if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$db->escape($search_product_category); +if ($socid > 0) $sql .= ' AND s.rowid = '.$socid; if ($viewstatut != '' && $viewstatut != '-1') { - $sql.= ' AND p.fk_statut IN ('.$db->escape($viewstatut).')'; + $sql .= ' AND p.fk_statut IN ('.$db->escape($viewstatut).')'; } -$sql.= dolSqlDateFilter("p.datep", $search_day, $search_month, $search_year); -$sql.= dolSqlDateFilter("p.fin_validite", $search_dayfin, $search_month_end, $search_yearfin); -$sql.= dolSqlDateFilter("p.date_livraison", $search_daydelivery, $search_monthdelivery, $search_yeardelivery); -if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$db->escape($search_sale); +$sql .= dolSqlDateFilter("p.datep", $search_day, $search_month, $search_year); +$sql .= dolSqlDateFilter("p.fin_validite", $search_dayfin, $search_month_end, $search_yearfin); +$sql .= dolSqlDateFilter("p.date_livraison", $search_daydelivery, $search_monthdelivery, $search_yeardelivery); +if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$db->escape($search_sale); if ($search_user > 0) { - $sql.= " AND c.fk_c_type_contact = tc.rowid AND tc.element='propal' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = ".$db->escape($search_user); + $sql .= " AND c.fk_c_type_contact = tc.rowid AND tc.element='propal' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = ".$db->escape($search_user); } // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); -$sql.=', p.ref DESC'; +$sql .= $db->order($sortfield, $sortorder); +$sql .= ', p.ref DESC'; // Count total nb of records $nbtotalofrecords = ''; @@ -374,20 +374,20 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { - $objectstatic=new Propal($db); - $userstatic=new User($db); + $objectstatic = new Propal($db); + $userstatic = new User($db); if ($socid > 0) { $soc = new Societe($db); $soc->fetch($socid); - $title = $langs->trans('ListOfProposals') . ' - '.$soc->name; + $title = $langs->trans('ListOfProposals').' - '.$soc->name; if (empty($search_societe)) $search_societe = $soc->name; } else @@ -397,9 +397,9 @@ if ($resql) $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); - if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) + if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { $obj = $db->fetch_object($resql); @@ -411,46 +411,46 @@ if ($resql) llxHeader('', $langs->trans('Proposal'), $help_url); - $param='&viewstatut='.urlencode($viewstatut); - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($sall) $param.='&sall='.urlencode($sall); - if ($search_day) $param.='&search_day='.urlencode($search_day); - if ($search_month) $param.='&search_month='.urlencode($search_month); - if ($search_year) $param.='&search_year='.urlencode($search_year); - if ($search_ref) $param.='&search_ref='.urlencode($search_ref); - if ($search_refcustomer) $param.='&search_refcustomer='.urlencode($search_refcustomer); - if ($search_refproject) $param.='&search_refproject='.urlencode($search_refproject); - if ($search_societe) $param.='&search_societe='.urlencode($search_societe); - if ($search_user > 0) $param.='&search_user='.urlencode($search_user); - if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale); - if ($search_montant_ht) $param.='&search_montant_ht='.urlencode($search_montant_ht); - if ($search_login) $param.='&search_login='.urlencode($search_login); - if ($search_town) $param.='&search_town='.urlencode($search_town); - if ($search_zip) $param.='&search_zip='.urlencode($search_zip); - if ($socid > 0) $param.='&socid='.urlencode($socid); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); - if ($search_categ_cus > 0) $param.='&search_categ_cus='.urlencode($search_categ_cus); - if ($search_product_category != '') $param.='&search_product_category='.$search_product_category; + $param = '&viewstatut='.urlencode($viewstatut); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($sall) $param .= '&sall='.urlencode($sall); + if ($search_day) $param .= '&search_day='.urlencode($search_day); + if ($search_month) $param .= '&search_month='.urlencode($search_month); + if ($search_year) $param .= '&search_year='.urlencode($search_year); + if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); + if ($search_refcustomer) $param .= '&search_refcustomer='.urlencode($search_refcustomer); + if ($search_refproject) $param .= '&search_refproject='.urlencode($search_refproject); + if ($search_societe) $param .= '&search_societe='.urlencode($search_societe); + if ($search_user > 0) $param .= '&search_user='.urlencode($search_user); + if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); + if ($search_montant_ht) $param .= '&search_montant_ht='.urlencode($search_montant_ht); + if ($search_login) $param .= '&search_login='.urlencode($search_login); + if ($search_town) $param .= '&search_town='.urlencode($search_town); + if ($search_zip) $param .= '&search_zip='.urlencode($search_zip); + if ($socid > 0) $param .= '&socid='.urlencode($socid); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + if ($search_categ_cus > 0) $param .= '&search_categ_cus='.urlencode($search_categ_cus); + if ($search_product_category != '') $param .= '&search_product_category='.$search_product_category; // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available - $arrayofmassactions = array( + $arrayofmassactions = array( 'generate_doc'=>$langs->trans("ReGeneratePDF"), 'builddoc'=>$langs->trans("PDFMerge"), 'presend'=>$langs->trans("SendByMail"), ); - if ($user->rights->propal->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); - if ($user->rights->propal->cloturer) $arrayofmassactions['closed']=$langs->trans("Close"); - if (in_array($massaction, array('presend','predelete','closed'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + if ($user->rights->propal->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); + if ($user->rights->propal->cloturer) $arrayofmassactions['closed'] = $langs->trans("Close"); + if (in_array($massaction, array('presend', 'predelete', 'closed'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); - $newcardbutton=''; + $newcardbutton = ''; if ($user->rights->propal->creer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewPropal'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/propal/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewPropal'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/propal/card.php?action=create'); } // Fields title search @@ -466,213 +466,213 @@ if ($resql) print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'commercial', 0, $newcardbutton, '', $limit); - $topicmail="SendPropalRef"; - $modelmail="proposal_send"; - $objecttmp=new Propal($db); - $trackid='pro'.$object->id; + $topicmail = "SendPropalRef"; + $modelmail = "proposal_send"; + $objecttmp = new Propal($db); + $trackid = 'pro'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } $i = 0; - $moreforfilter=''; + $moreforfilter = ''; // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); - $moreforfilter.='
'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; + $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $moreforfilter .= '
'; } // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; - $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); - $moreforfilter.='
'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; + $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); + $moreforfilter .= '
'; } // If the user can view products if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': '; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); - $moreforfilter.='
'; + $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter .= '
'; } - if (! empty($conf->categorie->enabled)) + if (!empty($conf->categorie->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('CustomersProspectsCategoriesShort').': '; - $moreforfilter.=$formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1); - $moreforfilter.='
'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': '; + $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1); + $moreforfilter .= '
'; } - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - if (! empty($moreforfilter)) + if (!empty($moreforfilter)) { print '
'; print $moreforfilter; print '
'; } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - $selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; - print ''."\n"; + print '
'."\n"; print ''; - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { print ''; } - if (! empty($arrayfields['p.ref_client']['checked'])) + if (!empty($arrayfields['p.ref_client']['checked'])) { print ''; } - if (! empty($arrayfields['pr.ref']['checked'])) + if (!empty($arrayfields['pr.ref']['checked'])) { print ''; } - if (! empty($arrayfields['pr.title']['checked'])) + if (!empty($arrayfields['pr.title']['checked'])) { print ''; } - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print ''; } - if (! empty($arrayfields['s.town']['checked'])) print ''; - if (! empty($arrayfields['s.zip']['checked'])) print ''; + if (!empty($arrayfields['s.town']['checked'])) print ''; + if (!empty($arrayfields['s.zip']['checked'])) print ''; // State - if (! empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print ''; } // Country - if (! empty($arrayfields['country.code_iso']['checked'])) + if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; } // Company type - if (! empty($arrayfields['typent.code']['checked'])) + if (!empty($arrayfields['typent.code']['checked'])) { print ''; } // Date - if (! empty($arrayfields['p.date']['checked'])) + if (!empty($arrayfields['p.date']['checked'])) { print ''; } // Date end - if (! empty($arrayfields['p.fin_validite']['checked'])) + if (!empty($arrayfields['p.fin_validite']['checked'])) { print ''; } // Date delivery - if (! empty($arrayfields['p.date_livraison']['checked'])) + if (!empty($arrayfields['p.date_livraison']['checked'])) { print ''; } // Availability - if (! empty($arrayfields['ava.rowid']['checked'])) + if (!empty($arrayfields['ava.rowid']['checked'])) { print ''; } - if (! empty($arrayfields['p.total_ht']['checked'])) + if (!empty($arrayfields['p.total_ht']['checked'])) { // Amount print ''; } - if (! empty($arrayfields['p.total_vat']['checked'])) + if (!empty($arrayfields['p.total_vat']['checked'])) { // Amount print ''; } - if (! empty($arrayfields['p.total_ttc']['checked'])) + if (!empty($arrayfields['p.total_ttc']['checked'])) { // Amount print ''; } - if (! empty($arrayfields['p.total_ht_invoiced']['checked'])) + if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) { // Amount invoiced print ''; } - if (! empty($arrayfields['p.total_invoiced']['checked'])) + if (!empty($arrayfields['p.total_invoiced']['checked'])) { // Amount invoiced print ''; } - if (! empty($arrayfields['u.login']['checked'])) + if (!empty($arrayfields['u.login']['checked'])) { // Author print ''; } - if (! empty($arrayfields['sale_representative']['checked'])) + if (!empty($arrayfields['sale_representative']['checked'])) { print ''; } @@ -680,29 +680,29 @@ if ($resql) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['p.datec']['checked'])) + if (!empty($arrayfields['p.datec']['checked'])) { print ''; } // Date modification - if (! empty($arrayfields['p.tms']['checked'])) + if (!empty($arrayfields['p.tms']['checked'])) { print ''; } // Date cloture - if (! empty($arrayfields['p.date_cloture']['checked'])) + if (!empty($arrayfields['p.date_cloture']['checked'])) { print ''; } // Status - if (! empty($arrayfields['p.fk_statut']['checked'])) + if (!empty($arrayfields['p.fk_statut']['checked'])) { print ''; @@ -719,65 +719,65 @@ if ($resql) // Fields title print ''; - if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['p.ref_client']['checked'])) print_liste_field_titre($arrayfields['p.ref_client']['label'], $_SERVER["PHP_SELF"], 'p.ref_client', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['pr.ref']['checked'])) print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], 'pr.ref', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['pr.title']['checked'])) print_liste_field_titre($arrayfields['pr.title']['label'], $_SERVER["PHP_SELF"], 'pr.title', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['p.date']['checked'])) print_liste_field_titre($arrayfields['p.date']['label'], $_SERVER["PHP_SELF"], 'p.datep', '', $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['p.fin_validite']['checked'])) print_liste_field_titre($arrayfields['p.fin_validite']['label'], $_SERVER["PHP_SELF"], 'dfv', '', $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['p.date_livraison']['checked'])) print_liste_field_titre($arrayfields['p.date_livraison']['label'], $_SERVER["PHP_SELF"], 'ddelivery', '', $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['ava.rowid']['checked'])) print_liste_field_titre($arrayfields['ava.rowid']['label'], $_SERVER["PHP_SELF"], 'availability', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['p.total_ht']['checked'])) print_liste_field_titre($arrayfields['p.total_ht']['label'], $_SERVER["PHP_SELF"], 'p.total_ht', '', $param, 'class="right"', $sortfield, $sortorder); - if (! empty($arrayfields['p.total_vat']['checked'])) print_liste_field_titre($arrayfields['p.total_vat']['label'], $_SERVER["PHP_SELF"], 'p.tva', '', $param, 'class="right"', $sortfield, $sortorder); - if (! empty($arrayfields['p.total_ttc']['checked'])) print_liste_field_titre($arrayfields['p.total_ttc']['label'], $_SERVER["PHP_SELF"], 'p.total', '', $param, 'class="right"', $sortfield, $sortorder); - if (! empty($arrayfields['p.total_ht_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.total_ht_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder); - if (! empty($arrayfields['p.total_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.total_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder); - if (! empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['sale_representative']['checked'])) print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder); + if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['p.ref_client']['checked'])) print_liste_field_titre($arrayfields['p.ref_client']['label'], $_SERVER["PHP_SELF"], 'p.ref_client', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['pr.ref']['checked'])) print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], 'pr.ref', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['pr.title']['checked'])) print_liste_field_titre($arrayfields['pr.title']['label'], $_SERVER["PHP_SELF"], 'pr.title', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['p.date']['checked'])) print_liste_field_titre($arrayfields['p.date']['label'], $_SERVER["PHP_SELF"], 'p.datep', '', $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['p.fin_validite']['checked'])) print_liste_field_titre($arrayfields['p.fin_validite']['label'], $_SERVER["PHP_SELF"], 'dfv', '', $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['p.date_livraison']['checked'])) print_liste_field_titre($arrayfields['p.date_livraison']['label'], $_SERVER["PHP_SELF"], 'ddelivery', '', $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['ava.rowid']['checked'])) print_liste_field_titre($arrayfields['ava.rowid']['label'], $_SERVER["PHP_SELF"], 'availability', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['p.total_ht']['checked'])) print_liste_field_titre($arrayfields['p.total_ht']['label'], $_SERVER["PHP_SELF"], 'p.total_ht', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['p.total_vat']['checked'])) print_liste_field_titre($arrayfields['p.total_vat']['label'], $_SERVER["PHP_SELF"], 'p.tva', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['p.total_ttc']['checked'])) print_liste_field_titre($arrayfields['p.total_ttc']['label'], $_SERVER["PHP_SELF"], 'p.total', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.total_ht_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['p.total_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.total_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['sale_representative']['checked'])) print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); - if (! empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); - if (! empty($arrayfields['p.date_cloture']['checked'])) print_liste_field_titre($arrayfields['p.date_cloture']['label'], $_SERVER["PHP_SELF"], "p.date_cloture", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); - if (! empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + if (!empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + if (!empty($arrayfields['p.date_cloture']['checked'])) print_liste_field_titre($arrayfields['p.date_cloture']['label'], $_SERVER["PHP_SELF"], "p.date_cloture", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + if (!empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print ''."\n"; $now = dol_now(); - $i=0; - $totalarray=array(); - $typenArray=null; + $i = 0; + $totalarray = array(); + $typenArray = null; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - $objectstatic->id=$obj->rowid; - $objectstatic->ref=$obj->ref; + $objectstatic->id = $obj->rowid; + $objectstatic->ref = $obj->ref; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=$obj->client; - $companystatic->code_client=$obj->code_client; - $companystatic->email=$obj->email; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = $obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->email = $obj->email; - $projectstatic->id=$obj->project_id; - $projectstatic->ref=$obj->project_ref; - $projectstatic->title=$obj->project_label; + $projectstatic->id = $obj->project_id; + $projectstatic->ref = $obj->project_ref; + $projectstatic->title = $obj->project_label; print ''; - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { print ''; // Warning - $warnornote=''; - if ($obj->fk_statut == 1 && $db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) $warnornote.=img_warning($langs->trans("Late")); - if (! empty($obj->note_private)) + $warnornote = ''; + if ($obj->fk_statut == 1 && $db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) $warnornote .= img_warning($langs->trans("Late")); + if (!empty($obj->note_private)) { - $warnornote.=($warnornote?' ':''); - $warnornote.= ''; - $warnornote.= ''.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').''; - $warnornote.= ''; + $warnornote .= ($warnornote ? ' ' : ''); + $warnornote .= ''; + $warnornote .= ''.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').''; + $warnornote .= ''; } if ($warnornote) { @@ -804,26 +804,26 @@ if ($resql) } // Other picto tool print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print ''; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT)); print ajax_combobox('search_type_thirdparty'); print ''; //print $langs->trans('Month').': '; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; //print ' '.$langs->trans('Year').': '; $formother->select_year($search_year, 'search_year', 1, 20, 5); print ''; //print $langs->trans('Month').': '; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; //print ' '.$langs->trans('Year').': '; $formother->select_year($search_yearfin, 'search_yearfin', 1, 20, 5); print ''; //print $langs->trans('Month').': '; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; //print ' '.$langs->trans('Year').': '; $formother->select_year($search_yeardelivery, 'search_yeardelivery', 1, 20, 5); print ''; print $form->selectAvailabilityDelay($search_availability, 'search_availability', '', 1); print ajax_combobox('search_availability'); print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; $formpropal->selectProposalStatus($viewstatut, 1, 0, 1, 'customer', 'search_statut'); @@ -710,7 +710,7 @@ if ($resql) } // Action column print ''; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; @@ -787,14 +787,14 @@ if ($resql) print $objectstatic->getNomUrl(1, '', '', 0, 1); print ''; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->propal->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->propal->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); print '
'; print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['p.ref_client']['checked'])) + if (!empty($arrayfields['p.ref_client']['checked'])) { // Customer ref print ''; print $obj->ref_client; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['pr.ref']['checked'])) + if (!empty($arrayfields['pr.ref']['checked'])) { // Project ref print ''; @@ -831,10 +831,10 @@ if ($resql) print $projectstatic->getNomUrl(1); } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['pr.title']['checked'])) + if (!empty($arrayfields['pr.title']['checked'])) { // Project label print ''; @@ -842,71 +842,71 @@ if ($resql) print $projectstatic->title; } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Thirdparty - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print ''; print $companystatic->getNomUrl(1, 'customer'); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Town - if (! empty($arrayfields['s.town']['checked'])) + if (!empty($arrayfields['s.town']['checked'])) { print ''; print $obj->town; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Zip - if (! empty($arrayfields['s.zip']['checked'])) + if (!empty($arrayfields['s.zip']['checked'])) { print ''; print $obj->zip; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // State - if (! empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print "".$obj->state_name."\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Country - if (! empty($arrayfields['country.code_iso']['checked'])) + if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; - $tmparray=getCountry($obj->fk_pays, 'all'); + $tmparray = getCountry($obj->fk_pays, 'all'); print $tmparray['label']; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Type ent - if (! empty($arrayfields['typent.code']['checked'])) + if (!empty($arrayfields['typent.code']['checked'])) { - if (! is_array($typenArray) || empty($typenArray)) $typenArray = $formcompany->typent_array(1); + if (!is_array($typenArray) || empty($typenArray)) $typenArray = $formcompany->typent_array(1); print ''; print $typenArray[$obj->typent_code]; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date proposal - if (! empty($arrayfields['p.date']['checked'])) + if (!empty($arrayfields['p.date']['checked'])) { print ''; print dol_print_date($db->jdate($obj->dp), 'day'); print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date end validity - if (! empty($arrayfields['p.fin_validite']['checked'])) + if (!empty($arrayfields['p.fin_validite']['checked'])) { if ($obj->dfv) { @@ -917,10 +917,10 @@ if ($resql) { print ' '; } - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date delivery - if (! empty($arrayfields['p.date_livraison']['checked'])) + if (!empty($arrayfields['p.date_livraison']['checked'])) { if ($obj->ddelivery) { @@ -1038,17 +1038,17 @@ if ($resql) } elseif ($nbofsalesrepresentative > 0) { - $userstatic=new User($db); - $j=0; - foreach($listsalesrepresentatives as $val) + $userstatic = new User($db); + $j = 0; + foreach ($listsalesrepresentatives as $val) { - $userstatic->id=$val['id']; - $userstatic->lastname=$val['lastname']; - $userstatic->firstname=$val['firstname']; - $userstatic->email=$val['email']; - $userstatic->statut=$val['statut']; - $userstatic->entity=$val['entity']; - $userstatic->photo=$val['photo']; + $userstatic->id = $val['id']; + $userstatic->lastname = $val['lastname']; + $userstatic->firstname = $val['firstname']; + $userstatic->email = $val['email']; + $userstatic->statut = $val['statut']; + $userstatic->entity = $val['entity']; + $userstatic->photo = $val['photo']; //print '
': print $userstatic->getNomUrl(-2); @@ -1064,55 +1064,55 @@ if ($resql) print ' '; } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['p.datec']['checked'])) + if (!empty($arrayfields['p.datec']['checked'])) { print ''; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date modification - if (! empty($arrayfields['p.tms']['checked'])) + if (!empty($arrayfields['p.tms']['checked'])) { print ''; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date cloture - if (! empty($arrayfields['p.date_cloture']['checked'])) + if (!empty($arrayfields['p.date_cloture']['checked'])) { print ''; print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser'); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Status - if (! empty($arrayfields['p.fk_statut']['checked'])) + if (!empty($arrayfields['p.fk_statut']['checked'])) { print ''.$objectstatic->LibStatut($obj->fk_statut, 5).''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Action column print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "\n"; @@ -1124,8 +1124,8 @@ if ($resql) $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 + $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 ''."\n"; @@ -1133,16 +1133,16 @@ if ($resql) print ''."\n"; - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->propal->lire; - $delallowed=$user->rights->propal->creer; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->propal->lire; + $delallowed = $user->rights->propal->creer; print $formfile->showdocuments('massfilesarea_proposals', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 0daf73db702..f949e118599 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -35,34 +35,34 @@ */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formorder.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formmargin.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/modules/commande/modules_commande.php'; -require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; -require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/order.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; -if (! empty($conf->propal->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formorder.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php'; +require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +if (!empty($conf->propal->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; } -if (! empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; - require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; +if (!empty($conf->projet->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } -require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; if (!empty($conf->variants->enabled)) { require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php'; } // Load translation files required by the page -$langs->loadLangs(array('orders','sendings','companies','bills','propal','deliveries','products','other')); +$langs->loadLangs(array('orders', 'sendings', 'companies', 'bills', 'propal', 'deliveries', 'products', 'other')); if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); -if (! empty($conf->margin->enabled)) $langs->load('margins'); -if (! empty($conf->productbatch->enabled)) $langs->load("productbatch"); +if (!empty($conf->margin->enabled)) $langs->load('margins'); +if (!empty($conf->productbatch->enabled)) $langs->load("productbatch"); $id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('orderid', 'int')); $ref = GETPOST('ref', 'alpha'); @@ -77,12 +77,12 @@ $origin = GETPOST('origin', 'alpha'); $originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility // PDF -$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); -$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); -$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); +$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); +$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); +$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); // Security check -if (! empty($user->socid)) +if (!empty($user->socid)) $socid = $user->socid; $result = restrictedArea($user, 'commande', $id); @@ -126,24 +126,24 @@ if (empty($reshook)) { if ($cancel) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } - $action=''; + $action = ''; } - include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once - include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once - include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes' && $usercancreate) { - if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) + if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } @@ -154,7 +154,7 @@ if (empty($reshook)) // Because createFromClone modifies the object, we must clone it so that we can restore it later $orig = clone $object; - $result=$object->createFromClone($user, $socid); + $result = $object->createFromClone($user, $socid); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); @@ -164,7 +164,7 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); $object = $orig; - $action=''; + $action = ''; } } } @@ -215,7 +215,7 @@ if (empty($reshook)) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -258,7 +258,7 @@ if (empty($reshook)) $error++; } - if (! $error) { + if (!$error) { $object->socid = $socid; $object->fetch_thirdparty(); @@ -286,14 +286,14 @@ if (empty($reshook)) $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); // Fill array 'array_options' with data from add form - if (! $error) + if (!$error) { $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; } // If creation from another object of another module (Example: origin=propal, originid=1) - if (! empty($origin) && ! empty($originid)) + if (!empty($origin) && !empty($originid)) { // Parse element/subelement (ex: project_task) $element = $subelement = $origin; @@ -320,22 +320,22 @@ if (empty($reshook)) // Possibility to add external linked objects with hooks $object->linked_objects [$object->origin] = $object->origin_id; $other_linked_objects = GETPOST('other_linked_objects', 'array'); - if (! empty($other_linked_objects)) { + if (!empty($other_linked_objects)) { $object->linked_objects = array_merge($object->linked_objects, $other_linked_objects); } - if (! $error) + if (!$error) { $object_id = $object->create($user); if ($object_id > 0) { - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); $srcobject = new $classname($db); - dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); + dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); $result = $srcobject->fetch($object->origin_id); if ($result > 0) { @@ -349,13 +349,13 @@ if (empty($reshook)) $fk_parent_line = 0; $num = count($lines); - for($i = 0; $i < $num; $i ++) + for ($i = 0; $i < $num; $i++) { - if(!in_array($lines[$i]->id, $selectedLines)) continue; // Skip unselected lines + if (!in_array($lines[$i]->id, $selectedLines)) continue; // Skip unselected lines - $label = (! empty($lines[$i]->label) ? $lines[$i]->label : ''); - $desc = (! empty($lines[$i]->desc) ? $lines[$i]->desc : ''); - $product_type = (! empty($lines[$i]->product_type) ? $lines[$i]->product_type : 0); + $label = (!empty($lines[$i]->label) ? $lines[$i]->label : ''); + $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc : ''); + $product_type = (!empty($lines[$i]->product_type) ? $lines[$i]->product_type : 0); // Dates // TODO mutualiser @@ -383,7 +383,7 @@ if (empty($reshook)) } $tva_tx = $lines[$i]->tva_tx; - if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; + if (!empty($lines[$i]->vat_src_code) && !preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; $result = $object->addline( $desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, @@ -449,17 +449,17 @@ if (empty($reshook)) $action = 'create'; } } else { - if (! $error) + if (!$error) { $object_id = $object->create($user); // If some invoice's lines already known $NBLINES = 8; - for($i = 1; $i <= $NBLINES; $i ++) { - if ($_POST['idprod' . $i]) { - $xid = 'idprod' . $i; - $xqty = 'qty' . $i; - $xremise = 'remise_percent' . $i; + for ($i = 1; $i <= $NBLINES; $i++) { + if ($_POST['idprod'.$i]) { + $xid = 'idprod'.$i; + $xqty = 'qty'.$i; + $xremise = 'remise_percent'.$i; $object->add_product($_POST[$xid], $_POST[$xqty], $_POST[$xremise]); } } @@ -483,10 +483,10 @@ if (empty($reshook)) } // End of object creation, we show it - if ($object_id > 0 && ! $error) + if ($object_id > 0 && !$error) { $db->commit(); - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object_id); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object_id); exit(); } else { $db->rollback(); @@ -498,7 +498,7 @@ if (empty($reshook)) elseif ($action == 'classifybilled' && $usercancreate) { - $ret=$object->classifyBilled($user); + $ret = $object->classifyBilled($user); if ($ret < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -506,7 +506,7 @@ if (empty($reshook)) } elseif ($action == 'classifyunbilled' && $usercancreate) { - $ret=$object->classifyUnBilled(); + $ret = $object->classifyUnBilled(); if ($ret < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -598,7 +598,7 @@ if (empty($reshook)) $newlang = GETPOST('lang_id', 'alpha'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -620,7 +620,7 @@ if (empty($reshook)) // bank account elseif ($action == 'setbankaccount' && $usercancreate) { - $result=$object->setBankAccount(GETPOST('fk_account', 'int')); + $result = $object->setBankAccount(GETPOST('fk_account', 'int')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -657,23 +657,23 @@ if (empty($reshook)) $error = 0; // Set if we used free entry or predefined product - $predef=''; - $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); + $predef = ''; + $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); $price_ht = GETPOST('price_ht'); $price_ht_devise = GETPOST('multicurrency_price_ht'); $prod_entry_mode = GETPOST('prod_entry_mode'); if ($prod_entry_mode == 'free') { - $idprod=0; + $idprod = 0; $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); } else { - $idprod=GETPOST('idprod', 'int'); + $idprod = GETPOST('idprod', 'int'); $tva_tx = ''; } - $qty = GETPOST('qty' . $predef); + $qty = GETPOST('qty'.$predef); $remise_percent = (GETPOST('remise_percent'.$predef) != '' ? GETPOST('remise_percent'.$predef) : 0); // Extrafields @@ -683,7 +683,7 @@ if (empty($reshook)) if (is_array($extralabelsline)) { // Get extra fields foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); + unset($_POST["options_".$key]); } } @@ -720,22 +720,22 @@ if (empty($reshook)) else { setEventMessages($langs->trans('ErrorProductCombinationNotFound'), null, 'errors'); - $error ++; + $error++; } } } - if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { + if (!$error && ($qty >= 0) && (!empty($product_desc) || !empty($idprod))) { // Clean parameters - $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); - $date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); - $price_base_type = (GETPOST('price_base_type', 'alpha')?GETPOST('price_base_type', 'alpha'):'HT'); + $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); + $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); + $price_base_type = (GETPOST('price_base_type', 'alpha') ?GETPOST('price_base_type', 'alpha') : 'HT'); // Ecrase $pu par celui du produit // Ecrase $desc par celui du produit // Ecrase $tva_tx par celui du produit // Ecrase $base_price_type par celui du produit - if (! empty($idprod)) { + if (!empty($idprod)) { $prod = new Product($db); $prod->fetch($idprod); @@ -744,7 +744,7 @@ if (empty($reshook)) // Update if prices fields are defined $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); - if (empty($tva_tx)) $tva_npr=0; + if (empty($tva_tx)) $tva_npr = 0; $pu_ht = $prod->price; $pu_ttc = $prod->price_ttc; @@ -752,26 +752,26 @@ if (empty($reshook)) $price_base_type = $prod->price_base_type; // If price per segment - if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level)) + if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) { $pu_ht = $prod->multiprices[$object->thirdparty->price_level]; $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level]; $price_min = $prod->multiprices_min[$object->thirdparty->price_level]; $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; - if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility + if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility { - if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level]; - if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level]; + if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level]; + if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level]; } } // If price per customer - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { - require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; $prodcustprice = new Productcustomerprice($db); - $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id); + $filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $object->thirdparty->id); $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); if ($result >= 0) @@ -782,9 +782,9 @@ if (empty($reshook)) $pu_ttc = price($prodcustprice->lines[0]->price_ttc); $price_base_type = $prodcustprice->lines[0]->price_base_type; $tva_tx = $prodcustprice->lines[0]->tva_tx; - if ($prodcustprice->lines[0]->default_vat_code && ! preg_match('/\(.*\)/', $tva_tx)) $tva_tx.= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; $tva_npr = $prodcustprice->lines[0]->recuperableonly; - if (empty($tva_tx)) $tva_npr=0; + if (empty($tva_tx)) $tva_npr = 0; } } else @@ -793,7 +793,7 @@ if (empty($reshook)) } } // If price per quantity - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) { if ($prod->prices_by_qty[0]) // yes, this product has some prices per quantity { @@ -801,7 +801,7 @@ if (empty($reshook)) $pqp = GETPOST('pbq', 'int'); // Search price into product_price_by_qty from $prod->id - foreach($prod->prices_by_qty_list[0] as $priceforthequantityarray) + foreach ($prod->prices_by_qty_list[0] as $priceforthequantityarray) { if ($priceforthequantityarray['rowid'] != $pqp) continue; // We found the price @@ -819,14 +819,14 @@ if (empty($reshook)) } } // If price per quantity and customer - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { if ($prod->prices_by_qty[$object->thirdparty->price_level]) // yes, this product has some prices per quantity { // Search the correct price into loaded array product_price_by_qty using id of array retrieved into POST['pqp']. $pqp = GETPOST('pbq', 'int'); // Search price into product_price_by_qty from $prod->id - foreach($prod->prices_by_qty_list[$object->thirdparty->price_level] as $priceforthequantityarray) + foreach ($prod->prices_by_qty_list[$object->thirdparty->price_level] as $priceforthequantityarray) { if ($priceforthequantityarray['rowid'] != $pqp) continue; // We found the price @@ -848,7 +848,7 @@ if (empty($reshook)) $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); // if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ? - if (! empty($price_ht)) { + if (!empty($price_ht)) { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); } @@ -865,55 +865,55 @@ if (empty($reshook)) $desc = ''; // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; $newlang = ''; if (empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if (empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; + $desc = (!empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description; } else { $desc = $prod->description; } - if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) $desc= $product_desc; + if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) $desc = $product_desc; else $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); // Add custom code and origin country into description - if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) { + if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (!empty($prod->customcode) || !empty($prod->country_code))) { $tmptxt = '('; // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; $newlang = ''; if (empty($newlang) && GETPOST('lang_id', 'alpha')) $newlang = GETPOST('lang_id', 'alpha'); if (empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); $outputlangs->load('products'); } - if (! empty($prod->customcode)) - $tmptxt .= $outputlangs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; - if (! empty($prod->customcode) && ! empty($prod->country_code)) + if (!empty($prod->customcode)) + $tmptxt .= $outputlangs->transnoentitiesnoconv("CustomCode").': '.$prod->customcode; + if (!empty($prod->customcode) && !empty($prod->country_code)) $tmptxt .= ' - '; - if (! empty($prod->country_code)) - $tmptxt .= $outputlangs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $outputlangs, 0); + if (!empty($prod->country_code)) + $tmptxt .= $outputlangs->transnoentitiesnoconv("CountryOrigin").': '.getCountry($prod->country_code, 0, $db, $outputlangs, 0); } else { - if (! empty($prod->customcode)) - $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; - if (! empty($prod->customcode) && ! empty($prod->country_code)) + if (!empty($prod->customcode)) + $tmptxt .= $langs->transnoentitiesnoconv("CustomCode").': '.$prod->customcode; + if (!empty($prod->customcode) && !empty($prod->country_code)) $tmptxt .= ' - '; - if (! empty($prod->country_code)) - $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); + if (!empty($prod->country_code)) + $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin").': '.getCountry($prod->country_code, 0, $db, $langs, 0); } $tmptxt .= ')'; $desc = dol_concatdesc($desc, $tmptxt); @@ -929,13 +929,13 @@ if (empty($reshook)) $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); $desc = $product_desc; $type = GETPOST('type'); - $fk_unit=GETPOST('units', 'alpha'); + $fk_unit = GETPOST('units', 'alpha'); $pu_ht_devise = price2num($price_ht_devise, 'MU'); } // Margin - $fournprice = price2num(GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : ''); - $buyingprice = price2num(GETPOST('buying_price' . $predef) != '' ? GETPOST('buying_price' . $predef) : ''); // If buying_price is '0', we muste keep this value + $fournprice = price2num(GETPOST('fournprice'.$predef) ? GETPOST('fournprice'.$predef) : ''); + $buyingprice = price2num(GETPOST('buying_price'.$predef) != '' ? GETPOST('buying_price'.$predef) : ''); // If buying_price is '0', we muste keep this value // Local Taxes $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty); @@ -947,7 +947,7 @@ if (empty($reshook)) if ($tva_npr) $info_bits |= 0x01; - if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) { + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && (!empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); setEventMessages($mesg, null, 'errors'); } else { @@ -961,9 +961,9 @@ if (empty($reshook)) // Define output language $outputlangs = $langs; $newlang = GETPOST('lang_id', 'alpha'); - if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) + if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -1016,13 +1016,13 @@ if (empty($reshook)) elseif ($action == 'updateline' && $usercancreate && GETPOST('save')) { // Clean parameters - $date_start=''; - $date_end=''; - $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); - $date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); - $description=dol_htmlcleanlastbr(GETPOST('product_desc', 'none')); - $pu_ht=GETPOST('price_ht'); - $vat_rate=(GETPOST('tva_tx')?GETPOST('tva_tx'):0); + $date_start = ''; + $date_end = ''; + $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); + $date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); + $description = dol_htmlcleanlastbr(GETPOST('product_desc', 'none')); + $pu_ht = GETPOST('price_ht'); + $vat_rate = (GETPOST('tva_tx') ?GETPOST('tva_tx') : 0); $pu_ht_devise = GETPOST('multicurrency_subprice'); // Define info_bits @@ -1037,7 +1037,7 @@ if (empty($reshook)) // Add buying price $fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : ''); - $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value + $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value // Extrafields Lines $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -1045,29 +1045,29 @@ if (empty($reshook)) // Unset extrafield POST Data if (is_array($extralabelsline)) { foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); + unset($_POST["options_".$key]); } } // Define special_code for special lines - $special_code=GETPOST('special_code'); - if (! GETPOST('qty')) $special_code=3; + $special_code = GETPOST('special_code'); + if (!GETPOST('qty')) $special_code = 3; // Check minimum price $productid = GETPOST('productid', 'int'); - if (! empty($productid)) { + if (!empty($productid)) { $product = new Product($db); $product->fetch($productid); $type = $product->type; $price_min = $product->price_min; - if ((! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && ! empty($object->thirdparty->price_level)) + if ((!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !empty($object->thirdparty->price_level)) $price_min = $product->multiprices_min[$object->thirdparty->price_level]; $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); - if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)))) { + if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)))) { setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors'); $error++; } @@ -1082,7 +1082,7 @@ if (empty($reshook)) } } - if (! $error) { + if (!$error) { if (empty($user->rights->margins->creer)) { foreach ($object->lines as &$line) @@ -1106,7 +1106,7 @@ if (empty($reshook)) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -1146,7 +1146,7 @@ if (empty($reshook)) } } } elseif ($action == 'updateline' && $usercancreate && GETPOST('cancel', 'alpha') == $langs->trans('Cancel')) { - header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition + header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // Pour reaffichage de la fiche en cours d'edition exit(); } @@ -1154,28 +1154,28 @@ if (empty($reshook)) { $idwarehouse = GETPOST('idwarehouse'); - $qualified_for_stock_change=0; + $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $qualified_for_stock_change=$object->hasProductsOrServices(2); + $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { - $qualified_for_stock_change=$object->hasProductsOrServices(1); + $qualified_for_stock_change = $object->hasProductsOrServices(1); } // Check parameters - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) { - if (! $idwarehouse || $idwarehouse == -1) + if (!$idwarehouse || $idwarehouse == -1) { $error++; setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); - $action=''; + $action = ''; } } - if (! $error) { + if (!$error) { $result = $object->valid($user, $idwarehouse); if ($result >= 0) { @@ -1186,11 +1186,11 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -1207,28 +1207,28 @@ if (empty($reshook)) elseif ($action == 'confirm_modif' && $usercancreate) { $idwarehouse = GETPOST('idwarehouse'); - $qualified_for_stock_change=0; + $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $qualified_for_stock_change=$object->hasProductsOrServices(2); + $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { - $qualified_for_stock_change=$object->hasProductsOrServices(1); + $qualified_for_stock_change = $object->hasProductsOrServices(1); } // Check parameters - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) { - if (! $idwarehouse || $idwarehouse == -1) + if (!$idwarehouse || $idwarehouse == -1) { $error++; setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); - $action=''; + $action = ''; } } - if (! $error) { + if (!$error) { $result = $object->setDraft($user, $idwarehouse); if ($result >= 0) { @@ -1239,11 +1239,11 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -1263,28 +1263,28 @@ if (empty($reshook)) { $idwarehouse = GETPOST('idwarehouse'); - $qualified_for_stock_change=0; + $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $qualified_for_stock_change=$object->hasProductsOrServices(2); + $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { - $qualified_for_stock_change=$object->hasProductsOrServices(1); + $qualified_for_stock_change = $object->hasProductsOrServices(1); } // Check parameters - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) { - if (! $idwarehouse || $idwarehouse == -1) + if (!$idwarehouse || $idwarehouse == -1) { $error++; setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); - $action=''; + $action = ''; } } - if (! $error) { + if (!$error) { $result = $object->cancel($idwarehouse); if ($result < 0) { @@ -1301,7 +1301,7 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; - if (! $error) + if (!$error) { // Actions on extra fields $result = $object->insertExtraFields('ORDER_MODIFY'); @@ -1320,12 +1320,12 @@ if (empty($reshook)) $object->fetch($id); $object->setValueFrom('fk_soc', $socid, '', '', 'date', '', $user, 'ORDER_MODIFY'); - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); exit(); } // add lines from objectlinked - if($action == 'import_lines_from_object' + if ($action == 'import_lines_from_object' && $usercancreate && $object->statut == Commande::STATUS_DRAFT ) @@ -1334,14 +1334,14 @@ if (empty($reshook)) $fromElementid = GETPOST('fromelementid'); $importLines = GETPOST('line_checkbox'); - if(!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) + if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) { - if($fromElement == 'commande') + if ($fromElement == 'commande') { dol_include_once('/'.$fromElement.'/class/'.$fromElement.'.class.php'); $lineClassName = 'OrderLine'; } - elseif($fromElement == 'propal') + elseif ($fromElement == 'propal') { dol_include_once('/comm/'.$fromElement.'/class/'.$fromElement.'.class.php'); $lineClassName = 'PropaleLigne'; @@ -1349,11 +1349,11 @@ if (empty($reshook)) $nextRang = count($object->lines) + 1; $importCount = 0; $error = 0; - foreach($importLines as $lineId) + foreach ($importLines as $lineId) { $lineId = intval($lineId); $originLine = new $lineClassName($db); - if(intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) + if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) { $originLine->fetch_optionals($lineId); $desc = $originLine->desc; @@ -1369,15 +1369,15 @@ if (empty($reshook)) $ventil = 0; $info_bits = $originLine->info_bits; $fk_remise_except = $originLine->fk_remise_except; - $price_base_type='HT'; - $pu_ttc=0; + $price_base_type = 'HT'; + $pu_ttc = 0; $type = $originLine->product_type; - $rang=$nextRang++; + $rang = $nextRang++; $special_code = $originLine->special_code; $origin = $originLine->element; $origin_id = $originLine->id; - $fk_parent_line=0; - $fk_fournprice=$originLine->fk_fournprice; + $fk_parent_line = 0; + $fk_fournprice = $originLine->fk_fournprice; $pa_ht = $originLine->pa_ht; $label = $originLine->label; $array_options = $originLine->array_options; @@ -1388,18 +1388,18 @@ if (empty($reshook)) $res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $info_bits, $fk_remise_except, $price_base_type, $pu_ttc, $date_start, $date_end, $type, $rang, $special_code, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $array_options, $fk_unit, $origin, $origin_id, $pu_ht_devise); - if($res > 0){ + if ($res > 0) { $importCount++; - }else{ + } else { $error++; } } - else{ + else { $error++; } } - if($error) + if ($error) { setEventMessages($langs->trans('ErrorsOnXLines', $error), null, 'errors'); } @@ -1415,14 +1415,14 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; // Actions to send emails - $trigger_name='ORDER_SENTBYMAIL'; - $paramname='id'; - $autocopy='MAIN_MAIL_AUTOCOPY_ORDER_TO'; // used to know the automatic BCC to add - $trackid='ord'.$object->id; + $trigger_name = 'ORDER_SENTBYMAIL'; + $paramname = 'id'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_ORDER_TO'; // used to know the automatic BCC to add + $trackid = 'ord'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; - if (! $error && ! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate) + if (!$error && !empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate) { if ($action == 'addcontact') { @@ -1432,7 +1432,7 @@ if (empty($reshook)) } if ($result >= 0) { - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit(); } else { if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { @@ -1460,7 +1460,7 @@ if (empty($reshook)) $result = $object->delete_contact($lineid); if ($result >= 0) { - header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit(); } else { dol_print_error($db); @@ -1480,7 +1480,7 @@ $form = new Form($db); $formfile = new FormFile($db); $formorder = new FormOrder($db); $formmargin = new FormMargin($db); -if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } // Mode creation if ($action == 'create' && $usercancreate) @@ -1495,7 +1495,7 @@ if ($action == 'create' && $usercancreate) $currency_code = $conf->currency; - if (! empty($origin) && ! empty($originid)) { + if (!empty($origin) && !empty($originid)) { // Parse element/subelement (ex: project_task) $element = $subelement = $origin; if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) { @@ -1517,7 +1517,7 @@ if ($action == 'create' && $usercancreate) } if (!$dateorder) { // Do not set 0 here (0 for a date is 1970) - $dateorder = (empty($dateinvoice)?(empty($conf->global->MAIN_AUTOFILL_DATE_ODER)?-1:''):$dateorder); + $dateorder = (empty($dateinvoice) ? (empty($conf->global->MAIN_AUTOFILL_DATE_ODER) ?-1 : '') : $dateorder); } } else { // For compatibility @@ -1532,7 +1532,7 @@ if ($action == 'create' && $usercancreate) $element = $subelement = 'contrat'; } - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); $objectsrc = new $classname($db); @@ -1545,22 +1545,22 @@ if ($action == 'create' && $usercancreate) $objectsrc->fetch_optionals($originid); $object->array_options = $objectsrc->array_options; - $projectid = (! empty($objectsrc->fk_project) ? $objectsrc->fk_project : ''); - $ref_client = (! empty($objectsrc->ref_client) ? $objectsrc->ref_client : ''); + $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project : ''); + $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client : ''); $soc = $objectsrc->thirdparty; - $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:0)); // TODO maybe add default value option - $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); - $fk_account = (! empty($objectsrc->fk_account)?$objectsrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0)); - $availability_id = (!empty($objectsrc->availability_id)?$objectsrc->availability_id:(!empty($soc->availability_id)?$soc->availability_id:0)); - $shipping_method_id = (! empty($objectsrc->shipping_method_id)?$objectsrc->shipping_method_id:(! empty($soc->shipping_method_id)?$soc->shipping_method_id:0)); - $warehouse_id = (! empty($objectsrc->warehouse_id)?$objectsrc->warehouse_id:(! empty($soc->warehouse_id)?$soc->warehouse_id:0)); - $demand_reason_id = (!empty($objectsrc->demand_reason_id)?$objectsrc->demand_reason_id:(!empty($soc->demand_reason_id)?$soc->demand_reason_id:0)); - $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0)); - $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); - $dateorder = empty($conf->global->MAIN_AUTOFILL_DATE_ORDER)?-1:''; + $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0)); // TODO maybe add default value option + $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0)); + $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0)); + $availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : (!empty($soc->availability_id) ? $soc->availability_id : 0)); + $shipping_method_id = (!empty($objectsrc->shipping_method_id) ? $objectsrc->shipping_method_id : (!empty($soc->shipping_method_id) ? $soc->shipping_method_id : 0)); + $warehouse_id = (!empty($objectsrc->warehouse_id) ? $objectsrc->warehouse_id : (!empty($soc->warehouse_id) ? $soc->warehouse_id : 0)); + $demand_reason_id = (!empty($objectsrc->demand_reason_id) ? $objectsrc->demand_reason_id : (!empty($soc->demand_reason_id) ? $soc->demand_reason_id : 0)); + $remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_percent) ? $soc->remise_percent : 0)); + $remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); + $dateorder = empty($conf->global->MAIN_AUTOFILL_DATE_ORDER) ?-1 : ''; - $datedelivery = (! empty($objectsrc->date_livraison) ? $objectsrc->date_livraison : ''); + $datedelivery = (!empty($objectsrc->date_livraison) ? $objectsrc->date_livraison : ''); if (!empty($conf->multicurrency->enabled)) { @@ -1568,11 +1568,11 @@ if ($action == 'create' && $usercancreate) if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx; } - $note_private = $object->getDefaultCreateValueFor('note_private', (! empty($objectsrc->note_private) ? $objectsrc->note_private : null)); - $note_public = $object->getDefaultCreateValueFor('note_public', (! empty($objectsrc->note_public) ? $objectsrc->note_public : null)); + $note_private = $object->getDefaultCreateValueFor('note_private', (!empty($objectsrc->note_private) ? $objectsrc->note_private : null)); + $note_public = $object->getDefaultCreateValueFor('note_public', (!empty($objectsrc->note_public) ? $objectsrc->note_public : null)); // Object source contacts list - $srccontactslist = $objectsrc->liste_contact(- 1, 'external', 1); + $srccontactslist = $objectsrc->liste_contact(-1, 'external', 1); } } else @@ -1586,7 +1586,7 @@ if ($action == 'create' && $usercancreate) $demand_reason_id = $soc->demand_reason_id; $remise_percent = $soc->remise_percent; $remise_absolue = 0; - $dateorder = empty($conf->global->MAIN_AUTOFILL_DATE_ORDER)?-1:''; + $dateorder = empty($conf->global->MAIN_AUTOFILL_DATE_ORDER) ?-1 : ''; if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code; @@ -1620,11 +1620,11 @@ if ($action == 'create' && $usercancreate) // Thirdparty print ''; - print '' . $langs->trans('Customer') . ''; + print ''.$langs->trans('Customer').''; if ($socid > 0) { print ''; print $soc->getNomUrl(1); - print ''; + print ''; print ''; } else { print ''; @@ -1645,96 +1645,96 @@ if ($action == 'create' && $usercancreate) print ' '.$langs->trans("AddThirdParty").''; print ''; } - print '' . "\n"; + print ''."\n"; // Contact of order if ($socid > 0) { // Contacts (ask contact only if thirdparty already defined). - print "" . $langs->trans("DefaultContact") . ''; + print "".$langs->trans("DefaultContact").''; $form->select_contacts($soc->id, $contactid, 'contactid', 1, $srccontactslist, '', 1); print ''; // Ligne info remises tiers - print '' . $langs->trans('Discounts') . ''; + print ''.$langs->trans('Discounts').''; $absolute_discount = $soc->getAvailableDiscounts(); $thirdparty = $soc; $discount_type = 0; - $backtopage = urlencode($_SERVER["PHP_SELF"] . '?socid=' . $thirdparty->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')); + $backtopage = urlencode($_SERVER["PHP_SELF"].'?socid='.$thirdparty->id.'&action='.$action.'&origin='.GETPOST('origin').'&originid='.GETPOST('originid')); include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; print ''; } // Date - print '' . $langs->trans('Date') . ''; - print $form->selectDate('', 're', '', '', '', "crea_commande", 1, 1); // Always autofill date with current date + print ''.$langs->trans('Date').''; + print $form->selectDate('', 're', '', '', '', "crea_commande", 1, 1); // Always autofill date with current date print ''; // Delivery date planed print "".$langs->trans("DateDeliveryPlanned").''; if (empty($datedelivery)) { - if (! empty($conf->global->DATE_LIVRAISON_WEEK_DELAY)) $datedelivery = time() + ((7*$conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); - else $datedelivery=empty($conf->global->MAIN_AUTOFILL_DATE_DELIVERY)?-1:''; + if (!empty($conf->global->DATE_LIVRAISON_WEEK_DELAY)) $datedelivery = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); + else $datedelivery = empty($conf->global->MAIN_AUTOFILL_DATE_DELIVERY) ?-1 : ''; } print $form->selectDate($datedelivery, 'liv_', '', '', '', "crea_commande", 1, 1); print ""; // terms of the settlement - print '' . $langs->trans('PaymentConditionsShort') . ''; + print ''.$langs->trans('PaymentConditionsShort').''; $form->select_conditions_paiements($cond_reglement_id, 'cond_reglement_id', - 1, 1); print ''; // Mode de reglement - print '' . $langs->trans('PaymentMode') . ''; + print ''.$langs->trans('PaymentMode').''; $form->select_types_paiements($mode_reglement_id, 'mode_reglement_id'); print ''; // Bank Account - if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && ! empty($conf->banque->enabled)) + if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && !empty($conf->banque->enabled)) { - print '' . $langs->trans('BankAccount') . ''; + print ''.$langs->trans('BankAccount').''; $form->select_comptes($fk_account, 'fk_account', 0, '', 1); print ''; } // Delivery delay - print '' . $langs->trans('AvailabilityPeriod') . ''; + print ''.$langs->trans('AvailabilityPeriod').''; $form->selectAvailabilityDelay($availability_id, 'availability_id', '', 1); print ''; // Shipping Method - if (! empty($conf->expedition->enabled)) { - print '' . $langs->trans('SendingMethod') . ''; + if (!empty($conf->expedition->enabled)) { + print ''.$langs->trans('SendingMethod').''; print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1); print ''; } // Warehouse - if (! empty($conf->expedition->enabled) && ! empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { + if (!empty($conf->expedition->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; - $formproduct=new FormProduct($db); - print '' . $langs->trans('Warehouse') . ''; + $formproduct = new FormProduct($db); + print ''.$langs->trans('Warehouse').''; print $formproduct->selectWarehouses($warehouse_id, 'warehouse_id', '', 1); print ''; } // What trigger creation - print '' . $langs->trans('Channel') . ''; + print ''.$langs->trans('Channel').''; $form->selectInputReason($demand_reason_id, 'demand_reason_id', '', 1); print ''; // TODO How record was recorded OrderMode (llx_c_input_method) // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); print ''; - print '' . $langs->trans("Project") . ''; + print ''.$langs->trans("Project").''; $numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0); - print '   id).'">' . $langs->trans("AddProject") . ''; + print '   id).'">'.$langs->trans("AddProject").''; print ''; print ''; } @@ -1762,7 +1762,7 @@ if ($action == 'create' && $usercancreate) $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); print $hookmanager->resPrint; if (empty($reshook)) { - if (! empty($conf->global->THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_ORDER)) { + if (!empty($conf->global->THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_ORDER)) { // copy from thirdparty $tpExtrafields = new Extrafields($db); $tpExtrafieldLabels = $tpExtrafields->fetch_name_optionals_label($soc->table_element); @@ -1775,15 +1775,15 @@ if ($action == 'create' && $usercancreate) } // Template to use by default - print '' . $langs->trans('DefaultModel') . ''; + print ''.$langs->trans('DefaultModel').''; print ''; - include_once DOL_DOCUMENT_ROOT . '/core/modules/commande/modules_commande.php'; + include_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php'; $liste = ModelePDFCommandes::liste_modeles($db); print $form->selectarray('model', $liste, $conf->global->COMMANDE_ADDON_PDF); print ""; // Multicurrency - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; print ''.$form->editfieldkey("Currency", 'multicurrency_code', '', $object, 0).''; @@ -1794,7 +1794,7 @@ if ($action == 'create' && $usercancreate) // Note public print ''; - print '' . $langs->trans('NotePublic') . ''; + print ''.$langs->trans('NotePublic').''; print ''; $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); @@ -1805,7 +1805,7 @@ if ($action == 'create' && $usercancreate) // Note private if (empty($user->socid)) { print ''; - print '' . $langs->trans('NotePrivate') . ''; + print ''.$langs->trans('NotePrivate').''; print ''; $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); @@ -1814,7 +1814,7 @@ if ($action == 'create' && $usercancreate) print ''; } - if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) + if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { // TODO for compatibility if ($origin == 'contrat') { @@ -1824,13 +1824,13 @@ if ($action == 'create' && $usercancreate) $objectsrc->update_price(1); } - print "\n"; + print "\n"; print "\n"; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - print ''; - print ''; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''; + print ''; switch ($classname) { case 'Propal': @@ -1849,28 +1849,28 @@ if ($action == 'create' && $usercancreate) $newclassname = $classname; } - print '' . $langs->trans($newclassname) . '' . $objectsrc->getNomUrl(1) . ''; + print ''.$langs->trans($newclassname).''.$objectsrc->getNomUrl(1).''; // Amount - print '' . $langs->trans('AmountHT') . '' . price($objectsrc->total_ht) . ''; - print '' . $langs->trans('AmountVAT') . '' . price($objectsrc->total_tva) . ""; + print ''.$langs->trans('AmountHT').''.price($objectsrc->total_ht).''; + print ''.$langs->trans('AmountVAT').''.price($objectsrc->total_tva).""; if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE { - print '' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($objectsrc->total_localtax1) . ""; + print ''.$langs->transcountry("AmountLT1", $mysoc->country_code).''.price($objectsrc->total_localtax1).""; } if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 IRPF { - print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($objectsrc->total_localtax2) . ""; + print ''.$langs->transcountry("AmountLT2", $mysoc->country_code).''.price($objectsrc->total_localtax2).""; } - print '' . $langs->trans('AmountTTC') . '' . price($objectsrc->total_ttc) . ""; + print ''.$langs->trans('AmountTTC').''.price($objectsrc->total_ttc).""; if (!empty($conf->multicurrency->enabled)) { - print '' . $langs->trans('MulticurrencyAmountHT') . '' . price($objectsrc->multicurrency_total_ht) . ''; - print '' . $langs->trans('MulticurrencyAmountVAT') . '' . price($objectsrc->multicurrency_total_tva) . ""; - print '' . $langs->trans('MulticurrencyAmountTTC') . '' . price($objectsrc->multicurrency_total_ttc) . ""; + print ''.$langs->trans('MulticurrencyAmountHT').''.price($objectsrc->multicurrency_total_ht).''; + print ''.$langs->trans('MulticurrencyAmountVAT').''.price($objectsrc->multicurrency_total_tva).""; + print ''.$langs->trans('MulticurrencyAmountTTC').''.price($objectsrc->multicurrency_total_ttc).""; } } @@ -1880,13 +1880,13 @@ if ($action == 'create' && $usercancreate) // Button "Create Draft" print '
'; - print ''; + print ''; print '     '; - print ''; + print ''; print '
'; // Show origin lines - if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) { + if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { $title = $langs->trans('ProductsAndServices'); print load_fiche_titre($title); @@ -1920,7 +1920,7 @@ if ($action == 'create' && $usercancreate) // Confirmation to delete if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); } // Confirmation of validation @@ -1935,81 +1935,81 @@ if ($action == 'create' && $usercancreate) } $text = $langs->trans('ConfirmValidateOrder', $numref); - if (! empty($conf->notification->enabled)) + if (!empty($conf->notification->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; $notify = new Notify($db); $text .= '
'; $text .= $notify->confirmMessage('ORDER_VALIDATE', $object->socid, $object); } - $qualified_for_stock_change=0; + $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $qualified_for_stock_change=$object->hasProductsOrServices(2); + $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { - $qualified_for_stock_change=$object->hasProductsOrServices(1); + $qualified_for_stock_change = $object->hasProductsOrServices(1); } - $formquestion=array(); - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) + $formquestion = array(); + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) { $langs->load("stocks"); - require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); - $forcecombo=0; - if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + $forcecombo = 0; + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy $formquestion = array( // 'text' => $langs->trans("ConfirmClone"), // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - array('type' => 'other','name' => 'idwarehouse','label' => $langs->trans("SelectWarehouseForStockDecrease"),'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse', 'int')?GETPOST('idwarehouse', 'int'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) + array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse', 'int') ?GETPOST('idwarehouse', 'int') : 'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) ); } - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', $formquestion, 0, 1, 220); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', $formquestion, 0, 1, 220); } // Confirm back to draft status if ($action == 'modif') { - $qualified_for_stock_change=0; + $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $qualified_for_stock_change=$object->hasProductsOrServices(2); + $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { - $qualified_for_stock_change=$object->hasProductsOrServices(1); + $qualified_for_stock_change = $object->hasProductsOrServices(1); } - $text=$langs->trans('ConfirmUnvalidateOrder', $object->ref); - $formquestion=array(); - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) + $text = $langs->trans('ConfirmUnvalidateOrder', $object->ref); + $formquestion = array(); + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) { $langs->load("stocks"); - require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); - $forcecombo=0; - if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + $forcecombo = 0; + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy $formquestion = array( // 'text' => $langs->trans("ConfirmClone"), // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - array('type' => 'other','name' => 'idwarehouse','label' => $langs->trans("SelectWarehouseForStockIncrease"),'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) + array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockIncrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse') ?GETPOST('idwarehouse') : 'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) ); } - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('UnvalidateOrder'), $text, 'confirm_modif', $formquestion, "yes", 1, 220); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('UnvalidateOrder'), $text, 'confirm_modif', $formquestion, "yes", 1, 220); } /* * Confirmation de la cloture */ if ($action == 'shipped') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloseOrder'), $langs->trans('ConfirmCloseOrder'), 'confirm_shipped', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('CloseOrder'), $langs->trans('ConfirmCloseOrder'), 'confirm_shipped', '', 0, 1); } /* @@ -2017,57 +2017,57 @@ if ($action == 'create' && $usercancreate) */ if ($action == 'cancel') { - $qualified_for_stock_change=0; + $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $qualified_for_stock_change=$object->hasProductsOrServices(2); + $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { - $qualified_for_stock_change=$object->hasProductsOrServices(1); + $qualified_for_stock_change = $object->hasProductsOrServices(1); } - $text=$langs->trans('ConfirmCancelOrder', $object->ref); - $formquestion=array(); - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) + $text = $langs->trans('ConfirmCancelOrder', $object->ref); + $formquestion = array(); + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $qualified_for_stock_change) { $langs->load("stocks"); - require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); - $forcecombo=0; - if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + $forcecombo = 0; + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy $formquestion = array( // 'text' => $langs->trans("ConfirmClone"), // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - array('type' => 'other','name' => 'idwarehouse','label' => $langs->trans("SelectWarehouseForStockIncrease"),'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) + array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockIncrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse') ?GETPOST('idwarehouse') : 'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) ); } - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('Cancel'), $text, 'confirm_cancel', $formquestion, 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Cancel'), $text, 'confirm_cancel', $formquestion, 0, 1); } // Confirmation to delete line if ($action == 'ask_deleteline') { - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); } // Clone confirmation if ($action == 'clone') { // Create an array for form $formquestion = array( - array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=3)')) + array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=3)')) ); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneOrder', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneOrder', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } // Call Hook formConfirm $parameters = array('lineid' => $lineid); // Note that $action and $object may be modified by hook $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; // Print form confirm print $formconfirm; @@ -2075,49 +2075,49 @@ if ($action == 'create' && $usercancreate) // Order card - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
'; + $morehtmlref = '
'; // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', null, null, '', 1); + $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' ('.$langs->trans("OtherOrders").')'; + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$soc->getNomUrl(1); + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; + $morehtmlref .= '
'.$langs->trans('Project').' '; if ($usercancreate) { if ($action != 'classify') - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='
'; + $morehtmlref .= '
'; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -2136,14 +2136,14 @@ if ($action == 'create' && $usercancreate) print $langs->trans('OutstandingBill'); print ''; $arrayoutstandingbills = $soc->getOutstandingBills(); - print price($arrayoutstandingbills['opened']) . ' / '; + print price($arrayoutstandingbills['opened']).' / '; print price($soc->outstanding_limit, 0, '', 1, - 1, - 1, $conf->currency); print ''; print ''; } // Relative and absolute discounts - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice } else { @@ -2151,11 +2151,11 @@ if ($action == 'create' && $usercancreate) $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')"; } - $addrelativediscount = '' . $langs->trans("EditRelativeDiscounts") . ''; - $addabsolutediscount = '' . $langs->trans("EditGlobalDiscounts") . ''; - $addcreditnote = '' . $langs->trans("AddCreditNote") . ''; + $addrelativediscount = ''.$langs->trans("EditRelativeDiscounts").''; + $addabsolutediscount = ''.$langs->trans("EditGlobalDiscounts").''; + $addcreditnote = ''.$langs->trans("AddCreditNote").''; - print '' . $langs->trans('Discounts') . ''; + print ''.$langs->trans('Discounts').''; $absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount); $absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote); @@ -2164,7 +2164,7 @@ if ($action == 'create' && $usercancreate) $thirdparty = $soc; $discount_type = 0; - $backtopage = urlencode($_SERVER["PHP_SELF"] . '?id=' . $object->id); + $backtopage = urlencode($_SERVER["PHP_SELF"].'?id='.$object->id); include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; print ''; @@ -2175,15 +2175,15 @@ if ($action == 'create' && $usercancreate) print $form->editfieldkey("Date", 'date', '', $object, $editenable); print ''; if ($action == 'editdate') { - print '
'; - print ''; + print ''; + print ''; print ''; print $form->selectDate($object->date, 'order_', '', '', '', "setdate"); - print ''; + print ''; print '
'; } else { print $object->date ? dol_print_date($object->date, 'day') : ' '; - if ($object->hasDelay() && ! empty($object->date_livraison)) { + if ($object->hasDelay() && !empty($object->date_livraison)) { print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); } } @@ -2196,15 +2196,15 @@ if ($action == 'create' && $usercancreate) print $form->editfieldkey("DateDeliveryPlanned", 'date_livraison', '', $object, $editenable); print ''; if ($action == 'editdate_livraison') { - print '
'; - print ''; + print ''; + print ''; print ''; print $form->selectDate($object->date_livraison ? $object->date_livraison : - 1, 'liv_', '', '', '', "setdate_livraison"); - print ''; + print ''; print '
'; } else { print $object->date_livraison ? dol_print_date($object->date_livraison, 'daytext') : ' '; - if ($object->hasDelay() && ! empty($object->date_livraison)) { + if ($object->hasDelay() && !empty($object->date_livraison)) { print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); } } @@ -2212,7 +2212,7 @@ if ($action == 'create' && $usercancreate) print ''; // Shipping Method - if (! empty($conf->expedition->enabled)) { + if (!empty($conf->expedition->enabled)) { print ''; $editenable = $usercancreate; print $form->editfieldkey("SendingMethod", 'shippingmethod', '', $object, $editenable); @@ -2227,10 +2227,10 @@ if ($action == 'create' && $usercancreate) } // Warehouse - if (! empty($conf->expedition->enabled) && ! empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { + if (!empty($conf->expedition->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { $langs->load('stocks'); require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; - $formproduct=new FormProduct($db); + $formproduct = new FormProduct($db); print ''; $editenable = $usercancreate; print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $editenable); @@ -2250,9 +2250,9 @@ if ($action == 'create' && $usercancreate) print $form->editfieldkey("PaymentConditionsShort", 'conditions', '', $object, $editenable); print ''; if ($action == 'editconditions') { - $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->cond_reglement_id, 'cond_reglement_id', 1); + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 1); } else { - $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->cond_reglement_id, 'none', 1); + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none', 1); } print ''; @@ -2264,14 +2264,14 @@ if ($action == 'create' && $usercancreate) print $form->editfieldkey("PaymentMode", 'mode', '', $object, $editenable); print ''; if ($action == 'editmode') { - $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); } else { - $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'none'); + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none'); } print ''; // Multicurrency - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { // Multicurrency code print ''; @@ -2280,9 +2280,9 @@ if ($action == 'create' && $usercancreate) print $form->editfieldkey("Currency", 'multicurrencycode', '', $object, $editenable); print ''; if ($action == 'editmulticurrencycode') { - $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code'); + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'multicurrency_code'); } else { - $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none'); + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'none'); } print ''; @@ -2295,13 +2295,13 @@ if ($action == 'create' && $usercancreate) print $form->editfieldkey("CurrencyRate", 'multicurrencyrate', '', $object, $editenable); print ''; if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { - if($action == 'actualizemulticurrencyrate') { + if ($action == 'actualizemulticurrencyrate') { list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); } - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); - if($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); + if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { print '
        '; print ''.$langs->trans("ActualizeCurrency").''; print '
'; @@ -2317,9 +2317,9 @@ if ($action == 'create' && $usercancreate) print $form->editfieldkey("AvailabilityPeriod", 'availability', '', $object, $editenable); print ''; if ($action == 'editavailability') { - $form->form_availability($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->availability_id, 'availability_id', 1); + $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, $object->availability_id, 'availability_id', 1); } else { - $form->form_availability($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->availability_id, 'none', 1); + $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, $object->availability_id, 'none', 1); } print ''; @@ -2329,9 +2329,9 @@ if ($action == 'create' && $usercancreate) print $form->editfieldkey("Channel", 'demandreason', '', $object, $editenable); print ''; if ($action == 'editdemandreason') { - $form->formInputReason($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->demand_reason_id, 'demand_reason_id', 1); + $form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, $object->demand_reason_id, 'demand_reason_id', 1); } else { - $form->formInputReason($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->demand_reason_id, 'none'); + $form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, $object->demand_reason_id, 'none'); } print ''; @@ -2349,19 +2349,19 @@ if ($action == 'create' && $usercancreate) print ''; */ - $tmparray=$object->getTotalWeightVolume(); - $totalWeight=$tmparray['weight']; - $totalVolume=$tmparray['volume']; + $tmparray = $object->getTotalWeightVolume(); + $totalWeight = $tmparray['weight']; + $totalVolume = $tmparray['volume']; if ($totalWeight) { print ''.$langs->trans("CalculatedWeight").''; print ''; - print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND)?$conf->global->MAIN_WEIGHT_DEFAULT_ROUND:-1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?$conf->global->MAIN_WEIGHT_DEFAULT_UNIT:'no'); + print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); print ''; } if ($totalVolume) { print ''.$langs->trans("CalculatedVolume").''; print ''; - print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no'); + print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); print ''; } @@ -2380,13 +2380,13 @@ if ($action == 'create' && $usercancreate) } else { - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?id='.$object->id); + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); } print ''; } // Bank Account - if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && ! empty($conf->banque->enabled)) { + if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && !empty($conf->banque->enabled)) { print ''; $editenable = $usercancreate; print $form->editfieldkey("BankAccount", 'bankaccount', '', $object, $editenable); @@ -2401,7 +2401,7 @@ if ($action == 'create' && $usercancreate) } // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print ''; @@ -2415,46 +2415,46 @@ if ($action == 'create' && $usercancreate) if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) { // Multicurrency Amount HT - print '' . $form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0) . ''; - print '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; + print ''.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).''; + print ''.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).''; print ''; // Multicurrency Amount VAT - print '' . $form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0) . ''; - print '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; + print ''.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).''; + print ''.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).''; print ''; // Multicurrency Amount TTC - print '' . $form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0) . ''; - print '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; + print ''.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).''; + print ''.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).''; print ''; } // Total HT $alert = ''; - if (! empty($conf->global->ORDER_MANAGE_MIN_AMOUNT) && $object->total_ht < $object->thirdparty->order_min_amount) { - $alert = ' ' . img_warning($langs->trans('OrderMinAmount').': '.price($object->thirdparty->order_min_amount)); + if (!empty($conf->global->ORDER_MANAGE_MIN_AMOUNT) && $object->total_ht < $object->thirdparty->order_min_amount) { + $alert = ' '.img_warning($langs->trans('OrderMinAmount').': '.price($object->thirdparty->order_min_amount)); } - print '' . $langs->trans('AmountHT') . ''; - print '' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . $alert . ''; + print ''.$langs->trans('AmountHT').''; + print ''.price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).$alert.''; // Total VAT - print '' . $langs->trans('AmountVAT') . '' . price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency) . ''; + print ''.$langs->trans('AmountVAT').''.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency).''; // Amount Local Taxes if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) // Localtax1 { - print '' . $langs->transcountry("AmountLT1", $mysoc->country_code) . ''; - print '' . price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency) . ''; + print ''.$langs->transcountry("AmountLT1", $mysoc->country_code).''; + print ''.price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).''; } if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) // Localtax2 IRPF { - print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . ''; - print '' . price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency) . ''; + print ''.$langs->transcountry("AmountLT2", $mysoc->country_code).''; + print ''.price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).''; } // Total TTC - print '' . $langs->trans('AmountTTC') . '' . price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency) . ''; + print ''.$langs->trans('AmountTTC').''.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).''; // Statut //print '' . $langs->trans('Status') . '' . $object->getLibStatut(4) . ''; @@ -2462,27 +2462,27 @@ if ($action == 'create' && $usercancreate) print ''; // Margin Infos - if (! empty($conf->margin->enabled)) { + if (!empty($conf->margin->enabled)) { $formmargin->displayMarginInfos($object); } print '
'; print '
'; - print '
'; // Close fichecenter + print '
'; // Close fichecenter print '

'; - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; $title = $langs->trans('ContactsAddresses'); - include DOL_DOCUMENT_ROOT . '/core/tpl/bloc_showhide.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; } - if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { + if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $blocname = 'notes'; $title = $langs->trans('Notes'); - include DOL_DOCUMENT_ROOT . '/core/tpl/bloc_showhide.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; } /* @@ -2490,21 +2490,21 @@ if ($action == 'create' && $usercancreate) */ $result = $object->getLinesArray(); - print '
- - + print ' + + - '; + '; - if (! empty($conf->use_javascript_ajax) && $object->statut == Commande::STATUS_DRAFT) { - include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + if (!empty($conf->use_javascript_ajax) && $object->statut == Commande::STATUS_DRAFT) { + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } print '
'; print ''; // Show object lines - if (! empty($object->lines)) + if (!empty($object->lines)) $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); $numlines = count($object->lines); @@ -2544,19 +2544,19 @@ if ($action == 'create' && $usercancreate) // Send if ($object->statut > Commande::STATUS_DRAFT || !empty($conf->global->COMMANDE_SENDBYEMAIL_FOR_ALL_STATUS)) { if ($usercansend) { - print '' . $langs->trans('SendMail') . ''; + print ''.$langs->trans('SendMail').''; } else - print '' . $langs->trans('SendMail') . ''; + print ''.$langs->trans('SendMail').''; } // Valid if ($object->statut == Commande::STATUS_DRAFT && $object->total_ttc >= 0 && $numlines > 0 && $usercanvalidate) { - print '' . $langs->trans('Validate') . ''; + print ''.$langs->trans('Validate').''; } // Edit if ($object->statut == Commande::STATUS_VALIDATED && $usercancreate) { - print '' . $langs->trans('Modify') . ''; + print ''.$langs->trans('Modify').''; } // Create event /*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) @@ -2568,11 +2568,11 @@ if ($action == 'create' && $usercancreate) }*/ // Create a purchase order - if (! empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_SALE_ORDER)) + if (!empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_SALE_ORDER)) { - if (! empty($conf->fournisseur->enabled) && $object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) { + if (!empty($conf->fournisseur->enabled) && $object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) { if ($usercancreatepurchaseorder) { - print '' . $langs->trans("AddPurchaseOrder") . ''; + print ''.$langs->trans("AddPurchaseOrder").''; } } } @@ -2583,9 +2583,9 @@ if ($action == 'create' && $usercancreate) if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) { if ($user->rights->ficheinter->creer) { - print '' . $langs->trans('AddIntervention') . ''; + print ''.$langs->trans('AddIntervention').''; } else { - print '' . $langs->trans('AddIntervention') . ''; + print ''.$langs->trans('AddIntervention').''; } } } @@ -2595,71 +2595,71 @@ if ($action == 'create' && $usercancreate) $langs->load("contracts"); if ($user->rights->contrat->creer) { - print '' . $langs->trans('AddContract') . ''; + print ''.$langs->trans('AddContract').''; } } // Ship $numshipping = 0; - if (! empty($conf->expedition->enabled)) { + if (!empty($conf->expedition->enabled)) { $numshipping = $object->nb_expedition(); if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && ($object->getNbOfProductsLines() > 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) { if (($conf->expedition_bon->enabled && $user->rights->expedition->creer) || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->creer)) { if ($user->rights->expedition->creer) { - print '' . $langs->trans('CreateShipment') . ''; + print ''.$langs->trans('CreateShipment').''; } else { - print '' . $langs->trans('CreateShipment') . ''; + print ''.$langs->trans('CreateShipment').''; } } else { $langs->load("errors"); - print 'transnoentitiesnoconv("Shipment"))) . '">' . $langs->trans('CreateShipment') . ''; + print 'transnoentitiesnoconv("Shipment"))).'">'.$langs->trans('CreateShipment').''; } } } // Reopen a closed order if (($object->statut == Commande::STATUS_CLOSED || $object->statut == Commande::STATUS_CANCELED) && $usercancreate) { - print ''; + print ''; } // Set to shipped if (($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_SHIPMENTONPROCESS) && $usercanclose) { - print ''; + print ''; } // Create bill and Classify billed // Note: Even if module invoice is not enabled, we should be able to use button "Classified billed" - if ($object->statut > Commande::STATUS_DRAFT && ! $object->billed) { - if (! empty($conf->facture->enabled) && $user->rights->facture->creer && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) { - print ''; + if ($object->statut > Commande::STATUS_DRAFT && !$object->billed) { + if (!empty($conf->facture->enabled) && $user->rights->facture->creer && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) { + print ''; } if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { - print ''; + print ''; } } if ($object->statut > Commande::STATUS_DRAFT && $object->billed) { if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { - print ''; + print ''; } } // Clone if ($usercancreate) { - print ''; + print ''; } // Cancel order - if ($object->statut == Commande::STATUS_VALIDATED && (! empty($usercanclose) || ! empty($usercancancel))) + if ($object->statut == Commande::STATUS_VALIDATED && (!empty($usercanclose) || !empty($usercancancel))) { - print ''; + print ''; } // Delete order if ($usercandelete) { if ($numshipping == 0) { - print ''; + print ''; } else { - print ''; + print ''; } } } @@ -2677,9 +2677,9 @@ if ($action == 'create' && $usercancreate) print ''; // ancre // Documents $comref = dol_sanitizeFileName($object->ref); - $relativepath = $comref . '/' . $comref . '.pdf'; - $filedir = $conf->commande->multidir_output[$object->entity] . '/' . $comref; - $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; + $relativepath = $comref.'/'.$comref.'.pdf'; + $filedir = $conf->commande->multidir_output[$object->entity].'/'.$comref; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed = $usercanread; $delallowed = $usercancreate; print $formfile->showdocuments('commande', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang, '', $object); @@ -2689,16 +2689,16 @@ if ($action == 'create' && $usercancreate) $linktoelem = $form->showLinkToObjectBlock($object, null, array('order')); $compatibleImportElementsList = false; - if($usercancreate + if ($usercancreate && $object->statut == Commande::STATUS_DRAFT) { - $compatibleImportElementsList = array('commande','propal'); // import from linked elements + $compatibleImportElementsList = array('commande', 'propal'); // import from linked elements } $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, $compatibleImportElementsList); // Show online payment link - $useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled)); - if (! empty($conf->global->ORDER_HIDE_ONLINE_PAYMENT_ON_ORDER)) $useonlinepayment = 0; + $useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled)); + if (!empty($conf->global->ORDER_HIDE_ONLINE_PAYMENT_ON_ORDER)) $useonlinepayment = 0; if ($object->statut != Commande::STATUS_DRAFT && $useonlinepayment) { print '
'; @@ -2707,7 +2707,7 @@ if ($action == 'create' && $usercancreate) } // Show direct download link - if ($object->statut != Commande::STATUS_DRAFT && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) + if ($object->statut != Commande::STATUS_DRAFT && !empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) { print '
'."\n"; print showDirectDownloadLink($object).'
'; @@ -2716,7 +2716,7 @@ if ($action == 'create' && $usercancreate) print '
'; // List of actions on element - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'order', $socid, 1); @@ -2724,8 +2724,8 @@ if ($action == 'create' && $usercancreate) } // Presend form - $modelmail='order_send'; - $defaulttopic='SendOrderRef'; + $modelmail = 'order_send'; + $defaulttopic = 'SendOrderRef'; $diroutput = $conf->commande->multidir_output[$object->entity]; $trackid = 'ord'.$object->id; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index dadc25737b6..1de1e64e0c7 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -47,54 +47,54 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; // Load translation files required by the page -$langs->loadLangs(array("orders",'sendings','deliveries','companies','compta','bills')); +$langs->loadLangs(array("orders", 'sendings', 'deliveries', 'companies', 'compta', 'bills')); -$action=GETPOST('action', 'aZ09'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'orderlist'; +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'orderlist'; -$search_orderyear=GETPOST("search_orderyear", "int"); -$search_ordermonth=GETPOST("search_ordermonth", "int"); -$search_orderday=GETPOST("search_orderday", "int"); -$search_deliveryyear=GETPOST("search_deliveryyear", "int"); -$search_deliverymonth=GETPOST("search_deliverymonth", "int"); -$search_deliveryday=GETPOST("search_deliveryday", "int"); -$search_product_category=GETPOST('search_product_category', 'int'); -$search_ref=GETPOST('search_ref', 'alpha')!=''?GETPOST('search_ref', 'alpha'):GETPOST('sref', 'alpha'); -$search_ref_customer=GETPOST('search_ref_customer', 'alpha'); -$search_company=GETPOST('search_company', 'alpha'); -$search_town=GETPOST('search_town', 'alpha'); -$search_zip=GETPOST('search_zip', 'alpha'); -$search_state=trim(GETPOST("search_state")); -$search_country=GETPOST("search_country", 'int'); -$search_type_thirdparty=GETPOST("search_type_thirdparty", 'int'); -$sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$socid=GETPOST('socid', 'int'); -$search_user=GETPOST('search_user', 'int'); -$search_sale=GETPOST('search_sale', 'int'); -$search_total_ht=GETPOST('search_total_ht', 'alpha'); -$search_total_ttc=GETPOST('search_total_ttc', 'alpha'); -$search_categ_cus=trim(GETPOST("search_categ_cus", 'int')); +$search_orderyear = GETPOST("search_orderyear", "int"); +$search_ordermonth = GETPOST("search_ordermonth", "int"); +$search_orderday = GETPOST("search_orderday", "int"); +$search_deliveryyear = GETPOST("search_deliveryyear", "int"); +$search_deliverymonth = GETPOST("search_deliverymonth", "int"); +$search_deliveryday = GETPOST("search_deliveryday", "int"); +$search_product_category = GETPOST('search_product_category', 'int'); +$search_ref = GETPOST('search_ref', 'alpha') != '' ?GETPOST('search_ref', 'alpha') : GETPOST('sref', 'alpha'); +$search_ref_customer = GETPOST('search_ref_customer', 'alpha'); +$search_company = GETPOST('search_company', 'alpha'); +$search_town = GETPOST('search_town', 'alpha'); +$search_zip = GETPOST('search_zip', 'alpha'); +$search_state = trim(GETPOST("search_state")); +$search_country = GETPOST("search_country", 'int'); +$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$socid = GETPOST('socid', 'int'); +$search_user = GETPOST('search_user', 'int'); +$search_sale = GETPOST('search_sale', 'int'); +$search_total_ht = GETPOST('search_total_ht', 'alpha'); +$search_total_ttc = GETPOST('search_total_ttc', 'alpha'); +$search_categ_cus = trim(GETPOST("search_categ_cus", 'int')); $optioncss = GETPOST('optioncss', 'alpha'); $billed = GETPOST('billed', 'int'); -$viewstatut=GETPOST('viewstatut'); -$search_btn=GETPOST('button_search', 'alpha'); -$search_remove_btn=GETPOST('button_removefilter', 'alpha'); -$search_project_ref=GETPOST('search_project_ref', 'alpha'); -$search_project=GETPOST('search_project', 'alpha'); +$viewstatut = GETPOST('viewstatut'); +$search_btn = GETPOST('button_search', 'alpha'); +$search_remove_btn = GETPOST('button_removefilter', 'alpha'); +$search_project_ref = GETPOST('search_project_ref', 'alpha'); +$search_project = GETPOST('search_project', 'alpha'); // Security check -$id = (GETPOST('orderid')?GETPOST('orderid', 'int'):GETPOST('id', 'int')); -if ($user->socid) $socid=$user->socid; +$id = (GETPOST('orderid') ?GETPOST('orderid', 'int') : GETPOST('id', 'int')); +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'commande', $id, ''); -$diroutputmassaction=$conf->commande->multidir_output[$conf->entity] . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->commande->multidir_output[$conf->entity].'/temp/massgeneration/'.$user->id; // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -102,8 +102,8 @@ if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='c.ref'; -if (! $sortorder) $sortorder='DESC'; +if (!$sortfield) $sortfield = 'c.ref'; +if (!$sortorder) $sortorder = 'DESC'; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Commande($db); @@ -112,7 +112,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label('commande'); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -123,14 +123,14 @@ $fieldstosearchall = array( 's.name_alias'=>"AliasNameShort", 'c.note_public'=>'NotePublic', ); -if (empty($user->socid)) $fieldstosearchall["c.note_private"]="NotePrivate"; +if (empty($user->socid)) $fieldstosearchall["c.note_private"] = "NotePrivate"; -$checkedtypetiers=0; -$arrayfields=array( +$checkedtypetiers = 0; +$arrayfields = array( 'c.ref'=>array('label'=>"Ref", 'checked'=>1), 'c.ref_client'=>array('label'=>"RefCustomerOrder", 'checked'=>1), - 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled)?0:1)), - 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled)?0:1)), + 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)), + 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)), 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1), 's.town'=>array('label'=>"Town", 'checked'=>1), 's.zip'=>array('label'=>"Zip", 'checked'=>1), @@ -151,10 +151,10 @@ $arrayfields=array( // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -166,11 +166,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; } -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) @@ -181,49 +181,49 @@ if (empty($reshook)) // Purge search criteria 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_categ=''; - $search_user=''; - $search_sale=''; - $search_product_category=''; - $search_ref=''; - $search_ref_customer=''; - $search_company=''; - $search_town=''; - $search_zip=""; - $search_state=""; - $search_type=''; - $search_country=''; - $search_type_thirdparty=''; - $search_total_ht=''; - $search_total_vat=''; - $search_total_ttc=''; - $search_orderyear=''; - $search_ordermonth=''; - $search_orderday=''; - $search_deliveryday=''; - $search_deliverymonth=''; - $search_deliveryyear=''; - $search_project_ref=''; - $search_project=''; - $viewstatut=''; - $billed=''; - $toselect=''; - $search_array_options=array(); - $search_categ_cus=0; + $search_categ = ''; + $search_user = ''; + $search_sale = ''; + $search_product_category = ''; + $search_ref = ''; + $search_ref_customer = ''; + $search_company = ''; + $search_town = ''; + $search_zip = ""; + $search_state = ""; + $search_type = ''; + $search_country = ''; + $search_type_thirdparty = ''; + $search_total_ht = ''; + $search_total_vat = ''; + $search_total_ttc = ''; + $search_orderyear = ''; + $search_ordermonth = ''; + $search_orderday = ''; + $search_deliveryday = ''; + $search_deliverymonth = ''; + $search_deliveryyear = ''; + $search_project_ref = ''; + $search_project = ''; + $viewstatut = ''; + $billed = ''; + $toselect = ''; + $search_array_options = array(); + $search_categ_cus = 0; } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { - $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='Commande'; - $objectlabel='Orders'; + $objectclass = 'Commande'; + $objectlabel = 'Orders'; $permissiontoread = $user->rights->commande->lire; $permissiontodelete = $user->rights->commande->supprimer; $uploaddir = $conf->commande->multidir_output[$conf->entity]; - $trigger_name='ORDER_SENTBYMAIL'; + $trigger_name = 'ORDER_SENTBYMAIL'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -232,77 +232,77 @@ if (empty($reshook)) * View */ -$now=dol_now(); +$now = dol_now(); $form = new Form($db); $formother = new FormOther($db); $formfile = new FormFile($db); $companystatic = new Societe($db); -$formcompany=new FormCompany($db); -$projectstatic=new Project($db); +$formcompany = new FormCompany($db); +$projectstatic = new Project($db); -$title=$langs->trans("Orders"); -$help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes"; +$title = $langs->trans("Orders"); +$help_url = "EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes"; // llxHeader('',$title,$help_url); $sql = 'SELECT'; if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; -$sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; -$sql.= " typent.code as typent_code,"; -$sql.= " state.code_departement as state_code, state.nom as state_name,"; -$sql.= ' c.rowid, c.ref, c.total_ht, c.tva as total_tva, c.total_ttc, c.ref_client,'; -$sql.= ' c.date_valid, c.date_commande, c.note_private, c.date_livraison as date_delivery, c.fk_statut, c.facture as billed,'; -$sql.= ' c.date_creation as date_creation, c.tms as date_update, c.date_cloture as date_cloture,'; -$sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_label"; +$sql .= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; +$sql .= " typent.code as typent_code,"; +$sql .= " state.code_departement as state_code, state.nom as state_name,"; +$sql .= ' c.rowid, c.ref, c.total_ht, c.tva as total_tva, c.total_ttc, c.ref_client,'; +$sql .= ' c.date_valid, c.date_commande, c.note_private, c.date_livraison as date_delivery, c.fk_statut, c.facture as billed,'; +$sql .= ' c.date_creation as date_creation, c.tms as date_update, c.date_cloture as date_cloture,'; +$sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_label"; if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; // 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 : ''); +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 : ''); // 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 '.MAIN_DB_PREFIX.'societe as s'; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; -if (! empty($search_categ_cus)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ -$sql.= ', '.MAIN_DB_PREFIX.'commande as c'; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande_extrafields as ef on (c.rowid = ef.fk_object)"; -if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet as pd ON c.rowid=pd.fk_commande'; -if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = c.fk_projet"; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s'; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +if (!empty($search_categ_cus)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ +$sql .= ', '.MAIN_DB_PREFIX.'commande as c'; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_extrafields as ef on (c.rowid = ef.fk_object)"; +if ($sall || $search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet as pd ON c.rowid=pd.fk_commande'; +if ($search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = c.fk_projet"; // We'll need this table joined to the select in order to filter by sale -if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if ($search_user > 0) { - $sql.=", ".MAIN_DB_PREFIX."element_contact as ec"; - $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; } -$sql.= ' WHERE c.fk_soc = s.rowid'; -$sql.= ' AND c.entity IN ('.getEntity('commande').')'; -if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$search_product_category; -if ($socid > 0) $sql.= ' AND s.rowid = '.$socid; -if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; +$sql .= ' WHERE c.fk_soc = s.rowid'; +$sql .= ' AND c.entity IN ('.getEntity('commande').')'; +if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$search_product_category; +if ($socid > 0) $sql .= ' AND s.rowid = '.$socid; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($search_ref) $sql .= natural_search('c.ref', $search_ref); -if ($search_ref_customer) $sql.= natural_search('c.ref_client', $search_ref_customer); +if ($search_ref_customer) $sql .= natural_search('c.ref_client', $search_ref_customer); if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); -if ($billed != '' && $billed >= 0) $sql.=' AND c.facture = '.$billed; +if ($billed != '' && $billed >= 0) $sql .= ' AND c.facture = '.$billed; if ($viewstatut <> '') { if ($viewstatut < 4 && $viewstatut > -3) { - if ($viewstatut == 1 && empty($conf->expedition->enabled)) $sql.= ' AND c.fk_statut IN (1,2)'; // If module expedition disabled, we include order with status 'sending in process' into 'validated' - else $sql.= ' AND c.fk_statut = '.$viewstatut; // brouillon, validee, en cours, annulee + if ($viewstatut == 1 && empty($conf->expedition->enabled)) $sql .= ' AND c.fk_statut IN (1,2)'; // If module expedition disabled, we include order with status 'sending in process' into 'validated' + else $sql .= ' AND c.fk_statut = '.$viewstatut; // brouillon, validee, en cours, annulee } if ($viewstatut == 4) { - $sql.= ' AND c.facture = 1'; // invoice created + $sql .= ' AND c.facture = 1'; // invoice created } if ($viewstatut == -2) // To process { //$sql.= ' AND c.fk_statut IN (1,2,3) AND c.facture = 0'; - $sql.= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected + $sql .= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected } if ($viewstatut == -3) // To bill { @@ -311,30 +311,30 @@ if ($viewstatut <> '') $sql .= ' AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))'; // validated, in process or closed but not billed } } -$sql.= dolSqlDateFilter("c.date_commande", $search_orderday, $search_ordermonth, $search_orderyear); -$sql.= dolSqlDateFilter("c.date_livraison", $search_deliveryday, $search_deliverymonth, $search_deliveryyear); -if ($search_town) $sql.= natural_search('s.town', $search_town); -if ($search_zip) $sql.= natural_search("s.zip", $search_zip); -if ($search_state) $sql.= natural_search("state.nom", $search_state); +$sql .= dolSqlDateFilter("c.date_commande", $search_orderday, $search_ordermonth, $search_orderyear); +$sql .= dolSqlDateFilter("c.date_livraison", $search_deliveryday, $search_deliverymonth, $search_deliveryyear); +if ($search_town) $sql .= natural_search('s.town', $search_town); +if ($search_zip) $sql .= natural_search("s.zip", $search_zip); +if ($search_state) $sql .= natural_search("state.nom", $search_state); if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; if ($search_company) $sql .= natural_search('s.nom', $search_company); -if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale; -if ($search_user > 0) $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user; -if ($search_total_ht != '') $sql.= natural_search('c.total_ht', $search_total_ht, 1); -if ($search_total_ttc != '') $sql.= natural_search('c.total_ttc', $search_total_ttc, 1); -if ($search_project_ref != '') $sql.= natural_search("p.ref", $search_project_ref); -if ($search_project != '') $sql.= natural_search("p.title", $search_project); -if ($search_categ_cus > 0) $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); -if ($search_categ_cus == -2) $sql.= " AND cc.fk_categorie IS NULL"; +if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$search_sale; +if ($search_user > 0) $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user; +if ($search_total_ht != '') $sql .= natural_search('c.total_ht', $search_total_ht, 1); +if ($search_total_ttc != '') $sql .= natural_search('c.total_ttc', $search_total_ttc, 1); +if ($search_project_ref != '') $sql .= natural_search("p.ref", $search_project_ref); +if ($search_project != '') $sql .= natural_search("p.title", $search_project); +if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); +if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL"; // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -350,7 +350,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit + 1, $offset); +$sql .= $db->plimit($limit + 1, $offset); //print $sql; $resql = $db->query($sql); @@ -360,7 +360,7 @@ if ($resql) { $soc = new Societe($db); $soc->fetch($socid); - $title = $langs->trans('ListOfOrders') . ' - '.$soc->name; + $title = $langs->trans('ListOfOrders').' - '.$soc->name; if (empty($search_company)) $search_company = $soc->name; } else @@ -368,27 +368,27 @@ if ($resql) $title = $langs->trans('ListOfOrders'); } if (strval($viewstatut) == '0') - $title.=' - '.$langs->trans('StatusOrderDraftShort'); + $title .= ' - '.$langs->trans('StatusOrderDraftShort'); if ($viewstatut == 1) - $title.=' - '.$langs->trans('StatusOrderValidatedShort'); + $title .= ' - '.$langs->trans('StatusOrderValidatedShort'); if ($viewstatut == 2) - $title.=' - '.$langs->trans('StatusOrderSentShort'); + $title .= ' - '.$langs->trans('StatusOrderSentShort'); if ($viewstatut == 3) - $title.=' - '.$langs->trans('StatusOrderToBillShort'); + $title .= ' - '.$langs->trans('StatusOrderToBillShort'); if ($viewstatut == 4) - $title.=' - '.$langs->trans('StatusOrderProcessedShort'); + $title .= ' - '.$langs->trans('StatusOrderProcessedShort'); if ($viewstatut == -1) - $title.=' - '.$langs->trans('StatusOrderCanceledShort'); + $title .= ' - '.$langs->trans('StatusOrderCanceledShort'); if ($viewstatut == -2) - $title.=' - '.$langs->trans('StatusOrderToProcessShort'); + $title .= ' - '.$langs->trans('StatusOrderToProcessShort'); if ($viewstatut == -3) - $title.=' - '.$langs->trans('StatusOrderValidated').', '.(empty($conf->expedition->enabled)?'':$langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill'); + $title .= ' - '.$langs->trans('StatusOrderValidated').', '.(empty($conf->expedition->enabled) ? '' : $langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill'); $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); - if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) + if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -398,58 +398,58 @@ if ($resql) llxHeader('', $title, $help_url); - $param=''; + $param = ''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($sall) $param.='&sall='.urlencode($sall); - if ($socid > 0) $param.='&socid='.urlencode($socid); - if ($viewstatut != '') $param.='&viewstatut='.urlencode($viewstatut); - if ($search_orderday) $param.='&search_orderday='.urlencode($search_orderday); - if ($search_ordermonth) $param.='&search_ordermonth='.urlencode($search_ordermonth); - if ($search_orderyear) $param.='&search_orderyear='.urlencode($search_orderyear); - if ($search_deliveryday) $param.='&search_deliveryday='.urlencode($search_deliveryday); - if ($search_deliverymonth) $param.='&search_deliverymonth='.urlencode($search_deliverymonth); - if ($search_deliveryyear) $param.='&search_deliveryyear='.urlencode($search_deliveryyear); - if ($search_ref) $param.='&search_ref='.urlencode($search_ref); - if ($search_company) $param.='&search_company='.urlencode($search_company); - if ($search_ref_customer) $param.='&search_ref_customer='.urlencode($search_ref_customer); - if ($search_user > 0) $param.='&search_user='.urlencode($search_user); - if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale); - if ($search_total_ht != '') $param.='&search_total_ht='.urlencode($search_total_ht); - if ($search_total_vat != '') $param.='&search_total_vat='.urlencode($search_total_vat); - if ($search_total_ttc != '') $param.='&search_total_ttc='.urlencode($search_total_ttc); - if ($search_project_ref >= 0) $param.="&search_project_ref=".urlencode($search_project_ref); - if ($search_town != '') $param.='&search_town='.urlencode($search_town); - if ($search_zip != '') $param.='&search_zip='.urlencode($search_zip); - if ($search_state != '') $param.='&search_state='.urlencode($search_state); - if ($search_country != '') $param.='&search_country='.urlencode($search_country); - if ($search_type_thirdparty != '') $param.='&search_type_thirdparty='.urlencode($search_type_thirdparty); - if ($search_product_category != '') $param.='&search_product_category='.urlencode($search_product_category); - if ($search_categ_cus > 0) $param.='&search_categ_cus='.urlencode($search_categ_cus); - if ($show_files) $param.='&show_files=' .urlencode($show_files); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); - if ($billed != '') $param.='&billed='.urlencode($billed); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($sall) $param .= '&sall='.urlencode($sall); + if ($socid > 0) $param .= '&socid='.urlencode($socid); + if ($viewstatut != '') $param .= '&viewstatut='.urlencode($viewstatut); + if ($search_orderday) $param .= '&search_orderday='.urlencode($search_orderday); + if ($search_ordermonth) $param .= '&search_ordermonth='.urlencode($search_ordermonth); + if ($search_orderyear) $param .= '&search_orderyear='.urlencode($search_orderyear); + if ($search_deliveryday) $param .= '&search_deliveryday='.urlencode($search_deliveryday); + if ($search_deliverymonth) $param .= '&search_deliverymonth='.urlencode($search_deliverymonth); + if ($search_deliveryyear) $param .= '&search_deliveryyear='.urlencode($search_deliveryyear); + if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); + if ($search_company) $param .= '&search_company='.urlencode($search_company); + if ($search_ref_customer) $param .= '&search_ref_customer='.urlencode($search_ref_customer); + if ($search_user > 0) $param .= '&search_user='.urlencode($search_user); + if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); + if ($search_total_ht != '') $param .= '&search_total_ht='.urlencode($search_total_ht); + if ($search_total_vat != '') $param .= '&search_total_vat='.urlencode($search_total_vat); + if ($search_total_ttc != '') $param .= '&search_total_ttc='.urlencode($search_total_ttc); + if ($search_project_ref >= 0) $param .= "&search_project_ref=".urlencode($search_project_ref); + if ($search_town != '') $param .= '&search_town='.urlencode($search_town); + if ($search_zip != '') $param .= '&search_zip='.urlencode($search_zip); + if ($search_state != '') $param .= '&search_state='.urlencode($search_state); + if ($search_country != '') $param .= '&search_country='.urlencode($search_country); + if ($search_type_thirdparty != '') $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty); + if ($search_product_category != '') $param .= '&search_product_category='.urlencode($search_product_category); + if ($search_categ_cus > 0) $param .= '&search_categ_cus='.urlencode($search_categ_cus); + if ($show_files) $param .= '&show_files='.urlencode($show_files); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + if ($billed != '') $param .= '&billed='.urlencode($billed); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available - $arrayofmassactions = array( + $arrayofmassactions = array( 'generate_doc'=>$langs->trans("ReGeneratePDF"), 'builddoc'=>$langs->trans("PDFMerge"), 'cancelorders'=>$langs->trans("Cancel"), 'presend'=>$langs->trans("SendByMail"), ); - if($user->rights->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); - if ($user->rights->commande->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); - if (in_array($massaction, array('presend','predelete','createbills'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + if ($user->rights->facture->creer) $arrayofmassactions['createbills'] = $langs->trans("CreateInvoiceForThisCustomer"); + if ($user->rights->commande->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); + if (in_array($massaction, array('presend', 'predelete', 'createbills'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); - $newcardbutton=''; + $newcardbutton = ''; if ($contextpage == 'orderlist' && $user->rights->commande->creer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/commande/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/commande/card.php?action=create'); } // Lines of title fields @@ -468,10 +468,10 @@ if ($resql) print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'commercial', 0, $newcardbutton, '', $limit); - $topicmail="SendOrderRef"; - $modelmail="order_send"; - $objecttmp=new Commande($db); - $trackid='ord'.$object->id; + $topicmail = "SendOrderRef"; + $modelmail = "order_send"; + $objecttmp = new Commande($db); + $trackid = 'ord'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($massaction == 'createbills') @@ -501,7 +501,7 @@ if ($resql) print $langs->trans('ValidateInvoices'); print ''; print '
'; print ''; @@ -526,155 +526,155 @@ if ($resql) if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } - $moreforfilter=''; + $moreforfilter = ''; // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); - $moreforfilter.='
'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; + $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $moreforfilter .= '
'; } // If the user can view other users if ($user->rights->user->user->lire) { - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; - $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); - $moreforfilter.='
'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; + $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); + $moreforfilter .= '
'; } // If the user can view prospects other than his' if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': '; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); - $moreforfilter.='
'; + $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter .= '
'; } - if (! empty($conf->categorie->enabled)) + if (!empty($conf->categorie->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('CustomersProspectsCategoriesShort').': '; - $moreforfilter.=$formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1); - $moreforfilter.='
'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': '; + $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1); + $moreforfilter .= '
'; } - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - if (! empty($moreforfilter)) + if (!empty($moreforfilter)) { print '
'; print $moreforfilter; print '
'; } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); print '
'; - print '
'; - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL)) + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) { print $form->selectyesno('validate_invoices', 0, 1, 1); print ' ('.$langs->trans("AutoValidationNotPossibleWhenStockIsDecreasedOnInvoiceValidation").')'; @@ -510,7 +510,7 @@ if ($resql) { print $form->selectyesno('validate_invoices', 0, 1); } - if (! empty($conf->workflow->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER)) print '     '.$langs->trans("IfValidateInvoiceIsNoOrderStayUnbilled").''; + if (!empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER)) print '     '.$langs->trans("IfValidateInvoiceIsNoOrderStayUnbilled").''; else print '     '.$langs->trans("OptionToSetOrderBilledNotEnabled").''; print '
'."\n"; + print '
'."\n"; print ''; // Ref - if (! empty($arrayfields['c.ref']['checked'])) + if (!empty($arrayfields['c.ref']['checked'])) { print ''; } // Ref customer - if (! empty($arrayfields['c.ref_client']['checked'])) + if (!empty($arrayfields['c.ref_client']['checked'])) { print ''; } // Project ref - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { print ''; } // Project title - if (! empty($arrayfields['p.title']['checked'])) + if (!empty($arrayfields['p.title']['checked'])) { print ''; } // Thirpdarty - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print ''; } // Town - if (! empty($arrayfields['s.town']['checked'])) print ''; + if (!empty($arrayfields['s.town']['checked'])) print ''; // Zip - if (! empty($arrayfields['s.zip']['checked'])) print ''; + if (!empty($arrayfields['s.zip']['checked'])) print ''; // State - if (! empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print ''; } // Country - if (! empty($arrayfields['country.code_iso']['checked'])) + if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; } // Company type - if (! empty($arrayfields['typent.code']['checked'])) + if (!empty($arrayfields['typent.code']['checked'])) { print ''; } // Date order - if (! empty($arrayfields['c.date_commande']['checked'])) + if (!empty($arrayfields['c.date_commande']['checked'])) { print ''; } - if (! empty($arrayfields['c.date_delivery']['checked'])) + if (!empty($arrayfields['c.date_delivery']['checked'])) { print ''; } - if (! empty($arrayfields['c.total_ht']['checked'])) + if (!empty($arrayfields['c.total_ht']['checked'])) { // Amount print ''; } - if (! empty($arrayfields['c.total_vat']['checked'])) + if (!empty($arrayfields['c.total_vat']['checked'])) { // Amount print ''; } - if (! empty($arrayfields['c.total_ttc']['checked'])) + if (!empty($arrayfields['c.total_ttc']['checked'])) { // Amount print ''; } // Date modification - if (! empty($arrayfields['c.tms']['checked'])) + if (!empty($arrayfields['c.tms']['checked'])) { print ''; } // Date cloture - if (! empty($arrayfields['c.date_cloture']['checked'])) + if (!empty($arrayfields['c.date_cloture']['checked'])) { print ''; } // Status - if (! empty($arrayfields['c.fk_statut']['checked'])) + if (!empty($arrayfields['c.fk_statut']['checked'])) { print ''; } // Status billed - if (! empty($arrayfields['c.facture']['checked'])) + if (!empty($arrayfields['c.facture']['checked'])) { print ''; @@ -737,54 +737,54 @@ if ($resql) // Fields title print ''; - if (! empty($arrayfields['c.ref']['checked'])) print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], 'c.ref', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['c.ref_client']['checked'])) print_liste_field_titre($arrayfields['c.ref_client']['label'], $_SERVER["PHP_SELF"], 'c.ref_client', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['c.date_commande']['checked'])) print_liste_field_titre($arrayfields['c.date_commande']['label'], $_SERVER["PHP_SELF"], 'c.date_commande', '', $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['c.date_delivery']['checked'])) print_liste_field_titre($arrayfields['c.date_delivery']['label'], $_SERVER["PHP_SELF"], 'c.date_livraison', '', $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['c.total_ht']['checked'])) print_liste_field_titre($arrayfields['c.total_ht']['label'], $_SERVER["PHP_SELF"], 'c.total_ht', '', $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['c.total_vat']['checked'])) print_liste_field_titre($arrayfields['c.total_vat']['label'], $_SERVER["PHP_SELF"], 'c.tva', '', $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['c.total_ttc']['checked'])) print_liste_field_titre($arrayfields['c.total_ttc']['label'], $_SERVER["PHP_SELF"], 'c.total_ttc', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['c.ref']['checked'])) print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], 'c.ref', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['c.ref_client']['checked'])) print_liste_field_titre($arrayfields['c.ref_client']['label'], $_SERVER["PHP_SELF"], 'c.ref_client', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['c.date_commande']['checked'])) print_liste_field_titre($arrayfields['c.date_commande']['label'], $_SERVER["PHP_SELF"], 'c.date_commande', '', $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['c.date_delivery']['checked'])) print_liste_field_titre($arrayfields['c.date_delivery']['label'], $_SERVER["PHP_SELF"], 'c.date_livraison', '', $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['c.total_ht']['checked'])) print_liste_field_titre($arrayfields['c.total_ht']['label'], $_SERVER["PHP_SELF"], 'c.total_ht', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['c.total_vat']['checked'])) print_liste_field_titre($arrayfields['c.total_vat']['label'], $_SERVER["PHP_SELF"], 'c.tva', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['c.total_ttc']['checked'])) print_liste_field_titre($arrayfields['c.total_ttc']['label'], $_SERVER["PHP_SELF"], 'c.total_ttc', '', $param, '', $sortfield, $sortorder, 'right '); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['c.datec']['checked'])) print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (! empty($arrayfields['c.tms']['checked'])) print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (! empty($arrayfields['c.date_cloture']['checked'])) print_liste_field_titre($arrayfields['c.date_cloture']['label'], $_SERVER["PHP_SELF"], "c.date_cloture", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (! empty($arrayfields['c.fk_statut']['checked'])) print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['c.facture']['checked'])) print_liste_field_titre($arrayfields['c.facture']['label'], $_SERVER["PHP_SELF"], 'c.facture', '', $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['c.datec']['checked'])) print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['c.tms']['checked'])) print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['c.date_cloture']['checked'])) print_liste_field_titre($arrayfields['c.date_cloture']['label'], $_SERVER["PHP_SELF"], "c.date_cloture", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['c.fk_statut']['checked'])) print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['c.facture']['checked'])) print_liste_field_titre($arrayfields['c.facture']['label'], $_SERVER["PHP_SELF"], 'c.facture', '', $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center '); print ''."\n"; - $total=0; - $subtotal=0; - $productstat_cache=array(); - $getNomUrl_cache=array(); + $total = 0; + $subtotal = 0; + $productstat_cache = array(); + $getNomUrl_cache = array(); $generic_commande = new Commande($db); $generic_product = new Product($db); - $i=0; - $totalarray=array(); + $i = 0; + $totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - $notshippable=0; + $notshippable = 0; $warning = 0; - $text_info=''; - $text_warning=''; - $nbprod=0; + $text_info = ''; + $text_warning = ''; + $nbprod = 0; $companystatic->id = $obj->socid; $companystatic->code_client = $obj->code_client; @@ -795,8 +795,8 @@ if ($resql) $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1, 'customer'); } - $generic_commande->id=$obj->rowid; - $generic_commande->ref=$obj->ref; + $generic_commande->id = $obj->rowid; + $generic_commande->ref = $obj->ref; $generic_commande->statut = $obj->fk_statut; $generic_commande->date = $db->jdate($obj->date_commande); $generic_commande->date_livraison = $db->jdate($obj->date_delivery); @@ -805,21 +805,21 @@ if ($resql) $generic_commande->total_tva = $obj->total_tva; $generic_commande->total_ttc = $obj->total_ttc; - $projectstatic->id=$obj->project_id; - $projectstatic->ref=$obj->project_ref; - $projectstatic->title=$obj->project_label; + $projectstatic->id = $obj->project_id; + $projectstatic->ref = $obj->project_ref; + $projectstatic->title = $obj->project_label; print ''; // Ref - if (! empty($arrayfields['c.ref']['checked'])) + if (!empty($arrayfields['c.ref']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Ref customer - if (! empty($arrayfields['c.ref_client']['checked'])) + if (!empty($arrayfields['c.ref_client']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Project ref - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Project label - if (! empty($arrayfields['p.title']['checked'])) + if (!empty($arrayfields['p.title']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Third party - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print ''; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT)); print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; - $formother->select_year($search_orderyear?$search_orderyear:-1, 'search_orderyear', 1, 20, 5); + $formother->select_year($search_orderyear ? $search_orderyear : -1, 'search_orderyear', 1, 20, 5); print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; - $formother->select_year($search_deliveryyear?$search_deliveryyear:-1, 'search_deliveryyear', 1, 20, 5); + $formother->select_year($search_deliveryyear ? $search_deliveryyear : -1, 'search_deliveryyear', 1, 20, 5); print ''; print ''; print ''; print ''; print ''; @@ -684,32 +684,32 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['c.datec']['checked'])) + if (!empty($arrayfields['c.datec']['checked'])) { print ''; print ''; print ''; print ''; - $liststatus=array( + $liststatus = array( Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraftShort"), Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), Commande::STATUS_SHIPMENTONPROCESS=>$langs->trans("StatusOrderSentShort"), @@ -721,7 +721,7 @@ if ($resql) print ''; print $form->selectyesno('billed', $billed, 1, 0, 1); @@ -729,7 +729,7 @@ if ($resql) } // Action column print ''; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; - $generic_commande->lines=array(); + $generic_commande->lines = array(); $generic_commande->getLinesArray(); - print $generic_commande->getNomUrl(1, ($viewstatut != 2?0:$obj->fk_statut), 0, 0, 0, 1); + print $generic_commande->getNomUrl(1, ($viewstatut != 2 ? 0 : $obj->fk_statut), 0, 0, 0, 1); // Show shippable Icon (create subloop, so may be slow) if ($conf->stock->enabled) @@ -828,7 +828,7 @@ if ($resql) if (($obj->fk_statut > 0) && ($obj->fk_statut < 3)) { $numlines = count($generic_commande->lines); // Loop on each line of order - for ($lig=0; $lig < $numlines; $lig++) + for ($lig = 0; $lig < $numlines; $lig++) { if ($generic_commande->lines[$lig]->product_type == 0 && $generic_commande->lines[$lig]->fk_product > 0) // If line is a product and not a service { @@ -860,11 +860,11 @@ if ($resql) } else { // Detailed code, looks bugged // stock order and stock order_supplier - $stock_order=0; - $stock_order_supplier=0; - if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) // What about other options ? + $stock_order = 0; + $stock_order_supplier = 0; + if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) // What about other options ? { - if (! empty($conf->commande->enabled)) + if (!empty($conf->commande->enabled)) { if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'])) { $generic_product->load_stats_commande(0, '1,2'); @@ -872,9 +872,9 @@ if ($resql) } else { $generic_product->stats_commande['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer']; } - $stock_order=$generic_product->stats_commande['qty']; + $stock_order = $generic_product->stats_commande['qty']; } - if (! empty($conf->fournisseur->enabled)) + if (!empty($conf->fournisseur->enabled)) { if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'])) { $generic_product->load_stats_commande_fournisseur(0, '3'); @@ -882,25 +882,25 @@ if ($resql) } else { $generic_product->stats_commande_fournisseur['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier']; } - $stock_order_supplier=$generic_product->stats_commande_fournisseur['qty']; + $stock_order_supplier = $generic_product->stats_commande_fournisseur['qty']; } } $text_info .= $generic_commande->lines[$lig]->qty.' X '.$generic_commande->lines[$lig]->ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 25); $text_stock_reel = $generic_product->stock_reel.'/'.$stock_order; - if ($stock_order > $generic_product->stock_reel && ! ($generic_product->stock_reel < $generic_commande->lines[$lig]->qty)) { + if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $generic_commande->lines[$lig]->qty)) { $warning++; - $text_warning.=''.$langs->trans('Available').' : '.$text_stock_reel.''; + $text_warning .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; } if ($generic_product->stock_reel < $generic_commande->lines[$lig]->qty) { $notshippable++; - $text_info.=''.$langs->trans('Available').' : '.$text_stock_reel.''; + $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; } else { - $text_info.=''.$langs->trans('Available').' : '.$text_stock_reel.''; + $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; } - if (! empty($conf->fournisseur->enabled)) { - $text_info.= ' '.$langs->trans('SupplierOrder').' : '.$stock_order_supplier.'
'; + if (!empty($conf->fournisseur->enabled)) { + $text_info .= ' '.$langs->trans('SupplierOrder').' : '.$stock_order_supplier.'
'; } else { - $text_info.= '
'; + $text_info .= '
'; } } } @@ -934,24 +934,24 @@ if ($resql) print ''; } - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->commande->multidir_output[$conf->entity] . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->commande->multidir_output[$conf->entity].'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir); print '
'.$obj->ref_client.''; if ($obj->project_id > 0) @@ -959,11 +959,11 @@ if ($resql) print $projectstatic->getNomUrl(1); } print ''; if ($obj->project_id > 0) @@ -971,17 +971,17 @@ if ($resql) print $projectstatic->title; } print ''; print $getNomUrl_cache[$obj->socid]; // If module invoices enabled and user with invoice creation permissions - if (! empty($conf->facture->enabled) && ! empty($conf->global->ORDER_BILLING_ALL_CUSTOMER)) + if (!empty($conf->facture->enabled) && !empty($conf->global->ORDER_BILLING_ALL_CUSTOMER)) { if ($user->rights->facture->creer) { @@ -1143,8 +1143,8 @@ if ($resql) $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 + $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 '
'."\n"; @@ -1152,16 +1152,16 @@ if ($resql) print ''."\n"; - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->commande->lire; - $delallowed=$user->rights->commande->creer; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->commande->lire; + $delallowed = $user->rights->commande->creer; print $formfile->showdocuments('massfilesarea_orders', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 0912dfaba0a..bfbafc93bd5 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -52,51 +52,51 @@ require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; // Load translation files required by the page -$langs->loadLangs(array("banks","bills","categories","companies","margins","salaries","loan","donations","trips","members","compta","accountancy")); +$langs->loadLangs(array("banks", "bills", "categories", "companies", "margins", "salaries", "loan", "donations", "trips", "members", "compta", "accountancy")); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action=GETPOST('action', 'alpha'); -$cancel=GETPOST('cancel', 'alpha'); -$confirm=GETPOST('confirm', 'alpha'); -$contextpage='banktransactionlist'.(empty($object->ref)?'':'-'.$object->id); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); +$contextpage = 'banktransactionlist'.(empty($object->ref) ? '' : '-'.$object->id); // Security check -$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :'')); -$fieldtype = (! empty($ref) ? 'ref' :'rowid'); +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); if ($fielvalue) { - if ($user->socid) $socid=$user->socid; - $result=restrictedArea($user, 'banque', $fieldvalue, 'bank_account&bank_account', '', '', $fieldtype); + if ($user->socid) $socid = $user->socid; + $result = restrictedArea($user, 'banque', $fieldvalue, 'bank_account&bank_account', '', '', $fieldtype); } else { - if ($user->socid) $socid=$user->socid; - $result=restrictedArea($user, 'banque'); + if ($user->socid) $socid = $user->socid; + $result = restrictedArea($user, 'banque'); } $dateop = dol_mktime(12, 0, 0, GETPOST("opmonth", 'int'), GETPOST("opday", 'int'), GETPOST("opyear", 'int')); -$search_debit=GETPOST("search_debit", 'alpha'); -$search_credit=GETPOST("search_credit", 'alpha'); -$search_type=GETPOST("search_type", 'alpha'); -$search_account=GETPOST("search_account", 'int')?GETPOST("search_account", 'int'):GETPOST("account", 'int'); -$search_accountancy_code=GETPOST('search_accountancy_code', 'alpha')?GETPOST('search_accountancy_code', 'alpha'):GETPOST('accountancy_code', 'alpha'); -$search_bid=GETPOST("search_bid", "int")?GETPOST("search_bid", "int"):GETPOST("bid", "int"); -$search_ref=GETPOST('search_ref', 'alpha'); -$search_description=GETPOST("search_description", 'alpha'); +$search_debit = GETPOST("search_debit", 'alpha'); +$search_credit = GETPOST("search_credit", 'alpha'); +$search_type = GETPOST("search_type", 'alpha'); +$search_account = GETPOST("search_account", 'int') ?GETPOST("search_account", 'int') : GETPOST("account", 'int'); +$search_accountancy_code = GETPOST('search_accountancy_code', 'alpha') ?GETPOST('search_accountancy_code', 'alpha') : GETPOST('accountancy_code', 'alpha'); +$search_bid = GETPOST("search_bid", "int") ?GETPOST("search_bid", "int") : GETPOST("bid", "int"); +$search_ref = GETPOST('search_ref', 'alpha'); +$search_description = GETPOST("search_description", 'alpha'); $search_dt_start = dol_mktime(0, 0, 0, GETPOST('search_start_dtmonth', 'int'), GETPOST('search_start_dtday', 'int'), GETPOST('search_start_dtyear', 'int')); $search_dt_end = dol_mktime(0, 0, 0, GETPOST('search_end_dtmonth', 'int'), GETPOST('search_end_dtday', 'int'), GETPOST('search_end_dtyear', 'int')); $search_dv_start = dol_mktime(0, 0, 0, GETPOST('search_start_dvmonth', 'int'), GETPOST('search_start_dvday', 'int'), GETPOST('search_start_dvyear', 'int')); $search_dv_end = dol_mktime(0, 0, 0, GETPOST('search_end_dvmonth', 'int'), GETPOST('search_end_dvday', 'int'), GETPOST('search_end_dvyear', 'int')); -$search_thirdparty=GETPOST("search_thirdparty", 'alpha')?GETPOST("search_thirdparty", 'alpha'):GETPOST("thirdparty", 'alpha'); -$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"); -$cat=GETPOST("cat"); -if (empty($dateop)) $dateop=-1; +$search_thirdparty = GETPOST("search_thirdparty", 'alpha') ?GETPOST("search_thirdparty", 'alpha') : GETPOST("thirdparty", 'alpha'); +$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"); +$cat = GETPOST("cat"); +if (empty($dateop)) $dateop = -1; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -106,24 +106,24 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $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'; -$mode_balance_ok=false; +$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')) { $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; } $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 + $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')); @@ -138,9 +138,9 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label('banktransaction'); -$search_array_options=$extrafields->getOptionalsFromPost('banktransaction', '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost('banktransaction', '', 'search_'); -$arrayfields=array( +$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), @@ -148,21 +148,21 @@ $arrayfields=array( '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"), 'checked'=>1, 'position'=>500), - 'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>(($id > 0 || ! empty($ref))?0:1), 'position'=>1000), + '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), - 'b.conciliated'=>array('label'=>$langs->trans("Conciliated"), 'enabled'=> $object->rappro, 'checked'=>($action == 'reconcile'?1:0), 'position'=>1020), + 'b.conciliated'=>array('label'=>$langs->trans("Conciliated"), 'enabled'=> $object->rappro, 'checked'=>($action == 'reconcile' ? 1 : 0), 'position'=>1020), ); // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -174,41 +174,41 @@ $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 +$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'); 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 { - $search_dt_start=''; - $search_dt_end=''; - $search_dv_start=''; - $search_dv_end=''; - $search_type=""; - $search_debit=""; - $search_credit=""; - $search_bid=""; - $search_ref=""; - $search_req_nb=''; - $search_description=''; - $search_thirdparty=''; - $search_num_releve=''; - $search_conciliated=''; - $thirdparty=''; + $search_dt_start = ''; + $search_dt_end = ''; + $search_dv_start = ''; + $search_dv_end = ''; + $search_type = ""; + $search_debit = ""; + $search_credit = ""; + $search_bid = ""; + $search_ref = ""; + $search_req_nb = ''; + $search_description = ''; + $search_thirdparty = ''; + $search_num_releve = ''; + $search_conciliated = ''; + $thirdparty = ''; - $search_account=""; - if ($id > 0 || ! empty($ref)) $search_account=$object->id; + $search_account = ""; + if ($id > 0 || !empty($ref)) $search_account = $object->id; } if (empty($reshook)) { - $objectclass='Account'; - $objectlabel='BankTransaction'; + $objectclass = 'Account'; + $objectlabel = 'BankTransaction'; $permissiontoread = $user->rights->banque->lire; $permissiontodelete = $user->rights->banque->supprimer; $uploaddir = $conf->bank->dir_output; @@ -218,23 +218,23 @@ if (empty($reshook)) // Conciliation if ((GETPOST('confirm_savestatement', 'alpha') || GETPOST('confirm_reconcile', 'alpha')) && $user->rights->banque->consolidate) { - $error=0; + $error = 0; // Definition, nettoyage parametres - $num_releve=trim(GETPOST("num_releve", "alpha")); + $num_releve = trim(GETPOST("num_releve", "alpha")); if ($num_releve) { - $bankline=new AccountLine($db); + $bankline = new AccountLine($db); if (isset($_POST['rowid']) && is_array($_POST['rowid'])) { - foreach($_POST['rowid'] as $row) + foreach ($_POST['rowid'] as $row) { if ($row > 0) { - $result=$bankline->fetch($row); - $bankline->num_releve=$num_releve; //$_POST["num_releve"]; - $result=$bankline->update_conciliation($user, GETPOST("cat"), GETPOST('confirm_reconcile', 'alpha')?1:0); // If we confirm_reconcile, we set flag 'rappro' to 1. + $result = $bankline->fetch($row); + $bankline->num_releve = $num_releve; //$_POST["num_releve"]; + $result = $bankline->update_conciliation($user, GETPOST("cat"), GETPOST('confirm_reconcile', 'alpha') ? 1 : 0); // If we confirm_reconcile, we set flag 'rappro' to 1. if ($result < 0) { setEventMessages($bankline->error, $bankline->errors, 'errors'); @@ -258,30 +258,30 @@ 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) $param.='&search_thirdparty='.urlencode($search_thirdparty); - 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 + $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) $param .= '&search_thirdparty='.urlencode($search_thirdparty); + 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; } } -if (GETPOST('save') && ! $cancel && $user->rights->banque->modifier) +if (GETPOST('save') && !$cancel && $user->rights->banque->modifier) { $error = 0; @@ -302,23 +302,23 @@ if (GETPOST('save') && ! $cancel && $user->rights->banque->modifier) $bankaccountid = $id; if (GETPOST('add_account', 'int') > 0) $bankaccountid = GETPOST('add_account', 'int'); - if (! $dateop) { + if (!$dateop) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); } - if (! $operation) { + if (!$operation) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); } - if (! $label) { + if (!$label) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); } - if (! $amount) { + if (!$amount) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors'); } - if (! $bankaccountid > 0) + if (!$bankaccountid > 0) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors'); @@ -329,7 +329,7 @@ if (GETPOST('save') && ! $cancel && $user->rights->banque->modifier) $error++; }*/ - if (! $error && ! empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)) + if (!$error && !empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)) { $objecttmp = new Account($db); $objecttmp->fetch($bankaccountid); @@ -347,15 +347,15 @@ if (GETPOST('save') && ! $cancel && $user->rights->banque->modifier) } else { - $action='addline'; + $action = 'addline'; } } if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->modifier) { - $accline=new AccountLine($db); - $result=$accline->fetch(GETPOST("rowid")); - $result=$accline->delete($user); + $accline = new AccountLine($db); + $result = $accline->fetch(GETPOST("rowid")); + $result = $accline->delete($user); } @@ -368,52 +368,52 @@ $form = new Form($db); $formother = new FormOther($db); $formaccounting = new FormAccounting($db); -$companystatic=new Societe($db); -$bankaccountstatic=new Account($db); +$companystatic = new Societe($db); +$bankaccountstatic = new Account($db); -$banktransferstatic=new BonPrelevement($db); -$societestatic=new Societe($db); -$userstatic=new User($db); -$chargestatic=new ChargeSociales($db); -$loanstatic=new Loan($db); -$memberstatic=new Adherent($db); -$paymentstatic=new Paiement($db); -$paymentsupplierstatic=new PaiementFourn($db); -$paymentvatstatic=new TVA($db); -$paymentsalstatic=new PaymentSalary($db); -$paymentvariousstatic=new PaymentVarious($db); -$donstatic=new Don($db); -$paymentexpensereportstatic=new PaymentExpenseReport($db); -$bankstatic=new Account($db); -$banklinestatic=new AccountLine($db); +$banktransferstatic = new BonPrelevement($db); +$societestatic = new Societe($db); +$userstatic = new User($db); +$chargestatic = new ChargeSociales($db); +$loanstatic = new Loan($db); +$memberstatic = new Adherent($db); +$paymentstatic = new Paiement($db); +$paymentsupplierstatic = new PaiementFourn($db); +$paymentvatstatic = new TVA($db); +$paymentsalstatic = new PaymentSalary($db); +$paymentvariousstatic = new PaymentVarious($db); +$donstatic = new Don($db); +$paymentexpensereportstatic = new PaymentExpenseReport($db); +$bankstatic = new Account($db); +$banklinestatic = new AccountLine($db); $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)) $param.='&search_thirdparty='.urlencode($search_thirdparty); -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'; +$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)) $param .= '&search_thirdparty='.urlencode($search_thirdparty); +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'; @@ -421,7 +421,7 @@ $options = array(); $buttonreconcile = ''; -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $title = $langs->trans("FinancialAccount").' - '.$langs->trans("Transactions"); $helpurl = ""; @@ -436,7 +436,7 @@ if ($id > 0 || ! empty($ref)) } // Bank card - $head=bank_prepare_head($object); + $head = bank_prepare_head($object); dol_fiche_head($head, 'journal', $langs->trans("FinancialAccount"), 0, 'account'); $linkback = ''.$langs->trans("BackToList").''; @@ -471,43 +471,43 @@ else } $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro as conciliated, b.num_releve, b.num_chq,"; -$sql.= " b.fk_account, b.fk_type,"; -$sql.= " ba.rowid as bankid, ba.ref as bankref,"; -$sql.= " bu.url_id,"; -$sql.= " s.nom, s.name_alias, s.client, s.fournisseur, s.email, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; +$sql .= " b.fk_account, b.fk_type,"; +$sql .= " ba.rowid as bankid, ba.ref as bankref,"; +$sql .= " bu.url_id,"; +$sql .= " s.nom, s.name_alias, s.client, s.fournisseur, s.email, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; // 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 : ''); +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 : ''); } // 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,"; -$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)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND type = 'company'"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.rowid"; -$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; +$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,"; +$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)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND type = 'company'"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.rowid"; +$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; // 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 = ".$search_conciliated; -if ($search_thirdparty) $sql.= natural_search("s.nom", $search_thirdparty); +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 = ".$search_conciliated; +if ($search_thirdparty) $sql .= natural_search("s.nom", $search_thirdparty); if ($search_description) { $search_description_to_use = $search_description; - $arrayoffixedlabels=array( + $arrayoffixedlabels = array( 'payment_salary', 'CustomerInvoicePayment', 'CustomerInvoicePaymentBack', 'SupplierInvoicePayment', 'SupplierInvoicePaymentBack', @@ -517,32 +517,32 @@ if ($search_description) 'SubscriptionPayment', 'WithdrawalPayment' ); - foreach($arrayoffixedlabels as $keyforlabel) + foreach ($arrayoffixedlabels as $keyforlabel) { $translatedlabel = $langs->transnoentitiesnoconv($keyforlabel); if (preg_match('/'.$search_description.'/i', $translatedlabel)) { - $search_description_to_use.="|".$keyforlabel; + $search_description_to_use .= "|".$keyforlabel; } } - $sql.= natural_search("b.label", $search_description_to_use); // Warning some text are just translation keys, not translated strings + $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'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; $nbtotalofpages = 0; @@ -550,10 +550,10 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - $nbtotalofpages = ceil($nbtotalofrecords/$limit); + $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. @@ -564,22 +564,22 @@ if (($id > 0 || ! empty($ref)) && ((string) $page == '')) if ($page >= $nbtotalofpages) { // If we made a search and result has low page than the page number we were on - $page = ($nbtotalofpages -1); + $page = ($nbtotalofpages - 1); $offset = $limit * $page; 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($req_nb)) $mode_balance_ok=false; -if (! empty($search_type)) $mode_balance_ok=false; -if (! empty($debit)) $mode_balance_ok=false; -if (! empty($credit)) $mode_balance_ok=false; -if (! empty($thirdparty)) $mode_balance_ok=false; +if (!empty($search_ref)) $mode_balance_ok = false; +if (!empty($req_nb)) $mode_balance_ok = false; +if (!empty($search_type)) $mode_balance_ok = false; +if (!empty($debit)) $mode_balance_ok = false; +if (!empty($credit)) $mode_balance_ok = false; +if (!empty($thirdparty)) $mode_balance_ok = false; -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); //print $sql; dol_syslog('compta/bank/bankentries_list.php', LOG_DEBUG); $resql = $db->query($sql); @@ -587,21 +587,21 @@ if ($resql) { $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); // List of mass actions available - $arrayofmassactions = array( + $arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); //if ($user->rights->bank->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); - if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); // Confirmation delete if ($action == 'delete') { - $text=$langs->trans('ConfirmDeleteTransaction'); + $text = $langs->trans('ConfirmDeleteTransaction'); print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&rowid='.GETPOST("rowid"), $langs->trans('DeleteTransaction'), $text, 'confirm_delete', null, '', 1); } @@ -610,7 +610,7 @@ if ($resql) if ($optioncss != '') print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -624,7 +624,7 @@ if ($resql) { print '
'; print ''.$langs->trans("InputReceiptNumber").': '; - print ''; // The only default value is value we just entered + print ''; // The only default value is value we just entered print '
'; if (is_array($options) && count($options)) { @@ -640,31 +640,31 @@ if ($resql) print '
'; // Show last bank statements - $nbmax=15; // We accept to show last 15 receipts (so we can have more than one year) - $liste=""; + $nbmax = 15; // We accept to show last 15 receipts (so we can have more than one year) + $liste = ""; $sql = "SELECT DISTINCT num_releve FROM ".MAIN_DB_PREFIX."bank"; - $sql.= " WHERE fk_account=".$object->id." AND num_releve IS NOT NULL"; - $sql.= $db->order("num_releve", "DESC"); - $sql.= $db->plimit($nbmax+1); + $sql .= " WHERE fk_account=".$object->id." AND num_releve IS NOT NULL"; + $sql .= $db->order("num_releve", "DESC"); + $sql .= $db->plimit($nbmax + 1); print '
'; print $langs->trans("LastAccountStatements").' : '; - $resqlr=$db->query($sql); + $resqlr = $db->query($sql); if ($resqlr) { - $numr=$db->num_rows($resqlr); - $i=0; - $last_ok=0; + $numr = $db->num_rows($resqlr); + $i = 0; + $last_ok = 0; while (($i < $numr) && ($i < $nbmax)) { $objr = $db->fetch_object($resqlr); - if (! $last_ok) { + if (!$last_ok) { $last_releve = $objr->num_releve; - $last_ok=1; + $last_ok = 1; } $i++; - $liste=''.$objr->num_releve.'   '.$liste; + $liste = ''.$objr->num_releve.'   '.$liste; } - if ($numr >= $nbmax) $liste="...   ".$liste; + if ($numr >= $nbmax) $liste = "...   ".$liste; print $liste; if ($numr <= 0) print ''.$langs->trans("None").''; } @@ -674,11 +674,11 @@ if ($resql) } // 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 ' '; } @@ -686,7 +686,7 @@ if ($resql) } // Form to add a transaction with no invoice - if ($user->rights->banque->modifier && $action == 'addline' && ! empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)) + if ($user->rights->banque->modifier && $action == 'addline' && !empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)) { print load_fiche_titre($langs->trans("AddBankRecordLong"), '', ''); @@ -723,11 +723,11 @@ if ($resql) } print ''; print ''; - print $form->selectDate(empty($dateop)?-1:$dateop, 'op', 0, 0, 0, 'transaction'); + print $form->selectDate(empty($dateop) ?-1 : $dateop, 'op', 0, 0, 0, 'transaction'); print ''; print ' '; print ''; - $form->select_types_paiements((GETPOST('operation')?GETPOST('operation'):($object->courant == Account::TYPE_CASH ? 'LIQ' : '')), 'operation', '1,2', 2, 1); + $form->select_types_paiements((GETPOST('operation') ?GETPOST('operation') : ($object->courant == Account::TYPE_CASH ? 'LIQ' : '')), 'operation', '1,2', 2, 1); print ''; print ''; print ''; @@ -735,7 +735,7 @@ if ($resql) //if (! $search_account > 0) //{ print ''; - $form->select_comptes(GETPOST('add_account', 'int')?GETPOST('add_account', 'int'):$search_account, 'add_account', 0, '', 1, ($id > 0 || ! empty($ref)?' disabled="disabled"':'')); + $form->select_comptes(GETPOST('add_account', 'int') ?GETPOST('add_account', 'int') : $search_account, 'add_account', 0, '', 1, ($id > 0 || !empty($ref) ? ' disabled="disabled"' : '')); print ''; //} print ''; @@ -778,7 +778,7 @@ if ($resql) $i = 0; // Title - $bankcateg=new BankCateg($db); + $bankcateg = new BankCateg($db); $newcardbutton = ''; if ($action != 'addline' && $action != 'reconcile') @@ -800,63 +800,63 @@ if ($resql) } } - $morehtml='
'; - $morehtml.= ' "; // ' Page '; - $morehtml.=''; - $morehtml.='/'.$nbtotalofpages.' '; - $morehtml.='
'; + $morehtml = '
'; + $morehtml .= ' "; // ' Page '; + $morehtml .= ''; + $morehtml .= '/'.$nbtotalofpages.' '; + $morehtml .= '
'; if ($action != 'addline' && $action != 'reconcile') { - $morehtml.=$buttonreconcile; + $morehtml .= $buttonreconcile; } - $morehtml.=$newcardbutton; + $morehtml .= $newcardbutton; - $picto='title_bank'; - if ($id > 0 || ! empty($ref)) $picto=''; + $picto = 'title_bank'; + if ($id > 0 || !empty($ref)) $picto = ''; print_barre_liste($langs->trans("BankTransactions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $morehtml, '', $limit); // We can add page now to param - if ($page != '') $param.='&page='.urlencode($page); + if ($page != '') $param .= '&page='.urlencode($page); $moreforfilter = ''; - $moreforfilter.='
'; + $moreforfilter .= '
'; $moreforfilter .= $langs->trans('DateOperationShort').' : '; - $moreforfilter .= '
'.$langs->trans('From') . ' '; + $moreforfilter .= '
'.$langs->trans('From').' '; $moreforfilter .= $form->selectDate($search_dt_start, 'search_start_dt', 0, 0, 1, "search_form", 1, 0).'
'; //$moreforfilter .= ' - '; - $moreforfilter .= '
'.$langs->trans('to') . ' ' . $form->selectDate($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0).'
'; + $moreforfilter .= '
'.$langs->trans('to').' '.$form->selectDate($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0).'
'; $moreforfilter .= '
'; - $moreforfilter.='
'; + $moreforfilter .= '
'; $moreforfilter .= $langs->trans('DateValueShort').' : '; - $moreforfilter .= '
'.$langs->trans('From') . ' '; + $moreforfilter .= '
'.$langs->trans('From').' '; $moreforfilter .= $form->selectDate($search_dv_start, 'search_start_dv', 0, 0, 1, "search_form", 1, 0).'
'; //$moreforfilter .= ' - '; - $moreforfilter .= '
'.$langs->trans('to') . ' ' . $form->selectDate($search_dv_end, 'search_end_dv', 0, 0, 1, "search_form", 1, 0).'
'; + $moreforfilter .= '
'.$langs->trans('to').' '.$form->selectDate($search_dv_end, 'search_end_dv', 0, 0, 1, "search_form", 1, 0).'
'; $moreforfilter .= '
'; - if (! empty($conf->categorie->enabled)) + if (!empty($conf->categorie->enabled)) { // Categories - if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { $langs->load('categories'); // Bank line - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('RubriquesTransactions').' : '; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('RubriquesTransactions').' : '; $cate_arbo = $form->select_all_categories(Categorie::TYPE_BANK_LINE, $search_bid, 'parent', null, null, 1); - $moreforfilter.=$form->selectarray('search_bid', $cate_arbo, $search_bid, 1); - $moreforfilter.='
'; + $moreforfilter .= $form->selectarray('search_bid', $cate_arbo, $search_bid, 1); + $moreforfilter .= '
'; } } - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; @@ -957,39 +957,39 @@ if ($resql) print ''; print ''; print ''; - $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); + $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); print $searchpicto; print ''; print "\n"; // Fields title print ''; - if (! empty($arrayfields['b.rowid']['checked'])) print_liste_field_titre($arrayfields['b.rowid']['label'], $_SERVER['PHP_SELF'], 'b.rowid', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['b.label']['checked'])) print_liste_field_titre($arrayfields['b.label']['label'], $_SERVER['PHP_SELF'], 'b.label', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['b.dateo']['checked'])) print_liste_field_titre($arrayfields['b.dateo']['label'], $_SERVER['PHP_SELF'], 'b.dateo', '', $param, '', $sortfield, $sortorder, "center "); - if (! empty($arrayfields['b.datev']['checked'])) print_liste_field_titre($arrayfields['b.datev']['label'], $_SERVER['PHP_SELF'], 'b.datev,b.dateo,b.rowid', '', $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['type']['checked'])) print_liste_field_titre($arrayfields['type']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['b.num_chq']['checked'])) print_liste_field_titre($arrayfields['b.num_chq']['label'], $_SERVER['PHP_SELF'], 'b.num_chq', '', $param, '', $sortfield, $sortorder, "center "); - if (! empty($arrayfields['bu.label']['checked'])) print_liste_field_titre($arrayfields['bu.label']['label'], $_SERVER['PHP_SELF'], 'bu.label', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['ba.ref']['checked'])) print_liste_field_titre($arrayfields['ba.ref']['label'], $_SERVER['PHP_SELF'], 'ba.ref', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['b.debit']['checked'])) print_liste_field_titre($arrayfields['b.debit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, '', $sortfield, $sortorder, "right "); - if (! empty($arrayfields['b.credit']['checked'])) print_liste_field_titre($arrayfields['b.credit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, '', $sortfield, $sortorder, "right "); - if (! empty($arrayfields['balancebefore']['checked'])) print_liste_field_titre($arrayfields['balancebefore']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, "right "); - if (! empty($arrayfields['balance']['checked'])) print_liste_field_titre($arrayfields['balance']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, "right "); - if (! empty($arrayfields['b.num_releve']['checked'])) print_liste_field_titre($arrayfields['b.num_releve']['label'], $_SERVER['PHP_SELF'], 'b.num_releve', '', $param, '', $sortfield, $sortorder, "center "); - if (! empty($arrayfields['b.conciliated']['checked'])) print_liste_field_titre($arrayfields['b.conciliated']['label'], $_SERVER['PHP_SELF'], 'b.rappro', '', $param, '', $sortfield, $sortorder, "center "); + if (!empty($arrayfields['b.rowid']['checked'])) print_liste_field_titre($arrayfields['b.rowid']['label'], $_SERVER['PHP_SELF'], 'b.rowid', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['b.label']['checked'])) print_liste_field_titre($arrayfields['b.label']['label'], $_SERVER['PHP_SELF'], 'b.label', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['b.dateo']['checked'])) print_liste_field_titre($arrayfields['b.dateo']['label'], $_SERVER['PHP_SELF'], 'b.dateo', '', $param, '', $sortfield, $sortorder, "center "); + if (!empty($arrayfields['b.datev']['checked'])) print_liste_field_titre($arrayfields['b.datev']['label'], $_SERVER['PHP_SELF'], 'b.datev,b.dateo,b.rowid', '', $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['type']['checked'])) print_liste_field_titre($arrayfields['type']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['b.num_chq']['checked'])) print_liste_field_titre($arrayfields['b.num_chq']['label'], $_SERVER['PHP_SELF'], 'b.num_chq', '', $param, '', $sortfield, $sortorder, "center "); + if (!empty($arrayfields['bu.label']['checked'])) print_liste_field_titre($arrayfields['bu.label']['label'], $_SERVER['PHP_SELF'], 'bu.label', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['ba.ref']['checked'])) print_liste_field_titre($arrayfields['ba.ref']['label'], $_SERVER['PHP_SELF'], 'ba.ref', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['b.debit']['checked'])) print_liste_field_titre($arrayfields['b.debit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, '', $sortfield, $sortorder, "right "); + if (!empty($arrayfields['b.credit']['checked'])) print_liste_field_titre($arrayfields['b.credit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, '', $sortfield, $sortorder, "right "); + if (!empty($arrayfields['balancebefore']['checked'])) print_liste_field_titre($arrayfields['balancebefore']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, "right "); + if (!empty($arrayfields['balance']['checked'])) print_liste_field_titre($arrayfields['balance']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, "right "); + if (!empty($arrayfields['b.num_releve']['checked'])) print_liste_field_titre($arrayfields['b.num_releve']['label'], $_SERVER['PHP_SELF'], 'b.num_releve', '', $param, '', $sortfield, $sortorder, "center "); + if (!empty($arrayfields['b.conciliated']['checked'])) print_liste_field_titre($arrayfields['b.conciliated']['label'], $_SERVER['PHP_SELF'], 'b.rappro', '', $param, '', $sortfield, $sortorder, "center "); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', 'class="right"', $sortfield, $sortorder, 'maxwidthsearch '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; - $balance = 0; // For balance - $balancebefore = 0; // For balance + $balance = 0; // For balance + $balancebefore = 0; // For balance $balancecalculated = false; $posconciliatecol = 0; $cachebankaccount = array(); @@ -997,15 +997,15 @@ if ($resql) // Loop on each record $sign = 1; - $totalarray=array(); + $totalarray = array(); while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); // If we are in a situation where we need/can show balance, we calculate the start of balance - if (! $balancecalculated && (! empty($arrayfields['balancebefore']['checked']) || ! empty($arrayfields['balance']['checked'])) && $mode_balance_ok) + if (!$balancecalculated && (!empty($arrayfields['balancebefore']['checked']) || !empty($arrayfields['balance']['checked'])) && $mode_balance_ok) { - if (! $search_account) + if (!$search_account) { dol_print_error('', 'account is not defined but $mode_balance_ok is true'); exit; @@ -1014,14 +1014,14 @@ if ($resql) // Loop on each record before $sign = 1; $i = 0; - $sqlforbalance='SELECT SUM(b.amount) as previoustotal'; - $sqlforbalance.= " FROM "; - $sqlforbalance.= " ".MAIN_DB_PREFIX."bank_account as ba,"; - $sqlforbalance.= " ".MAIN_DB_PREFIX."bank as b"; - $sqlforbalance.= " WHERE b.fk_account = ba.rowid"; - $sqlforbalance.= " AND ba.entity IN (".getEntity('bank_account').")"; - $sqlforbalance.= " AND b.fk_account = ".$search_account; - $sqlforbalance.= " AND (b.datev < '" . $db->idate($db->jdate($objp->dv)) . "' OR (b.datev = '" . $db->idate($db->jdate($objp->dv)) . "' AND (b.dateo < '".$db->idate($db->jdate($objp->do))."' OR (b.dateo = '".$db->idate($db->jdate($objp->do))."' AND b.rowid < ".$objp->rowid."))))"; + $sqlforbalance = 'SELECT SUM(b.amount) as previoustotal'; + $sqlforbalance .= " FROM "; + $sqlforbalance .= " ".MAIN_DB_PREFIX."bank_account as ba,"; + $sqlforbalance .= " ".MAIN_DB_PREFIX."bank as b"; + $sqlforbalance .= " WHERE b.fk_account = ba.rowid"; + $sqlforbalance .= " AND ba.entity IN (".getEntity('bank_account').")"; + $sqlforbalance .= " AND b.fk_account = ".$search_account; + $sqlforbalance .= " AND (b.datev < '".$db->idate($db->jdate($objp->dv))."' OR (b.datev = '".$db->idate($db->jdate($objp->dv))."' AND (b.dateo < '".$db->idate($db->jdate($objp->do))."' OR (b.dateo = '".$db->idate($db->jdate($objp->do))."' AND b.rowid < ".$objp->rowid."))))"; $resqlforbalance = $db->query($sqlforbalance); //print $sqlforbalance; if ($resqlforbalance) @@ -1043,24 +1043,24 @@ if ($resql) } else dol_print_error($db); - $balancecalculated=true; + $balancecalculated = true; // Output a line with start balance if ($user->rights->banque->consolidate && $action == 'reconcile') { - $tmpnbfieldbeforebalance=0; - $tmpnbfieldafterbalance=0; - $balancefieldfound=0; - foreach($arrayfields as $key => $val) + $tmpnbfieldbeforebalance = 0; + $tmpnbfieldafterbalance = 0; + $balancefieldfound = 0; + foreach ($arrayfields as $key => $val) { if ($key == 'balancebefore' || $key == 'balance') { $balancefieldfound++; continue; } - if (! empty($arrayfields[$key]['checked'])) + if (!empty($arrayfields[$key]['checked'])) { - if (! $balancefieldfound) $tmpnbfieldbeforebalance++; + if (!$balancefieldfound) $tmpnbfieldbeforebalance++; else $tmpnbfieldafterbalance++; } } @@ -1068,13 +1068,13 @@ if ($resql) $element = 'banktransaction'; if (is_array($extrafields->attributes[$element]['label']) && count($extrafields->attributes[$element]['label'])) { - foreach($extrafields->attributes[$element]['label'] as $key => $val) + foreach ($extrafields->attributes[$element]['label'] as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) + if (!empty($arrayfields["ef.".$key]['checked'])) { - if (! empty($arrayfields[$key]['checked'])) + if (!empty($arrayfields[$key]['checked'])) { - if (! $balancefieldfound) $tmpnbfieldbeforebalance++; + if (!$balancefieldfound) $tmpnbfieldbeforebalance++; else $tmpnbfieldafterbalance++; } } @@ -1089,13 +1089,13 @@ if ($resql) print ''; } - if (! empty($arrayfields['balancebefore']['checked'])) + if (!empty($arrayfields['balancebefore']['checked'])) { print ''; print price(price2num($balance, 'MT'), 1, $langs); print ''; } - if (! empty($arrayfields['balance']['checked'])) + if (!empty($arrayfields['balance']['checked'])) { print ''; print price(price2num($balance, 'MT'), 1, $langs); @@ -1120,12 +1120,12 @@ if ($resql) if ($sortfield == 'b.datev,b.dateo,b.rowid' && $sortorder == 'desc,desc,desc') { - $balance = price2num($balancebefore, 'MT'); // balance = balancebefore of previous line (sort is desc) + $balance = price2num($balancebefore, 'MT'); // balance = balancebefore of previous line (sort is desc) $balancebefore = price2num($balancebefore - ($sign * $objp->amount), 'MT'); } else { - $balancebefore = price2num($balance, 'MT'); // balancebefore = balance of previous line (sort is asc) + $balancebefore = price2num($balance, 'MT'); // balancebefore = balance of previous line (sort is asc) $balance = price2num($balance + ($sign * $objp->amount), 'MT'); } @@ -1133,7 +1133,7 @@ if ($resql) { $bankaccounttmp = new Account($db); $bankaccounttmp->fetch($objp->bankid); - $cachebankaccount[$objp->bankid]=$bankaccounttmp; + $cachebankaccount[$objp->bankid] = $bankaccounttmp; $bankaccount = $bankaccounttmp; } else @@ -1149,159 +1149,159 @@ if ($resql) if (empty($conf->global->BANK_COLORIZE_MOVEMENT_COLOR1)) { $color = '#fca955'; } else { - $color = '#' . $conf->global->BANK_COLORIZE_MOVEMENT_COLOR1; + $color = '#'.$conf->global->BANK_COLORIZE_MOVEMENT_COLOR1; } - $backgroundcolor = 'style="background-color: ' . $color . ';"'; + $backgroundcolor = 'style="background-color: '.$color.';"'; } else { if (empty($conf->global->BANK_COLORIZE_MOVEMENT_COLOR2)) { $color = '#7fdb86'; } else { - $color = '#' . $conf->global->BANK_COLORIZE_MOVEMENT_COLOR2; + $color = '#'.$conf->global->BANK_COLORIZE_MOVEMENT_COLOR2; } - $backgroundcolor = 'style="background-color: ' . $color . ';"'; + $backgroundcolor = 'style="background-color: '.$color.';"'; } } print ''; // Ref - if (! empty($arrayfields['b.rowid']['checked'])) + if (!empty($arrayfields['b.rowid']['checked'])) { print ''; print "rowid.'&save_lastsearch_values=1">'.img_object($langs->trans("ShowPayment").': '.$objp->rowid, 'account', 'class="classfortooltip"').' '.$objp->rowid."   "; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Description - if (! empty($arrayfields['b.label']['checked'])) + if (!empty($arrayfields['b.label']['checked'])) { print ""; //print "rowid."&account=".$objp->fk_account."\">"; - $reg=array(); - preg_match('/\((.+)\)/i', $objp->label, $reg); // Si texte entoure de parenthee on tente recherche de traduction - if ($reg[1] && $langs->trans($reg[1])!=$reg[1]) print $langs->trans($reg[1]); + $reg = array(); + preg_match('/\((.+)\)/i', $objp->label, $reg); // Si texte entoure de parenthee on tente recherche de traduction + if ($reg[1] && $langs->trans($reg[1]) != $reg[1]) print $langs->trans($reg[1]); else print dol_trunc($objp->label, 40); //print " "; // Add links after description $links = $bankaccountstatic->get_url($objp->rowid); - $cachebankaccount=array(); - foreach($links as $key=>$val) + $cachebankaccount = array(); + foreach ($links as $key=>$val) { - if ($links[$key]['type']=='withdraw') + if ($links[$key]['type'] == 'withdraw') { - $banktransferstatic->id=$links[$key]['url_id']; - $banktransferstatic->ref=$links[$key]['label']; + $banktransferstatic->id = $links[$key]['url_id']; + $banktransferstatic->ref = $links[$key]['label']; print ' '.$banktransferstatic->getNomUrl(0); } - elseif ($links[$key]['type']=='payment') + elseif ($links[$key]['type'] == 'payment') { - $paymentstatic->id=$links[$key]['url_id']; - $paymentstatic->ref=$links[$key]['url_id']; // FIXME This is id, not ref of payment + $paymentstatic->id = $links[$key]['url_id']; + $paymentstatic->ref = $links[$key]['url_id']; // FIXME This is id, not ref of payment print ' '.$paymentstatic->getNomUrl(2); } - elseif ($links[$key]['type']=='payment_supplier') + elseif ($links[$key]['type'] == 'payment_supplier') { - $paymentsupplierstatic->id=$links[$key]['url_id']; - $paymentsupplierstatic->ref=$links[$key]['url_id']; // FIXME This is id, not ref of payment + $paymentsupplierstatic->id = $links[$key]['url_id']; + $paymentsupplierstatic->ref = $links[$key]['url_id']; // FIXME This is id, not ref of payment print ' '.$paymentsupplierstatic->getNomUrl(2); } - elseif ($links[$key]['type']=='payment_sc') + elseif ($links[$key]['type'] == 'payment_sc') { print ''; print ' '.img_object($langs->trans('ShowPayment'), 'payment').' '; //print $langs->trans("SocialContributionPayment"); print ''; } - elseif ($links[$key]['type']=='payment_vat') + elseif ($links[$key]['type'] == 'payment_vat') { - $paymentvatstatic->id=$links[$key]['url_id']; - $paymentvatstatic->ref=$links[$key]['url_id']; + $paymentvatstatic->id = $links[$key]['url_id']; + $paymentvatstatic->ref = $links[$key]['url_id']; print ' '.$paymentvatstatic->getNomUrl(2); } - elseif ($links[$key]['type']=='payment_salary') + elseif ($links[$key]['type'] == 'payment_salary') { - $paymentsalstatic->id=$links[$key]['url_id']; - $paymentsalstatic->ref=$links[$key]['url_id']; + $paymentsalstatic->id = $links[$key]['url_id']; + $paymentsalstatic->ref = $links[$key]['url_id']; print ' '.$paymentsalstatic->getNomUrl(2); } - elseif ($links[$key]['type']=='payment_loan') + elseif ($links[$key]['type'] == 'payment_loan') { print ''; print ' '.img_object($langs->trans('ShowPayment'), 'payment').' '; print ''; } - elseif ($links[$key]['type']=='payment_donation') + elseif ($links[$key]['type'] == 'payment_donation') { print ''; print ' '.img_object($langs->trans('ShowPayment'), 'payment').' '; print ''; } - elseif ($links[$key]['type']=='payment_expensereport') + elseif ($links[$key]['type'] == 'payment_expensereport') { - $paymentexpensereportstatic->id=$links[$key]['url_id']; - $paymentexpensereportstatic->ref=$links[$key]['url_id']; + $paymentexpensereportstatic->id = $links[$key]['url_id']; + $paymentexpensereportstatic->ref = $links[$key]['url_id']; print ' '.$paymentexpensereportstatic->getNomUrl(2); } - elseif ($links[$key]['type']=='payment_various') + elseif ($links[$key]['type'] == 'payment_various') { - $paymentvariousstatic->id=$links[$key]['url_id']; - $paymentvariousstatic->ref=$links[$key]['url_id']; + $paymentvariousstatic->id = $links[$key]['url_id']; + $paymentvariousstatic->ref = $links[$key]['url_id']; print ' '.$paymentvariousstatic->getNomUrl(2); } - elseif ($links[$key]['type']=='banktransfert') + elseif ($links[$key]['type'] == 'banktransfert') { // Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail. if ($objp->amount > 0) { $banklinestatic->fetch($links[$key]['url_id']); - $bankstatic->id=$banklinestatic->fk_account; - $bankstatic->label=$banklinestatic->bank_account_ref; + $bankstatic->id = $banklinestatic->fk_account; + $bankstatic->label = $banklinestatic->bank_account_ref; print ' ('.$langs->trans("TransferFrom").' '; print $bankstatic->getNomUrl(1, 'transactions'); print ' '.$langs->trans("toward").' '; - $bankstatic->id=$objp->bankid; - $bankstatic->label=$objp->bankref; + $bankstatic->id = $objp->bankid; + $bankstatic->label = $objp->bankref; print $bankstatic->getNomUrl(1, ''); print ')'; } else { - $bankstatic->id=$objp->bankid; - $bankstatic->label=$objp->bankref; + $bankstatic->id = $objp->bankid; + $bankstatic->label = $objp->bankref; print ' ('.$langs->trans("TransferFrom").' '; print $bankstatic->getNomUrl(1, ''); print ' '.$langs->trans("toward").' '; $banklinestatic->fetch($links[$key]['url_id']); - $bankstatic->id=$banklinestatic->fk_account; - $bankstatic->label=$banklinestatic->bank_account_ref; + $bankstatic->id = $banklinestatic->fk_account; + $bankstatic->label = $banklinestatic->bank_account_ref; print $bankstatic->getNomUrl(1, 'transactions'); print ')'; } //var_dump($links); } - elseif ($links[$key]['type']=='company') + elseif ($links[$key]['type'] == 'company') { } - elseif ($links[$key]['type']=='user') + elseif ($links[$key]['type'] == 'user') { } - elseif ($links[$key]['type']=='member') + elseif ($links[$key]['type'] == 'member') { } - elseif ($links[$key]['type']=='sc') + elseif ($links[$key]['type'] == 'sc') { } else { // Show link with label $links[$key]['label'] - if (! empty($objp->label) && ! empty($links[$key]['label'])) print ' - '; + if (!empty($objp->label) && !empty($links[$key]['label'])) print ' - '; print ''; if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) { // Label generique car entre parentheses. On l'affiche en le traduisant - if ($reg[1]=='paiement') $reg[1]='Payment'; + if ($reg[1] == 'paiement') $reg[1] = 'Payment'; print ' '.$langs->trans($reg[1]); } else @@ -1312,75 +1312,75 @@ if ($resql) } } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date ope - if (! empty($arrayfields['b.dateo']['checked'])) + if (!empty($arrayfields['b.dateo']['checked'])) { print ''; print ''.dol_print_date($db->jdate($objp->do), "day").""; print ' '; print ''; print ''; - print img_edit_remove() . " "; + print img_edit_remove()." "; print ''; - print img_edit_add() .""; + print img_edit_add().""; print ''; print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date value - if (! empty($arrayfields['b.datev']['checked'])) + if (!empty($arrayfields['b.datev']['checked'])) { print ''; print ''.dol_print_date($db->jdate($objp->dv), "day").""; print ' '; print ''; print ''; - print img_edit_remove() . " "; + print img_edit_remove()." "; print ''; - print img_edit_add() .""; + print img_edit_add().""; print ''; print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Payment type - if (! empty($arrayfields['type']['checked'])) + if (!empty($arrayfields['type']['checked'])) { print ''; - $labeltype=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$langs->getLabelFromKey($db, $objp->fk_type, 'c_paiement', 'code', 'libelle', '', 1); + $labeltype = ($langs->trans("PaymentTypeShort".$objp->fk_type) != "PaymentTypeShort".$objp->fk_type) ? $langs->trans("PaymentTypeShort".$objp->fk_type) : $langs->getLabelFromKey($db, $objp->fk_type, 'c_paiement', 'code', 'libelle', '', 1); if ($labeltype == 'SOLD') print ' '; //$langs->trans("InitialBankBalance"); else print $labeltype; print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Num cheque - if (! empty($arrayfields['b.num_chq']['checked'])) + if (!empty($arrayfields['b.num_chq']['checked'])) { - print ''.($objp->num_chq?$objp->num_chq:"")."\n"; - if (! $i) $totalarray['nbfield']++; + print ''.($objp->num_chq ? $objp->num_chq : "")."\n"; + if (!$i) $totalarray['nbfield']++; } // Third party - if (! empty($arrayfields['bu.label']['checked'])) + if (!empty($arrayfields['bu.label']['checked'])) { print ""; if ($objp->url_id) { - $companystatic->id=$objp->url_id; - $companystatic->name=$objp->nom; - $companystatic->name_alias=$objp->name_alias; - $companystatic->client=$objp->client; - $companystatic->email=$objp->email; - $companystatic->fournisseur=$objp->fournisseur; - $companystatic->code_client=$objp->code_client; - $companystatic->code_fournisseur=$objp->code_fournisseur; - $companystatic->code_compta=$objp->code_compta; - $companystatic->code_compta_fournisseur=$objp->code_compta_fournisseur; + $companystatic->id = $objp->url_id; + $companystatic->name = $objp->nom; + $companystatic->name_alias = $objp->name_alias; + $companystatic->client = $objp->client; + $companystatic->email = $objp->email; + $companystatic->fournisseur = $objp->fournisseur; + $companystatic->code_client = $objp->code_client; + $companystatic->code_fournisseur = $objp->code_fournisseur; + $companystatic->code_compta = $objp->code_compta; + $companystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; print $companystatic->getNomUrl(1); } else @@ -1388,20 +1388,20 @@ if ($resql) print ' '; } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Bank account - if (! empty($arrayfields['ba.ref']['checked'])) + if (!empty($arrayfields['ba.ref']['checked'])) { print ''; print $bankaccount->getNomUrl(1); print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Debit - if (! empty($arrayfields['b.debit']['checked'])) + if (!empty($arrayfields['b.debit']['checked'])) { print ''; if ($objp->amount < 0) @@ -1410,12 +1410,12 @@ if ($resql) $totalarray['totaldeb'] += $objp->amount; } print "\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totaldebfield']=$totalarray['nbfield']; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['totaldebfield'] = $totalarray['nbfield']; } // Credit - if (! empty($arrayfields['b.credit']['checked'])) + if (!empty($arrayfields['b.credit']['checked'])) { print ''; if ($objp->amount > 0) @@ -1424,12 +1424,12 @@ if ($resql) $totalarray['totalcred'] += $objp->amount; } print "\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totalcredfield']=$totalarray['nbfield']; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['totalcredfield'] = $totalarray['nbfield']; } // Balance before - if (! empty($arrayfields['balancebefore']['checked'])) + if (!empty($arrayfields['balancebefore']['checked'])) { if ($mode_balance_ok) { @@ -1446,10 +1446,10 @@ if ($resql) { print '-'; } - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Balance - if (! empty($arrayfields['balance']['checked'])) + if (!empty($arrayfields['balance']['checked'])) { if ($mode_balance_ok) { @@ -1466,10 +1466,10 @@ if ($resql) { print '-'; } - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['b.num_releve']['checked'])) + if (!empty($arrayfields['b.num_releve']['checked'])) { print ''; // Transaction reconciliated or edit link @@ -1479,26 +1479,26 @@ if ($resql) { print ''.$objp->num_releve.''; } - if (! $objp->conciliated && $action == 'reconcile') + if (!$objp->conciliated && $action == 'reconcile') { if ($objp->num_releve) print ' '; - print 'rowid])?' checked':'').'>'; + print 'rowid]) ? ' checked' : '').'>'; } } print ''; - if (! $i) + if (!$i) { $totalarray['nbfield']++; $posconciliatecol = $totalarray['nbfield']; } } - if (! empty($arrayfields['b.conciliated']['checked'])) + if (!empty($arrayfields['b.conciliated']['checked'])) { print ''; - print $objp->conciliated?$langs->trans("Yes"):$langs->trans("No"); + print $objp->conciliated ? $langs->trans("Yes") : $langs->trans("No"); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Action edit/delete @@ -1539,18 +1539,18 @@ if ($resql) } } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Action column print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print ""; @@ -1561,7 +1561,7 @@ if ($resql) if (isset($totalarray['totaldebfield']) || isset($totalarray['totalcredfield'])) { print ''; - $i=0; + $i = 0; while ($i < $totalarray['nbfield']) { $i++; @@ -1575,7 +1575,7 @@ if ($resql) elseif ($i == $posconciliatecol) { print ''; - if ($user->rights->banque->consolidate && $action == 'reconcile') print ''; + if ($user->rights->banque->consolidate && $action == 'reconcile') print ''; print ''; } else print ''; @@ -1586,9 +1586,9 @@ if ($resql) // If no record found if ($num == 0) { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } - print ''.$langs->trans("NoRecordFound").''; + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } + print ''.$langs->trans("NoRecordFound").''; } print ""; diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php index 7a40d6638ee..c32c11226dd 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_list.php +++ b/htdocs/compta/cashcontrol/cashcontrol_list.php @@ -47,22 +47,22 @@ 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("banks","other")); +$langs->loadLangs(array("banks", "other")); -$action = GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... -$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) -$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? -$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation -$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button -$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'cashcontrol'; // To manage different context of search -$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'cashcontrol'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -74,22 +74,22 @@ $pagenext = $page + 1; //if (! $sortorder) $sortorder="DESC"; // Initialize technical objects -$object=new CashControl($db); +$object = new CashControl($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->monmodule->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('cashcontrol')); // Note that conf->hooks_modules contains array +$diroutputmassaction = $conf->monmodule->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('cashcontrol')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. +if (!$sortorder) $sortorder = "ASC"; // Security check -$socid=0; +$socid = 0; if ($user->socid > 0) // Protection if external user { //$socid = $user->socid; @@ -98,34 +98,34 @@ if ($user->socid > 0) // Protection if external user //$result = restrictedArea($user, 'monmodule', $id, ''); // Initialize array of search criterias -$search_all=trim(GETPOST("search_all", 'alpha')); -$search=array(); -foreach($object->fields as $key => $val) +$search_all = trim(GETPOST("search_all", 'alpha')); +$search = array(); +foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; + if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; } // Definition of fields for list -$arrayfields=array(); -foreach($object->fields as $key => $val) +$arrayfields = array(); +foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); } // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -137,11 +137,11 @@ $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 +$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)) @@ -150,24 +150,24 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - 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 { - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $search[$key]=''; + $search[$key] = ''; } - $toselect=''; - $search_array_options=array(); + $toselect = ''; + $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { - $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='CashControl'; - $objectlabel='CashControl'; + $objectclass = 'CashControl'; + $objectlabel = 'CashControl'; $permissiontoread = ($user->rights->cashdesk->use || $user->rights->takepos->use); $permissiontodelete = ($user->rights->cashdesk->use || $user->rights->takepos->use); @@ -181,49 +181,49 @@ if (empty($reshook)) * View */ -$form=new Form($db); +$form = new Form($db); -$now=dol_now(); +$now = dol_now(); //$help_url="EN:Module_pos_cash_fence|FR:Module_pos_cash_fence_FR|ES:Módulo_pos_cash_fence"; -$help_url=''; +$help_url = ''; $title = $langs->trans('CashControl'); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $sql.='t.'.$key.', '; + $sql .= 't.'.$key.', '; } // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) +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, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/, $/', '', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -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 (t.rowid = ef.fk_object)"; -if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity($object->element).")"; -else $sql.=" WHERE 1 = 1"; -foreach($search as $key => $val) +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql = preg_replace('/, $/', '', $sql); +$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +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 (t.rowid = ef.fk_object)"; +if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; +else $sql .= " WHERE 1 = 1"; +foreach ($search as $key => $val) { if ($key == 'status' && $search[$key] == -1) continue; - $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); - if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); } -if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; /* If a group by is required $sql.= " GROUP BY " @@ -241,7 +241,7 @@ $sql.=$hookmanager->resPrint; $sql=preg_replace('/, $/','', $sql); */ -$sql.=$db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -262,10 +262,10 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) } else { - $sql.= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); - $resql=$db->query($sql); - if (! $resql) + $resql = $db->query($sql); + if (!$resql) { dol_print_error($db); exit; @@ -275,7 +275,7 @@ else } // Direct jump if only one record found -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -304,27 +304,27 @@ jQuery(document).ready(function() { }); '; -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); -foreach($search as $key => $val) +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +foreach ($search as $key => $val) { - $param.= '&search_'.$key.'='.urlencode($search[$key]); + $param .= '&search_'.$key.'='.urlencode($search[$key]); } -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); //if ($user->rights->monmodule->delete) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '
'; if ($optioncss != '') print ''; @@ -343,16 +343,16 @@ $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle' print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'cash-register', 0, $newcardbutton, '', $limit); // Add code for pre mass action (confirmation or email presend form) -$topicmail="SendCashControlRef"; -$modelmail="cashcontrol"; -$objecttmp=new CashControl($db); -$trackid='xxxx'.$object->id; +$topicmail = "SendCashControlRef"; +$modelmail = "cashcontrol"; +$objecttmp = new CashControl($db); +$trackid = 'xxxx'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } $moreforfilter = ''; @@ -360,39 +360,39 @@ $moreforfilter = ''; $moreforfilter.= $langs->trans('MyFilter') . ': '; $moreforfilter.= '
';*/ -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '
'; print $moreforfilter; print '
'; } -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); -print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print ''."\n"; +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '
'."\n"; // Fields title search // -------------------------------------------------------------------- print ''; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; @@ -402,12 +402,12 @@ foreach($object->fields as $key => $val) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; print ''."\n"; @@ -416,79 +416,79 @@ print ''."\n"; // Fields title label // -------------------------------------------------------------------- print ''; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n"; + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n"; print ''."\n"; // Detect if we need a fetch on each output line -$needToFetchEachLine=0; +$needToFetchEachLine = 0; if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object + if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object } } // Loop on record // -------------------------------------------------------------------- -$i=0; -$totalarray=array(); +$i = 0; +$totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) break; // Should not happen // Store properties in $object $object->id = $obj->rowid; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { if (property_exists($obj, $key)) $object->$key = $obj->$key; } // Show here line of result print ''; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; + if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield.=($cssforfield?' ':'').'right'; + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; if ($key == 'status') print $object->getLibStatut(5); - elseif (in_array($val['type'], array('date','datetime','timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); else print $object->showOutputField($val, $key, $obj->$key, ''); print ''; - if (! $i) $totalarray['nbfield']++; - if (! empty($val['isameasure'])) + if (!$i) $totalarray['nbfield']++; + if (!empty($val['isameasure'])) { - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; $totalarray['val']['t.'.$key] += $obj->$key; } } @@ -496,19 +496,19 @@ while ($i < min($num, $limit)) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print ''; @@ -522,15 +522,15 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found if ($num == 0) { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print ''; } $db->free($resql); -$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; + print ''; if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75'); else print ''; print ''; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; } print '
'.$langs->trans("NoRecordFound").'
'."\n"; @@ -540,19 +540,19 @@ print ''."\n"; if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->monmodule->read; - $delallowed=$user->rights->monmodule->create; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->monmodule->read; + $delallowed = $user->rights->monmodule->create; print $formfile->showdocuments('massfilesarea_monmodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 408ce2c1303..8482ede3c3a 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -42,27 +42,27 @@ class FactureRec extends CommonInvoice /** * @var string ID to identify managed object */ - public $element='facturerec'; + public $element = 'facturerec'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='facture_rec'; + public $table_element = 'facture_rec'; /** * @var int Name of subtable line */ - public $table_element_line='facturedet_rec'; + public $table_element_line = 'facturedet_rec'; /** * @var int Field with ID of parent key if this field has a parent */ - public $fk_element='fk_facture'; + public $fk_element = 'fk_facture'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ - public $picto='bill'; + public $picto = 'bill'; /** * @var int Entity @@ -89,9 +89,9 @@ class FactureRec extends CommonInvoice public $rang; public $special_code; - public $usenewprice=0; + public $usenewprice = 0; - public $suspended; // status + public $suspended; // status const STATUS_NOTSUSPENDED = 0; const STATUS_SUSPENDED = 1; @@ -119,96 +119,96 @@ class FactureRec extends CommonInvoice { global $conf; - $error=0; - $now=dol_now(); + $error = 0; + $now = dol_now(); // Clean parameters - $this->titre=trim($this->titre); // deprecated - $this->title=trim($this->title); - $this->usenewprice=empty($this->usenewprice)?0:$this->usenewprice; - if (empty($this->suspended)) $this->suspended=0; + $this->titre = trim($this->titre); // deprecated + $this->title = trim($this->title); + $this->usenewprice = empty($this->usenewprice) ? 0 : $this->usenewprice; + if (empty($this->suspended)) $this->suspended = 0; // No frequency defined then no next date to execution if (empty($this->frequency)) { - $this->frequency=0; - $this->date_when=null; + $this->frequency = 0; + $this->date_when = null; } - $this->frequency=abs($this->frequency); - $this->nb_gen_done=0; - $this->nb_gen_max=empty($this->nb_gen_max)?0:$this->nb_gen_max; - $this->auto_validate=empty($this->auto_validate)?0:$this->auto_validate; - $this->generate_pdf = empty($this->generate_pdf)?0:$this->generate_pdf; + $this->frequency = abs($this->frequency); + $this->nb_gen_done = 0; + $this->nb_gen_max = empty($this->nb_gen_max) ? 0 : $this->nb_gen_max; + $this->auto_validate = empty($this->auto_validate) ? 0 : $this->auto_validate; + $this->generate_pdf = empty($this->generate_pdf) ? 0 : $this->generate_pdf; $this->db->begin(); // Charge facture modele - $facsrc=new Facture($this->db); - $result=$facsrc->fetch($facid); + $facsrc = new Facture($this->db); + $result = $facsrc->fetch($facid); if ($result > 0) { // On positionne en mode brouillon la facture $this->brouillon = 1; $sql = "INSERT INTO ".MAIN_DB_PREFIX."facture_rec ("; - $sql.= "titre"; - $sql.= ", fk_soc"; - $sql.= ", entity"; - $sql.= ", datec"; - $sql.= ", amount"; - $sql.= ", remise"; - $sql.= ", note_private"; - $sql.= ", note_public"; - $sql.= ", modelpdf"; - $sql.= ", fk_user_author"; - $sql.= ", fk_projet"; - $sql.= ", fk_account"; - $sql.= ", fk_cond_reglement"; - $sql.= ", fk_mode_reglement"; - $sql.= ", usenewprice"; - $sql.= ", frequency"; - $sql.= ", unit_frequency"; - $sql.= ", date_when"; - $sql.= ", date_last_gen"; - $sql.= ", nb_gen_done"; - $sql.= ", nb_gen_max"; - $sql.= ", auto_validate"; - $sql.= ", generate_pdf"; - $sql.= ", fk_multicurrency"; - $sql.= ", multicurrency_code"; - $sql.= ", multicurrency_tx"; - $sql.= ", suspended"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->escape($this->titre ? $this->titre : $this->title)."'"; - $sql.= ", ".$facsrc->socid; - $sql.= ", ".$conf->entity; - $sql.= ", '".$this->db->idate($now)."'"; - $sql.= ", ".(!empty($facsrc->amount)?$facsrc->amount:'0'); - $sql.= ", ".(!empty($facsrc->remise)?$this->remise:'0'); - $sql.= ", ".(!empty($this->note_private)?("'".$this->db->escape($this->note_private)."'"):"NULL"); - $sql.= ", ".(!empty($this->note_public)?("'".$this->db->escape($this->note_public)."'"):"NULL"); - $sql.= ", ".(!empty($this->modelpdf)?("'".$this->db->escape($this->modelpdf)."'"):"NULL"); - $sql.= ", '".$this->db->escape($user->id)."'"; - $sql.= ", ".(! empty($facsrc->fk_project)?"'".$facsrc->fk_project."'":"null"); - $sql.= ", ".(! empty($facsrc->fk_account)?"'".$facsrc->fk_account."'":"null"); - $sql.= ", ".($facsrc->cond_reglement_id > 0 ? $this->db->escape($facsrc->cond_reglement_id) : "null"); - $sql.= ", ".($facsrc->mode_reglement_id > 0 ? $this->db->escape($facsrc->mode_reglement_id) : "null"); - $sql.= ", ".$this->usenewprice; - $sql.= ", ".$this->frequency; - $sql.= ", '".$this->db->escape($this->unit_frequency)."'"; - $sql.= ", ".(!empty($this->date_when)?"'".$this->db->idate($this->date_when)."'":'NULL'); - $sql.= ", ".(!empty($this->date_last_gen)?"'".$this->db->idate($this->date_last_gen)."'":'NULL'); - $sql.= ", ".$this->db->escape($this->nb_gen_done); - $sql.= ", ".$this->db->escape($this->nb_gen_max); - $sql.= ", ".$this->db->escape($this->auto_validate); - $sql.= ", ".$this->db->escape($this->generate_pdf); - $sql.= ", ".$this->db->escape($facsrc->fk_multicurrency); - $sql.= ", '".$this->db->escape($facsrc->multicurrency_code)."'"; - $sql.= ", ".$this->db->escape($facsrc->multicurrency_tx); - $sql.= ", ".$this->db->escape($this->suspended); - $sql.= ")"; + $sql .= "titre"; + $sql .= ", fk_soc"; + $sql .= ", entity"; + $sql .= ", datec"; + $sql .= ", amount"; + $sql .= ", remise"; + $sql .= ", note_private"; + $sql .= ", note_public"; + $sql .= ", modelpdf"; + $sql .= ", fk_user_author"; + $sql .= ", fk_projet"; + $sql .= ", fk_account"; + $sql .= ", fk_cond_reglement"; + $sql .= ", fk_mode_reglement"; + $sql .= ", usenewprice"; + $sql .= ", frequency"; + $sql .= ", unit_frequency"; + $sql .= ", date_when"; + $sql .= ", date_last_gen"; + $sql .= ", nb_gen_done"; + $sql .= ", nb_gen_max"; + $sql .= ", auto_validate"; + $sql .= ", generate_pdf"; + $sql .= ", fk_multicurrency"; + $sql .= ", multicurrency_code"; + $sql .= ", multicurrency_tx"; + $sql .= ", suspended"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->escape($this->titre ? $this->titre : $this->title)."'"; + $sql .= ", ".$facsrc->socid; + $sql .= ", ".$conf->entity; + $sql .= ", '".$this->db->idate($now)."'"; + $sql .= ", ".(!empty($facsrc->amount) ? $facsrc->amount : '0'); + $sql .= ", ".(!empty($facsrc->remise) ? $this->remise : '0'); + $sql .= ", ".(!empty($this->note_private) ? ("'".$this->db->escape($this->note_private)."'") : "NULL"); + $sql .= ", ".(!empty($this->note_public) ? ("'".$this->db->escape($this->note_public)."'") : "NULL"); + $sql .= ", ".(!empty($this->modelpdf) ? ("'".$this->db->escape($this->modelpdf)."'") : "NULL"); + $sql .= ", '".$this->db->escape($user->id)."'"; + $sql .= ", ".(!empty($facsrc->fk_project) ? "'".$facsrc->fk_project."'" : "null"); + $sql .= ", ".(!empty($facsrc->fk_account) ? "'".$facsrc->fk_account."'" : "null"); + $sql .= ", ".($facsrc->cond_reglement_id > 0 ? $this->db->escape($facsrc->cond_reglement_id) : "null"); + $sql .= ", ".($facsrc->mode_reglement_id > 0 ? $this->db->escape($facsrc->mode_reglement_id) : "null"); + $sql .= ", ".$this->usenewprice; + $sql .= ", ".$this->frequency; + $sql .= ", '".$this->db->escape($this->unit_frequency)."'"; + $sql .= ", ".(!empty($this->date_when) ? "'".$this->db->idate($this->date_when)."'" : 'NULL'); + $sql .= ", ".(!empty($this->date_last_gen) ? "'".$this->db->idate($this->date_last_gen)."'" : 'NULL'); + $sql .= ", ".$this->db->escape($this->nb_gen_done); + $sql .= ", ".$this->db->escape($this->nb_gen_max); + $sql .= ", ".$this->db->escape($this->auto_validate); + $sql .= ", ".$this->db->escape($this->generate_pdf); + $sql .= ", ".$this->db->escape($facsrc->fk_multicurrency); + $sql .= ", '".$this->db->escape($facsrc->multicurrency_code)."'"; + $sql .= ", ".$this->db->escape($facsrc->multicurrency_tx); + $sql .= ", ".$this->db->escape($this->suspended); + $sql .= ")"; if ($this->db->query($sql)) { @@ -220,11 +220,11 @@ class FactureRec extends CommonInvoice $this->multicurrency_tx = $facsrc->multicurrency_tx; // Add lines - $num=count($facsrc->lines); + $num = count($facsrc->lines); for ($i = 0; $i < $num; $i++) { $tva_tx = $facsrc->lines[$i]->tva_tx; - if (! empty($facsrc->lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$facsrc->lines[$i]->vat_src_code.')'; + if (!empty($facsrc->lines[$i]->vat_src_code) && !preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$facsrc->lines[$i]->vat_src_code.')'; $result_insert = $this->addline( $facsrc->lines[$i]->desc, @@ -253,24 +253,24 @@ class FactureRec extends CommonInvoice } } - if (! empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects + if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects { - $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds + $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds } // Add object linked - if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects)) + if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects)) { - foreach($this->linked_objects as $origin => $tmp_origin_id) + foreach ($this->linked_objects as $origin => $tmp_origin_id) { if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) { - foreach($tmp_origin_id as $origin_id) + foreach ($tmp_origin_id as $origin_id) { $ret = $this->add_object_linked($origin, $origin_id); - if (! $ret) + if (!$ret) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } } @@ -279,9 +279,9 @@ class FactureRec extends CommonInvoice { $origin_id = $tmp_origin_id; $ret = $this->add_object_linked($origin, $origin_id); - if (! $ret) + if (!$ret) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } } @@ -300,7 +300,7 @@ class FactureRec extends CommonInvoice } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -2; } @@ -327,27 +327,27 @@ class FactureRec extends CommonInvoice $error = 0; $sql = "UPDATE ".MAIN_DB_PREFIX."facture_rec SET"; - $sql.= " fk_soc = ".$this->fk_soc; + $sql .= " fk_soc = ".$this->fk_soc; // TODO Add missing fields - $sql.= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('BILLREC_UPDATE', $user); + $result = $this->call_trigger('BILLREC_UPDATE', $user); if ($result < 0) { $this->db->rollback(); @@ -360,7 +360,7 @@ class FactureRec extends CommonInvoice } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -2; } @@ -378,25 +378,25 @@ class FactureRec extends CommonInvoice public function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '') { $sql = 'SELECT f.rowid, f.entity, f.titre as title, f.suspended, f.fk_soc, f.amount, f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc'; - $sql.= ', f.remise_percent, f.remise_absolue, f.remise'; - $sql.= ', f.date_lim_reglement as dlr'; - $sql.= ', f.note_private, f.note_public, f.fk_user_author'; - $sql.= ', f.modelpdf'; - $sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet as fk_project'; - $sql.= ', f.fk_account'; - $sql.= ', f.frequency, f.unit_frequency, f.date_when, f.date_last_gen, f.nb_gen_done, f.nb_gen_max, f.usenewprice, f.auto_validate'; - $sql.= ', f.generate_pdf'; - $sql.= ", f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc"; - $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; - $sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; + $sql .= ', f.remise_percent, f.remise_absolue, f.remise'; + $sql .= ', f.date_lim_reglement as dlr'; + $sql .= ', f.note_private, f.note_public, f.fk_user_author'; + $sql .= ', f.modelpdf'; + $sql .= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet as fk_project'; + $sql .= ', f.fk_account'; + $sql .= ', f.frequency, f.unit_frequency, f.date_when, f.date_last_gen, f.nb_gen_done, f.nb_gen_max, f.usenewprice, f.auto_validate'; + $sql .= ', f.generate_pdf'; + $sql .= ", f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc"; + $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; + $sql .= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; //$sql.= ', el.fk_source'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_rec as f'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_rec as f'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id'; //$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = f.rowid AND el.targettype = 'facture'"; - $sql.= ' WHERE f.entity IN ('.getEntity('invoice').')'; - if ($rowid) $sql.= ' AND f.rowid='.$rowid; - elseif ($ref) $sql.= " AND f.titre='".$this->db->escape($ref)."'"; + $sql .= ' WHERE f.entity IN ('.getEntity('invoice').')'; + if ($rowid) $sql .= ' AND f.rowid='.$rowid; + elseif ($ref) $sql .= " AND f.titre='".$this->db->escape($ref)."'"; /* This field are not used for template invoice if ($ref_ext) $sql.= " AND f.ref_ext='".$this->db->escape($ref_ext)."'"; if ($ref_int) $sql.= " AND f.ref_int='".$this->db->escape($ref_int)."'"; @@ -411,7 +411,7 @@ class FactureRec extends CommonInvoice $this->id = $obj->rowid; $this->entity = $obj->entity; - $this->titre = $obj->title; // deprecated + $this->titre = $obj->title; // deprecated $this->title = $obj->title; $this->ref = $obj->title; $this->ref_client = $obj->ref_client; @@ -447,23 +447,23 @@ class FactureRec extends CommonInvoice $this->note_public = $obj->note_public; $this->user_author = $obj->fk_user_author; $this->modelpdf = $obj->modelpdf; - $this->rang = $obj->rang; - $this->special_code = $obj->special_code; + $this->rang = $obj->rang; + $this->special_code = $obj->special_code; $this->frequency = $obj->frequency; - $this->unit_frequency = $obj->unit_frequency; + $this->unit_frequency = $obj->unit_frequency; $this->date_when = $this->db->jdate($obj->date_when); - $this->date_last_gen = $this->db->jdate($obj->date_last_gen); + $this->date_last_gen = $this->db->jdate($obj->date_last_gen); $this->nb_gen_done = $obj->nb_gen_done; - $this->nb_gen_max = $obj->nb_gen_max; + $this->nb_gen_max = $obj->nb_gen_max; $this->usenewprice = $obj->usenewprice; - $this->auto_validate = $obj->auto_validate; - $this->generate_pdf = $obj->generate_pdf; + $this->auto_validate = $obj->auto_validate; + $this->generate_pdf = $obj->generate_pdf; // Multicurrency $this->fk_multicurrency = $obj->fk_multicurrency; - $this->multicurrency_code = $obj->multicurrency_code; + $this->multicurrency_code = $obj->multicurrency_code; $this->multicurrency_tx = $obj->multicurrency_tx; - $this->multicurrency_total_ht = $obj->multicurrency_total_ht; + $this->multicurrency_total_ht = $obj->multicurrency_total_ht; $this->multicurrency_total_tva = $obj->multicurrency_total_tva; $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; @@ -476,24 +476,24 @@ class FactureRec extends CommonInvoice /* * Lines */ - $result=$this->fetch_lines(); + $result = $this->fetch_lines(); if ($result < 0) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -3; } return 1; } else { - $this->error='Bill with id '.$rowid.' or ref '.$ref.' not found sql='.$sql; + $this->error = 'Bill with id '.$rowid.' or ref '.$ref.' not found sql='.$sql; dol_syslog('Facture::Fetch Error '.$this->error, LOG_ERR); return -2; } } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -521,31 +521,31 @@ class FactureRec extends CommonInvoice global $extrafields; // phpcs:enable - $this->lines=array(); + $this->lines = array(); // Retreive all extrafield for line // fetch optionals attributes and labels - if (! is_object($extrafields)) + if (!is_object($extrafields)) { require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields=new ExtraFields($this->db); + $extrafields = new ExtraFields($this->db); } $extrafields->fetch_name_optionals_label($this->table_element_line, true); $sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx, '; - $sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,'; - $sql.= ' l.info_bits, l.date_start_fill, l.date_end_fill, l.total_ht, l.total_tva, l.total_ttc, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; + $sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,'; + $sql .= ' l.info_bits, l.date_start_fill, l.date_end_fill, l.total_ht, l.total_tva, l.total_ttc, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; //$sql.= ' l.situation_percent, l.fk_prev_id,'; //$sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,'; - $sql.= ' l.rang, l.special_code,'; + $sql .= ' l.rang, l.special_code,'; //$sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; - $sql.= ' l.fk_unit, l.fk_contract_line,'; - $sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,'; - $sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet_rec as l'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; - $sql.= ' WHERE l.fk_facture = '.$this->id; - $sql.= ' ORDER BY l.rang'; + $sql .= ' l.fk_unit, l.fk_contract_line,'; + $sql .= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,'; + $sql .= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facturedet_rec as l'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; + $sql .= ' WHERE l.fk_facture = '.$this->id; + $sql .= ' ORDER BY l.rang'; dol_syslog('FactureRec::fetch_lines', LOG_DEBUG); $result = $this->db->query($sql); @@ -558,21 +558,21 @@ class FactureRec extends CommonInvoice $objp = $this->db->fetch_object($result); $line = new FactureLigneRec($this->db); - $line->id = $objp->rowid; - $line->rowid = $objp->rowid; - $line->desc = $objp->description; // Description line - $line->description = $objp->description; // Description line - $line->product_type = $objp->product_type; // Type of line - $line->ref = $objp->product_ref; // Ref product - $line->product_ref = $objp->product_ref; // Ref product - $line->libelle = $objp->product_label; // deprecated - $line->product_label = $objp->product_label; // Label product - $line->product_desc = $objp->product_desc; // Description product - $line->fk_product_type = $objp->fk_product_type; // Type of product + $line->id = $objp->rowid; + $line->rowid = $objp->rowid; + $line->desc = $objp->description; // Description line + $line->description = $objp->description; // Description line + $line->product_type = $objp->product_type; // Type of line + $line->ref = $objp->product_ref; // Ref product + $line->product_ref = $objp->product_ref; // Ref product + $line->libelle = $objp->product_label; // deprecated + $line->product_label = $objp->product_label; // Label product + $line->product_desc = $objp->product_desc; // Description product + $line->fk_product_type = $objp->fk_product_type; // Type of product $line->qty = $objp->qty; $line->subprice = $objp->subprice; - $line->label = $objp->custom_label; // @deprecated + $line->label = $objp->custom_label; // @deprecated $line->vat_src_code = $objp->vat_src_code; $line->tva_tx = $objp->tva_tx; @@ -590,14 +590,14 @@ class FactureRec extends CommonInvoice $line->total_tva = $objp->total_tva; $line->total_ttc = $objp->total_ttc; $line->code_ventilation = $objp->fk_code_ventilation; - $line->fk_fournprice = $objp->fk_fournprice; - $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); - $line->pa_ht = $marginInfos[0]; + $line->fk_fournprice = $objp->fk_fournprice; + $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); + $line->pa_ht = $marginInfos[0]; $line->marge_tx = $marginInfos[1]; $line->marque_tx = $marginInfos[2]; - $line->rang = $objp->rang; - $line->special_code = $objp->special_code; - $line->fk_unit = $objp->fk_unit; + $line->rang = $objp->rang; + $line->special_code = $objp->special_code; + $line->fk_unit = $objp->fk_unit; $line->fk_contract_line = $objp->fk_contract_line; // Ne plus utiliser @@ -607,8 +607,8 @@ class FactureRec extends CommonInvoice $line->fetch_optionals($line->id); // Multicurrency - $line->fk_multicurrency = $objp->fk_multicurrency; - $line->multicurrency_code = $objp->multicurrency_code; + $line->fk_multicurrency = $objp->fk_multicurrency; + $line->multicurrency_code = $objp->multicurrency_code; $line->multicurrency_subprice = $objp->multicurrency_subprice; $line->multicurrency_total_ht = $objp->multicurrency_total_ht; $line->multicurrency_total_tva = $objp->multicurrency_total_tva; @@ -624,7 +624,7 @@ class FactureRec extends CommonInvoice } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -3; } } @@ -640,11 +640,11 @@ class FactureRec extends CommonInvoice */ public function delete(User $user, $notrigger = 0, $idwarehouse = -1) { - $rowid=$this->id; + $rowid = $this->id; dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG); - $error=0; + $error = 0; $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet_rec WHERE fk_facture = ".$rowid; @@ -657,21 +657,21 @@ class FactureRec extends CommonInvoice { // Delete linked object $res = $this->deleteObjectLinked(); - if ($res < 0) $error=-3; + if ($res < 0) $error = -3; } else { - $this->error=$this->db->lasterror(); - $error=-1; + $this->error = $this->db->lasterror(); + $error = -1; } } else { - $this->error=$this->db->lasterror(); - $error=-2; + $this->error = $this->db->lasterror(); + $error = -2; } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -715,7 +715,7 @@ class FactureRec extends CommonInvoice { global $mysoc; - $facid=$this->id; + $facid = $this->id; dol_syslog(get_class($this)."::addline facid=$facid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva,txlocaltax1=$txlocaltax1,txlocaltax2=$txlocaltax2,fk_product=$fk_product,remise_percent=$remise_percent,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type,fk_unit=$fk_unit,pu_ht_devise=$pu_ht_devise,date_start_fill=$date_start_fill,date_end_fill=$date_end_fill,pa_ht=$pa_ht", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -723,39 +723,39 @@ class FactureRec extends CommonInvoice // Check parameters if ($type < 0) return -1; - $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); + $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); // Clean vat code - $vat_src_code=''; + $vat_src_code = ''; if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } if ($this->brouillon) { // Clean parameters - $remise_percent=price2num($remise_percent); - if (empty($remise_percent)) $remise_percent=0; - $qty=price2num($qty); + $remise_percent = price2num($remise_percent); + if (empty($remise_percent)) $remise_percent = 0; + $qty = price2num($qty); $pu_ht = price2num($pu_ht); $pu_ttc = price2num($pu_ttc); $txtva = price2num($txtva); $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); - if (empty($txtva)) $txtva=0; - if (empty($txlocaltax1)) $txlocaltax1=0; - if (empty($txlocaltax2)) $txlocaltax2=0; - if (empty($info_bits)) $info_bits=0; + if (empty($txtva)) $txtva = 0; + if (empty($txlocaltax1)) $txlocaltax1 = 0; + if (empty($txlocaltax2)) $txlocaltax2 = 0; + if (empty($info_bits)) $info_bits = 0; - if ($price_base_type=='HT') + if ($price_base_type == 'HT') { - $pu=$pu_ht; + $pu = $pu_ht; } else { - $pu=$pu_ttc; + $pu = $pu_ttc; } // Calcul du total TTC et de la TVA pour la ligne a partir de @@ -763,12 +763,12 @@ class FactureRec extends CommonInvoice // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; - $total_localtax1=$tabprice[9]; - $total_localtax2=$tabprice[10]; + $total_localtax1 = $tabprice[9]; + $total_localtax2 = $tabprice[10]; $pu_ht = $tabprice[3]; // MultiCurrency @@ -777,94 +777,94 @@ class FactureRec extends CommonInvoice $multicurrency_total_ttc = $tabprice[18]; $pu_ht_devise = $tabprice[19]; - $product_type=$type; + $product_type = $type; if ($fk_product) { - $product=new Product($this->db); - $result=$product->fetch($fk_product); - $product_type=$product->type; + $product = new Product($this->db); + $result = $product->fetch($fk_product); + $product_type = $product->type; } $sql = "INSERT INTO ".MAIN_DB_PREFIX."facturedet_rec ("; - $sql.= "fk_facture"; - $sql.= ", label"; - $sql.= ", description"; - $sql.= ", price"; - $sql.= ", qty"; - $sql.= ", tva_tx"; - $sql.= ", vat_src_code"; - $sql.= ", localtax1_tx"; - $sql.= ", localtax1_type"; - $sql.= ", localtax2_tx"; - $sql.= ", localtax2_type"; - $sql.= ", fk_product"; - $sql.= ", product_type"; - $sql.= ", remise_percent"; - $sql.= ", subprice"; - $sql.= ", remise"; - $sql.= ", total_ht"; - $sql.= ", total_tva"; - $sql.= ", total_localtax1"; - $sql.= ", total_localtax2"; - $sql.= ", total_ttc"; - $sql.= ", date_start_fill"; - $sql.= ", date_end_fill"; - $sql.= ", fk_product_fournisseur_price"; - $sql.= ", buy_price_ht"; - $sql.= ", info_bits"; - $sql.= ", rang"; - $sql.= ", special_code"; - $sql.= ", fk_unit"; - $sql.= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; - $sql.= ") VALUES ("; - $sql.= "'".$facid."'"; - $sql.= ", ".(! empty($label)?"'".$this->db->escape($label)."'":"null"); - $sql.= ", '".$this->db->escape($desc)."'"; - $sql.= ", ".price2num($pu_ht); - $sql.= ", ".price2num($qty); - $sql.= ", ".price2num($txtva); - $sql.= ", '".$this->db->escape($vat_src_code)."'"; - $sql.= ", ".price2num($txlocaltax1); - $sql.= ", '".$this->db->escape($localtaxes_type[0])."'"; - $sql.= ", ".price2num($txlocaltax2); - $sql.= ", '".$this->db->escape($localtaxes_type[2])."'"; - $sql.= ", ".(! empty($fk_product)?"'".$fk_product."'":"null"); - $sql.= ", ".$product_type; - $sql.= ", ".price2num($remise_percent); - $sql.= ", ".price2num($pu_ht); - $sql.= ", null"; - $sql.= ", ".price2num($total_ht); - $sql.= ", ".price2num($total_tva); - $sql.= ", ".price2num($total_localtax1); - $sql.= ", ".price2num($total_localtax2); - $sql.= ", ".price2num($total_ttc); - $sql.= ", ".(int) $date_start_fill; - $sql.= ", ".(int) $date_end_fill; - $sql.= ", ".($fk_fournprice > 0 ? $fk_fournprice : 'null'); - $sql.= ", ".($pa_ht ? price2num($pa_ht) : 0); - $sql.= ", ".$info_bits; - $sql.= ", ".$rang; - $sql.= ", ".$special_code; - $sql.= ", ".($fk_unit?"'".$this->db->escape($fk_unit)."'":"null"); - $sql.= ", ".(int) $this->fk_multicurrency; - $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; - $sql.= ", ".price2num($pu_ht_devise); - $sql.= ", ".price2num($multicurrency_total_ht); - $sql.= ", ".price2num($multicurrency_total_tva); - $sql.= ", ".price2num($multicurrency_total_ttc); - $sql.= ")"; + $sql .= "fk_facture"; + $sql .= ", label"; + $sql .= ", description"; + $sql .= ", price"; + $sql .= ", qty"; + $sql .= ", tva_tx"; + $sql .= ", vat_src_code"; + $sql .= ", localtax1_tx"; + $sql .= ", localtax1_type"; + $sql .= ", localtax2_tx"; + $sql .= ", localtax2_type"; + $sql .= ", fk_product"; + $sql .= ", product_type"; + $sql .= ", remise_percent"; + $sql .= ", subprice"; + $sql .= ", remise"; + $sql .= ", total_ht"; + $sql .= ", total_tva"; + $sql .= ", total_localtax1"; + $sql .= ", total_localtax2"; + $sql .= ", total_ttc"; + $sql .= ", date_start_fill"; + $sql .= ", date_end_fill"; + $sql .= ", fk_product_fournisseur_price"; + $sql .= ", buy_price_ht"; + $sql .= ", info_bits"; + $sql .= ", rang"; + $sql .= ", special_code"; + $sql .= ", fk_unit"; + $sql .= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; + $sql .= ") VALUES ("; + $sql .= "'".$facid."'"; + $sql .= ", ".(!empty($label) ? "'".$this->db->escape($label)."'" : "null"); + $sql .= ", '".$this->db->escape($desc)."'"; + $sql .= ", ".price2num($pu_ht); + $sql .= ", ".price2num($qty); + $sql .= ", ".price2num($txtva); + $sql .= ", '".$this->db->escape($vat_src_code)."'"; + $sql .= ", ".price2num($txlocaltax1); + $sql .= ", '".$this->db->escape($localtaxes_type[0])."'"; + $sql .= ", ".price2num($txlocaltax2); + $sql .= ", '".$this->db->escape($localtaxes_type[2])."'"; + $sql .= ", ".(!empty($fk_product) ? "'".$fk_product."'" : "null"); + $sql .= ", ".$product_type; + $sql .= ", ".price2num($remise_percent); + $sql .= ", ".price2num($pu_ht); + $sql .= ", null"; + $sql .= ", ".price2num($total_ht); + $sql .= ", ".price2num($total_tva); + $sql .= ", ".price2num($total_localtax1); + $sql .= ", ".price2num($total_localtax2); + $sql .= ", ".price2num($total_ttc); + $sql .= ", ".(int) $date_start_fill; + $sql .= ", ".(int) $date_end_fill; + $sql .= ", ".($fk_fournprice > 0 ? $fk_fournprice : 'null'); + $sql .= ", ".($pa_ht ? price2num($pa_ht) : 0); + $sql .= ", ".$info_bits; + $sql .= ", ".$rang; + $sql .= ", ".$special_code; + $sql .= ", ".($fk_unit ? "'".$this->db->escape($fk_unit)."'" : "null"); + $sql .= ", ".(int) $this->fk_multicurrency; + $sql .= ", '".$this->db->escape($this->multicurrency_code)."'"; + $sql .= ", ".price2num($pu_ht_devise); + $sql .= ", ".price2num($multicurrency_total_ht); + $sql .= ", ".price2num($multicurrency_total_tva); + $sql .= ", ".price2num($multicurrency_total_ttc); + $sql .= ")"; dol_syslog(get_class($this)."::addline", LOG_DEBUG); if ($this->db->query($sql)) { $lineId = $this->db->last_insert_id(MAIN_DB_PREFIX."facturedet_rec"); - $this->id=$facid; + $this->id = $facid; $this->update_price(); return $lineId; } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -903,7 +903,7 @@ class FactureRec extends CommonInvoice { global $mysoc; - $facid=$this->id; + $facid = $this->id; dol_syslog(get_class($this)."::updateline facid=".$facid." rowid=$rowid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, type=$type, fk_unit=$fk_unit, pu_ht_devise=$pu_ht_devise", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -917,53 +917,53 @@ class FactureRec extends CommonInvoice if ($this->brouillon) { // Clean parameters - $remise_percent=price2num($remise_percent); - $qty=price2num($qty); - if (empty($info_bits)) $info_bits=0; + $remise_percent = price2num($remise_percent); + $qty = price2num($qty); + if (empty($info_bits)) $info_bits = 0; $pu_ht = price2num($pu_ht); $pu_ttc = price2num($pu_ttc); - $pu_ht_devise = price2num($pu_ht_devise); - $txtva=price2num($txtva); + $pu_ht_devise = price2num($pu_ht_devise); + $txtva = price2num($txtva); $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); - if (empty($txlocaltax1)) $txlocaltax1=0; - if (empty($txlocaltax2)) $txlocaltax2=0; + if (empty($txlocaltax1)) $txlocaltax1 = 0; + if (empty($txlocaltax2)) $txlocaltax2 = 0; - if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice=0; - if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht=0; - if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva=0; - if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc=0; + if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice = 0; + if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht = 0; + if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva = 0; + if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc = 0; - if ($price_base_type=='HT') + if ($price_base_type == 'HT') { - $pu=$pu_ht; + $pu = $pu_ht; } else { - $pu=$pu_ttc; + $pu = $pu_ttc; } // Calculate total with, without tax and tax from qty, pu, remise_percent and txtva // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); + $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); // Clean vat code - $vat_src_code=''; + $vat_src_code = ''; if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; - $total_localtax1=$tabprice[9]; - $total_localtax2=$tabprice[10]; + $total_localtax1 = $tabprice[9]; + $total_localtax2 = $tabprice[10]; $pu_ht = $tabprice[3]; $pu_tva = $tabprice[4]; $pu_ttc = $tabprice[5]; @@ -974,59 +974,59 @@ class FactureRec extends CommonInvoice $multicurrency_total_ttc = $tabprice[18]; $pu_ht_devise = $tabprice[19]; - $product_type=$type; + $product_type = $type; if ($fk_product) { - $product=new Product($this->db); - $result=$product->fetch($fk_product); - $product_type=$product->type; + $product = new Product($this->db); + $result = $product->fetch($fk_product); + $product_type = $product->type; } $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet_rec SET "; - $sql.= "fk_facture = '".$facid."'"; - $sql.= ", label=".(! empty($label)?"'".$this->db->escape($label)."'":"null"); - $sql.= ", description='".$this->db->escape($desc)."'"; - $sql.= ", price=".price2num($pu_ht); - $sql.= ", qty=".price2num($qty); - $sql.= ", tva_tx=".price2num($txtva); - $sql.= ", vat_src_code='".$this->db->escape($vat_src_code)."'"; - $sql.= ", localtax1_tx=".$txlocaltax1; - $sql.= ", localtax1_type='".$this->db->escape($localtaxes_type[0])."'"; - $sql.= ", localtax2_tx=".$txlocaltax2; - $sql.= ", localtax2_type='".$this->db->escape($localtaxes_type[2])."'"; - $sql.= ", fk_product=".(! empty($fk_product)?"'".$fk_product."'":"null"); - $sql.= ", product_type=".$product_type; - $sql.= ", remise_percent='".price2num($remise_percent)."'"; - $sql.= ", subprice='".price2num($pu_ht)."'"; - $sql.= ", total_ht='".price2num($total_ht)."'"; - $sql.= ", total_tva='".price2num($total_tva)."'"; - $sql.= ", total_localtax1='".price2num($total_localtax1)."'"; - $sql.= ", total_localtax2='".price2num($total_localtax2)."'"; - $sql.= ", total_ttc='".price2num($total_ttc)."'"; - $sql.= ", date_start_fill=".((int) $date_start_fill); - $sql.= ", date_end_fill=".((int) $date_end_fill); - $sql.= ", fk_product_fournisseur_price=".($fk_fournprice > 0 ? $fk_fournprice : 'null'); - $sql.= ", buy_price_ht=".($pa_ht ? price2num($pa_ht) : 0); - $sql.= ", info_bits=".$info_bits; - $sql.= ", rang=".$rang; - $sql.= ", special_code=".$special_code; - $sql.= ", fk_unit=".($fk_unit?"'".$this->db->escape($fk_unit)."'":"null"); - $sql.= ', multicurrency_subprice = '.$pu_ht_devise; - $sql.= ', multicurrency_total_ht = '.$multicurrency_total_ht; - $sql.= ', multicurrency_total_tva = '.$multicurrency_total_tva; - $sql.= ', multicurrency_total_ttc = '.$multicurrency_total_ttc; - $sql.= " WHERE rowid = ".$rowid; + $sql .= "fk_facture = '".$facid."'"; + $sql .= ", label=".(!empty($label) ? "'".$this->db->escape($label)."'" : "null"); + $sql .= ", description='".$this->db->escape($desc)."'"; + $sql .= ", price=".price2num($pu_ht); + $sql .= ", qty=".price2num($qty); + $sql .= ", tva_tx=".price2num($txtva); + $sql .= ", vat_src_code='".$this->db->escape($vat_src_code)."'"; + $sql .= ", localtax1_tx=".$txlocaltax1; + $sql .= ", localtax1_type='".$this->db->escape($localtaxes_type[0])."'"; + $sql .= ", localtax2_tx=".$txlocaltax2; + $sql .= ", localtax2_type='".$this->db->escape($localtaxes_type[2])."'"; + $sql .= ", fk_product=".(!empty($fk_product) ? "'".$fk_product."'" : "null"); + $sql .= ", product_type=".$product_type; + $sql .= ", remise_percent='".price2num($remise_percent)."'"; + $sql .= ", subprice='".price2num($pu_ht)."'"; + $sql .= ", total_ht='".price2num($total_ht)."'"; + $sql .= ", total_tva='".price2num($total_tva)."'"; + $sql .= ", total_localtax1='".price2num($total_localtax1)."'"; + $sql .= ", total_localtax2='".price2num($total_localtax2)."'"; + $sql .= ", total_ttc='".price2num($total_ttc)."'"; + $sql .= ", date_start_fill=".((int) $date_start_fill); + $sql .= ", date_end_fill=".((int) $date_end_fill); + $sql .= ", fk_product_fournisseur_price=".($fk_fournprice > 0 ? $fk_fournprice : 'null'); + $sql .= ", buy_price_ht=".($pa_ht ? price2num($pa_ht) : 0); + $sql .= ", info_bits=".$info_bits; + $sql .= ", rang=".$rang; + $sql .= ", special_code=".$special_code; + $sql .= ", fk_unit=".($fk_unit ? "'".$this->db->escape($fk_unit)."'" : "null"); + $sql .= ', multicurrency_subprice = '.$pu_ht_devise; + $sql .= ', multicurrency_total_ht = '.$multicurrency_total_ht; + $sql .= ', multicurrency_total_tva = '.$multicurrency_total_tva; + $sql .= ', multicurrency_total_ttc = '.$multicurrency_total_ttc; + $sql .= " WHERE rowid = ".$rowid; dol_syslog(get_class($this)."::updateline", LOG_DEBUG); if ($this->db->query($sql)) { - $this->id=$facid; + $this->id = $facid; $this->update_price(); return 1; } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -1065,7 +1065,7 @@ class FactureRec extends CommonInvoice public function strikeIfMaxNbGenReached($ret) { // Special case to strike the date - return ($this->isMaxNbGenReached()?'':'').$ret.($this->isMaxNbGenReached()?'':''); + return ($this->isMaxNbGenReached() ? '' : '').$ret.($this->isMaxNbGenReached() ? '' : ''); } /** @@ -1082,27 +1082,27 @@ class FactureRec extends CommonInvoice { global $conf, $langs, $db, $user, $hookmanager; - $error=0; - $nb_create=0; + $error = 0; + $nb_create = 0; // Load translation files required by the page - $langs->loadLangs(array("main","bills")); + $langs->loadLangs(array("main", "bills")); $now = dol_now(); - $tmparray=dol_getdate($now); - $today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); // Today is last second of current day + $tmparray = dol_getdate($now); + $today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); // Today is last second of current day dol_syslog("createRecurringInvoices restrictioninvoiceid=".$restrictioninvoiceid." forcevalidation=".$forcevalidation); $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'facture_rec'; - $sql.= ' WHERE frequency > 0'; // A recurring invoice is an invoice with a frequency - $sql.= " AND (date_when IS NULL OR date_when <= '".$db->idate($today)."')"; - $sql.= ' AND (nb_gen_done < nb_gen_max OR nb_gen_max = 0)'; - $sql.= ' AND suspended = 0'; - $sql.= ' AND entity = '.$conf->entity; // MUST STAY = $conf->entity here + $sql .= ' WHERE frequency > 0'; // A recurring invoice is an invoice with a frequency + $sql .= " AND (date_when IS NULL OR date_when <= '".$db->idate($today)."')"; + $sql .= ' AND (nb_gen_done < nb_gen_max OR nb_gen_max = 0)'; + $sql .= ' AND suspended = 0'; + $sql .= ' AND entity = '.$conf->entity; // MUST STAY = $conf->entity here if ($restrictioninvoiceid > 0) - $sql.=' AND rowid = '.$restrictioninvoiceid; - $sql.= $db->order('entity', 'ASC'); + $sql .= ' AND rowid = '.$restrictioninvoiceid; + $sql .= $db->order('entity', 'ASC'); //print $sql;exit; $parameters = array( 'restrictioninvoiceid' => $restrictioninvoiceid, @@ -1113,13 +1113,13 @@ class FactureRec extends CommonInvoice $resql = $db->query($sql); if ($resql) { - $i=0; + $i = 0; $num = $db->num_rows($resql); if ($num) - $this->output.=$langs->trans("FoundXQualifiedRecurringInvoiceTemplate", $num)."\n"; + $this->output .= $langs->trans("FoundXQualifiedRecurringInvoiceTemplate", $num)."\n"; else - $this->output.=$langs->trans("NoQualifiedRecurringInvoiceTemplateFound"); + $this->output .= $langs->trans("NoQualifiedRecurringInvoiceTemplateFound"); $saventity = $conf->entity; @@ -1143,12 +1143,12 @@ class FactureRec extends CommonInvoice dol_syslog("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref.", entity=".$facturerec->entity); $facture = new Facture($db); - $facture->fac_rec = $facturerec->id; // We will create $facture from this recurring invoice - $facture->fk_fac_rec_source = $facturerec->id; // We will create $facture from this recurring invoice + $facture->fac_rec = $facturerec->id; // We will create $facture from this recurring invoice + $facture->fk_fac_rec_source = $facturerec->id; // We will create $facture from this recurring invoice $facture->type = self::TYPE_STANDARD; $facture->brouillon = 1; - $facture->date = (empty($facturerec->date_when)?$now:$facturerec->date_when); // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later. + $facture->date = (empty($facturerec->date_when) ? $now : $facturerec->date_when); // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later. $facture->socid = $facturerec->socid; $invoiceidgenerated = $facture->create($user); @@ -1158,7 +1158,7 @@ class FactureRec extends CommonInvoice $this->error = $facture->error; $error++; } - if (! $error && ($facturerec->auto_validate || $forcevalidation)) + if (!$error && ($facturerec->auto_validate || $forcevalidation)) { $result = $facture->validate($user); if ($result <= 0) @@ -1168,7 +1168,7 @@ class FactureRec extends CommonInvoice $error++; } } - if (! $error && $facturerec->generate_pdf) + if (!$error && $facturerec->generate_pdf) { // We refresh the object in order to have all necessary data (like date_lim_reglement) $facture->fetch($facture->id); @@ -1184,17 +1184,17 @@ class FactureRec extends CommonInvoice else { $error++; - $this->error="Failed to load invoice template with id=".$line->rowid.", entity=".$conf->entity."\n"; - $this->errors[]="Failed to load invoice template with id=".$line->rowid.", entity=".$conf->entity; + $this->error = "Failed to load invoice template with id=".$line->rowid.", entity=".$conf->entity."\n"; + $this->errors[] = "Failed to load invoice template with id=".$line->rowid.", entity=".$conf->entity; dol_syslog("createRecurringInvoices Failed to load invoice template with id=".$line->rowid.", entity=".$conf->entity); } - if (! $error && $invoiceidgenerated >= 0) + if (!$error && $invoiceidgenerated >= 0) { $db->commit("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref); dol_syslog("createRecurringInvoices Process invoice template ".$facturerec->ref." is finished with a success generation"); $nb_create++; - $this->output.=$langs->trans("InvoiceGeneratedFromTemplate", $facture->ref, $facturerec->ref)."\n"; + $this->output .= $langs->trans("InvoiceGeneratedFromTemplate", $facture->ref, $facturerec->ref)."\n"; } else { @@ -1206,21 +1206,21 @@ class FactureRec extends CommonInvoice 'total' => $num, 'errorCount' => $error, 'invoiceidgenerated' => $invoiceidgenerated, - 'facturerec' => $facturerec, // it's an object which PHP passes by "reference", so modifiable by hooks. - 'this' => $this, // it's an object which PHP passes by "reference", so modifiable by hooks. + 'facturerec' => $facturerec, // it's an object which PHP passes by "reference", so modifiable by hooks. + 'this' => $this, // it's an object which PHP passes by "reference", so modifiable by hooks. ); - $reshook = $hookmanager->executeHooks('afterCreationOfRecurringInvoice', $parameters, $facture); // note: $facture can be modified by hooks (warning: $facture can be null) + $reshook = $hookmanager->executeHooks('afterCreationOfRecurringInvoice', $parameters, $facture); // note: $facture can be modified by hooks (warning: $facture can be null) $i++; } - $conf->entity = $saventity; // Restore entity context + $conf->entity = $saventity; // Restore entity context } else dol_print_error($db); - $this->output=trim($this->output); + $this->output = trim($this->output); - return $error?$error:0; + return $error ? $error : 0; } /** @@ -1239,23 +1239,23 @@ class FactureRec extends CommonInvoice { global $langs; - $result=''; + $result = ''; - $label = '' . $langs->trans("ShowInvoice") . ''; - if (! empty($this->ref)) { - $label .= '
'.$langs->trans('Ref') . ': ' . $this->ref; + $label = ''.$langs->trans("ShowInvoice").''; + if (!empty($this->ref)) { + $label .= '
'.$langs->trans('Ref').': '.$this->ref; } if ($this->frequency > 0) { - $label .= '
'.$langs->trans('Frequency') . ': ' . $langs->trans('FrequencyPer_'.$this->unit_frequency, $this->frequency); + $label .= '
'.$langs->trans('Frequency').': '.$langs->trans('FrequencyPer_'.$this->unit_frequency, $this->frequency); } - if (! empty($this->date_last_gen)) { - $label .= '
'.$langs->trans('DateLastGeneration') . ': ' . dol_print_date($this->date_last_gen, 'dayhour'); + if (!empty($this->date_last_gen)) { + $label .= '
'.$langs->trans('DateLastGeneration').': '.dol_print_date($this->date_last_gen, 'dayhour'); } if ($this->frequency > 0) { - if (! empty($this->date_when)) { - $label .= '
'.$langs->trans('NextDateToExecution') . ': '; - $label .= (empty($this->suspended)?'':''). dol_print_date($this->date_when, 'day').(empty($this->suspended)?'':''); // No hour for this property - if (! empty($this->suspended)) $label .= ' ('.$langs->trans("Disabled").')'; + if (!empty($this->date_when)) { + $label .= '
'.$langs->trans('NextDateToExecution').': '; + $label .= (empty($this->suspended) ? '' : '').dol_print_date($this->date_when, 'day').(empty($this->suspended) ? '' : ''); // No hour for this property + if (!empty($this->suspended)) $label .= ' ('.$langs->trans("Disabled").')'; } } @@ -1266,17 +1266,17 @@ class FactureRec extends CommonInvoice if ($option != 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } $linkstart = ''; - $linkend=''; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; return $result; @@ -1292,7 +1292,7 @@ class FactureRec extends CommonInvoice public function getLibStatut($mode = 0, $alreadypaid = -1) { - return $this->LibStatut($this->frequency?1:0, $this->suspended, $mode, $alreadypaid, empty($this->type)?0:$this->type); + return $this->LibStatut($this->frequency ? 1 : 0, $this->suspended, $mode, $alreadypaid, empty($this->type) ? 0 : $this->type); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -1315,7 +1315,7 @@ class FactureRec extends CommonInvoice //print "$recur,$status,$mode,$alreadypaid,$type"; if ($mode == 0) { - $prefix=''; + $prefix = ''; if ($recur) { if ($status == self::STATUS_SUSPENDED) return $langs->trans('Disabled'); @@ -1329,7 +1329,7 @@ class FactureRec extends CommonInvoice } elseif ($mode == 1) { - $prefix='Short'; + $prefix = 'Short'; if ($recur) { if ($status == self::STATUS_SUSPENDED) return $langs->trans('Disabled'); @@ -1358,7 +1358,7 @@ class FactureRec extends CommonInvoice { if ($recur) { - $prefix='Short'; + $prefix = 'Short'; if ($status == self::STATUS_SUSPENDED) return img_picto($langs->trans('Disabled'), 'statut6'); else return img_picto($langs->trans('Active'), 'statut4'); } @@ -1370,7 +1370,7 @@ class FactureRec extends CommonInvoice } elseif ($mode == 4) { - $prefix=''; + $prefix = ''; if ($recur) { if ($status == self::STATUS_SUSPENDED) return img_picto($langs->trans('Disabled'), 'statut6').' '.$langs->trans('Disabled'); @@ -1384,8 +1384,8 @@ class FactureRec extends CommonInvoice } elseif ($mode == 5 || $mode == 6) { - $prefix=''; - if ($mode == 5) $prefix='Short'; + $prefix = ''; + if ($mode == 5) $prefix = 'Short'; if ($recur) { if ($status == self::STATUS_SUSPENDED) return ''.$langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut6'); @@ -1409,19 +1409,19 @@ class FactureRec extends CommonInvoice */ public function initAsSpecimen($option = '') { - global $user,$langs,$conf; + global $user, $langs, $conf; - $now=dol_now(); - $arraynow=dol_getdate($now); - $nownotime=dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); + $now = dol_now(); + $arraynow = dol_getdate($now); + $nownotime = dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); // Load array of products prodids $num_prods = 0; $prodids = array(); $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity IN (".getEntity('product').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."product"; + $sql .= " WHERE entity IN (".getEntity('product').")"; $resql = $this->db->query($sql); if ($resql) { @@ -1436,22 +1436,22 @@ class FactureRec extends CommonInvoice } // Initialize parameters - $this->id=0; + $this->id = 0; $this->ref = 'SPECIMEN'; - $this->specimen=1; + $this->specimen = 1; $this->socid = 1; $this->date = $nownotime; - $this->date_lim_reglement = $nownotime + 3600 * 24 *30; + $this->date_lim_reglement = $nownotime + 3600 * 24 * 30; $this->cond_reglement_id = 1; $this->cond_reglement_code = 'RECEP'; - $this->date_lim_reglement=$this->calculate_date_lim_reglement(); - $this->mode_reglement_id = 0; // Not forced to show payment mode CHQ + VIR - $this->mode_reglement_code = ''; // Not forced to show payment mode CHQ + VIR - $this->note_public='This is a comment (public)'; - $this->note_private='This is a comment (private)'; - $this->note='This is a comment (private)'; - $this->fk_incoterms=0; - $this->location_incoterms=''; + $this->date_lim_reglement = $this->calculate_date_lim_reglement(); + $this->mode_reglement_id = 0; // Not forced to show payment mode CHQ + VIR + $this->mode_reglement_code = ''; // Not forced to show payment mode CHQ + VIR + $this->note_public = 'This is a comment (public)'; + $this->note_private = 'This is a comment (private)'; + $this->note = 'This is a comment (private)'; + $this->fk_incoterms = 0; + $this->location_incoterms = ''; if (empty($option) || $option != 'nolines') { @@ -1460,51 +1460,51 @@ class FactureRec extends CommonInvoice $xnbp = 0; while ($xnbp < $nbp) { - $line=new FactureLigne($this->db); - $line->desc=$langs->trans("Description")." ".$xnbp; - $line->qty=1; - $line->subprice=100; - $line->tva_tx=19.6; - $line->localtax1_tx=0; - $line->localtax2_tx=0; - $line->remise_percent=0; + $line = new FactureLigne($this->db); + $line->desc = $langs->trans("Description")." ".$xnbp; + $line->qty = 1; + $line->subprice = 100; + $line->tva_tx = 19.6; + $line->localtax1_tx = 0; + $line->localtax2_tx = 0; + $line->remise_percent = 0; if ($xnbp == 1) // Qty is negative (product line) { $prodid = mt_rand(1, $num_prods); - $line->fk_product=$prodids[$prodid]; - $line->qty=-1; - $line->total_ht=-100; - $line->total_ttc=-119.6; - $line->total_tva=-19.6; + $line->fk_product = $prodids[$prodid]; + $line->qty = -1; + $line->total_ht = -100; + $line->total_ttc = -119.6; + $line->total_tva = -19.6; } elseif ($xnbp == 2) // UP is negative (free line) { - $line->subprice=-100; - $line->total_ht=-100; - $line->total_ttc=-119.6; - $line->total_tva=-19.6; - $line->remise_percent=0; + $line->subprice = -100; + $line->total_ht = -100; + $line->total_ttc = -119.6; + $line->total_tva = -19.6; + $line->remise_percent = 0; } elseif ($xnbp == 3) // Discount is 50% (product line) { $prodid = mt_rand(1, $num_prods); - $line->fk_product=$prodids[$prodid]; - $line->total_ht=50; - $line->total_ttc=59.8; - $line->total_tva=9.8; - $line->remise_percent=50; + $line->fk_product = $prodids[$prodid]; + $line->total_ht = 50; + $line->total_ttc = 59.8; + $line->total_tva = 9.8; + $line->remise_percent = 50; } else // (product line) { $prodid = mt_rand(1, $num_prods); - $line->fk_product=$prodids[$prodid]; - $line->total_ht=100; - $line->total_ttc=119.6; - $line->total_tva=19.6; - $line->remise_percent=00; + $line->fk_product = $prodids[$prodid]; + $line->total_ht = 100; + $line->total_ttc = 119.6; + $line->total_tva = 19.6; + $line->remise_percent = 00; } - $this->lines[$xnbp]=$line; + $this->lines[$xnbp] = $line; $xnbp++; $this->total_ht += $line->total_ht; @@ -1514,21 +1514,21 @@ class FactureRec extends CommonInvoice $this->revenuestamp = 0; // Add a line "offered" - $line=new FactureLigne($this->db); - $line->desc=$langs->trans("Description")." (offered line)"; - $line->qty=1; - $line->subprice=100; - $line->tva_tx=19.6; - $line->localtax1_tx=0; - $line->localtax2_tx=0; - $line->remise_percent=100; - $line->total_ht=0; - $line->total_ttc=0; // 90 * 1.196 - $line->total_tva=0; + $line = new FactureLigne($this->db); + $line->desc = $langs->trans("Description")." (offered line)"; + $line->qty = 1; + $line->subprice = 100; + $line->tva_tx = 19.6; + $line->localtax1_tx = 0; + $line->localtax2_tx = 0; + $line->remise_percent = 100; + $line->total_ht = 0; + $line->total_ttc = 0; // 90 * 1.196 + $line->total_tva = 0; $prodid = mt_rand(1, $num_prods); - $line->fk_product=$prodids[$prodid]; + $line->fk_product = $prodids[$prodid]; - $this->lines[$xnbp]=$line; + $this->lines[$xnbp] = $line; $xnbp++; } @@ -1561,7 +1561,7 @@ class FactureRec extends CommonInvoice */ public function setFrequencyAndUnit($frequency, $unit) { - if (! $this->table_element) { + if (!$this->table_element) { dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with property table_element not defined", LOG_ERR); return -1; } @@ -1572,11 +1572,11 @@ class FactureRec extends CommonInvoice } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= ' SET frequency = '.($frequency?$this->db->escape($frequency):'null'); + $sql .= ' SET frequency = '.($frequency ? $this->db->escape($frequency) : 'null'); if (!empty($unit)) { - $sql.= ', unit_frequency = \''.$this->db->escape($unit).'\''; + $sql .= ', unit_frequency = \''.$this->db->escape($unit).'\''; } - $sql.= ' WHERE rowid = '.$this->id; + $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::setFrequencyAndUnit", LOG_DEBUG); if ($this->db->query($sql)) { @@ -1600,21 +1600,21 @@ class FactureRec extends CommonInvoice */ public function setNextDate($date, $increment_nb_gen_done = 0) { - if (! $this->table_element) + if (!$this->table_element) { dol_syslog(get_class($this)."::setNextDate was called on objet with property table_element not defined", LOG_ERR); return -1; } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET date_when = ".($date ? "'".$this->db->idate($date)."'" : "null"); - if ($increment_nb_gen_done>0) $sql.= ', nb_gen_done = nb_gen_done + 1'; - $sql.= ' WHERE rowid = '.$this->id; + $sql .= " SET date_when = ".($date ? "'".$this->db->idate($date)."'" : "null"); + if ($increment_nb_gen_done > 0) $sql .= ', nb_gen_done = nb_gen_done + 1'; + $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::setNextDate", LOG_DEBUG); if ($this->db->query($sql)) { $this->date_when = $date; - if ($increment_nb_gen_done>0) $this->nb_gen_done++; + if ($increment_nb_gen_done > 0) $this->nb_gen_done++; return 1; } else @@ -1632,17 +1632,17 @@ class FactureRec extends CommonInvoice */ public function setMaxPeriod($nb) { - if (! $this->table_element) + if (!$this->table_element) { dol_syslog(get_class($this)."::setMaxPeriod was called on objet with property table_element not defined", LOG_ERR); return -1; } - if (empty($nb)) $nb=0; + if (empty($nb)) $nb = 0; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= ' SET nb_gen_max = '.$nb; - $sql.= ' WHERE rowid = '.$this->id; + $sql .= ' SET nb_gen_max = '.$nb; + $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::setMaxPeriod", LOG_DEBUG); if ($this->db->query($sql)) @@ -1665,15 +1665,15 @@ class FactureRec extends CommonInvoice */ public function setAutoValidate($validate) { - if (! $this->table_element) + if (!$this->table_element) { dol_syslog(get_class($this)."::setAutoValidate was called on objet with property table_element not defined", LOG_ERR); return -1; } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= ' SET auto_validate = '.$validate; - $sql.= ' WHERE rowid = '.$this->id; + $sql .= ' SET auto_validate = '.$validate; + $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::setAutoValidate", LOG_DEBUG); if ($this->db->query($sql)) @@ -1696,15 +1696,15 @@ class FactureRec extends CommonInvoice */ public function setGeneratePdf($validate) { - if (! $this->table_element) + if (!$this->table_element) { dol_syslog(get_class($this)."::setGeneratePdf was called on objet with property table_element not defined", LOG_ERR); return -1; } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= ' SET generate_pdf = '.$validate; - $sql.= ' WHERE rowid = '.$this->id; + $sql .= ' SET generate_pdf = '.$validate; + $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::setGeneratePdf", LOG_DEBUG); if ($this->db->query($sql)) @@ -1727,15 +1727,15 @@ class FactureRec extends CommonInvoice */ public function setModelPdf($model) { - if (! $this->table_element) + if (!$this->table_element) { dol_syslog(get_class($this)."::setModelPdf was called on objet with property table_element not defined", LOG_ERR); return -1; } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= ' SET modelpdf = "' . $model . '"'; - $sql.= ' WHERE rowid = '.$this->id; + $sql .= ' SET modelpdf = "'.$model.'"'; + $sql .= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::setModelPdf", LOG_DEBUG); if ($this->db->query($sql)) @@ -1762,12 +1762,12 @@ class FactureLigneRec extends CommonInvoiceLine /** * @var string ID to identify managed object */ - public $element='facturedetrec'; + public $element = 'facturedetrec'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='facturedet_rec'; + public $table_element = 'facturedet_rec'; public $date_start_fill; public $date_end_fill; @@ -1782,25 +1782,25 @@ class FactureLigneRec extends CommonInvoiceLine */ public function delete(User $user, $notrigger = false) { - $error=0; + $error = 0; $this->db->begin(); - if (! $error) { - if (! $notrigger) { + if (!$error) { + if (!$notrigger) { // Call triggers - $result=$this->call_trigger('LINEBILLREC_DELETE', $user); + $result = $this->call_trigger('LINEBILLREC_DELETE', $user); if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail // End call triggers } } - if (! $error) + if (!$error) { $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id; $res = $this->db->query($sql); - if($res===false) { + if ($res === false) { $error++; $this->errors[] = $this->db->lasterror(); } @@ -1826,15 +1826,15 @@ class FactureLigneRec extends CommonInvoiceLine public function fetch($rowid) { $sql = 'SELECT l.rowid, l.fk_facture ,l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,'; - $sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,'; - $sql.= ' l.date_start_fill, l.date_end_fill, l.info_bits, l.total_ht, l.total_tva, l.total_ttc,'; - $sql.= ' l.rang, l.special_code,'; - $sql.= ' l.fk_unit, l.fk_contract_line,'; - $sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet_rec as l'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; - $sql.= ' WHERE l.rowid = '.$rowid; - $sql.= ' ORDER BY l.rang'; + $sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,'; + $sql .= ' l.date_start_fill, l.date_end_fill, l.info_bits, l.total_ht, l.total_tva, l.total_ttc,'; + $sql .= ' l.rang, l.special_code,'; + $sql .= ' l.fk_unit, l.fk_contract_line,'; + $sql .= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facturedet_rec as l'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; + $sql .= ' WHERE l.rowid = '.$rowid; + $sql .= ' ORDER BY l.rang'; dol_syslog('FactureRec::fetch', LOG_DEBUG); $result = $this->db->query($sql); @@ -1842,21 +1842,21 @@ class FactureLigneRec extends CommonInvoiceLine { $objp = $this->db->fetch_object($result); - $this->id = $objp->rowid; - $this->label = $objp->custom_label; // Label line - $this->desc = $objp->description; // Description line - $this->description = $objp->description; // Description line - $this->product_type = $objp->product_type; // Type of line - $this->ref = $objp->product_ref; // Ref product - $this->product_ref = $objp->product_ref; // Ref product - $this->libelle = $objp->product_label; // deprecated - $this->product_label = $objp->product_label; // Label product - $this->product_desc = $objp->product_desc; // Description product - $this->fk_product_type = $objp->fk_product_type; // Type of product + $this->id = $objp->rowid; + $this->label = $objp->custom_label; // Label line + $this->desc = $objp->description; // Description line + $this->description = $objp->description; // Description line + $this->product_type = $objp->product_type; // Type of line + $this->ref = $objp->product_ref; // Ref product + $this->product_ref = $objp->product_ref; // Ref product + $this->libelle = $objp->product_label; // deprecated + $this->product_label = $objp->product_label; // Label product + $this->product_desc = $objp->product_desc; // Description product + $this->fk_product_type = $objp->fk_product_type; // Type of product $this->qty = $objp->qty; - $this->price = $objp->price; + $this->price = $objp->price; $this->subprice = $objp->subprice; - $this->fk_facture = $objp->fk_facture; + $this->fk_facture = $objp->fk_facture; $this->vat_src_code = $objp->vat_src_code; $this->tva_tx = $objp->tva_tx; $this->localtax1_tx = $objp->localtax1_tx; @@ -1873,8 +1873,8 @@ class FactureLigneRec extends CommonInvoiceLine $this->total_tva = $objp->total_tva; $this->total_ttc = $objp->total_ttc; $this->code_ventilation = $objp->fk_code_ventilation; - $this->rang = $objp->rang; - $this->special_code = $objp->special_code; + $this->rang = $objp->rang; + $this->special_code = $objp->special_code; $this->fk_unit = $objp->fk_unit; $this->fk_contract_line = $objp->fk_contract_line; @@ -1884,7 +1884,7 @@ class FactureLigneRec extends CommonInvoiceLine } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -3; } } @@ -1906,54 +1906,54 @@ class FactureLigneRec extends CommonInvoiceLine include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet_rec SET"; - $sql.= " fk_facture = ".$this->fk_facture; - $sql.= ", label=".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null"); - $sql.= ", description='".$this->db->escape($this->desc)."'"; - $sql.= ", price=".price2num($this->price); - $sql.= ", qty=".price2num($this->qty); - $sql.= ", tva_tx=".price2num($this->tva_tx); - $sql.= ", vat_src_code='".$this->db->escape($this->vat_src_code)."'"; - $sql.= ", localtax1_tx=".price2num($this->localtax1_tx); - $sql.= ", localtax1_type='".$this->db->escape($this->localtax1_type)."'"; - $sql.= ", localtax2_tx=".price2num($this->localtax2_tx); - $sql.= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'"; - $sql.= ", fk_product=".($this->fk_product > 0 ? $this->fk_product :"null"); - $sql.= ", product_type=".$this->product_type; - $sql.= ", remise_percent='".price2num($this->remise_percent)."'"; - $sql.= ", subprice='".price2num($this->subprice)."'"; - $sql.= ", info_bits='".price2num($this->info_bits)."'"; - $sql.= ", date_start_fill=".(int) $this->date_start_fill; - $sql.= ", date_end_fill=".(int) $this->date_end_fill; + $sql .= " fk_facture = ".$this->fk_facture; + $sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); + $sql .= ", description='".$this->db->escape($this->desc)."'"; + $sql .= ", price=".price2num($this->price); + $sql .= ", qty=".price2num($this->qty); + $sql .= ", tva_tx=".price2num($this->tva_tx); + $sql .= ", vat_src_code='".$this->db->escape($this->vat_src_code)."'"; + $sql .= ", localtax1_tx=".price2num($this->localtax1_tx); + $sql .= ", localtax1_type='".$this->db->escape($this->localtax1_type)."'"; + $sql .= ", localtax2_tx=".price2num($this->localtax2_tx); + $sql .= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'"; + $sql .= ", fk_product=".($this->fk_product > 0 ? $this->fk_product : "null"); + $sql .= ", product_type=".$this->product_type; + $sql .= ", remise_percent='".price2num($this->remise_percent)."'"; + $sql .= ", subprice='".price2num($this->subprice)."'"; + $sql .= ", info_bits='".price2num($this->info_bits)."'"; + $sql .= ", date_start_fill=".(int) $this->date_start_fill; + $sql .= ", date_end_fill=".(int) $this->date_end_fill; if (empty($this->skip_update_total)) { - $sql.= ", total_ht=".price2num($this->total_ht); - $sql.= ", total_tva=".price2num($this->total_tva); - $sql.= ", total_localtax1=".price2num($this->total_localtax1); - $sql.= ", total_localtax2=".price2num($this->total_localtax2); - $sql.= ", total_ttc=".price2num($this->total_ttc); + $sql .= ", total_ht=".price2num($this->total_ht); + $sql .= ", total_tva=".price2num($this->total_tva); + $sql .= ", total_localtax1=".price2num($this->total_localtax1); + $sql .= ", total_localtax2=".price2num($this->total_localtax2); + $sql .= ", total_ttc=".price2num($this->total_ttc); } - $sql.= ", rang=".$this->rang; - $sql.= ", special_code=".$this->special_code; - $sql.= ", fk_unit=".($this->fk_unit ?"'".$this->db->escape($this->fk_unit)."'":"null"); - $sql.= ", fk_contract_line=".($this->fk_contract_line?$this->fk_contract_line:"null"); - $sql.= " WHERE rowid = ".$this->id; + $sql .= ", rang=".$this->rang; + $sql .= ", special_code=".$this->special_code; + $sql .= ", fk_unit=".($this->fk_unit ? "'".$this->db->escape($this->fk_unit)."'" : "null"); + $sql .= ", fk_contract_line=".($this->fk_contract_line ? $this->fk_contract_line : "null"); + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::updateline", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('LINEBILLREC_UPDATE', $user); + $result = $this->call_trigger('LINEBILLREC_UPDATE', $user); if ($result < 0) { $this->db->rollback(); @@ -1966,7 +1966,7 @@ class FactureLigneRec extends CommonInvoiceLine } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -2; } diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 75945106b72..ca8c78dd478 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -48,94 +48,94 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.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.'/projet/class/project.class.php'; -if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; // Load translation files required by the page $langs->loadLangs(array('bills', 'companies', 'products', 'categories')); -$sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$projectid=(GETPOST('projectid')?GETPOST('projectid', 'int'):0); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$projectid = (GETPOST('projectid') ?GETPOST('projectid', 'int') : 0); -$id=(GETPOST('id', 'int')?GETPOST('id', 'int'):GETPOST('facid', 'int')); // For backward compatibility -$ref=GETPOST('ref', 'alpha'); -$socid=GETPOST('socid', 'int'); +$id = (GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility +$ref = GETPOST('ref', 'alpha'); +$socid = GETPOST('socid', 'int'); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'invoicelist'; +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'invoicelist'; if ($contextpage == 'poslist') { $_GET['optioncss'] = 'print'; } -$lineid=GETPOST('lineid', 'int'); -$userid=GETPOST('userid', 'int'); -$search_product_category=GETPOST('search_product_category', 'int'); -$search_ref=GETPOST('sf_ref')?GETPOST('sf_ref', 'alpha'):GETPOST('search_ref', 'alpha'); -$search_refcustomer=GETPOST('search_refcustomer', 'alpha'); -$search_type=GETPOST('search_type', 'int'); -$search_project_ref=GETPOST('search_project_ref', 'alpha'); -$search_project=GETPOST('search_project', 'alpha'); -$search_societe=GETPOST('search_societe', 'alpha'); -$search_montant_ht=GETPOST('search_montant_ht', 'alpha'); -$search_montant_vat=GETPOST('search_montant_vat', 'alpha'); -$search_montant_localtax1=GETPOST('search_montant_localtax1', 'alpha'); -$search_montant_localtax2=GETPOST('search_montant_localtax2', 'alpha'); -$search_montant_ttc=GETPOST('search_montant_ttc', 'alpha'); -$search_status=GETPOST('search_status', 'intcomma'); -$search_paymentmode=GETPOST('search_paymentmode', 'int'); -$search_paymentterms=GETPOST('search_paymentterms', 'int'); -$search_module_source=GETPOST('search_module_source', 'alpha'); -$search_pos_source=GETPOST('search_pos_source', 'alpha'); -$search_town=GETPOST('search_town', 'alpha'); -$search_zip=GETPOST('search_zip', 'alpha'); -$search_state=trim(GETPOST("search_state")); -$search_country=GETPOST("search_country", 'int'); -$search_type_thirdparty=GETPOST("search_type_thirdparty", 'int'); +$lineid = GETPOST('lineid', 'int'); +$userid = GETPOST('userid', 'int'); +$search_product_category = GETPOST('search_product_category', 'int'); +$search_ref = GETPOST('sf_ref') ?GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha'); +$search_refcustomer = GETPOST('search_refcustomer', 'alpha'); +$search_type = GETPOST('search_type', 'int'); +$search_project_ref = GETPOST('search_project_ref', 'alpha'); +$search_project = GETPOST('search_project', 'alpha'); +$search_societe = GETPOST('search_societe', 'alpha'); +$search_montant_ht = GETPOST('search_montant_ht', 'alpha'); +$search_montant_vat = GETPOST('search_montant_vat', 'alpha'); +$search_montant_localtax1 = GETPOST('search_montant_localtax1', 'alpha'); +$search_montant_localtax2 = GETPOST('search_montant_localtax2', 'alpha'); +$search_montant_ttc = GETPOST('search_montant_ttc', 'alpha'); +$search_status = GETPOST('search_status', 'intcomma'); +$search_paymentmode = GETPOST('search_paymentmode', 'int'); +$search_paymentterms = GETPOST('search_paymentterms', 'int'); +$search_module_source = GETPOST('search_module_source', 'alpha'); +$search_pos_source = GETPOST('search_pos_source', 'alpha'); +$search_town = GETPOST('search_town', 'alpha'); +$search_zip = GETPOST('search_zip', 'alpha'); +$search_state = trim(GETPOST("search_state")); +$search_country = GETPOST("search_country", 'int'); +$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); $search_user = GETPOST('search_user', 'int'); $search_sale = GETPOST('search_sale', 'int'); -$search_day = GETPOST('search_day', 'int'); -$search_month = GETPOST('search_month', 'int'); +$search_day = GETPOST('search_day', 'int'); +$search_month = GETPOST('search_month', 'int'); $search_year = GETPOST('search_year', 'int'); $search_day_lim = GETPOST('search_day_lim', 'int'); -$search_month_lim = GETPOST('search_month_lim', 'int'); +$search_month_lim = GETPOST('search_month_lim', 'int'); $search_year_lim = GETPOST('search_year_lim', 'int'); -$search_categ_cus=trim(GETPOST("search_categ_cus", 'int')); -$search_btn=GETPOST('button_search', 'alpha'); -$search_remove_btn=GETPOST('button_removefilter', 'alpha'); +$search_categ_cus = trim(GETPOST("search_categ_cus", 'int')); +$search_btn = GETPOST('button_search', 'alpha'); +$search_remove_btn = GETPOST('button_removefilter', 'alpha'); $option = GETPOST('search_option'); if ($option == 'late') { $search_status = '1'; } -$filtre = GETPOST('filtre', 'alpha'); +$filtre = GETPOST('filtre', 'alpha'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; -if (! $sortorder && ! empty($conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER) && $search_status == '1') $sortorder=$conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER; -if (! $sortorder) $sortorder='DESC'; -if (! $sortfield) $sortfield='f.datef'; +if (!$sortorder && !empty($conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER) && $search_status == '1') $sortorder = $conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER; +if (!$sortorder) $sortorder = 'DESC'; +if (!$sortfield) $sortfield = 'f.datef'; $pageprev = $page - 1; $pagenext = $page + 1; // Security check -$fieldid = (! empty($ref)?'ref':'rowid'); -if (! empty($user->socid)) $socid=$user->socid; +$fieldid = (!empty($ref) ? 'ref' : 'rowid'); +if (!empty($user->socid)) $socid = $user->socid; $result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid); -$diroutputmassaction=$conf->facture->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->facture->dir_output.'/temp/massgeneration/'.$user->id; -$object=new Facture($db); +$object = new Facture($db); -$now=dol_now(); +$now = dol_now(); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Facture($db); @@ -145,7 +145,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label('facture'); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -155,18 +155,18 @@ $fieldstosearchall = array( 's.nom'=>"ThirdParty", 'f.note_public'=>'NotePublic', ); -if (empty($user->socid)) $fieldstosearchall["f.note_private"]="NotePrivate"; +if (empty($user->socid)) $fieldstosearchall["f.note_private"] = "NotePrivate"; -$checkedtypetiers=0; -$arrayfields=array( +$checkedtypetiers = 0; +$arrayfields = array( 'f.ref'=>array('label'=>"Ref", 'checked'=>1, 'position'=>5), 'f.ref_client'=>array('label'=>"RefCustomer", 'checked'=>1, 'position'=>10), 'f.type'=>array('label'=>"Type", 'checked'=>0, 'position'=>15), 'f.date'=>array('label'=>"DateInvoice", 'checked'=>1, 'position'=>20), 'f.date_lim_reglement'=>array('label'=>"DateDue", 'checked'=>1, 'position'=>25), 'f.date_closing'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>30), - 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled)?0:1), 'position'=>40), - 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled)?0:1), 'position'=>40), + 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1), 'position'=>40), + 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1), 'position'=>40), 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>50), 's.town'=>array('label'=>"Town", 'checked'=>1, 'position'=>55), 's.zip'=>array('label'=>"Zip", 'checked'=>1, 'position'=>60), @@ -179,17 +179,17 @@ $arrayfields=array( 'f.pos_source'=>array('label'=>"Terminal", 'checked'=>($contextpage == 'poslist' ? 1 : 0), 'enabled'=>($conf->cashdesk->enabled || $conf->takepos->enabled || $conf->global->INVOICE_SHOW_POS), 'position'=>91), 'f.total_ht'=>array('label'=>"AmountHT", 'checked'=>1, 'position'=>95), 'f.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0, 'position'=>100), - 'f.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax1_assuj=="1"), 'position'=>110), - 'f.total_localtax2'=>array('label'=>$langs->transcountry("AmountLT2", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax2_assuj=="1"), 'position'=>120), + 'f.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax1_assuj == "1"), 'position'=>110), + 'f.total_localtax2'=>array('label'=>$langs->transcountry("AmountLT2", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax2_assuj == "1"), 'position'=>120), 'f.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0, 'position'=>130), 'dynamount_payed'=>array('label'=>"Received", 'checked'=>0, 'position'=>140), - 'rtp'=>array('label'=>"Rest", 'checked'=>0, 'position'=>150), // Not enabled by default because slow + 'rtp'=>array('label'=>"Rest", 'checked'=>0, 'position'=>150), // Not enabled by default because slow 'f.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), 'f.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), ); -if($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY) +if ($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY) { $arrayfields['f.retained_warranty'] = array('label'=>$langs->trans("RetainedWarranty"), 'checked'=>0, 'position'=>86); } @@ -197,10 +197,10 @@ if($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_SITUATION_ // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -211,11 +211,11 @@ $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('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; @@ -223,48 +223,48 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Do we click on purge search criteria ? if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha')) // All tests are required to be compatible with all browsers { - $search_user=''; - $search_sale=''; - $search_product_category=''; - $search_ref=''; - $search_refcustomer=''; - $search_type=''; - $search_project_ref=''; - $search_project=''; - $search_societe=''; - $search_montant_ht=''; - $search_montant_vat=''; - $search_montant_localtax1=''; - $search_montant_localtax2=''; - $search_montant_ttc=''; - $search_status=''; - $search_paymentmode=''; - $search_paymentterms=''; - $search_module_source=''; - $search_pos_source=''; - $search_town=''; - $search_zip=""; - $search_state=""; - $search_type=''; - $search_country=''; - $search_type_thirdparty=''; - $search_day=''; - $search_year=''; - $search_month=''; - $option=''; - $filter=''; - $search_day_lim=''; - $search_year_lim=''; - $search_month_lim=''; - $toselect=''; - $search_array_options=array(); - $search_categ_cus=0; + $search_user = ''; + $search_sale = ''; + $search_product_category = ''; + $search_ref = ''; + $search_refcustomer = ''; + $search_type = ''; + $search_project_ref = ''; + $search_project = ''; + $search_societe = ''; + $search_montant_ht = ''; + $search_montant_vat = ''; + $search_montant_localtax1 = ''; + $search_montant_localtax2 = ''; + $search_montant_ttc = ''; + $search_status = ''; + $search_paymentmode = ''; + $search_paymentterms = ''; + $search_module_source = ''; + $search_pos_source = ''; + $search_town = ''; + $search_zip = ""; + $search_state = ""; + $search_type = ''; + $search_country = ''; + $search_type_thirdparty = ''; + $search_day = ''; + $search_year = ''; + $search_month = ''; + $option = ''; + $filter = ''; + $search_day_lim = ''; + $search_year_lim = ''; + $search_month_lim = ''; + $toselect = ''; + $search_array_options = array(); + $search_categ_cus = 0; } if (empty($reshook)) { - $objectclass='Facture'; - $objectlabel='Invoices'; + $objectclass = 'Facture'; + $objectlabel = 'Invoices'; $permissiontoread = $user->rights->facture->lire; $permissiontoadd = $user->rights->facture->creer; $permissiontodelete = $user->rights->facture->supprimer; @@ -286,26 +286,26 @@ if ($massaction == 'withdrawrequest') //Checking error $error = 0; - $arrayofselected=is_array($toselect)?$toselect:array(); - $listofbills=array(); - foreach($arrayofselected as $toselectid) + $arrayofselected = is_array($toselect) ? $toselect : array(); + $listofbills = array(); + foreach ($arrayofselected as $toselectid) { - $objecttmp=new Facture($db); - $result=$objecttmp->fetch($toselectid); + $objecttmp = new Facture($db); + $result = $objecttmp->fetch($toselectid); if ($result > 0) { - $totalpaye = $objecttmp->getSommePaiement(); + $totalpaye = $objecttmp->getSommePaiement(); $totalcreditnotes = $objecttmp->getSumCreditNotesUsed(); $totaldeposits = $objecttmp->getSumDepositsUsed(); $objecttmp->resteapayer = price2num($objecttmp->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); - if($objecttmp->paye || $objecttmp->resteapayer==0){ + if ($objecttmp->paye || $objecttmp->resteapayer == 0) { $error++; setEventMessages($objecttmp->ref.' '.$langs->trans("AlreadyPaid"), $objecttmp->errors, 'errors'); - } elseif($objecttmp->resteapayer<0){ + } elseif ($objecttmp->resteapayer < 0) { $error++; setEventMessages($objecttmp->ref.' '.$langs->trans("AmountMustBePositive"), $objecttmp->errors, 'errors'); } - if (!($objecttmp->statut > Facture::STATUS_DRAFT)){ + if (!($objecttmp->statut > Facture::STATUS_DRAFT)) { $error++; setEventMessages($objecttmp->ref.' '.$langs->trans("Draft"), $objecttmp->errors, 'errors'); } @@ -327,25 +327,25 @@ if ($massaction == 'withdrawrequest') $numprlv = $db->num_rows($result_sql); } - if ($numprlv>0){ + if ($numprlv > 0) { $error++; setEventMessages($objecttmp->ref.' '.$langs->trans("RequestAlreadyDone"), $objecttmp->errors, 'warnings'); } - elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code != 'PRE'){ + elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code != 'PRE') { $error++; setEventMessages($objecttmp->ref.' '.$langs->trans("BadPaymentMethod"), $objecttmp->errors, 'errors'); } else { - $listofbills[] = $objecttmp; // $listofbills will only contains invoices with good payment method and no request already done + $listofbills[] = $objecttmp; // $listofbills will only contains invoices with good payment method and no request already done } } } //Massive withdraw request for request with no errors - if(!empty($listofbills)) + if (!empty($listofbills)) { - $nbwithdrawrequestok=0; - foreach($listofbills as $aBill) + $nbwithdrawrequestok = 0; + foreach ($listofbills as $aBill) { $db->begin(); $result = $aBill->demande_prelevement($user, $aBill->resteapayer); @@ -377,64 +377,64 @@ if ($massaction == 'withdrawrequest') $form = new Form($db); $formother = new FormOther($db); $formfile = new FormFile($db); -$bankaccountstatic=new Account($db); -$facturestatic=new Facture($db); -$formcompany=new FormCompany($db); -$thirdpartystatic=new Societe($db); +$bankaccountstatic = new Account($db); +$facturestatic = new Facture($db); +$formcompany = new FormCompany($db); +$thirdpartystatic = new Societe($db); $sql = 'SELECT'; if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; -$sql.= ' f.rowid as id, f.ref, f.ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total as total_ht, f.tva as total_vat, f.total_ttc,'; -$sql.= ' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,'; -$sql.= ' f.datef as df, f.date_lim_reglement as datelimite, f.module_source, f.pos_source,'; -$sql.= ' f.paye as paye, f.fk_statut,'; -$sql.= ' f.datec as date_creation, f.tms as date_update, f.date_closing as date_closing,'; -$sql.= ' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final, f.situation_cycle_ref, f.situation_counter,'; -$sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,'; -$sql.= " typent.code as typent_code,"; -$sql.= " state.code_departement as state_code, state.nom as state_name,"; -$sql.= " country.code as country_code,"; -$sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_label"; +$sql .= ' f.rowid as id, f.ref, f.ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total as total_ht, f.tva as total_vat, f.total_ttc,'; +$sql .= ' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,'; +$sql .= ' f.datef as df, f.date_lim_reglement as datelimite, f.module_source, f.pos_source,'; +$sql .= ' f.paye as paye, f.fk_statut,'; +$sql .= ' f.datec as date_creation, f.tms as date_update, f.date_closing as date_closing,'; +$sql .= ' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final, f.situation_cycle_ref, f.situation_counter,'; +$sql .= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,'; +$sql .= " typent.code as typent_code,"; +$sql .= " state.code_departement as state_code, state.nom as state_name,"; +$sql .= " country.code as country_code,"; +$sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_label"; // We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0) // TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field. -if (! $sall) $sql.= ', SUM(pf.amount) as dynamount_payed'; +if (!$sall) $sql .= ', SUM(pf.amount) as dynamount_payed'; if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; // 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 : ''); +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 : ''); } // 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 '.MAIN_DB_PREFIX.'societe as s'; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; -if (! empty($search_categ_cus)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s'; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +if (!empty($search_categ_cus)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ -$sql.= ', '.MAIN_DB_PREFIX.'facture as f'; -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 (f.rowid = ef.fk_object)"; -if (! $sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid'; -if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet as pd ON f.rowid=pd.fk_facture'; -if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = f.fk_projet"; +$sql .= ', '.MAIN_DB_PREFIX.'facture as f'; +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 (f.rowid = ef.fk_object)"; +if (!$sall) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid'; +if ($sall || $search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet as pd ON f.rowid=pd.fk_facture'; +if ($search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = f.fk_projet"; // We'll need this table joined to the select in order to filter by sale -if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if ($search_user > 0) { - $sql.=", ".MAIN_DB_PREFIX."element_contact as ec"; - $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; } -$sql.= ' WHERE f.fk_soc = s.rowid'; -$sql.= ' AND f.entity IN ('.getEntity('invoice').')'; -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$db->escape($search_product_category); -if ($socid > 0) $sql.= ' AND s.rowid = '.$socid; +$sql .= ' WHERE f.fk_soc = s.rowid'; +$sql .= ' AND f.entity IN ('.getEntity('invoice').')'; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$db->escape($search_product_category); +if ($socid > 0) $sql .= ' AND s.rowid = '.$socid; if ($userid) { - if ($userid == -1) $sql.=' AND f.fk_user_author IS NULL'; - else $sql.=' AND f.fk_user_author = '.$userid; + if ($userid == -1) $sql .= ' AND f.fk_user_author IS NULL'; + else $sql .= ' AND f.fk_user_author = '.$userid; } if ($filtre) { @@ -442,78 +442,78 @@ if ($filtre) foreach ($aFilter as $filter) { $filt = explode(':', $filter); - $sql .= ' AND ' . $db->escape(trim($filt[0])) . ' = ' . $db->escape(trim($filt[1])); + $sql .= ' AND '.$db->escape(trim($filt[0])).' = '.$db->escape(trim($filt[1])); } } if ($search_ref) $sql .= natural_search('f.ref', $search_ref); if ($search_refcustomer) $sql .= natural_search('f.ref_client', $search_refcustomer); -if ($search_type != '' && $search_type != '-1') $sql.=" AND f.type IN (".$db->escape($search_type).")"; +if ($search_type != '' && $search_type != '-1') $sql .= " AND f.type IN (".$db->escape($search_type).")"; if ($search_project_ref) $sql .= natural_search('p.ref', $search_project_ref); if ($search_project) $sql .= natural_search('p.title', $search_project); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); -if ($search_town) $sql.= natural_search('s.town', $search_town); -if ($search_zip) $sql.= natural_search("s.zip", $search_zip); -if ($search_state) $sql.= natural_search("state.nom", $search_state); +if ($search_town) $sql .= natural_search('s.town', $search_town); +if ($search_zip) $sql .= natural_search("s.zip", $search_zip); +if ($search_state) $sql .= natural_search("state.nom", $search_state); if ($search_country) $sql .= " AND s.fk_pays IN (".$db->escape($search_country).')'; if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->escape($search_type_thirdparty).')'; if ($search_company) $sql .= natural_search('s.nom', $search_company); -if ($search_montant_ht != '') $sql.= natural_search('f.total', $search_montant_ht, 1); -if ($search_montant_vat != '') $sql.= natural_search('f.tva', $search_montant_vat, 1); -if ($search_montant_localtax1 != '') $sql.= natural_search('f.localtax1', $search_montant_localtax1, 1); -if ($search_montant_localtax2 != '') $sql.= natural_search('f.localtax2', $search_montant_localtax2, 1); -if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1); -if ($search_categ_cus > 0) $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); -if ($search_categ_cus == -2) $sql.= " AND cc.fk_categorie IS NULL"; +if ($search_montant_ht != '') $sql .= natural_search('f.total', $search_montant_ht, 1); +if ($search_montant_vat != '') $sql .= natural_search('f.tva', $search_montant_vat, 1); +if ($search_montant_localtax1 != '') $sql .= natural_search('f.localtax1', $search_montant_localtax1, 1); +if ($search_montant_localtax2 != '') $sql .= natural_search('f.localtax2', $search_montant_localtax2, 1); +if ($search_montant_ttc != '') $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1); +if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); +if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL"; if ($search_status != '-1' && $search_status != '') { if (is_numeric($search_status) && $search_status >= 0) { - if ($search_status == '0') $sql.=" AND f.fk_statut = 0"; // draft - if ($search_status == '1') $sql.=" AND f.fk_statut = 1"; // unpayed - if ($search_status == '2') $sql.=" AND f.fk_statut = 2"; // payed Not that some corrupted data may contains f.fk_statut = 1 AND f.paye = 1 (it means payed too but should not happend. If yes, reopen and reclassify billed) - if ($search_status == '3') $sql.=" AND f.fk_statut = 3"; // abandonned + if ($search_status == '0') $sql .= " AND f.fk_statut = 0"; // draft + if ($search_status == '1') $sql .= " AND f.fk_statut = 1"; // unpayed + if ($search_status == '2') $sql .= " AND f.fk_statut = 2"; // payed Not that some corrupted data may contains f.fk_statut = 1 AND f.paye = 1 (it means payed too but should not happend. If yes, reopen and reclassify billed) + if ($search_status == '3') $sql .= " AND f.fk_statut = 3"; // abandonned } else { - $sql.= " AND f.fk_statut IN (".$db->escape($search_status).")"; // When search_status is '1,2' for example + $sql .= " AND f.fk_statut IN (".$db->escape($search_status).")"; // When search_status is '1,2' for example } } if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".$db->escape($search_paymentmode); if ($search_paymentterms > 0) $sql .= " AND f.fk_cond_reglement = ".$db->escape($search_paymentterms); if ($search_module_source) $sql .= natural_search("f.module_source", $search_module_source); if ($search_pos_source) $sql .= natural_search("f.pos_source", $search_pos_source); -$sql.= dolSqlDateFilter("f.datef", $search_day, $search_month, $search_year); -$sql.= dolSqlDateFilter("f.date_lim_reglement", $search_day_lim, $search_month_lim, $search_year_lim); -if ($option == 'late') $sql.=" AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->client->warning_delay)."'"; -if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .(int) $search_sale; +$sql .= dolSqlDateFilter("f.datef", $search_day, $search_month, $search_year); +$sql .= dolSqlDateFilter("f.date_lim_reglement", $search_day_lim, $search_month_lim, $search_year_lim); +if ($option == 'late') $sql .= " AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->client->warning_delay)."'"; +if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".(int) $search_sale; if ($search_user > 0) { - $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='facture' AND tc.source='internal' AND ec.element_id = f.rowid AND ec.fk_socpeople = ".$search_user; + $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='facture' AND tc.source='internal' AND ec.element_id = f.rowid AND ec.fk_socpeople = ".$search_user; } // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -if (! $sall) +if (!$sall) { - $sql.= ' GROUP BY f.rowid, f.ref, ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total, f.tva, f.total_ttc,'; - $sql.= ' f.localtax1, f.localtax2,'; - $sql.= ' f.datef, f.date_lim_reglement, f.module_source, f.pos_source,'; - $sql.= ' f.paye, f.fk_statut,'; - $sql.= ' f.datec, f.tms, f.date_closing,'; - $sql.= ' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final, f.situation_cycle_ref, f.situation_counter,'; - $sql.= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,'; - $sql.= ' typent.code,'; - $sql.= ' state.code_departement, state.nom,'; - $sql.= ' country.code,'; - $sql.= " p.rowid, p.ref, p.title"; + $sql .= ' GROUP BY f.rowid, f.ref, ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total, f.tva, f.total_ttc,'; + $sql .= ' f.localtax1, f.localtax2,'; + $sql .= ' f.datef, f.date_lim_reglement, f.module_source, f.pos_source,'; + $sql .= ' f.paye, f.fk_statut,'; + $sql .= ' f.datec, f.tms, f.date_closing,'; + $sql .= ' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final, f.situation_cycle_ref, f.situation_counter,'; + $sql .= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,'; + $sql .= ' typent.code,'; + $sql .= ' state.code_departement, state.nom,'; + $sql .= ' country.code,'; + $sql .= " p.rowid, p.ref, p.title"; if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; // 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 : ''); + 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 : ''); } } else @@ -521,11 +521,11 @@ else $sql .= natural_search(array_keys($fieldstosearchall), $sall); } -$sql.= ' ORDER BY '; -$listfield=explode(',', $sortfield); -$listorder=explode(',', $sortorder); -foreach ($listfield as $key => $value) $sql.= $listfield[$key].' '.($listorder[$key]?$listorder[$key]:'DESC').','; -$sql.= ' f.rowid DESC '; +$sql .= ' ORDER BY '; +$listfield = explode(',', $sortfield); +$listorder = explode(',', $sortorder); +foreach ($listfield as $key => $value) $sql .= $listfield[$key].' '.($listorder[$key] ? $listorder[$key] : 'DESC').','; +$sql .= ' f.rowid DESC '; $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -539,7 +539,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); @@ -547,9 +547,9 @@ if ($resql) { $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); - if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) + if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { $obj = $db->fetch_object($resql); $id = $obj->id; @@ -567,46 +567,46 @@ if ($resql) if (empty($search_societe)) $search_societe = $soc->name; } - $param='&socid='.$socid; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($sall) $param.='&sall='.urlencode($sall); - if ($search_day) $param.='&search_day='.urlencode($search_day); - if ($search_month) $param.='&search_month='.urlencode($search_month); - if ($search_year) $param.='&search_year=' .urlencode($search_year); - if ($search_day_lim) $param.='&search_day_lim='.urlencode($search_day_lim); - if ($search_month_lim) $param.='&search_month_lim='.urlencode($search_month_lim); - if ($search_year_lim) $param.='&search_year_lim=' .urlencode($search_year_lim); - if ($search_ref) $param.='&search_ref=' .urlencode($search_ref); - if ($search_refcustomer) $param.='&search_refcustomer=' .urlencode($search_refcustomer); - if ($search_project_ref) $param.='&search_project_ref='.urlencode($search_project_ref); - if ($search_project) $param.='&search_project='.urlencode($search_project); - if ($search_type != '') $param.='&search_type='.urlencode($search_type); - if ($search_societe) $param.='&search_societe=' .urlencode($search_societe); - if ($search_town) $param.='&search_town='.urlencode($search_town); - if ($search_zip) $param.='&search_zip='.urlencode($search_zip); - if ($search_sale > 0) $param.='&search_sale=' .urlencode($search_sale); - if ($search_user > 0) $param.='&search_user=' .urlencode($search_user); - if ($search_product_category > 0) $param.='&search_product_category=' .urlencode($search_product_category); - if ($search_montant_ht != '') $param.='&search_montant_ht='.urlencode($search_montant_ht); - if ($search_montant_vat != '') $param.='&search_montant_vat='.urlencode($search_montant_vat); - if ($search_montant_localtax1 != '') $param.='&search_montant_localtax1='.urlencode($search_montant_localtax1); - if ($search_montant_localtax2 != '') $param.='&search_montant_localtax2='.urlencode($search_montant_localtax2); - if ($search_montant_ttc != '') $param.='&search_montant_ttc='.urlencode($search_montant_ttc); - if ($search_status != '') $param.='&search_status='.urlencode($search_status); - if ($search_paymentmode > 0) $param.='&search_paymentmode='.urlencode($search_paymentmode); - if ($search_paymentterms > 0) $param.='&search_paymentterms='.urlencode($search_paymentterms); - if ($search_module_source) $param.='&search_module_source='.urlencode($search_module_source); - if ($search_pos_source) $param.='&search_pos_source='.urlencode($search_pos_source); - if ($show_files) $param.='&show_files='.urlencode($show_files); - if ($option) $param.="&search_option=".urlencode($option); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); - if ($search_categ_cus > 0) $param.='&search_categ_cus='.urlencode($search_categ_cus); + $param = '&socid='.$socid; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($sall) $param .= '&sall='.urlencode($sall); + if ($search_day) $param .= '&search_day='.urlencode($search_day); + if ($search_month) $param .= '&search_month='.urlencode($search_month); + if ($search_year) $param .= '&search_year='.urlencode($search_year); + if ($search_day_lim) $param .= '&search_day_lim='.urlencode($search_day_lim); + if ($search_month_lim) $param .= '&search_month_lim='.urlencode($search_month_lim); + if ($search_year_lim) $param .= '&search_year_lim='.urlencode($search_year_lim); + if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); + if ($search_refcustomer) $param .= '&search_refcustomer='.urlencode($search_refcustomer); + if ($search_project_ref) $param .= '&search_project_ref='.urlencode($search_project_ref); + if ($search_project) $param .= '&search_project='.urlencode($search_project); + if ($search_type != '') $param .= '&search_type='.urlencode($search_type); + if ($search_societe) $param .= '&search_societe='.urlencode($search_societe); + if ($search_town) $param .= '&search_town='.urlencode($search_town); + if ($search_zip) $param .= '&search_zip='.urlencode($search_zip); + if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); + if ($search_user > 0) $param .= '&search_user='.urlencode($search_user); + if ($search_product_category > 0) $param .= '&search_product_category='.urlencode($search_product_category); + if ($search_montant_ht != '') $param .= '&search_montant_ht='.urlencode($search_montant_ht); + if ($search_montant_vat != '') $param .= '&search_montant_vat='.urlencode($search_montant_vat); + if ($search_montant_localtax1 != '') $param .= '&search_montant_localtax1='.urlencode($search_montant_localtax1); + if ($search_montant_localtax2 != '') $param .= '&search_montant_localtax2='.urlencode($search_montant_localtax2); + if ($search_montant_ttc != '') $param .= '&search_montant_ttc='.urlencode($search_montant_ttc); + if ($search_status != '') $param .= '&search_status='.urlencode($search_status); + if ($search_paymentmode > 0) $param .= '&search_paymentmode='.urlencode($search_paymentmode); + if ($search_paymentterms > 0) $param .= '&search_paymentterms='.urlencode($search_paymentterms); + if ($search_module_source) $param .= '&search_module_source='.urlencode($search_module_source); + if ($search_pos_source) $param .= '&search_pos_source='.urlencode($search_pos_source); + if ($show_files) $param .= '&show_files='.urlencode($show_files); + if ($option) $param .= "&search_option=".urlencode($option); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + if ($search_categ_cus > 0) $param .= '&search_categ_cus='.urlencode($search_categ_cus); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - $arrayofmassactions=array( + $arrayofmassactions = array( 'validate'=>$langs->trans("Validate"), 'generate_doc'=>$langs->trans("ReGeneratePDF"), 'builddoc'=>$langs->trans("PDFMerge"), @@ -625,12 +625,12 @@ if ($resql) } } if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); - $newcardbutton=''; - if($user->rights->facture->creer && $contextpage != 'poslist') + $newcardbutton = ''; + if ($user->rights->facture->creer && $contextpage != 'poslist') { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewBill'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/facture/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewBill'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/facture/card.php?action=create'); } $i = 0; @@ -646,58 +646,58 @@ if ($resql) print ''; print ''; - print_barre_liste($langs->trans('BillsCustomers').' '.($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'invoicing', 0, $newcardbutton, '', $limit); + print_barre_liste($langs->trans('BillsCustomers').' '.($socid ? ' '.$soc->name : ''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'invoicing', 0, $newcardbutton, '', $limit); - $topicmail="SendBillRef"; - $modelmail="facture_send"; - $objecttmp=new Facture($db); - $trackid='inv'.$object->id; + $topicmail = "SendBillRef"; + $modelmail = "facture_send"; + $objecttmp = new Facture($db); + $trackid = 'inv'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } // If the user can view prospects other than his' - $moreforfilter=''; + $moreforfilter = ''; if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); - $moreforfilter.='
'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; + $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $moreforfilter .= '
'; } // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; - $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); - $moreforfilter.='
'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; + $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); + $moreforfilter .= '
'; } // If the user can view prospects other than his' if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': '; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); - $moreforfilter.='
'; + $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter .= '
'; } - if (! empty($conf->categorie->enabled)) + if (!empty($conf->categorie->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('CustomersProspectsCategoriesShort').': '; - $moreforfilter.=$formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1); - $moreforfilter.='
'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': '; + $moreforfilter .= $formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1); + $moreforfilter .= '
'; } - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; @@ -708,40 +708,40 @@ if ($resql) print '
'; } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton && $contextpage != 'poslist') $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + if ($massactionbutton && $contextpage != 'poslist') $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); print '
'; - print ''."\n"; + print '
'."\n"; // Filters lines print ''; // Ref - if (! empty($arrayfields['f.ref']['checked'])) + if (!empty($arrayfields['f.ref']['checked'])) { print ''; } // Ref customer - if (! empty($arrayfields['f.ref_client']['checked'])) + if (!empty($arrayfields['f.ref_client']['checked'])) { print ''; } // Type - if (! empty($arrayfields['f.type']['checked'])) + if (!empty($arrayfields['f.type']['checked'])) { print ''; } // Date invoice - if (! empty($arrayfields['f.date']['checked'])) + if (!empty($arrayfields['f.date']['checked'])) { print ''; } // Date due - if (! empty($arrayfields['f.date_lim_reglement']['checked'])) + if (!empty($arrayfields['f.date_lim_reglement']['checked'])) { print ''; } // Project ref - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { print ''; } // Project label - if (! empty($arrayfields['p.title']['checked'])) + if (!empty($arrayfields['p.title']['checked'])) { print ''; } // Thirpdarty - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print ''; } // Town - if (! empty($arrayfields['s.town']['checked'])) print ''; + if (!empty($arrayfields['s.town']['checked'])) print ''; // Zip - if (! empty($arrayfields['s.zip']['checked'])) print ''; + if (!empty($arrayfields['s.zip']['checked'])) print ''; // State - if (! empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print ''; } // Country - if (! empty($arrayfields['country.code_iso']['checked'])) + if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; } // Company type - if (! empty($arrayfields['typent.code']['checked'])) + if (!empty($arrayfields['typent.code']['checked'])) { print ''; } // Payment mode - if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { print ''; } // Payment terms - if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) + if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { print ''; } // Module source - if (! empty($arrayfields['f.module_source']['checked'])) + if (!empty($arrayfields['f.module_source']['checked'])) { print ''; } // POS Terminal - if (! empty($arrayfields['f.pos_source']['checked'])) + if (!empty($arrayfields['f.pos_source']['checked'])) { print ''; } - if (! empty($arrayfields['f.total_ht']['checked'])) + if (!empty($arrayfields['f.total_ht']['checked'])) { // Amount print ''; } - if (! empty($arrayfields['f.total_vat']['checked'])) + if (!empty($arrayfields['f.total_vat']['checked'])) { // Amount print ''; } - if (! empty($arrayfields['f.total_localtax1']['checked'])) + if (!empty($arrayfields['f.total_localtax1']['checked'])) { // Localtax1 print ''; } - if (! empty($arrayfields['f.total_localtax2']['checked'])) + if (!empty($arrayfields['f.total_localtax2']['checked'])) { // Localtax2 print ''; } - if (! empty($arrayfields['f.total_ttc']['checked'])) + if (!empty($arrayfields['f.total_ttc']['checked'])) { // Amount print ''; } - if(! empty($arrayfields['f.retained_warranty']['checked'])) + if (!empty($arrayfields['f.retained_warranty']['checked'])) { print ''; } - if (! empty($arrayfields['dynamount_payed']['checked'])) + if (!empty($arrayfields['dynamount_payed']['checked'])) { print ''; } - if (! empty($arrayfields['rtp']['checked'])) + if (!empty($arrayfields['rtp']['checked'])) { print ''; } - if (! empty($arrayfields['f.date_closing']['checked'])) + if (!empty($arrayfields['f.date_closing']['checked'])) { print ''; @@ -898,124 +898,124 @@ if ($resql) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['f.datec']['checked'])) + if (!empty($arrayfields['f.datec']['checked'])) { print ''; } // Date modification - if (! empty($arrayfields['f.tms']['checked'])) + if (!empty($arrayfields['f.tms']['checked'])) { print ''; } // Status - if (! empty($arrayfields['f.fk_statut']['checked'])) + if (!empty($arrayfields['f.fk_statut']['checked'])) { print ''; } // Action column print ''; print "\n"; print ''; - if (! empty($arrayfields['f.ref']['checked'])) print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER['PHP_SELF'], 'f.ref', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['f.ref_client']['checked'])) print_liste_field_titre($arrayfields['f.ref_client']['label'], $_SERVER["PHP_SELF"], 'f.ref_client', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['f.type']['checked'])) print_liste_field_titre($arrayfields['f.type']['label'], $_SERVER["PHP_SELF"], 'f.type', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['f.date']['checked'])) print_liste_field_titre($arrayfields['f.date']['label'], $_SERVER['PHP_SELF'], 'f.datef', '', $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['f.date_lim_reglement']['checked'])) print_liste_field_titre($arrayfields['f.date_lim_reglement']['label'], $_SERVER['PHP_SELF'], "f.date_lim_reglement", '', $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER['PHP_SELF'], "p.ref", '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER['PHP_SELF'], "p.title", '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], 's.nom', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_mode_reglement", "", $param, "", $sortfield, $sortorder); - if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_cond_reglement", "", $param, "", $sortfield, $sortorder); - if (! empty($arrayfields['f.module_source']['checked'])) print_liste_field_titre($arrayfields['f.module_source']['label'], $_SERVER["PHP_SELF"], "f.module_source", "", $param, "", $sortfield, $sortorder); - if (! empty($arrayfields['f.pos_source']['checked'])) print_liste_field_titre($arrayfields['f.pos_source']['label'], $_SERVER["PHP_SELF"], "f.pos_source", "", $param, "", $sortfield, $sortorder); - if (! empty($arrayfields['f.total_ht']['checked'])) print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total', '', $param, 'class="right"', $sortfield, $sortorder); - if (! empty($arrayfields['f.total_vat']['checked'])) print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.tva', '', $param, 'class="right"', $sortfield, $sortorder); - if (! empty($arrayfields['f.total_localtax1']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, 'class="right"', $sortfield, $sortorder); - if (! empty($arrayfields['f.total_localtax2']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax2']['label'], $_SERVER['PHP_SELF'], 'f.localtax2', '', $param, 'class="right"', $sortfield, $sortorder); - if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); - if (! empty($arrayfields['f.retained_warranty']['checked'])) print_liste_field_titre($arrayfields['f.retained_warranty']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'align="right"', $sortfield, $sortorder); - if (! empty($arrayfields['dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); - if (! empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.ref']['checked'])) print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER['PHP_SELF'], 'f.ref', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['f.ref_client']['checked'])) print_liste_field_titre($arrayfields['f.ref_client']['label'], $_SERVER["PHP_SELF"], 'f.ref_client', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['f.type']['checked'])) print_liste_field_titre($arrayfields['f.type']['label'], $_SERVER["PHP_SELF"], 'f.type', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['f.date']['checked'])) print_liste_field_titre($arrayfields['f.date']['label'], $_SERVER['PHP_SELF'], 'f.datef', '', $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['f.date_lim_reglement']['checked'])) print_liste_field_titre($arrayfields['f.date_lim_reglement']['label'], $_SERVER['PHP_SELF'], "f.date_lim_reglement", '', $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER['PHP_SELF'], "p.ref", '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER['PHP_SELF'], "p.title", '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], 's.nom', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_mode_reglement", "", $param, "", $sortfield, $sortorder); + if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_cond_reglement", "", $param, "", $sortfield, $sortorder); + if (!empty($arrayfields['f.module_source']['checked'])) print_liste_field_titre($arrayfields['f.module_source']['label'], $_SERVER["PHP_SELF"], "f.module_source", "", $param, "", $sortfield, $sortorder); + if (!empty($arrayfields['f.pos_source']['checked'])) print_liste_field_titre($arrayfields['f.pos_source']['label'], $_SERVER["PHP_SELF"], "f.pos_source", "", $param, "", $sortfield, $sortorder); + if (!empty($arrayfields['f.total_ht']['checked'])) print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.total_vat']['checked'])) print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.tva', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.total_localtax1']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.total_localtax2']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax2']['label'], $_SERVER['PHP_SELF'], 'f.localtax2', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.retained_warranty']['checked'])) print_liste_field_titre($arrayfields['f.retained_warranty']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'align="right"', $sortfield, $sortorder); + if (!empty($arrayfields['dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); - if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); - if (! empty($arrayfields['f.date_closing']['checked'])) print_liste_field_titre($arrayfields['f.date_closing']['label'], $_SERVER["PHP_SELF"], "f.date_closing", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); - if (! empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut,f.paye,f.type,dynamount_payed", "", $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + if (!empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + if (!empty($arrayfields['f.date_closing']['checked'])) print_liste_field_titre($arrayfields['f.date_closing']['label'], $_SERVER["PHP_SELF"], "f.date_closing", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + if (!empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut,f.paye,f.type,dynamount_payed", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; - $projectstatic=new Project($db); + $projectstatic = new Project($db); $discount = new DiscountAbsolute($db); if ($num > 0) { - $i=0; - $totalarray=array(); + $i = 0; + $totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - $datelimit=$db->jdate($obj->datelimite); + $datelimit = $db->jdate($obj->datelimite); - $facturestatic->id=$obj->id; - $facturestatic->ref=$obj->ref; - $facturestatic->type=$obj->type; - $facturestatic->total_ht=$obj->total_ht; - $facturestatic->total_tva=$obj->total_vat; - $facturestatic->total_ttc=$obj->total_ttc; - $facturestatic->statut=$obj->fk_statut; - $facturestatic->total_ttc=$obj->total_ttc; - $facturestatic->paye=$obj->paye; - $facturestatic->fk_soc=$obj->fk_soc; - $facturestatic->date_lim_reglement=$db->jdate($obj->datelimite); - $facturestatic->note_public=$obj->note_public; - $facturestatic->note_private=$obj->note_private; - if($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY) + $facturestatic->id = $obj->id; + $facturestatic->ref = $obj->ref; + $facturestatic->type = $obj->type; + $facturestatic->total_ht = $obj->total_ht; + $facturestatic->total_tva = $obj->total_vat; + $facturestatic->total_ttc = $obj->total_ttc; + $facturestatic->statut = $obj->fk_statut; + $facturestatic->total_ttc = $obj->total_ttc; + $facturestatic->paye = $obj->paye; + $facturestatic->fk_soc = $obj->fk_soc; + $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite); + $facturestatic->note_public = $obj->note_public; + $facturestatic->note_private = $obj->note_private; + if ($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY) { - $facturestatic->retained_warranty=$obj->retained_warranty; - $facturestatic->retained_warranty_date_limit=$obj->retained_warranty_date_limit; - $facturestatic->situation_final=$obj->retained_warranty_date_limit; - $facturestatic->situation_final=$obj->retained_warranty_date_limit; - $facturestatic->situation_cycle_ref=$obj->situation_cycle_ref; - $facturestatic->situation_counter=$obj->situation_counter; + $facturestatic->retained_warranty = $obj->retained_warranty; + $facturestatic->retained_warranty_date_limit = $obj->retained_warranty_date_limit; + $facturestatic->situation_final = $obj->retained_warranty_date_limit; + $facturestatic->situation_final = $obj->retained_warranty_date_limit; + $facturestatic->situation_cycle_ref = $obj->situation_cycle_ref; + $facturestatic->situation_counter = $obj->situation_counter; } - $thirdpartystatic->id=$obj->socid; - $thirdpartystatic->name=$obj->name; - $thirdpartystatic->client=$obj->client; - $thirdpartystatic->fournisseur=$obj->fournisseur; - $thirdpartystatic->code_client=$obj->code_client; - $thirdpartystatic->code_compta_client=$obj->code_compta_client; - $thirdpartystatic->code_fournisseur=$obj->code_fournisseur; - $thirdpartystatic->code_compta_fournisseur=$obj->code_compta_fournisseur; - $thirdpartystatic->email=$obj->email; - $thirdpartystatic->country_code=$obj->country_code; + $thirdpartystatic->id = $obj->socid; + $thirdpartystatic->name = $obj->name; + $thirdpartystatic->client = $obj->client; + $thirdpartystatic->fournisseur = $obj->fournisseur; + $thirdpartystatic->code_client = $obj->code_client; + $thirdpartystatic->code_compta_client = $obj->code_compta_client; + $thirdpartystatic->code_fournisseur = $obj->code_fournisseur; + $thirdpartystatic->code_compta_fournisseur = $obj->code_compta_fournisseur; + $thirdpartystatic->email = $obj->email; + $thirdpartystatic->country_code = $obj->country_code; - $projectstatic->id=$obj->project_id; - $projectstatic->ref=$obj->project_ref; - $projectstatic->title=$obj->project_label; + $projectstatic->id = $obj->project_id; + $projectstatic->ref = $obj->project_ref; + $projectstatic->title = $obj->project_label; $paiement = $facturestatic->getSommePaiement(); $totalcreditnotes = $facturestatic->getSumCreditNotesUsed(); @@ -1034,7 +1034,7 @@ if ($resql) print ' onclick="parent.$(\'#poslines\').load(\'invoice.php?action=history&placeid='.$obj->id.'\', function() {parent.$.colorbox.close();});"'; } print '>'; - if (! empty($arrayfields['f.ref']['checked'])) + if (!empty($arrayfields['f.ref']['checked'])) { print ''; print ''; print '
'; print ''; print ''; print ''; print ''; - $listtype=array( + $listtype = array( Facture::TYPE_STANDARD=>$langs->trans("InvoiceStandard"), Facture::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"), Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"), Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"), ); - if (! empty($conf->global->INVOICE_USE_SITUATION)) + if (!empty($conf->global->INVOICE_USE_SITUATION)) { $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation"); } @@ -750,121 +750,121 @@ if ($resql) print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; - $formother->select_year($search_year?$search_year:-1, 'search_year', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); + $formother->select_year($search_year ? $search_year : -1, 'search_year', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; - $formother->select_year($search_year_lim?$search_year_lim:-1, 'search_year_lim', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); - print '
'.$langs->trans("Alert"); + $formother->select_year($search_year_lim ? $search_year_lim : -1, 'search_year_lim', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); + print '
'.$langs->trans("Alert"); print '
'; print ''; print ''; print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print ''; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT), 'maxwidth100'); + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), 'maxwidth100'); print ''; $form->select_types_paiements($search_paymentmode, 'search_paymentmode', '', 0, 1, 1, 10); print ''; $form->select_conditions_paiements($search_paymentterms, 'search_paymentterms', -1, 1, 1); print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; @@ -872,23 +872,23 @@ if ($resql) print ''; print ''; print ''; print ''; print ''; print ''; print ''; - $liststatus=array('0'=>$langs->trans("BillShortStatusDraft"), '1'=>$langs->trans("BillShortStatusNotPaid"), '2'=>$langs->trans("BillShortStatusPaid"), '1,2'=>$langs->trans("BillShortStatusNotPaid").'+'.$langs->trans("BillShortStatusPaid"), '3'=>$langs->trans("BillShortStatusCanceled")); + $liststatus = array('0'=>$langs->trans("BillShortStatusDraft"), '1'=>$langs->trans("BillShortStatusNotPaid"), '2'=>$langs->trans("BillShortStatusPaid"), '1,2'=>$langs->trans("BillShortStatusNotPaid").'+'.$langs->trans("BillShortStatusPaid"), '3'=>$langs->trans("BillShortStatusCanceled")); print $form->selectarray('search_status', $liststatus, $search_status, 1); print ''; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; @@ -1049,49 +1049,49 @@ if ($resql) { print $facturestatic->getNomUrl(1, '', 200, 0, '', 0, 1); } - print empty($obj->increment)?'':' ('.$obj->increment.')'; + print empty($obj->increment) ? '' : ' ('.$obj->increment.')'; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->id; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->id; print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir); print '
'; print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Customer ref - if (! empty($arrayfields['f.ref_client']['checked'])) + if (!empty($arrayfields['f.ref_client']['checked'])) { print ''; print $obj->ref_client; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Type - if (! empty($arrayfields['f.type']['checked'])) + if (!empty($arrayfields['f.type']['checked'])) { print ''; print $facturestatic->getLibType(); print ""; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date - if (! empty($arrayfields['f.date']['checked'])) + if (!empty($arrayfields['f.date']['checked'])) { print ''; print dol_print_date($db->jdate($obj->df), 'day'); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date limit - if (! empty($arrayfields['f.date_lim_reglement']['checked'])) + if (!empty($arrayfields['f.date_lim_reglement']['checked'])) { print ''.dol_print_date($datelimit, 'day'); if ($facturestatic->hasDelay()) @@ -1099,11 +1099,11 @@ if ($resql) print img_warning($langs->trans('Alert').' - '.$langs->trans('Late')); } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Project ref - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { print ''; if ($obj->project_id > 0) @@ -1111,11 +1111,11 @@ if ($resql) print $projectstatic->getNomUrl(1); } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Project title - if (! empty($arrayfields['p.title']['checked'])) + if (!empty($arrayfields['p.title']['checked'])) { print ''; if ($obj->project_id > 0) @@ -1123,11 +1123,11 @@ if ($resql) print $projectstatic->title; } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Third party - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print ''; if ($contextpage == 'poslist') @@ -1350,8 +1350,8 @@ if ($resql) $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 + $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 "\n"; @@ -1359,16 +1359,16 @@ if ($resql) print "\n"; - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->facture->lire; - $delallowed=$user->rights->facture->creer; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->facture->lire; + $delallowed = $user->rights->facture->creer; $title = ''; print $formfile->showdocuments('massfilesarea_invoices', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 43c6c9c7f1d..1f262b18f13 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -145,7 +145,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label('contact'); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -159,8 +159,8 @@ $fieldstosearchall = array( ); // Definition of fields for list -$arrayfields=array( - 'p.rowid'=>array('label'=>"TechnicalID", 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0)), +$arrayfields = array( + 'p.rowid'=>array('label'=>"TechnicalID", 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID ? 1 : 0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID ? 1 : 0)), 'p.lastname'=>array('label'=>"Lastname", 'checked'=>1), 'p.firstname'=>array('label'=>"Firstname", 'checked'=>1), 'p.poste'=>array('label'=>"PostOrFunction", 'checked'=>1), @@ -193,19 +193,19 @@ if (! empty($conf->socialnetworks->enabled)) { // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -if (($id > 0 || ! empty($ref)) && $action != 'add') +if (($id > 0 || !empty($ref)) && $action != 'add') { - $result=$object->fetch($id, $ref); + $result = $object->fetch($id, $ref); if ($result < 0) dol_print_error($db); } @@ -214,11 +214,11 @@ if (($id > 0 || ! empty($ref)) && $action != 'add') * 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 +$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)) @@ -385,24 +385,24 @@ elseif ($type == "p") // filtre sur type { $sql .= " AND s.client IN (2, 3)"; } -if (! empty($socid)) +if (!empty($socid)) { $sql .= " AND s.rowid = ".$socid; } // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; // Add order if ($view == "recent") { - $sql.= $db->order("p.datec", "DESC"); + $sql .= $db->order("p.datec", "DESC"); } else { - $sql.= $db->order($sortfield, $sortorder); + $sql .= $db->order($sortfield, $sortorder); } // Count total nb of records @@ -418,10 +418,10 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); -if (! $result) +if (!$result) { dol_print_error($db); exit; @@ -429,9 +429,9 @@ if (! $result) $num = $db->num_rows($result); -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($sall != '' || $search_cti != '')) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($sall != '' || $search_cti != '')) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -439,55 +439,55 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && exit; } -$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas'; +$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas'; llxHeader('', $title, $help_url); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; -$param.='&begin='.urlencode($begin).'&userid='.urlencode($userid).'&contactname='.urlencode($sall); -$param.='&type='.urlencode($type).'&view='.urlencode($view); -if (!empty($search_categ)) $param.='&search_categ='.urlencode($search_categ); -if (!empty($search_categ_thirdparty)) $param.='&search_categ_thirdparty='.urlencode($search_categ_thirdparty); -if (!empty($search_categ_supplier)) $param.='&search_categ_supplier='.urlencode($search_categ_supplier); -if ($sall != '') $param.='&sall='.urlencode($sall); -if ($search_id > 0) $param.= "&search_id=".urlencode($search_id); -if ($search_lastname != '') $param.='&search_lastname='.urlencode($search_lastname); -if ($search_firstname != '') $param.='&search_firstname='.urlencode($search_firstname); -if ($search_societe != '') $param.='&search_societe='.urlencode($search_societe); -if ($search_zip != '') $param.='&search_zip='.urlencode($search_zip); -if ($search_town != '') $param.='&search_town='.urlencode($search_town); -if ($search_country != '') $param.= "&search_country=".urlencode($search_country); -if ($search_poste != '') $param.='&search_poste='.urlencode($search_poste); -if ($search_phone_pro != '') $param.='&search_phone_pro='.urlencode($search_phone_pro); -if ($search_phone_perso != '') $param.='&search_phone_perso='.urlencode($search_phone_perso); -if ($search_phone_mobile != '') $param.='&search_phone_mobile='.urlencode($search_phone_mobile); -if ($search_fax != '') $param.='&search_fax='.urlencode($search_fax); -if ($search_email != '') $param.='&search_email='.urlencode($search_email); -if ($search_no_email != '') $param.='&search_no_email='.urlencode($search_no_email); -if ($search_status != '') $param.='&search_status='.urlencode($search_status); -if ($search_priv == '0' || $search_priv == '1') $param.="&search_priv=".urlencode($search_priv); -if ($search_import_key != '') $param.='&search_import_key='.urlencode($search_import_key); -if ($optioncss != '') $param.='&optioncss='.$optioncss; -if (count($search_roles)>0) $param.=implode('&search_roles[]=', $search_roles); +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; +$param .= '&begin='.urlencode($begin).'&userid='.urlencode($userid).'&contactname='.urlencode($sall); +$param .= '&type='.urlencode($type).'&view='.urlencode($view); +if (!empty($search_categ)) $param .= '&search_categ='.urlencode($search_categ); +if (!empty($search_categ_thirdparty)) $param .= '&search_categ_thirdparty='.urlencode($search_categ_thirdparty); +if (!empty($search_categ_supplier)) $param .= '&search_categ_supplier='.urlencode($search_categ_supplier); +if ($sall != '') $param .= '&sall='.urlencode($sall); +if ($search_id > 0) $param .= "&search_id=".urlencode($search_id); +if ($search_lastname != '') $param .= '&search_lastname='.urlencode($search_lastname); +if ($search_firstname != '') $param .= '&search_firstname='.urlencode($search_firstname); +if ($search_societe != '') $param .= '&search_societe='.urlencode($search_societe); +if ($search_zip != '') $param .= '&search_zip='.urlencode($search_zip); +if ($search_town != '') $param .= '&search_town='.urlencode($search_town); +if ($search_country != '') $param .= "&search_country=".urlencode($search_country); +if ($search_poste != '') $param .= '&search_poste='.urlencode($search_poste); +if ($search_phone_pro != '') $param .= '&search_phone_pro='.urlencode($search_phone_pro); +if ($search_phone_perso != '') $param .= '&search_phone_perso='.urlencode($search_phone_perso); +if ($search_phone_mobile != '') $param .= '&search_phone_mobile='.urlencode($search_phone_mobile); +if ($search_fax != '') $param .= '&search_fax='.urlencode($search_fax); +if ($search_email != '') $param .= '&search_email='.urlencode($search_email); +if ($search_no_email != '') $param .= '&search_no_email='.urlencode($search_no_email); +if ($search_status != '') $param .= '&search_status='.urlencode($search_status); +if ($search_priv == '0' || $search_priv == '1') $param .= "&search_priv=".urlencode($search_priv); +if ($search_import_key != '') $param .= '&search_import_key='.urlencode($search_import_key); +if ($optioncss != '') $param .= '&optioncss='.$optioncss; +if (count($search_roles) > 0) $param .= implode('&search_roles[]=', $search_roles); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( // 'presend'=>$langs->trans("SendByMail"), // 'builddoc'=>$langs->trans("PDFMerge"), ); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); -if ($user->rights->societe->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); -if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($user->rights->societe->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); -$newcardbutton=''; +$newcardbutton = ''; if ($user->rights->societe->contact->creer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewContactAddress'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewContactAddress'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?action=create'); } print '
'; @@ -502,101 +502,101 @@ print ''; print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'address', 0, $newcardbutton, '', $limit); -$topicmail="Information"; -$modelmail="contact"; -$objecttmp=new Contact($db); -$trackid='ctc'.$object->id; +$topicmail = "Information"; +$modelmail = "contact"; +$objecttmp = new Contact($db); +$trackid = 'ctc'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } if ($search_firstlast_only) { - print '
'.$langs->trans("FilterOnInto", $search_firstlast_only) . $langs->trans("Lastname").", ".$langs->trans("Firstname").'
'; + print '
'.$langs->trans("FilterOnInto", $search_firstlast_only).$langs->trans("Lastname").", ".$langs->trans("Firstname").'
'; } -$moreforfilter=''; -if (! empty($conf->categorie->enabled)) +$moreforfilter = ''; +if (!empty($conf->categorie->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('Categories'). ': '; - $moreforfilter.=$formother->select_categories(Categorie::TYPE_CONTACT, $search_categ, 'search_categ', 1); - $moreforfilter.='
'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('Categories').': '; + $moreforfilter .= $formother->select_categories(Categorie::TYPE_CONTACT, $search_categ, 'search_categ', 1); + $moreforfilter .= '
'; if (empty($type) || $type == 'c' || $type == 'p') { - $moreforfilter.='
'; - if ($type == 'c') $moreforfilter.=$langs->trans('CustomersCategoriesShort'). ': '; - elseif ($type == 'p') $moreforfilter.=$langs->trans('ProspectsCategoriesShort'). ': '; - else $moreforfilter.=$langs->trans('CustomersProspectsCategoriesShort'). ': '; - $moreforfilter.=$formother->select_categories(Categorie::TYPE_CUSTOMER, $search_categ_thirdparty, 'search_categ_thirdparty', 1); - $moreforfilter.='
'; + $moreforfilter .= '
'; + if ($type == 'c') $moreforfilter .= $langs->trans('CustomersCategoriesShort').': '; + elseif ($type == 'p') $moreforfilter .= $langs->trans('ProspectsCategoriesShort').': '; + else $moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': '; + $moreforfilter .= $formother->select_categories(Categorie::TYPE_CUSTOMER, $search_categ_thirdparty, 'search_categ_thirdparty', 1); + $moreforfilter .= '
'; } if (empty($type) || $type == 'f') { - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('SuppliersCategoriesShort'). ': '; - $moreforfilter.=$formother->select_categories(Categorie::TYPE_SUPPLIER, $search_categ_supplier, 'search_categ_supplier', 1); - $moreforfilter.='
'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('SuppliersCategoriesShort').': '; + $moreforfilter .= $formother->select_categories(Categorie::TYPE_SUPPLIER, $search_categ_supplier, 'search_categ_supplier', 1); + $moreforfilter .= '
'; } - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('Roles'). ': '; - $moreforfilter.=$formcompany->showRoles("search_roles", $objecttmp, 'edit', $search_roles); - $moreforfilter.='
'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('Roles').': '; + $moreforfilter .= $formcompany->showRoles("search_roles", $objecttmp, 'edit', $search_roles); + $moreforfilter .= '
'; } if ($moreforfilter) { print '
'; print $moreforfilter; - $parameters=array('type'=>$type); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('type'=>$type); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; } -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); print '
'; -print ''."\n"; +print '
'."\n"; // Lines for filter fields print ''; -if (! empty($arrayfields['p.rowid']['checked'])) +if (!empty($arrayfields['p.rowid']['checked'])) { print ''; } -if (! empty($arrayfields['p.lastname']['checked'])) +if (!empty($arrayfields['p.lastname']['checked'])) { print ''; } -if (! empty($arrayfields['p.firstname']['checked'])) +if (!empty($arrayfields['p.firstname']['checked'])) { print ''; } -if (! empty($arrayfields['p.poste']['checked'])) +if (!empty($arrayfields['p.poste']['checked'])) { print ''; } -if (! empty($arrayfields['p.zip']['checked'])) +if (!empty($arrayfields['p.zip']['checked'])) { print ''; } -if (! empty($arrayfields['p.town']['checked'])) +if (!empty($arrayfields['p.town']['checked'])) { print ''; } // Date modification -if (! empty($arrayfields['p.tms']['checked'])) +if (!empty($arrayfields['p.tms']['checked'])) { print ''; } // Status -if (! empty($arrayfields['p.statut']['checked'])) +if (!empty($arrayfields['p.statut']['checked'])) { print ''; } -if (! empty($arrayfields['p.import_key']['checked'])) +if (!empty($arrayfields['p.import_key']['checked'])) { print ''; @@ -761,18 +761,18 @@ $parameters = array( 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, ); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (! empty($arrayfields['p.datec']['checked'])) { +if (!empty($arrayfields['p.datec']['checked'])) { print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } -if (! empty($arrayfields['p.tms']['checked'])) { +if (!empty($arrayfields['p.tms']['checked'])) { print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } -if (! empty($arrayfields['p.statut']['checked'])) { +if (!empty($arrayfields['p.statut']['checked'])) { print_liste_field_titre($arrayfields['p.statut']['label'], $_SERVER["PHP_SELF"], "p.statut", "", $param, '', $sortfield, $sortorder, 'center '); } -if (! empty($arrayfields['p.import_key']['checked'])) { +if (!empty($arrayfields['p.import_key']['checked'])) { print_liste_field_titre($arrayfields['p.import_key']['label'], $_SERVER["PHP_SELF"], "p.import_key", "", $param, '', $sortfield, $sortorder, 'center '); } print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); @@ -920,62 +920,62 @@ while ($i < min($num, $limit)) else print ' '; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Private/Public - if (! empty($arrayfields['p.priv']['checked'])) + if (!empty($arrayfields['p.priv']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['p.datec']['checked'])) + if (!empty($arrayfields['p.datec']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date modification - if (! empty($arrayfields['p.tms']['checked'])) + if (!empty($arrayfields['p.tms']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Status - if (! empty($arrayfields['p.statut']['checked'])) + if (!empty($arrayfields['p.statut']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['p.import_key']['checked'])) + if (!empty($arrayfields['p.import_key']['checked'])) { print '\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Action column print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "\n"; $i++; @@ -983,8 +983,8 @@ while ($i < min($num, $limit)) $db->free($result); -$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook +$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 "
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; @@ -688,29 +688,29 @@ if (! empty($arrayfields['p.priv']['checked'])) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation -if (! empty($arrayfields['p.datec']['checked'])) +if (!empty($arrayfields['p.datec']['checked'])) { print ''; print ''; print ''; - print $form->selectarray('search_status', array('-1'=>'', '0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), $search_status); + print $form->selectarray('search_status', array('-1'=>'', '0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $search_status); print ''; print ''; @@ -718,7 +718,7 @@ if (! empty($arrayfields['p.import_key']['checked'])) } // Action column print ''; -$searchpicto=$form->showFilterAndCheckAddButtons(0); +$searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print ''.$contactstatic->LibPubPriv($obj->priv).''; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''.$contactstatic->getLibStatut(5).''; print $obj->import_key; print "'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; } print '
"; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 8c6ca195755..47732d3459c 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -32,10 +32,10 @@ * \brief File of class to manage contracts */ -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT."/core/class/commonobjectline.class.php"; -require_once DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/margin/lib/margins.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/margin/lib/margins.lib.php'; /** * Class to manage contracts @@ -45,27 +45,27 @@ class Contrat extends CommonObject /** * @var string ID to identify managed object */ - public $element='contrat'; + public $element = 'contrat'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='contrat'; + public $table_element = 'contrat'; /** * @var int Name of subtable line */ - public $table_element_line='contratdet'; + public $table_element_line = 'contratdet'; /** * @var int Field with ID of parent key if this field has a parent */ - public $fk_element='fk_contrat'; + public $fk_element = 'fk_contrat'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ - public $picto='contract'; + public $picto = 'contract'; /** * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe @@ -108,13 +108,13 @@ class Contrat extends CommonObject */ public $socid; - public $societe; // Objet societe + public $societe; // Objet societe /** * Status of the contract * @var int */ - public $statut=0; // 0=Draft, + public $statut = 0; // 0=Draft, public $product; @@ -175,18 +175,18 @@ class Contrat extends CommonObject */ public $fk_projet; - public $extraparams=array(); + public $extraparams = array(); /** * @var ContratLigne[] Contract lines */ - public $lines=array(); + public $lines = array(); /** * Maps ContratLigne IDs to $this->lines indexes * @var int[] */ - protected $lines_id_index_mapper=array(); + protected $lines_id_index_mapper = array(); const STATUS_DRAFT = 0; @@ -230,10 +230,10 @@ class Contrat extends CommonObject $dir = dol_buildpath($reldir."core/modules/contract/"); // Load file with numbering class (if found) - $mybool|=@include_once $dir.$file; + $mybool |= @include_once $dir.$file; } - if (! $mybool) + if (!$mybool) { dol_print_error('', "Failed to include file ".$file); return ''; @@ -242,7 +242,7 @@ class Contrat extends CommonObject $obj = new $classname(); $numref = $obj->getNextValue($soc, $this); - if ( $numref != "") + if ($numref != "") { return $numref; } @@ -298,7 +298,7 @@ class Contrat extends CommonObject public function close_line($user, $line_id, $date_end, $comment = '') { // phpcs:enable - $result=$this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment); + $result = $this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment); if ($result < 0) { $this->error = $this->lines[$this->lines_id_index_mapper[$line_id]]->error; @@ -324,12 +324,12 @@ class Contrat extends CommonObject $this->db->begin(); - $error=0; + $error = 0; // Load lines $this->fetch_lines(); - foreach($this->lines as $contratline) + foreach ($this->lines as $contratline) { // Open lines not already open if ($contratline->statut != ContratLigne::STATUS_OPEN) @@ -347,13 +347,13 @@ class Contrat extends CommonObject } } - if (! $error && $this->statut == 0) + if (!$error && $this->statut == 0) { - $result=$this->validate($user, '', $notrigger); + $result = $this->validate($user, '', $notrigger); if ($result < 0) $error++; } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -385,15 +385,15 @@ class Contrat extends CommonObject $error = 0; - foreach($this->lines as $contratline) + foreach ($this->lines as $contratline) { // Close lines not already closed if ($contratline->statut != ContratLigne::STATUS_CLOSED) { - $contratline->date_cloture=$now; - $contratline->fk_user_cloture=$user->id; - $contratline->statut=ContratLigne::STATUS_CLOSED; - $result=$contratline->close_line($user, $now, $comment, $notrigger); + $contratline->date_cloture = $now; + $contratline->fk_user_cloture = $user->id; + $contratline->statut = ContratLigne::STATUS_CLOSED; + $result = $contratline->close_line($user, $now, $comment, $notrigger); if ($result < 0) { $error++; @@ -404,13 +404,13 @@ class Contrat extends CommonObject } } - if (! $error && $this->statut == 0) + if (!$error && $this->statut == 0) { - $result=$this->validate($user, '', $notrigger); + $result = $this->validate($user, '', $notrigger); if ($result < 0) $error++; } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -435,9 +435,9 @@ class Contrat extends CommonObject require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; global $langs, $conf; - $now=dol_now(); + $now = dol_now(); - $error=0; + $error = 0; dol_syslog(get_class($this).'::validate user='.$user->id.', force_number='.$force_number); @@ -448,7 +448,7 @@ class Contrat extends CommonObject // A contract is validated so we can move thirdparty to status customer if (empty($conf->global->CONTRACT_DISABLE_AUTOSET_AS_CLIENT_ON_CONTRACT_VALIDATION)) { - $result=$this->thirdparty->set_as_client(); + $result = $this->thirdparty->set_as_client(); } // Define new ref @@ -456,7 +456,7 @@ class Contrat extends CommonObject { $num = $force_number; } - elseif (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life + elseif (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life { $num = $this->getNextNumRef($this->thirdparty); } @@ -470,27 +470,27 @@ class Contrat extends CommonObject { $sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET ref = '".$num."', statut = 1"; //$sql.= ", fk_user_valid = ".$user->id.", date_valid = '".$this->db->idate($now)."'"; - $sql .= " WHERE rowid = ".$this->id . " AND statut = 0"; + $sql .= " WHERE rowid = ".$this->id." AND statut = 0"; dol_syslog(get_class($this)."::validate", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { dol_print_error($this->db); $error++; - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); } // Trigger calls - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('CONTRACT_VALIDATE', $user); + $result = $this->call_trigger('CONTRACT_VALIDATE', $user); if ($result < 0) { $error++; } // End call triggers } - if (! $error) + if (!$error) { $this->oldref = $this->ref; @@ -498,17 +498,17 @@ class Contrat extends CommonObject if (preg_match('/^[\(]?PROV/i', $this->ref)) { // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'contract/".$this->db->escape($this->newref)."'"; - $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'contract/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'contract/".$this->db->escape($this->newref)."'"; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'contract/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->error = $this->db->lasterror(); } + if (!$resql) { $error++; $this->error = $this->db->lasterror(); } // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($num); $dirsource = $conf->contract->dir_output.'/'.$oldref; $dirdest = $conf->contract->dir_output.'/'.$newref; - if (! $error && file_exists($dirsource)) + if (!$error && file_exists($dirsource)) { dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); @@ -516,13 +516,13 @@ class Contrat extends CommonObject { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref - $listoffiles=dol_dir_list($conf->contract->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach($listoffiles as $fileentry) + $listoffiles = dol_dir_list($conf->contract->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) { - $dirsource=$fileentry['name']; - $dirdest=preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); - $dirsource=$fileentry['path'].'/'.$dirsource; - $dirdest=$fileentry['path'].'/'.$dirdest; + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource = $fileentry['path'].'/'.$dirsource; + $dirdest = $fileentry['path'].'/'.$dirdest; @rename($dirsource, $dirdest); } } @@ -531,7 +531,7 @@ class Contrat extends CommonObject } // Set new ref and define current statut - if (! $error) + if (!$error) { $this->ref = $num; $this->statut = 1; @@ -544,7 +544,7 @@ class Contrat extends CommonObject $error++; } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -568,9 +568,9 @@ class Contrat extends CommonObject require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; global $langs, $conf; - $now=dol_now(); + $now = dol_now(); - $error=0; + $error = 0; dol_syslog(get_class($this).'::reopen user='.$user->id); $this->db->begin(); @@ -579,22 +579,22 @@ class Contrat extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET statut = 0"; //$sql.= ", fk_user_valid = null, date_valid = null"; - $sql .= " WHERE rowid = ".$this->id . " AND statut = 1"; + $sql .= " WHERE rowid = ".$this->id." AND statut = 1"; dol_syslog(get_class($this)."::validate", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { dol_print_error($this->db); $error++; - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); } // Trigger calls - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('CONTRACT_REOPEN', $user); + $result = $this->call_trigger('CONTRACT_REOPEN', $user); if ($result < 0) { $error++; } @@ -602,14 +602,14 @@ class Contrat extends CommonObject } // Set new ref and define current status - if (! $error) + if (!$error) { - $this->statut=0; - $this->brouillon=1; - $this->date_validation=$now; + $this->statut = 0; + $this->brouillon = 1; + $this->date_validation = $now; } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -633,38 +633,38 @@ class Contrat extends CommonObject public function fetch($id, $ref = '', $ref_customer = '', $ref_supplier = '') { $sql = "SELECT rowid, statut, ref, fk_soc, mise_en_service as datemise,"; - $sql.= " ref_supplier, ref_customer,"; - $sql.= " ref_ext,"; - $sql.= " entity,"; - $sql.= " fk_user_mise_en_service, date_contrat as datecontrat,"; - $sql.= " fk_user_author, fin_validite, date_cloture,"; - $sql.= " fk_projet as fk_project,"; - $sql.= " fk_commercial_signature, fk_commercial_suivi,"; - $sql.= " note_private, note_public, model_pdf, extraparams"; - $sql.= " FROM ".MAIN_DB_PREFIX."contrat"; - if (! $id) $sql.=" WHERE entity IN (".getEntity('contract').")"; - else $sql.= " WHERE rowid=".$id; + $sql .= " ref_supplier, ref_customer,"; + $sql .= " ref_ext,"; + $sql .= " entity,"; + $sql .= " fk_user_mise_en_service, date_contrat as datecontrat,"; + $sql .= " fk_user_author, fin_validite, date_cloture,"; + $sql .= " fk_projet as fk_project,"; + $sql .= " fk_commercial_signature, fk_commercial_suivi,"; + $sql .= " note_private, note_public, model_pdf, extraparams"; + $sql .= " FROM ".MAIN_DB_PREFIX."contrat"; + if (!$id) $sql .= " WHERE entity IN (".getEntity('contract').")"; + else $sql .= " WHERE rowid=".$id; if ($ref_customer) { - $sql.= " AND ref_customer = '".$this->db->escape($ref_customer)."'"; + $sql .= " AND ref_customer = '".$this->db->escape($ref_customer)."'"; } if ($ref_supplier) { - $sql.= " AND ref_supplier = '".$this->db->escape($ref_supplier)."'"; + $sql .= " AND ref_supplier = '".$this->db->escape($ref_supplier)."'"; } if ($ref) { - $sql.= " AND ref='".$this->db->escape($ref)."'"; + $sql .= " AND ref='".$this->db->escape($ref)."'"; } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $num=$this->db->num_rows($resql); + $num = $this->db->num_rows($resql); if ($num > 1) { - $this->error='Fetch found several records.'; + $this->error = 'Fetch found several records.'; dol_syslog($this->error, LOG_ERR); $result = -2; } @@ -673,14 +673,14 @@ class Contrat extends CommonObject $obj = $this->db->fetch_object($resql); if ($obj) { - $this->id = $obj->rowid; - $this->ref = (!isset($obj->ref) || !$obj->ref) ? $obj->rowid : $obj->ref; + $this->id = $obj->rowid; + $this->ref = (!isset($obj->ref) || !$obj->ref) ? $obj->rowid : $obj->ref; $this->ref_customer = $obj->ref_customer; $this->ref_supplier = $obj->ref_supplier; - $this->ref_ext = $obj->ref_ext; - $this->entity = $obj->entity; - $this->statut = $obj->statut; - $this->mise_en_service = $this->db->jdate($obj->datemise); + $this->ref_ext = $obj->ref_ext; + $this->entity = $obj->entity; + $this->statut = $obj->statut; + $this->mise_en_service = $this->db->jdate($obj->datemise); $this->date_contrat = $this->db->jdate($obj->datecontrat); $this->date_creation = $this->db->jdate($obj->datecontrat); @@ -689,20 +689,20 @@ class Contrat extends CommonObject $this->date_cloture = $this->db->jdate($obj->date_cloture); - $this->user_author_id = $obj->fk_user_author; + $this->user_author_id = $obj->fk_user_author; $this->commercial_signature_id = $obj->fk_commercial_signature; - $this->commercial_suivi_id = $obj->fk_commercial_suivi; + $this->commercial_suivi_id = $obj->fk_commercial_suivi; - $this->note_private = $obj->note_private; - $this->note_public = $obj->note_public; + $this->note_private = $obj->note_private; + $this->note_public = $obj->note_public; $this->modelpdf = $obj->model_pdf; $this->fk_projet = $obj->fk_project; // deprecated - $this->fk_project = $obj->fk_project; + $this->fk_project = $obj->fk_project; - $this->socid = $obj->fk_soc; - $this->fk_soc = $obj->fk_soc; + $this->socid = $obj->fk_soc; + $this->fk_soc = $obj->fk_soc; $this->extraparams = (array) json_decode($obj->extraparams, true); @@ -713,10 +713,10 @@ class Contrat extends CommonObject $this->fetch_optionals(); // Lines - $result=$this->fetch_lines(); + $result = $this->fetch_lines(); if ($result < 0) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -3; } @@ -726,14 +726,14 @@ class Contrat extends CommonObject else { dol_syslog(get_class($this)."::fetch Contract not found"); - $this->error="Contract not found"; + $this->error = "Contract not found"; return 0; } } else { dol_syslog(get_class($this)."::fetch Error searching contract"); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -753,47 +753,47 @@ class Contrat extends CommonObject // phpcs:enable global $langs, $conf, $extrafields; - $this->nbofserviceswait=0; - $this->nbofservicesopened=0; - $this->nbofservicesexpired=0; - $this->nbofservicesclosed=0; + $this->nbofserviceswait = 0; + $this->nbofservicesopened = 0; + $this->nbofservicesexpired = 0; + $this->nbofservicesclosed = 0; - $total_ttc=0; - $total_vat=0; - $total_ht=0; + $total_ttc = 0; + $total_vat = 0; + $total_ht = 0; - $now=dol_now(); + $now = dol_now(); - if (! is_object($extrafields)) + if (!is_object($extrafields)) { require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields=new ExtraFields($this->db); + $extrafields = new ExtraFields($this->db); } $line = new ContratLigne($this->db); $extrafields->fetch_name_optionals_label($line->table_element, true); - $this->lines=array(); + $this->lines = array(); $pos = 0; // Selects contract lines related to a product $sql = "SELECT p.label as product_label, p.description as product_desc, p.ref as product_ref,"; - $sql.= " d.rowid, d.fk_contrat, d.statut, d.description, d.price_ht, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.qty, d.remise_percent, d.subprice, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht,"; - $sql.= " d.total_ht,"; - $sql.= " d.total_tva,"; - $sql.= " d.total_localtax1,"; - $sql.= " d.total_localtax2,"; - $sql.= " d.total_ttc,"; - $sql.= " d.info_bits, d.fk_product,"; - $sql.= " d.date_ouverture_prevue, d.date_ouverture,"; - $sql.= " d.date_fin_validite, d.date_cloture,"; - $sql.= " d.fk_user_author,"; - $sql.= " d.fk_user_ouverture,"; - $sql.= " d.fk_user_cloture,"; - $sql.= " d.fk_unit"; - $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as d LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid"; - $sql.= " WHERE d.fk_contrat = ".$this->id; - $sql.= " ORDER by d.rowid ASC"; + $sql .= " d.rowid, d.fk_contrat, d.statut, d.description, d.price_ht, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.qty, d.remise_percent, d.subprice, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht,"; + $sql .= " d.total_ht,"; + $sql .= " d.total_tva,"; + $sql .= " d.total_localtax1,"; + $sql .= " d.total_localtax2,"; + $sql .= " d.total_ttc,"; + $sql .= " d.info_bits, d.fk_product,"; + $sql .= " d.date_ouverture_prevue, d.date_ouverture,"; + $sql .= " d.date_fin_validite, d.date_cloture,"; + $sql .= " d.fk_user_author,"; + $sql .= " d.fk_user_ouverture,"; + $sql .= " d.fk_user_cloture,"; + $sql .= " d.fk_unit"; + $sql .= " FROM ".MAIN_DB_PREFIX."contratdet as d LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid"; + $sql .= " WHERE d.fk_contrat = ".$this->id; + $sql .= " ORDER by d.rowid ASC"; dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG); $result = $this->db->query($sql); @@ -806,46 +806,46 @@ class Contrat extends CommonObject { $objp = $this->db->fetch_object($result); - $line = new ContratLigne($this->db); - $line->id = $objp->rowid; + $line = new ContratLigne($this->db); + $line->id = $objp->rowid; $line->ref = $objp->rowid; - $line->fk_contrat = $objp->fk_contrat; - $line->desc = $objp->description; // Description line + $line->fk_contrat = $objp->fk_contrat; + $line->desc = $objp->description; // Description line $line->qty = $objp->qty; - $line->vat_src_code = $objp->vat_src_code ; - $line->tva_tx = $objp->tva_tx; + $line->vat_src_code = $objp->vat_src_code; + $line->tva_tx = $objp->tva_tx; $line->localtax1_tx = $objp->localtax1_tx; $line->localtax2_tx = $objp->localtax2_tx; $line->localtax1_type = $objp->localtax1_type; $line->localtax2_type = $objp->localtax2_type; $line->subprice = $objp->subprice; - $line->statut = $objp->statut; + $line->statut = $objp->statut; $line->remise_percent = $objp->remise_percent; $line->price_ht = $objp->price_ht; - $line->price = $objp->price_ht; // For backward compatibility + $line->price = $objp->price_ht; // For backward compatibility $line->total_ht = $objp->total_ht; $line->total_tva = $objp->total_tva; $line->total_localtax1 = $objp->total_localtax1; $line->total_localtax2 = $objp->total_localtax2; $line->total_ttc = $objp->total_ttc; - $line->fk_product = (($objp->fk_product > 0)?$objp->fk_product:0); + $line->fk_product = (($objp->fk_product > 0) ? $objp->fk_product : 0); $line->info_bits = $objp->info_bits; - $line->fk_fournprice = $objp->fk_fournprice; + $line->fk_fournprice = $objp->fk_fournprice; $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); - $line->pa_ht = $marginInfos[0]; + $line->pa_ht = $marginInfos[0]; - $line->fk_user_author = $objp->fk_user_author; - $line->fk_user_ouverture= $objp->fk_user_ouverture; + $line->fk_user_author = $objp->fk_user_author; + $line->fk_user_ouverture = $objp->fk_user_ouverture; $line->fk_user_cloture = $objp->fk_user_cloture; - $line->fk_unit = $objp->fk_unit; + $line->fk_unit = $objp->fk_unit; - $line->ref = $objp->product_ref; // deprecated - $line->product_ref = $objp->product_ref; // Product Ref - $line->product_desc = $objp->product_desc; // Product Description + $line->ref = $objp->product_ref; // deprecated + $line->product_ref = $objp->product_ref; // Product Ref + $line->product_desc = $objp->product_desc; // Product Description $line->product_label = $objp->product_label; // Product Label - $line->description = $objp->description; + $line->description = $objp->description; $line->date_start = $this->db->jdate($objp->date_ouverture_prevue); $line->date_start_real = $this->db->jdate($objp->date_ouverture); @@ -866,7 +866,7 @@ class Contrat extends CommonObject $line->fetch_optionals(); // multilangs - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($objp->fk_product) && ! empty($loadalsotranslation)) { + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) { $line = new Product($this->db); $line->fetch($objp->fk_product); $line->getMultiLangs(); @@ -880,12 +880,12 @@ class Contrat extends CommonObject if ($line->statut == ContratLigne::STATUS_INITIAL) $this->nbofserviceswait++; if ($line->statut == ContratLigne::STATUS_OPEN && (empty($line->date_fin_prevue) || $line->date_fin_prevue >= $now)) $this->nbofservicesopened++; - if ($line->statut == ContratLigne::STATUS_OPEN && (! empty($line->date_fin_prevue) && $line->date_fin_prevue < $now)) $this->nbofservicesexpired++; + if ($line->statut == ContratLigne::STATUS_OPEN && (!empty($line->date_fin_prevue) && $line->date_fin_prevue < $now)) $this->nbofservicesexpired++; if ($line->statut == ContratLigne::STATUS_CLOSED) $this->nbofservicesclosed++; - $total_ttc+=$objp->total_ttc; // TODO Not saved into database - $total_vat+=$objp->total_tva; - $total_ht+=$objp->total_ht; + $total_ttc += $objp->total_ttc; // TODO Not saved into database + $total_vat += $objp->total_tva; + $total_ht += $objp->total_ht; $i++; $pos++; @@ -898,10 +898,10 @@ class Contrat extends CommonObject return -3; } - $this->nbofservices=count($this->lines); - $this->total_ttc = price2num($total_ttc); // TODO For the moment value is false as value is not stored in database for line linked to products - $this->total_vat = price2num($total_vat); // TODO For the moment value is false as value is not stored in database for line linked to products - $this->total_ht = price2num($total_ht); // TODO For the moment value is false as value is not stored in database for line linked to products + $this->nbofservices = count($this->lines); + $this->total_ttc = price2num($total_ttc); // TODO For the moment value is false as value is not stored in database for line linked to products + $this->total_vat = price2num($total_vat); // TODO For the moment value is false as value is not stored in database for line linked to products + $this->total_ht = price2num($total_ht); // TODO For the moment value is false as value is not stored in database for line linked to products return $this->lines; } @@ -914,82 +914,82 @@ class Contrat extends CommonObject */ public function create($user) { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; // Check parameters - $paramsok=1; + $paramsok = 1; if ($this->commercial_signature_id <= 0) { $langs->load("commercial"); - $this->error.=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("SalesRepresentativeSignature")); - $paramsok=0; + $this->error .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("SalesRepresentativeSignature")); + $paramsok = 0; } if ($this->commercial_suivi_id <= 0) { $langs->load("commercial"); - $this->error.=($this->error?"
":''); - $this->error.=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("SalesRepresentativeFollowUp")); - $paramsok=0; + $this->error .= ($this->error ? "
" : ''); + $this->error .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("SalesRepresentativeFollowUp")); + $paramsok = 0; } - if (! $paramsok) return -1; + if (!$paramsok) return -1; $this->db->begin(); - $now=dol_now(); + $now = dol_now(); // Insert contract $sql = "INSERT INTO ".MAIN_DB_PREFIX."contrat (datec, fk_soc, fk_user_author, date_contrat,"; - $sql.= " fk_commercial_signature, fk_commercial_suivi, fk_projet,"; - $sql.= " ref, entity, note_private, note_public, ref_customer, ref_supplier, ref_ext)"; - $sql.= " VALUES ('".$this->db->idate($now)."',".$this->socid.",".$user->id; - $sql.= ", ".(dol_strlen($this->date_contrat)!=0 ? "'".$this->db->idate($this->date_contrat)."'" : "NULL"); - $sql.= ",".($this->commercial_signature_id>0?$this->commercial_signature_id:"NULL"); - $sql.= ",".($this->commercial_suivi_id>0?$this->commercial_suivi_id:"NULL"); - $sql.= ",".($this->fk_project>0?$this->fk_project:"NULL"); - $sql.= ", ".(dol_strlen($this->ref)<=0 ? "null" : "'".$this->db->escape($this->ref)."'"); - $sql.= ", ".$conf->entity; - $sql.= ", ".(!empty($this->note_private)?("'".$this->db->escape($this->note_private)."'"):"NULL"); - $sql.= ", ".(!empty($this->note_public)?("'".$this->db->escape($this->note_public)."'"):"NULL"); - $sql.= ", ".(!empty($this->ref_customer)?("'".$this->db->escape($this->ref_customer)."'"):"NULL"); - $sql.= ", ".(!empty($this->ref_supplier)?("'".$this->db->escape($this->ref_supplier)."'"):"NULL"); - $sql.= ", ".(!empty($this->ref_ext)?("'".$this->db->escape($this->ref_ext)."'"):"NULL"); - $sql.= ")"; - $resql=$this->db->query($sql); + $sql .= " fk_commercial_signature, fk_commercial_suivi, fk_projet,"; + $sql .= " ref, entity, note_private, note_public, ref_customer, ref_supplier, ref_ext)"; + $sql .= " VALUES ('".$this->db->idate($now)."',".$this->socid.",".$user->id; + $sql .= ", ".(dol_strlen($this->date_contrat) != 0 ? "'".$this->db->idate($this->date_contrat)."'" : "NULL"); + $sql .= ",".($this->commercial_signature_id > 0 ? $this->commercial_signature_id : "NULL"); + $sql .= ",".($this->commercial_suivi_id > 0 ? $this->commercial_suivi_id : "NULL"); + $sql .= ",".($this->fk_project > 0 ? $this->fk_project : "NULL"); + $sql .= ", ".(dol_strlen($this->ref) <= 0 ? "null" : "'".$this->db->escape($this->ref)."'"); + $sql .= ", ".$conf->entity; + $sql .= ", ".(!empty($this->note_private) ? ("'".$this->db->escape($this->note_private)."'") : "NULL"); + $sql .= ", ".(!empty($this->note_public) ? ("'".$this->db->escape($this->note_public)."'") : "NULL"); + $sql .= ", ".(!empty($this->ref_customer) ? ("'".$this->db->escape($this->ref_customer)."'") : "NULL"); + $sql .= ", ".(!empty($this->ref_supplier) ? ("'".$this->db->escape($this->ref_supplier)."'") : "NULL"); + $sql .= ", ".(!empty($this->ref_ext) ? ("'".$this->db->escape($this->ref_ext)."'") : "NULL"); + $sql .= ")"; + $resql = $this->db->query($sql); if ($resql) { - $error=0; + $error = 0; $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."contrat"); // Load object modContract - $module=(! empty($conf->global->CONTRACT_ADDON)?$conf->global->CONTRACT_ADDON:'mod_contract_serpis'); + $module = (!empty($conf->global->CONTRACT_ADDON) ? $conf->global->CONTRACT_ADDON : 'mod_contract_serpis'); if (substr($module, 0, 13) == 'mod_contract_' && substr($module, -3) == 'php') { - $module = substr($module, 0, dol_strlen($module)-4); + $module = substr($module, 0, dol_strlen($module) - 4); } - $result=dol_include_once('/core/modules/contract/'.$module.'.php'); + $result = dol_include_once('/core/modules/contract/'.$module.'.php'); if ($result > 0) { $modCodeContract = new $module(); - if (! empty($modCodeContract->code_auto)) { + if (!empty($modCodeContract->code_auto)) { // Force the ref to a draft value if numbering module is an automatic numbering $sql = 'UPDATE '.MAIN_DB_PREFIX."contrat SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id; if ($this->db->query($sql)) { if ($this->id) { - $this->ref="(PROV".$this->id.")"; + $this->ref = "(PROV".$this->id.")"; } } } } - if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) + if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; @@ -997,39 +997,39 @@ class Contrat extends CommonObject } // Insert business contacts ('SALESREPSIGN','contrat') - if (! $error) + if (!$error) { - $result=$this->add_contact($this->commercial_signature_id, 'SALESREPSIGN', 'internal'); + $result = $this->add_contact($this->commercial_signature_id, 'SALESREPSIGN', 'internal'); if ($result < 0) $error++; } // Insert business contacts ('SALESREPFOLL','contrat') - if (! $error) + if (!$error) { - $result=$this->add_contact($this->commercial_suivi_id, 'SALESREPFOLL', 'internal'); + $result = $this->add_contact($this->commercial_suivi_id, 'SALESREPFOLL', 'internal'); if ($result < 0) $error++; } - if (! $error) + if (!$error) { - if (! empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects + if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects { - $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds + $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds } // Add object linked - if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects)) + if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects)) { - foreach($this->linked_objects as $origin => $tmp_origin_id) + foreach ($this->linked_objects as $origin => $tmp_origin_id) { if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) { - foreach($tmp_origin_id as $origin_id) + foreach ($tmp_origin_id as $origin_id) { $ret = $this->add_object_linked($origin, $origin_id); - if (! $ret) + if (!$ret) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } } @@ -1038,22 +1038,22 @@ class Contrat extends CommonObject { $origin_id = $tmp_origin_id; $ret = $this->add_object_linked($origin, $origin_id); - if (! $ret) + if (!$ret) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } } } } - if (! $error && $this->id && ! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && ! empty($this->origin) && ! empty($this->origin_id)) // Get contact from origin object + if (!$error && $this->id && !empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && !empty($this->origin) && !empty($this->origin_id)) // Get contact from origin object { $originforcontact = $this->origin; $originidforcontact = $this->origin_id; if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order { - require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php'; + require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; $exp = new Expedition($db); $exp->fetch($this->origin_id); $exp->fetchObjectLinked(); @@ -1069,31 +1069,31 @@ class Contrat extends CommonObject } $sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; - $sqlcontact.= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'"; + $sqlcontact .= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'"; $resqlcontact = $this->db->query($sqlcontact); if ($resqlcontact) { - while($objcontact = $this->db->fetch_object($resqlcontact)) + while ($objcontact = $this->db->fetch_object($resqlcontact)) { - if ($objcontact->source == 'internal' && in_array($objcontact->code, array('SALESREPSIGN', 'SALESREPFOLL'))) continue; // ignore this, already forced previously + if ($objcontact->source == 'internal' && in_array($objcontact->code, array('SALESREPSIGN', 'SALESREPFOLL'))) continue; // ignore this, already forced previously //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n"; - $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object + $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object } } else dol_print_error($resqlcontact); } } - if (! $error) + if (!$error) { // Call trigger - $result=$this->call_trigger('CONTRACT_CREATE', $user); + $result = $this->call_trigger('CONTRACT_CREATE', $user); if ($result < 0) { $error++; } // End call triggers - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; @@ -1107,7 +1107,7 @@ class Contrat extends CommonObject } else { - $this->error="Failed to add contract"; + $this->error = "Failed to add contract"; dol_syslog(get_class($this)."::create - 20 - ".$this->error, LOG_ERR); $this->db->rollback(); return -2; @@ -1115,7 +1115,7 @@ class Contrat extends CommonObject } else { - $this->error=$langs->trans("UnknownError: ".$this->db->error()." -", LOG_DEBUG); + $this->error = $langs->trans("UnknownError: ".$this->db->error()." -", LOG_DEBUG); $this->db->rollback(); return -1; @@ -1132,18 +1132,18 @@ class Contrat extends CommonObject public function delete($user) { global $conf, $langs; - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $error=0; + $error = 0; $this->db->begin(); // Call trigger - $result=$this->call_trigger('CONTRACT_DELETE', $user); + $result = $this->call_trigger('CONTRACT_DELETE', $user); if ($result < 0) { $error++; } // End call triggers - if (! $error) + if (!$error) { // Delete linked contacts $res = $this->delete_linked_contact(); @@ -1154,14 +1154,14 @@ class Contrat extends CommonObject } } - if (! $error) + if (!$error) { // Delete linked object $res = $this->deleteObjectLinked(); if ($res < 0) $error++; } - if (! $error) + if (!$error) { // Delete contratdet_log /* @@ -1170,73 +1170,73 @@ class Contrat extends CommonObject $sql.= " WHERE cdl.fk_contratdet=cd.rowid AND cd.fk_contrat=".$this->id; */ $sql = "SELECT cdl.rowid as cdlrowid "; - $sql.= " FROM ".MAIN_DB_PREFIX."contratdet_log as cdl, ".MAIN_DB_PREFIX."contratdet as cd"; - $sql.= " WHERE cdl.fk_contratdet=cd.rowid AND cd.fk_contrat=".$this->id; + $sql .= " FROM ".MAIN_DB_PREFIX."contratdet_log as cdl, ".MAIN_DB_PREFIX."contratdet as cd"; + $sql .= " WHERE cdl.fk_contratdet=cd.rowid AND cd.fk_contrat=".$this->id; dol_syslog(get_class($this)."::delete contratdet_log", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $error++; } - $numressql=$this->db->num_rows($resql); - if (! $error && $numressql ) + $numressql = $this->db->num_rows($resql); + if (!$error && $numressql) { - $tab_resql=array(); - for($i=0;$i<$numressql;$i++) + $tab_resql = array(); + for ($i = 0; $i < $numressql; $i++) { - $objresql=$this->db->fetch_object($resql); - $tab_resql[]= $objresql->cdlrowid; + $objresql = $this->db->fetch_object($resql); + $tab_resql[] = $objresql->cdlrowid; } $this->db->free($resql); - $sql= "DELETE FROM ".MAIN_DB_PREFIX."contratdet_log "; - $sql.= " WHERE ".MAIN_DB_PREFIX."contratdet_log.rowid IN (".implode(",", $tab_resql).")"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."contratdet_log "; + $sql .= " WHERE ".MAIN_DB_PREFIX."contratdet_log.rowid IN (".implode(",", $tab_resql).")"; dol_syslog(get_class($this)."::delete contratdet_log", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $error++; } } } - if (! $error) + if (!$error) { // Delete contratdet $sql = "DELETE FROM ".MAIN_DB_PREFIX."contratdet"; - $sql.= " WHERE fk_contrat=".$this->id; + $sql .= " WHERE fk_contrat=".$this->id; dol_syslog(get_class($this)."::delete contratdet", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $error++; } } - if (! $error) + if (!$error) { // Delete contrat $sql = "DELETE FROM ".MAIN_DB_PREFIX."contrat"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::delete contrat", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $error++; } } // Removed extrafields - if (! $error) { - $result=$this->deleteExtraFields(); + if (!$error) { + $result = $this->deleteExtraFields(); if ($result < 0) { $error++; @@ -1244,33 +1244,33 @@ class Contrat extends CommonObject } } - if (! $error) + if (!$error) { // We remove directory $ref = dol_sanitizeFileName($this->ref); if ($conf->contrat->dir_output) { - $dir = $conf->contrat->dir_output . "/" . $ref; + $dir = $conf->contrat->dir_output."/".$ref; if (file_exists($dir)) { - $res=@dol_delete_dir_recursive($dir); - if (! $res) + $res = @dol_delete_dir_recursive($dir); + if (!$res) { - $this->error='ErrorFailToDeleteDir'; + $this->error = 'ErrorFailToDeleteDir'; $error++; } } } } - if (! $error) + if (!$error) { $this->db->commit(); return 1; } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; } @@ -1286,7 +1286,7 @@ class Contrat extends CommonObject public function update($user, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters if (empty($this->fk_commercial_signature) && $this->commercial_signature_id > 0) $this->fk_commercial_signature = $this->commercial_signature_id; @@ -1294,20 +1294,20 @@ class Contrat extends CommonObject if (empty($this->fk_soc) && $this->socid > 0) $this->fk_soc = $this->socid; if (empty($this->fk_project) && $this->projet > 0) $this->fk_project = $this->projet; - if (isset($this->ref)) $this->ref=trim($this->ref); - if (isset($this->ref_customer)) $this->ref_customer=trim($this->ref_customer); - if (isset($this->ref_supplier)) $this->ref_supplier=trim($this->ref_supplier); - if (isset($this->ref_ext)) $this->ref_ext=trim($this->ref_ext); - if (isset($this->entity)) $this->entity=trim($this->entity); - if (isset($this->statut)) $this->statut=(int) $this->statut; - if (isset($this->fk_soc)) $this->fk_soc=trim($this->fk_soc); - if (isset($this->fk_commercial_signature)) $this->fk_commercial_signature=trim($this->fk_commercial_signature); - if (isset($this->fk_commercial_suivi)) $this->fk_commercial_suivi=trim($this->fk_commercial_suivi); - if (isset($this->fk_user_mise_en_service)) $this->fk_user_mise_en_service=trim($this->fk_user_mise_en_service); - if (isset($this->fk_user_cloture)) $this->fk_user_cloture=trim($this->fk_user_cloture); - if (isset($this->note_private)) $this->note_private=trim($this->note_private); - if (isset($this->note_public)) $this->note_public=trim($this->note_public); - if (isset($this->import_key)) $this->import_key=trim($this->import_key); + if (isset($this->ref)) $this->ref = trim($this->ref); + if (isset($this->ref_customer)) $this->ref_customer = trim($this->ref_customer); + if (isset($this->ref_supplier)) $this->ref_supplier = trim($this->ref_supplier); + if (isset($this->ref_ext)) $this->ref_ext = trim($this->ref_ext); + if (isset($this->entity)) $this->entity = trim($this->entity); + if (isset($this->statut)) $this->statut = (int) $this->statut; + if (isset($this->fk_soc)) $this->fk_soc = trim($this->fk_soc); + if (isset($this->fk_commercial_signature)) $this->fk_commercial_signature = trim($this->fk_commercial_signature); + if (isset($this->fk_commercial_suivi)) $this->fk_commercial_suivi = trim($this->fk_commercial_suivi); + if (isset($this->fk_user_mise_en_service)) $this->fk_user_mise_en_service = trim($this->fk_user_mise_en_service); + if (isset($this->fk_user_cloture)) $this->fk_user_cloture = trim($this->fk_user_cloture); + if (isset($this->note_private)) $this->note_private = trim($this->note_private); + if (isset($this->note_public)) $this->note_public = trim($this->note_public); + if (isset($this->import_key)) $this->import_key = trim($this->import_key); //if (isset($this->extraparams)) $this->extraparams=trim($this->extraparams); // Check parameters @@ -1315,46 +1315,46 @@ class Contrat extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET"; - $sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").","; - $sql.= " ref_customer=".(isset($this->ref_customer)?"'".$this->db->escape($this->ref_customer)."'":"null").","; - $sql.= " ref_supplier=".(isset($this->ref_supplier)?"'".$this->db->escape($this->ref_supplier)."'":"null").","; - $sql.= " ref_ext=".(isset($this->ref_ext)?"'".$this->db->escape($this->ref_ext)."'":"null").","; - $sql.= " entity=".$conf->entity.","; - $sql.= " date_contrat=".(dol_strlen($this->date_contrat)!=0 ? "'".$this->db->idate($this->date_contrat)."'" : 'null').","; - $sql.= " statut=".(isset($this->statut)?$this->statut:"null").","; - $sql.= " mise_en_service=".(dol_strlen($this->mise_en_service)!=0 ? "'".$this->db->idate($this->mise_en_service)."'" : 'null').","; - $sql.= " fin_validite=".(dol_strlen($this->fin_validite)!=0 ? "'".$this->db->idate($this->fin_validite)."'" : 'null').","; - $sql.= " date_cloture=".(dol_strlen($this->date_cloture)!=0 ? "'".$this->db->idate($this->date_cloture)."'" : 'null').","; - $sql.= " fk_soc=".($this->fk_soc > 0 ? $this->fk_soc:"null").","; - $sql.= " fk_projet=".($this->fk_project > 0 ? $this->fk_project:"null").","; - $sql.= " fk_commercial_signature=".(isset($this->fk_commercial_signature)?$this->fk_commercial_signature:"null").","; - $sql.= " fk_commercial_suivi=".(isset($this->fk_commercial_suivi)?$this->fk_commercial_suivi:"null").","; - $sql.= " fk_user_mise_en_service=".(isset($this->fk_user_mise_en_service)?$this->fk_user_mise_en_service:"null").","; - $sql.= " fk_user_cloture=".(isset($this->fk_user_cloture)?$this->fk_user_cloture:"null").","; - $sql.= " note_private=".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null").","; - $sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").","; - $sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null").""; + $sql .= " ref=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "null").","; + $sql .= " ref_customer=".(isset($this->ref_customer) ? "'".$this->db->escape($this->ref_customer)."'" : "null").","; + $sql .= " ref_supplier=".(isset($this->ref_supplier) ? "'".$this->db->escape($this->ref_supplier)."'" : "null").","; + $sql .= " ref_ext=".(isset($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null").","; + $sql .= " entity=".$conf->entity.","; + $sql .= " date_contrat=".(dol_strlen($this->date_contrat) != 0 ? "'".$this->db->idate($this->date_contrat)."'" : 'null').","; + $sql .= " statut=".(isset($this->statut) ? $this->statut : "null").","; + $sql .= " mise_en_service=".(dol_strlen($this->mise_en_service) != 0 ? "'".$this->db->idate($this->mise_en_service)."'" : 'null').","; + $sql .= " fin_validite=".(dol_strlen($this->fin_validite) != 0 ? "'".$this->db->idate($this->fin_validite)."'" : 'null').","; + $sql .= " date_cloture=".(dol_strlen($this->date_cloture) != 0 ? "'".$this->db->idate($this->date_cloture)."'" : 'null').","; + $sql .= " fk_soc=".($this->fk_soc > 0 ? $this->fk_soc : "null").","; + $sql .= " fk_projet=".($this->fk_project > 0 ? $this->fk_project : "null").","; + $sql .= " fk_commercial_signature=".(isset($this->fk_commercial_signature) ? $this->fk_commercial_signature : "null").","; + $sql .= " fk_commercial_suivi=".(isset($this->fk_commercial_suivi) ? $this->fk_commercial_suivi : "null").","; + $sql .= " fk_user_mise_en_service=".(isset($this->fk_user_mise_en_service) ? $this->fk_user_mise_en_service : "null").","; + $sql .= " fk_user_cloture=".(isset($this->fk_user_cloture) ? $this->fk_user_cloture : "null").","; + $sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; + $sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").","; + $sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null").""; //$sql.= " extraparams=".(isset($this->extraparams)?"'".$this->db->escape($this->extraparams)."'":"null").""; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) + if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options) > 0) { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call triggers - $result=$this->call_trigger('CONTRACT_MODIFY', $user); + $result = $this->call_trigger('CONTRACT_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } @@ -1362,13 +1362,13 @@ class Contrat extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -1404,66 +1404,66 @@ class Contrat extends CommonObject public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type = 'HT', $pu_ttc = 0.0, $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = 0, $fk_unit = null, $rang = 0) { global $user, $langs, $conf, $mysoc; - $error=0; + $error = 0; dol_syslog(get_class($this)."::addline $desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type, $pu_ttc, $info_bits, $rang"); // Check parameters if ($fk_product <= 0 && empty($desc)) { - $this->error="ErrorDescRequiredForFreeProductLines"; + $this->error = "ErrorDescRequiredForFreeProductLines"; return -1; } if ($this->statut >= 0) { // Clean parameters - $pu_ht=price2num($pu_ht); - $pu_ttc=price2num($pu_ttc); - $pa_ht=price2num($pa_ht); + $pu_ht = price2num($pu_ht); + $pu_ttc = price2num($pu_ttc); + $pa_ht = price2num($pa_ht); if (!preg_match('/\((.*)\)/', $txtva)) { - $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' + $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' } - $txlocaltax1=price2num($txlocaltax1); - $txlocaltax2=price2num($txlocaltax2); - $remise_percent=price2num($remise_percent); - $qty=price2num($qty); - if (empty($qty)) $qty=1; - if (empty($info_bits)) $info_bits=0; - if (empty($pu_ht) || ! is_numeric($pu_ht)) $pu_ht=0; - if (empty($pu_ttc)) $pu_ttc=0; - if (empty($txtva) || ! is_numeric($txtva)) $txtva=0; - if (empty($txlocaltax1) || ! is_numeric($txlocaltax1)) $txlocaltax1=0; - if (empty($txlocaltax2) || ! is_numeric($txlocaltax2)) $txlocaltax2=0; + $txlocaltax1 = price2num($txlocaltax1); + $txlocaltax2 = price2num($txlocaltax2); + $remise_percent = price2num($remise_percent); + $qty = price2num($qty); + if (empty($qty)) $qty = 1; + if (empty($info_bits)) $info_bits = 0; + if (empty($pu_ht) || !is_numeric($pu_ht)) $pu_ht = 0; + if (empty($pu_ttc)) $pu_ttc = 0; + if (empty($txtva) || !is_numeric($txtva)) $txtva = 0; + if (empty($txlocaltax1) || !is_numeric($txlocaltax1)) $txlocaltax1 = 0; + if (empty($txlocaltax2) || !is_numeric($txlocaltax2)) $txlocaltax2 = 0; - if ($price_base_type=='HT') + if ($price_base_type == 'HT') { - $pu=$pu_ht; + $pu = $pu_ht; } else { - $pu=$pu_ttc; + $pu = $pu_ttc; } // Check parameters - if (empty($remise_percent)) $remise_percent=0; + if (empty($remise_percent)) $remise_percent = 0; if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); - $this->error=$langs->trans('ErrorStartDateGreaterEnd'); + $this->error = $langs->trans('ErrorStartDateGreaterEnd'); return -1; } $this->db->begin(); - $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->societe, $mysoc); + $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->societe, $mysoc); // Clean vat code - $vat_src_code=''; + $vat_src_code = ''; if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } // Calcul du total TTC et de la TVA pour la ligne a partir de @@ -1471,15 +1471,15 @@ class Contrat extends CommonObject // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, 1, $mysoc, $localtaxes_type); + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, 1, $mysoc, $localtaxes_type); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; - $total_localtax1= $tabprice[9]; - $total_localtax2= $tabprice[10]; + $total_localtax1 = $tabprice[9]; + $total_localtax2 = $tabprice[10]; - $localtax1_type=$localtaxes_type[0]; - $localtax2_type=$localtaxes_type[2]; + $localtax1_type = $localtaxes_type[0]; + $localtax2_type = $localtaxes_type[2]; // TODO A virer // Anciens indicateurs: $price, $remise (a ne plus utiliser) @@ -1491,7 +1491,7 @@ class Contrat extends CommonObject $price = $pu_ht - $remise; } - if (empty($pa_ht)) $pa_ht=0; + if (empty($pa_ht)) $pa_ht = 0; // if buy price not defined, define buyprice as configured in margin admin @@ -1509,59 +1509,59 @@ class Contrat extends CommonObject // Insertion dans la base $sql = "INSERT INTO ".MAIN_DB_PREFIX."contratdet"; - $sql.= " (fk_contrat, label, description, fk_product, qty, tva_tx, vat_src_code,"; - $sql.= " localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, remise_percent, subprice,"; - $sql.= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc,"; - $sql.= " info_bits,"; - $sql.= " price_ht, remise, fk_product_fournisseur_price, buy_price_ht"; - if ($date_start > 0) { $sql.= ",date_ouverture_prevue"; } - if ($date_end > 0) { $sql.= ",date_fin_validite"; } - $sql.= ", fk_unit"; - $sql.= ") VALUES ("; - $sql.= $this->id.", '', '" . $this->db->escape($desc) . "',"; - $sql.= ($fk_product>0 ? $fk_product : "null").","; - $sql.= " ".$qty.","; - $sql.= " ".$txtva.","; - $sql.= " ".($vat_src_code?"'".$vat_src_code."'":"null").","; - $sql.= " ".$txlocaltax1.","; - $sql.= " ".$txlocaltax2.","; - $sql.= " '".$localtax1_type."',"; - $sql.= " '".$localtax2_type."',"; - $sql.= " ".price2num($remise_percent).","; - $sql.= " ".price2num($pu_ht).","; - $sql.= " ".price2num($total_ht).",".price2num($total_tva).",".price2num($total_localtax1).",".price2num($total_localtax2).",".price2num($total_ttc).","; - $sql.= " '".$info_bits."',"; - $sql.= " ".price2num($price).",".price2num($remise).","; - if (isset($fk_fournprice)) $sql.= ' '.$fk_fournprice.','; - else $sql.= ' null,'; - if (isset($pa_ht)) $sql.= ' '.price2num($pa_ht); - else $sql.= ' null'; - if ($date_start > 0) { $sql.= ",'".$this->db->idate($date_start)."'"; } - if ($date_end > 0) { $sql.= ",'".$this->db->idate($date_end)."'"; } - $sql.= ", ".($fk_unit?"'".$this->db->escape($fk_unit)."'":"null"); - $sql.= ")"; + $sql .= " (fk_contrat, label, description, fk_product, qty, tva_tx, vat_src_code,"; + $sql .= " localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, remise_percent, subprice,"; + $sql .= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc,"; + $sql .= " info_bits,"; + $sql .= " price_ht, remise, fk_product_fournisseur_price, buy_price_ht"; + if ($date_start > 0) { $sql .= ",date_ouverture_prevue"; } + if ($date_end > 0) { $sql .= ",date_fin_validite"; } + $sql .= ", fk_unit"; + $sql .= ") VALUES ("; + $sql .= $this->id.", '', '".$this->db->escape($desc)."',"; + $sql .= ($fk_product > 0 ? $fk_product : "null").","; + $sql .= " ".$qty.","; + $sql .= " ".$txtva.","; + $sql .= " ".($vat_src_code ? "'".$vat_src_code."'" : "null").","; + $sql .= " ".$txlocaltax1.","; + $sql .= " ".$txlocaltax2.","; + $sql .= " '".$localtax1_type."',"; + $sql .= " '".$localtax2_type."',"; + $sql .= " ".price2num($remise_percent).","; + $sql .= " ".price2num($pu_ht).","; + $sql .= " ".price2num($total_ht).",".price2num($total_tva).",".price2num($total_localtax1).",".price2num($total_localtax2).",".price2num($total_ttc).","; + $sql .= " '".$info_bits."',"; + $sql .= " ".price2num($price).",".price2num($remise).","; + if (isset($fk_fournprice)) $sql .= ' '.$fk_fournprice.','; + else $sql .= ' null,'; + if (isset($pa_ht)) $sql .= ' '.price2num($pa_ht); + else $sql .= ' null'; + if ($date_start > 0) { $sql .= ",'".$this->db->idate($date_start)."'"; } + if ($date_end > 0) { $sql .= ",'".$this->db->idate($date_end)."'"; } + $sql .= ", ".($fk_unit ? "'".$this->db->escape($fk_unit)."'" : "null"); + $sql .= ")"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $contractlineid = $this->db->last_insert_id(MAIN_DB_PREFIX."contratdet"); - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) // For avoid conflicts if trigger used { $contractline = new ContratLigne($this->db); - $contractline->array_options=$array_options; - $contractline->id=$contractlineid; - $result=$contractline->insertExtraFields(); + $contractline->array_options = $array_options; + $contractline->id = $contractlineid; + $result = $contractline->insertExtraFields(); if ($result < 0) { - $this->error[]=$contractline->error; + $this->error[] = $contractline->error; $error++; } } if (empty($error)) { // Call trigger - $result=$this->call_trigger('LINECONTRACT_INSERT', $user); + $result = $this->call_trigger('LINECONTRACT_INSERT', $user); if ($result < 0) { $error++; @@ -1583,7 +1583,7 @@ class Contrat extends CommonObject else { $this->db->rollback(); - $this->error=$this->db->error()." sql=".$sql; + $this->error = $this->db->error()." sql=".$sql; return -1; } } @@ -1621,18 +1621,18 @@ class Contrat extends CommonObject { global $user, $conf, $langs, $mysoc; - $error=0; + $error = 0; // Clean parameters - $qty=trim($qty); - $desc=trim($desc); - $desc=trim($desc); + $qty = trim($qty); + $desc = trim($desc); + $desc = trim($desc); $price = price2num($pu); $tvatx = price2num($tvatx); $localtax1tx = price2num($localtax1tx); $localtax2tx = price2num($localtax2tx); - $pa_ht=price2num($pa_ht); - if (empty($fk_fournprice)) $fk_fournprice=0; + $pa_ht = price2num($pa_ht); + if (empty($fk_fournprice)) $fk_fournprice = 0; $subprice = $price; $remise = 0; @@ -1643,12 +1643,12 @@ class Contrat extends CommonObject } else { - $remise_percent=0; + $remise_percent = 0; } if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); - $this->error=$langs->trans('ErrorStartDateGreaterEnd'); + $this->error = $langs->trans('ErrorStartDateGreaterEnd'); return -1; } @@ -1661,18 +1661,18 @@ class Contrat extends CommonObject // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $localtaxes_type=getLocalTaxesFromRate($tvatx, 0, $this->societe, $mysoc); - $tvatx = preg_replace('/\s*\(.*\)/', '', $tvatx); // Remove code into vatrate. + $localtaxes_type = getLocalTaxesFromRate($tvatx, 0, $this->societe, $mysoc); + $tvatx = preg_replace('/\s*\(.*\)/', '', $tvatx); // Remove code into vatrate. - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $tvatx, $localtax1tx, $localtax2tx, 0, $price_base_type, $info_bits, 1, $mysoc, $localtaxes_type); + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $tvatx, $localtax1tx, $localtax2tx, 0, $price_base_type, $info_bits, 1, $mysoc, $localtaxes_type); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; - $total_localtax1= $tabprice[9]; - $total_localtax2= $tabprice[10]; + $total_localtax1 = $tabprice[9]; + $total_localtax2 = $tabprice[10]; - $localtax1_type=$localtaxes_type[0]; - $localtax2_type=$localtaxes_type[2]; + $localtax1_type = $localtaxes_type[0]; + $localtax2_type = $localtaxes_type[2]; // TODO A virer // Anciens indicateurs: $price, $remise (a ne plus utiliser) @@ -1684,7 +1684,7 @@ class Contrat extends CommonObject $price = $pu - $remise; } - if (empty($pa_ht)) $pa_ht=0; + if (empty($pa_ht)) $pa_ht = 0; // if buy price not defined, define buyprice as configured in margin admin if ($this->pa_ht == 0) @@ -1700,57 +1700,57 @@ class Contrat extends CommonObject } $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet set description='".$this->db->escape($desc)."'"; - $sql.= ",price_ht='".price2num($price)."'"; - $sql.= ",subprice='".price2num($subprice)."'"; - $sql.= ",remise='".price2num($remise)."'"; - $sql.= ",remise_percent='".price2num($remise_percent)."'"; - $sql.= ",qty='".$qty."'"; - $sql.= ",tva_tx='".price2num($tvatx)."'"; - $sql.= ",localtax1_tx='".price2num($localtax1tx)."'"; - $sql.= ",localtax2_tx='".price2num($localtax2tx)."'"; - $sql.= ",localtax1_type='".$localtax1_type."'"; - $sql.= ",localtax2_type='".$localtax2_type."'"; - $sql.= ", total_ht='".price2num($total_ht)."'"; - $sql.= ", total_tva='".price2num($total_tva)."'"; - $sql.= ", total_localtax1='".price2num($total_localtax1)."'"; - $sql.= ", total_localtax2='".price2num($total_localtax2)."'"; - $sql.= ", total_ttc='".price2num($total_ttc)."'"; - $sql.= ", fk_product_fournisseur_price=".($fk_fournprice > 0 ? $fk_fournprice : "null"); - $sql.= ", buy_price_ht='".price2num($pa_ht)."'"; - if ($date_start > 0) { $sql.= ",date_ouverture_prevue='".$this->db->idate($date_start)."'"; } - else { $sql.=",date_ouverture_prevue=null"; } - if ($date_end > 0) { $sql.= ",date_fin_validite='".$this->db->idate($date_end)."'"; } - else { $sql.=",date_fin_validite=null"; } - if ($date_debut_reel > 0) { $sql.= ",date_ouverture='".$this->db->idate($date_debut_reel)."'"; } - else { $sql.=",date_ouverture=null"; } - if ($date_fin_reel > 0) { $sql.= ",date_cloture='".$this->db->idate($date_fin_reel)."'"; } - else { $sql.=",date_cloture=null"; } - $sql .= ", fk_unit=".($fk_unit?"'".$this->db->escape($fk_unit)."'":"null"); + $sql .= ",price_ht='".price2num($price)."'"; + $sql .= ",subprice='".price2num($subprice)."'"; + $sql .= ",remise='".price2num($remise)."'"; + $sql .= ",remise_percent='".price2num($remise_percent)."'"; + $sql .= ",qty='".$qty."'"; + $sql .= ",tva_tx='".price2num($tvatx)."'"; + $sql .= ",localtax1_tx='".price2num($localtax1tx)."'"; + $sql .= ",localtax2_tx='".price2num($localtax2tx)."'"; + $sql .= ",localtax1_type='".$localtax1_type."'"; + $sql .= ",localtax2_type='".$localtax2_type."'"; + $sql .= ", total_ht='".price2num($total_ht)."'"; + $sql .= ", total_tva='".price2num($total_tva)."'"; + $sql .= ", total_localtax1='".price2num($total_localtax1)."'"; + $sql .= ", total_localtax2='".price2num($total_localtax2)."'"; + $sql .= ", total_ttc='".price2num($total_ttc)."'"; + $sql .= ", fk_product_fournisseur_price=".($fk_fournprice > 0 ? $fk_fournprice : "null"); + $sql .= ", buy_price_ht='".price2num($pa_ht)."'"; + if ($date_start > 0) { $sql .= ",date_ouverture_prevue='".$this->db->idate($date_start)."'"; } + else { $sql .= ",date_ouverture_prevue=null"; } + if ($date_end > 0) { $sql .= ",date_fin_validite='".$this->db->idate($date_end)."'"; } + else { $sql .= ",date_fin_validite=null"; } + if ($date_debut_reel > 0) { $sql .= ",date_ouverture='".$this->db->idate($date_debut_reel)."'"; } + else { $sql .= ",date_ouverture=null"; } + if ($date_fin_reel > 0) { $sql .= ",date_cloture='".$this->db->idate($date_fin_reel)."'"; } + else { $sql .= ",date_cloture=null"; } + $sql .= ", fk_unit=".($fk_unit ? "'".$this->db->escape($fk_unit)."'" : "null"); $sql .= " WHERE rowid = ".$rowid; dol_syslog(get_class($this)."::updateline", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { - $result=$this->update_statut($user); + $result = $this->update_statut($user); if ($result >= 0) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) // For avoid conflicts if trigger used { $contractline = new ContratLigne($this->db); - $contractline->array_options=$array_options; - $contractline->id= $rowid; - $result=$contractline->insertExtraFields(); + $contractline->array_options = $array_options; + $contractline->id = $rowid; + $result = $contractline->insertExtraFields(); if ($result < 0) { - $this->error[]=$contractline->error; + $this->error[] = $contractline->error; $error++; } } if (empty($error)) { // Call trigger - $result=$this->call_trigger('LINECONTRACT_UPDATE', $user); + $result = $this->call_trigger('LINECONTRACT_UPDATE', $user); if ($result < 0) { $this->db->rollback(); @@ -1772,7 +1772,7 @@ class Contrat extends CommonObject else { $this->db->rollback(); - $this->error=$this->db->error(); + $this->error = $this->db->error(); dol_syslog(get_class($this)."::updateline Erreur -1"); return -1; } @@ -1789,25 +1789,25 @@ class Contrat extends CommonObject { global $conf, $langs; - $error=0; + $error = 0; if ($this->statut >= 0) { // Call trigger - $result=$this->call_trigger('LINECONTRACT_DELETE', $user); + $result = $this->call_trigger('LINECONTRACT_DELETE', $user); if ($result < 0) return -1; // End call triggers $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element_line; - $sql.= " WHERE rowid=".$idline; + $sql .= " WHERE rowid=".$idline; dol_syslog(get_class($this)."::deleteline", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); $error++; } @@ -1816,12 +1816,12 @@ class Contrat extends CommonObject if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { $contractline = new ContratLigne($this->db); - $contractline->id= $idline; - $result=$contractline->deleteExtraFields(); + $contractline->id = $idline; + $result = $contractline->deleteExtraFields(); if ($result < 0) { $error++; - $this->error="Error ".get_class($this)."::deleteline deleteExtraFields error -4 ".$contractline->error; + $this->error = "Error ".get_class($this)."::deleteline deleteExtraFields error -4 ".$contractline->error; } } } @@ -1854,7 +1854,7 @@ class Contrat extends CommonObject public function update_statut($user) { // phpcs:enable - dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING); + dol_syslog(__METHOD__." is deprecated", LOG_WARNING); // If draft, we keep it (should not happen) if ($this->statut == 0) return 1; @@ -1914,23 +1914,23 @@ class Contrat extends CommonObject if ($mode == 4 || $mode == 6 || $mode == 7) { - $text=''; + $text = ''; if ($mode == 4) { - $text =''; - $text.=($this->nbofserviceswait+$this->nbofservicesopened+$this->nbofservicesexpired+$this->nbofservicesclosed); - $text.=' '.$langs->trans("Services"); - $text.=':     '; - $text.=''; + $text = ''; + $text .= ($this->nbofserviceswait + $this->nbofservicesopened + $this->nbofservicesexpired + $this->nbofservicesclosed); + $text .= ' '.$langs->trans("Services"); + $text .= ':     '; + $text .= ''; } - $text.=($mode == 7?'':''); - $text.=($mode != 7 || $this->nbofserviceswait > 0) ? ($this->nbofserviceswait.ContratLigne::LibStatut(0, 3, -1, 'class="marginleft2"')).(($mode != 7 || $this->nbofservicesopened || $this->nbofservicesexpired || $this->nbofservicesclosed)?'   ':'') : ''; - $text.=($mode == 7?'':''); - $text.=($mode != 7 || $this->nbofservicesopened > 0) ? ($this->nbofservicesopened.ContratLigne::LibStatut(4, 3, 0, 'class="marginleft2"')).(($mode != 7 || $this->nbofservicesexpired || $this->nbofservicesclosed)?'   ':'') : ''; - $text.=($mode == 7?'':''); - $text.=($mode != 7 || $this->nbofservicesexpired > 0) ? ($this->nbofservicesexpired.ContratLigne::LibStatut(4, 3, 1, 'class="marginleft2"')).(($mode != 7 || $this->nbofservicesclosed)?'   ':'') : ''; - $text.=($mode == 7?'':''); - $text.=($mode != 7 || $this->nbofservicesclosed > 0) ? ($this->nbofservicesclosed.ContratLigne::LibStatut(5, 3, -1, 'class="marginleft2"')) : ''; - $text.=($mode == 7?'':''); + $text .= ($mode == 7 ? '' : ''); + $text .= ($mode != 7 || $this->nbofserviceswait > 0) ? ($this->nbofserviceswait.ContratLigne::LibStatut(0, 3, -1, 'class="marginleft2"')).(($mode != 7 || $this->nbofservicesopened || $this->nbofservicesexpired || $this->nbofservicesclosed) ? '   ' : '') : ''; + $text .= ($mode == 7 ? '' : ''); + $text .= ($mode != 7 || $this->nbofservicesopened > 0) ? ($this->nbofservicesopened.ContratLigne::LibStatut(4, 3, 0, 'class="marginleft2"')).(($mode != 7 || $this->nbofservicesexpired || $this->nbofservicesclosed) ? '   ' : '') : ''; + $text .= ($mode == 7 ? '' : ''); + $text .= ($mode != 7 || $this->nbofservicesexpired > 0) ? ($this->nbofservicesexpired.ContratLigne::LibStatut(4, 3, 1, 'class="marginleft2"')).(($mode != 7 || $this->nbofservicesclosed) ? '   ' : '') : ''; + $text .= ($mode == 7 ? '' : ''); + $text .= ($mode != 7 || $this->nbofservicesclosed > 0) ? ($this->nbofservicesclosed.ContratLigne::LibStatut(5, 3, -1, 'class="marginleft2"')) : ''; + $text .= ($mode == 7 ? '' : ''); return $text; } else @@ -1953,61 +1953,61 @@ class Contrat extends CommonObject { global $conf, $langs, $user, $hookmanager; - $result=''; + $result = ''; $url = DOL_URL_ROOT.'/contrat/card.php?id='.$this->id; //if ($option !== 'nolink') //{ // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; //} $label = ''; if ($user->rights->contrat->lire) { $label = ''.$langs->trans("ShowContract").''; - $label .= '
'.$langs->trans('Ref').': '.($this->ref?$this->ref:$this->id); + $label .= '
'.$langs->trans('Ref').': '.($this->ref ? $this->ref : $this->id); $label .= '
'.$langs->trans('RefCustomer').': '.($this->ref_customer ? $this->ref_customer : $this->ref_client); $label .= '
'.$langs->trans('RefSupplier').': '.$this->ref_supplier; if (!empty($this->total_ht)) { $label .= '
'.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); } if (!empty($this->total_tva)) { - $label .= '
'.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); + $label .= '
'.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); } if (!empty($this->total_ttc)) { $label .= '
'.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); } } - $linkclose=''; + $linkclose = ''; if (empty($notooltip) && $user->rights->contrat->lire) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowOrder"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowOrder"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; } $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), $this->picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= ($this->ref?$this->ref:$this->id); + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= ($this->ref ? $this->ref : $this->id); $result .= $linkend; global $action; $hookmanager->initHooks(array('contractdao')); - $parameters=array('id'=>$this->id, 'getnomurl'=>$result); - $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) { $result = $hookmanager->resPrint; } else { @@ -2026,12 +2026,12 @@ class Contrat extends CommonObject public function info($id) { $sql = "SELECT c.rowid, c.ref, c.datec, c.date_cloture,"; - $sql.= " c.tms as date_modification,"; - $sql.= " fk_user_author, fk_user_cloture"; - $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c"; - $sql.= " WHERE c.rowid = ".$id; + $sql .= " c.tms as date_modification,"; + $sql .= " fk_user_author, fk_user_cloture"; + $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c"; + $sql .= " WHERE c.rowid = ".$id; - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -2043,7 +2043,7 @@ class Contrat extends CommonObject if ($obj->fk_user_author) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_cloture) { @@ -2051,7 +2051,7 @@ class Contrat extends CommonObject $cuser->fetch($obj->fk_user_cloture); $this->user_cloture = $cuser; } - $this->ref = (! $obj->ref) ? $obj->rowid : $obj->ref; + $this->ref = (!$obj->ref) ? $obj->rowid : $obj->ref; $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->date_modification); $this->date_cloture = $this->db->jdate($obj->date_cloture); @@ -2075,30 +2075,30 @@ class Contrat extends CommonObject public function array_detail($status = -1) { // phpcs:enable - $tab=array(); + $tab = array(); $sql = "SELECT cd.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd"; - $sql.= " WHERE fk_contrat =".$this->id; - if ($status >= 0) $sql.= " AND statut = ".$status; + $sql .= " FROM ".MAIN_DB_PREFIX."contratdet as cd"; + $sql .= " WHERE fk_contrat =".$this->id; + if ($status >= 0) $sql .= " AND statut = ".$status; dol_syslog(get_class($this)."::array_detail()", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num=$this->db->num_rows($resql); - $i=0; + $num = $this->db->num_rows($resql); + $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); - $tab[$i]=$obj->rowid; + $tab[$i] = $obj->rowid; $i++; } return $tab; } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2111,32 +2111,32 @@ class Contrat extends CommonObject */ public function getListOfContracts($option = 'all') { - $tab=array(); + $tab = array(); $sql = "SELECT c.rowid, c.ref"; - $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c"; - $sql.= " WHERE fk_soc =".$this->socid; - if ($option == 'others') $sql.= " AND c.rowid != ".$this->id; + $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c"; + $sql .= " WHERE fk_soc =".$this->socid; + if ($option == 'others') $sql .= " AND c.rowid != ".$this->id; dol_syslog(get_class($this)."::getOtherContracts()", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num=$this->db->num_rows($resql); - $i=0; + $num = $this->db->num_rows($resql); + $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); - $contrat=new Contrat($this->db); + $contrat = new Contrat($this->db); $contrat->fetch($obj->rowid); - $tab[]=$contrat; + $tab[] = $contrat; $i++; } return $tab; } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2156,47 +2156,47 @@ class Contrat extends CommonObject global $conf, $langs; $this->from = " FROM ".MAIN_DB_PREFIX."contrat as c"; - $this->from.= ", ".MAIN_DB_PREFIX."contratdet as cd"; - $this->from.= ", ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$user->socid) $this->from.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $this->from .= ", ".MAIN_DB_PREFIX."contratdet as cd"; + $this->from .= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$user->socid) $this->from .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if ($mode == 'inactive') { $sql = "SELECT cd.rowid, cd.date_ouverture_prevue as datefin"; - $sql.= $this->from; - $sql.= " WHERE c.statut = 1"; - $sql.= " AND c.rowid = cd.fk_contrat"; - $sql.= " AND cd.statut = 0"; + $sql .= $this->from; + $sql .= " WHERE c.statut = 1"; + $sql .= " AND c.rowid = cd.fk_contrat"; + $sql .= " AND cd.statut = 0"; } elseif ($mode == 'expired') { $sql = "SELECT cd.rowid, cd.date_fin_validite as datefin"; - $sql.= $this->from; - $sql.= " WHERE c.statut = 1"; - $sql.= " AND c.rowid = cd.fk_contrat"; - $sql.= " AND cd.statut = 4"; - $sql.= " AND cd.date_fin_validite < '".$this->db->idate(dol_now())."'"; + $sql .= $this->from; + $sql .= " WHERE c.statut = 1"; + $sql .= " AND c.rowid = cd.fk_contrat"; + $sql .= " AND cd.statut = 4"; + $sql .= " AND cd.date_fin_validite < '".$this->db->idate(dol_now())."'"; } elseif ($mode == 'active') { $sql = "SELECT cd.rowid, cd.date_fin_validite as datefin"; - $sql.= $this->from; - $sql.= " WHERE c.statut = 1"; - $sql.= " AND c.rowid = cd.fk_contrat"; - $sql.= " AND cd.statut = 4"; + $sql .= $this->from; + $sql .= " WHERE c.statut = 1"; + $sql .= " AND c.rowid = cd.fk_contrat"; + $sql .= " AND cd.statut = 4"; //$datetouse = dol_now(); //$sql.= " AND cd.date_fin_validite < '".$this->db->idate($datetouse)."'"; } - $sql.= " AND c.fk_soc = s.rowid"; - $sql.= " AND c.entity = ".$conf->entity; - if ($user->socid) $sql.=" AND c.fk_soc = ".$user->socid; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " AND c.fk_soc = s.rowid"; + $sql .= " AND c.entity = ".$conf->entity; + if ($user->socid) $sql .= " AND c.fk_soc = ".$user->socid; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $langs->load("contracts"); - $now=dol_now(); + $now = dol_now(); if ($mode == 'inactive') { $warning_delay = $conf->contrat->services->inactifs->warning_delay; @@ -2219,13 +2219,13 @@ class Contrat extends CommonObject } $response = new WorkboardResponse(); - $response->warning_delay = $warning_delay/60/60/24; + $response->warning_delay = $warning_delay / 60 / 60 / 24; $response->label = $label; $response->labelShort = $labelShort; $response->url = $url; $response->img = img_object('', "contract"); - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { $response->nbtodo++; @@ -2239,7 +2239,7 @@ class Contrat extends CommonObject else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2255,26 +2255,26 @@ class Contrat extends CommonObject // phpcs:enable global $conf, $user; - $this->nb=array(); + $this->nb = array(); $clause = "WHERE"; $sql = "SELECT count(c.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; if (!$user->rights->societe->client->voir && !$user->socid) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; - $sql.= " WHERE sc.fk_user = " .$user->id; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; + $sql .= " WHERE sc.fk_user = ".$user->id; $clause = "AND"; } - $sql.= " ".$clause." c.entity = ".$conf->entity; + $sql .= " ".$clause." c.entity = ".$conf->entity; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $this->nb["Contracts"]=$obj->nb; + $this->nb["Contracts"] = $obj->nb; } $this->db->free($resql); return 1; @@ -2282,7 +2282,7 @@ class Contrat extends CommonObject else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2320,15 +2320,15 @@ class Contrat extends CommonObject */ public function initAsSpecimen() { - global $user,$langs,$conf; + global $user, $langs, $conf; // Load array of products prodids $num_prods = 0; $prodids = array(); $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE entity IN (".getEntity('product').")"; - $sql.= " AND tosell = 1"; + $sql .= " FROM ".MAIN_DB_PREFIX."product"; + $sql .= " WHERE entity IN (".getEntity('product').")"; + $sql .= " AND tosell = 1"; $resql = $this->db->query($sql); if ($resql) { @@ -2343,35 +2343,35 @@ class Contrat extends CommonObject } // Initialise parametres - $this->id=0; - $this->specimen=1; + $this->id = 0; + $this->specimen = 1; $this->ref = 'SPECIMEN'; $this->ref_customer = 'SPECIMENCUST'; $this->ref_supplier = 'SPECIMENSUPP'; $this->socid = 1; - $this->statut= 0; + $this->statut = 0; $this->date_creation = (dol_now() - 3600 * 24 * 7); $this->date_contrat = dol_now(); $this->commercial_signature_id = 1; $this->commercial_suivi_id = 1; - $this->note_private='This is a comment (private)'; - $this->note_public='This is a comment (public)'; + $this->note_private = 'This is a comment (private)'; + $this->note_public = 'This is a comment (public)'; $this->fk_projet = 0; // Lines $nbp = 5; $xnbp = 0; while ($xnbp < $nbp) { - $line=new ContratLigne($this->db); - $line->qty=1; - $line->subprice=100; - $line->price=100; - $line->tva_tx=19.6; - $line->remise_percent=10; - $line->total_ht=90; - $line->total_ttc=107.64; // 90 * 1.196 - $line->total_tva=17.64; + $line = new ContratLigne($this->db); + $line->qty = 1; + $line->subprice = 100; + $line->price = 100; + $line->tva_tx = 19.6; + $line->remise_percent = 10; + $line->total_ht = 90; + $line->total_ttc = 107.64; // 90 * 1.196 + $line->total_tva = 17.64; $line->date_start = dol_now() - 500000; $line->date_start_real = dol_now() - 200000; $line->date_end = dol_now() + 500000; @@ -2379,9 +2379,9 @@ class Contrat extends CommonObject if ($num_prods > 0) { $prodid = mt_rand(1, $num_prods); - $line->fk_product=$prodids[$prodid]; + $line->fk_product = $prodids[$prodid]; } - $this->lines[$xnbp]=$line; + $this->lines[$xnbp] = $line; $xnbp++; } } @@ -2410,16 +2410,16 @@ class Contrat extends CommonObject */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { - global $conf,$langs; + global $conf, $langs; $langs->load("contracts"); - if (! dol_strlen($modele)) { + if (!dol_strlen($modele)) { $modele = 'strato'; if ($this->modelpdf) { $modele = $this->modelpdf; - } elseif (! empty($conf->global->CONTRACT_ADDON_PDF)) { + } elseif (!empty($conf->global->CONTRACT_ADDON_PDF)) { $modele = $conf->global->CONTRACT_ADDON_PDF; } } @@ -2480,11 +2480,11 @@ class Contrat extends CommonObject if (is_array($clonedObj->array_options) && count($clonedObj->array_options) > 0) { $extrafields->fetch_name_optionals_label($this->table_element); - foreach($clonedObj->array_options as $key => $option) + foreach ($clonedObj->array_options as $key => $option) { $shortkey = preg_replace('/options_/', '', $key); //var_dump($shortkey); var_dump($extrafields->attributes[$this->element]['unique'][$shortkey]); - if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey])) + if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey])) { //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; unset($clonedObj->array_options[$key]); @@ -2492,14 +2492,14 @@ class Contrat extends CommonObject } } - if (empty($conf->global->CONTRACT_ADDON) || ! is_readable(DOL_DOCUMENT_ROOT . "/core/modules/contract/" . $conf->global->CONTRACT_ADDON . ".php")) { + if (empty($conf->global->CONTRACT_ADDON) || !is_readable(DOL_DOCUMENT_ROOT."/core/modules/contract/".$conf->global->CONTRACT_ADDON.".php")) { $this->error = 'ErrorSetupNotComplete'; dol_syslog($this->error); - return - 1; + return -1; } // Set ref - require_once DOL_DOCUMENT_ROOT . "/core/modules/contract/" . $conf->global->CONTRACT_ADDON . '.php'; + require_once DOL_DOCUMENT_ROOT."/core/modules/contract/".$conf->global->CONTRACT_ADDON.'.php'; $obj = $conf->global->CONTRACT_ADDON; $modContract = new $obj(); $clonedObj->ref = $modContract->getNextValue($objsoc, $clonedObj); @@ -2513,7 +2513,7 @@ class Contrat extends CommonObject $clonedObj->context['createfromclone'] = 'createfromclone'; $result = $clonedObj->create($user); if ($result < 0) { - $error ++; + $error++; $this->error = $clonedObj->error; $this->errors[] = $clonedObj->error; } else { @@ -2525,40 +2525,40 @@ class Contrat extends CommonObject } } - if (! $error) { + if (!$error) { foreach ($this->lines as $line) { $result = $clonedObj->addline($line->desc, $line->subprice, $line->qty, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->fk_product, $line->remise_percent, $line->date_ouverture, $line->date_cloture, 'HT', 0, $line->info_bits, $line->fk_fournprice, $line->pa_ht, $line->array_options, $line->fk_unit); if ($result < 0) { - $error ++; + $error++; $this->error = $clonedObj->error; $this->errors[] = $clonedObj->error; } } } - if (! $error) { + if (!$error) { // Hook of thirdparty module if (is_object($hookmanager)) { - $parameters = array ( + $parameters = array( 'objFrom' => $this, 'clonedObj' => $clonedObj ); $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $clonedObj, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) - $error ++; + $error++; } } unset($clonedObj->context['createfromclone']); // End - if (! $error) { + if (!$error) { $this->db->commit(); return $clonedObj->id; } else { $this->db->rollback(); - return - 1; + return -1; } } } @@ -2572,12 +2572,12 @@ class ContratLigne extends CommonObjectLine /** * @var string ID to identify managed object */ - public $element='contratdet'; + public $element = 'contratdet'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='contratdet'; + public $table_element = 'contratdet'; /** * @var int ID @@ -2601,8 +2601,8 @@ class ContratLigne extends CommonObjectLine */ public $fk_product; - public $statut; // 0 inactive, 4 active, 5 closed - public $type; // 0 for product, 1 for service + public $statut; // 0 inactive, 4 active, 5 closed + public $type; // 0 for product, 1 for service /** * @var string @@ -2626,20 +2626,20 @@ class ContratLigne extends CommonObjectLine public $date_commande; - public $date_start; // date start planned - public $date_start_real; // date start real - public $date_end; // date end planned - public $date_end_real; // date end real + public $date_start; // date start planned + public $date_start_real; // date start real + public $date_end; // date end planned + public $date_end_real; // date end real // For backward compatibility - public $date_ouverture_prevue; // date start planned - public $date_ouverture; // date start real - public $date_fin_validite; // date end planned - public $date_cloture; // date end real + public $date_ouverture_prevue; // date start planned + public $date_ouverture; // date start real + public $date_fin_validite; // date end planned + public $date_cloture; // date end real public $tva_tx; public $localtax1_tx; public $localtax2_tx; - public $localtax1_type; // Local tax 1 type - public $localtax2_type; // Local tax 2 type + public $localtax1_type; // Local tax 1 type + public $localtax2_type; // Local tax 2 type public $qty; public $remise_percent; public $remise; @@ -2649,7 +2649,7 @@ class ContratLigne extends CommonObjectLine */ public $fk_remise_except; - public $subprice; // Unit price HT + public $subprice; // Unit price HT /** * @var float @@ -2717,7 +2717,7 @@ class ContratLigne extends CommonObjectLine */ public function getLibStatut($mode) { - return $this->LibStatut($this->statut, $mode, ((! empty($this->date_fin_validite))?($this->date_fin_validite < dol_now()?1:0):-1)); + return $this->LibStatut($this->statut, $mode, ((!empty($this->date_fin_validite)) ? ($this->date_fin_validite < dol_now() ? 1 : 0) : -1)); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -2738,8 +2738,8 @@ class ContratLigne extends CommonObjectLine if ($status == self::STATUS_INITIAL) { $labelStatus = $langs->trans("ServiceStatusInitial"); $labelStatusShort = $langs->trans("ServiceStatusInitial"); } elseif ($status == self::STATUS_OPEN && $expired == -1) { $labelStatus = $langs->trans("ServiceStatusRunning"); $labelStatusShort = $langs->trans("ServiceStatusRunning"); } - elseif ($status == self::STATUS_OPEN && $expired == 0) { $labelStatus = $langs->trans("ServiceStatusNotLate"); $labelStatusShort = $langs->trans("ServiceStatusNotLateShort"); } - elseif ($status == self::STATUS_OPEN && $expired == 1) { $labelStatus = $langs->trans("ServiceStatusLate"); $labelStatusShort = $langs->trans("ServiceStatusLateShort"); } + elseif ($status == self::STATUS_OPEN && $expired == 0) { $labelStatus = $langs->trans("ServiceStatusNotLate"); $labelStatusShort = $langs->trans("ServiceStatusNotLateShort"); } + elseif ($status == self::STATUS_OPEN && $expired == 1) { $labelStatus = $langs->trans("ServiceStatusLate"); $labelStatusShort = $langs->trans("ServiceStatusLateShort"); } elseif ($status == self::STATUS_CLOSED) { $labelStatus = $langs->trans("ServiceStatusClosed"); $labelStatusShort = $langs->trans("ServiceStatusClosed"); } $statusType = 'status'.$status; @@ -2765,19 +2765,19 @@ class ContratLigne extends CommonObjectLine { global $langs; - $result=''; - $label=$langs->trans("ShowContractOfService").': '.$this->label; - if (empty($label)) $label=$this->description; + $result = ''; + $label = $langs->trans("ShowContractOfService").': '.$this->label; + if (empty($label)) $label = $this->description; $link = ''; - $linkend=''; + $linkend = ''; - $picto='service'; - if ($this->type == 0) $picto='product'; + $picto = 'service'; + if ($this->type == 0) $picto = 'product'; - if ($withpicto) $result.=($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); - if ($withpicto && $withpicto != 2) $result.=' '; - if ($withpicto != 2) $result.=$link.($this->product_ref?$this->product_ref.' ':'').($this->label?$this->label:$this->description).$linkend; + if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); + if ($withpicto && $withpicto != 2) $result .= ' '; + if ($withpicto != 2) $result .= $link.($this->product_ref ? $this->product_ref.' ' : '').($this->label ? $this->label : $this->description).$linkend; return $result; } @@ -2795,54 +2795,54 @@ class ContratLigne extends CommonObjectLine if (empty($id) && empty($ref)) return -1; $sql = "SELECT"; - $sql.= " t.rowid,"; + $sql .= " t.rowid,"; - $sql.= " t.tms,"; - $sql.= " t.fk_contrat,"; - $sql.= " t.fk_product,"; - $sql.= " t.statut,"; - $sql.= " t.label,"; // This field is not used. Only label of product - $sql.= " p.ref as product_ref,"; - $sql.= " p.label as product_label,"; - $sql.= " p.description as product_desc,"; - $sql.= " p.fk_product_type as product_type,"; - $sql.= " t.description,"; - $sql.= " t.date_commande,"; - $sql.= " t.date_ouverture_prevue as date_ouverture_prevue,"; - $sql.= " t.date_ouverture as date_ouverture,"; - $sql.= " t.date_fin_validite as date_fin_validite,"; - $sql.= " t.date_cloture as date_cloture,"; - $sql.= " t.tva_tx,"; - $sql.= " t.vat_src_code,"; - $sql.= " t.localtax1_tx,"; - $sql.= " t.localtax2_tx,"; - $sql.= " t.localtax1_type,"; - $sql.= " t.localtax2_type,"; - $sql.= " t.qty,"; - $sql.= " t.remise_percent,"; - $sql.= " t.remise,"; - $sql.= " t.fk_remise_except,"; - $sql.= " t.subprice,"; - $sql.= " t.price_ht,"; - $sql.= " t.total_ht,"; - $sql.= " t.total_tva,"; - $sql.= " t.total_localtax1,"; - $sql.= " t.total_localtax2,"; - $sql.= " t.total_ttc,"; - $sql.= " t.fk_product_fournisseur_price as fk_fournprice,"; - $sql.= " t.buy_price_ht as pa_ht,"; - $sql.= " t.info_bits,"; - $sql.= " t.fk_user_author,"; - $sql.= " t.fk_user_ouverture,"; - $sql.= " t.fk_user_cloture,"; - $sql.= " t.commentaire,"; - $sql.= " t.fk_unit"; - $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as t LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = t.fk_product"; - if ($id) $sql.= " WHERE t.rowid = ".$id; - if ($ref) $sql.= " WHERE t.rowid = '".$this->db->escape($ref)."'"; + $sql .= " t.tms,"; + $sql .= " t.fk_contrat,"; + $sql .= " t.fk_product,"; + $sql .= " t.statut,"; + $sql .= " t.label,"; // This field is not used. Only label of product + $sql .= " p.ref as product_ref,"; + $sql .= " p.label as product_label,"; + $sql .= " p.description as product_desc,"; + $sql .= " p.fk_product_type as product_type,"; + $sql .= " t.description,"; + $sql .= " t.date_commande,"; + $sql .= " t.date_ouverture_prevue as date_ouverture_prevue,"; + $sql .= " t.date_ouverture as date_ouverture,"; + $sql .= " t.date_fin_validite as date_fin_validite,"; + $sql .= " t.date_cloture as date_cloture,"; + $sql .= " t.tva_tx,"; + $sql .= " t.vat_src_code,"; + $sql .= " t.localtax1_tx,"; + $sql .= " t.localtax2_tx,"; + $sql .= " t.localtax1_type,"; + $sql .= " t.localtax2_type,"; + $sql .= " t.qty,"; + $sql .= " t.remise_percent,"; + $sql .= " t.remise,"; + $sql .= " t.fk_remise_except,"; + $sql .= " t.subprice,"; + $sql .= " t.price_ht,"; + $sql .= " t.total_ht,"; + $sql .= " t.total_tva,"; + $sql .= " t.total_localtax1,"; + $sql .= " t.total_localtax2,"; + $sql .= " t.total_ttc,"; + $sql .= " t.fk_product_fournisseur_price as fk_fournprice,"; + $sql .= " t.buy_price_ht as pa_ht,"; + $sql .= " t.info_bits,"; + $sql .= " t.fk_user_author,"; + $sql .= " t.fk_user_ouverture,"; + $sql .= " t.fk_user_cloture,"; + $sql .= " t.commentaire,"; + $sql .= " t.fk_unit"; + $sql .= " FROM ".MAIN_DB_PREFIX."contratdet as t LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = t.fk_product"; + if ($id) $sql .= " WHERE t.rowid = ".$id; + if ($ref) $sql .= " WHERE t.rowid = '".$this->db->escape($ref)."'"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) @@ -2860,7 +2860,7 @@ class ContratLigne extends CommonObjectLine $this->product_label = $obj->product_label; $this->product_description = $obj->product_description; $this->product_type = $obj->product_type; - $this->label = $obj->label; // deprecated. We do not use this field. Only ref and label of product, and description of contract line + $this->label = $obj->label; // deprecated. We do not use this field. Only ref and label of product, and description of contract line $this->description = $obj->description; $this->date_commande = $this->db->jdate($obj->date_commande); @@ -2899,7 +2899,7 @@ class ContratLigne extends CommonObjectLine $this->fk_fournprice = $obj->fk_fournprice; $marginInfos = getMarginInfos($obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, $this->fk_fournprice, $obj->pa_ht); $this->pa_ht = $marginInfos[0]; - $this->fk_unit = $obj->fk_unit; + $this->fk_unit = $obj->fk_unit; } $this->db->free($resql); @@ -2907,7 +2907,7 @@ class ContratLigne extends CommonObjectLine } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -2924,34 +2924,34 @@ class ContratLigne extends CommonObjectLine { global $conf, $langs, $mysoc; - $error=0; + $error = 0; // Clean parameters $this->fk_contrat = (int) $this->fk_contrat; $this->fk_product = (int) $this->fk_product; $this->statut = (int) $this->statut; - $this->label=trim($this->label); - $this->description=trim($this->description); - $this->vat_src_code=trim($this->vat_src_code); - $this->tva_tx=trim($this->tva_tx); - $this->localtax1_tx=trim($this->localtax1_tx); - $this->localtax2_tx=trim($this->localtax2_tx); - $this->qty=trim($this->qty); - $this->remise_percent=trim($this->remise_percent); - $this->remise=trim($this->remise); + $this->label = trim($this->label); + $this->description = trim($this->description); + $this->vat_src_code = trim($this->vat_src_code); + $this->tva_tx = trim($this->tva_tx); + $this->localtax1_tx = trim($this->localtax1_tx); + $this->localtax2_tx = trim($this->localtax2_tx); + $this->qty = trim($this->qty); + $this->remise_percent = trim($this->remise_percent); + $this->remise = trim($this->remise); $this->fk_remise_except = (int) $this->fk_remise_except; - $this->subprice=price2num($this->subprice); - $this->price_ht=price2num($this->price_ht); - $this->total_ht=trim($this->total_ht); - $this->total_tva=trim($this->total_tva); - $this->total_localtax1=trim($this->total_localtax1); - $this->total_localtax2=trim($this->total_localtax2); - $this->total_ttc=trim($this->total_ttc); - $this->info_bits=trim($this->info_bits); + $this->subprice = price2num($this->subprice); + $this->price_ht = price2num($this->price_ht); + $this->total_ht = trim($this->total_ht); + $this->total_tva = trim($this->total_tva); + $this->total_localtax1 = trim($this->total_localtax1); + $this->total_localtax2 = trim($this->total_localtax2); + $this->total_ttc = trim($this->total_ttc); + $this->info_bits = trim($this->info_bits); $this->fk_user_author = (int) $this->fk_user_author; $this->fk_user_ouverture = (int) $this->fk_user_ouverture; $this->fk_user_cloture = (int) $this->fk_user_cloture; - $this->commentaire=trim($this->commentaire); + $this->commentaire = trim($this->commentaire); //if (empty($this->subprice)) $this->subprice = 0; if (empty($this->price_ht)) $this->price_ht = 0; if (empty($this->total_ht)) $this->total_ht = 0; @@ -2961,10 +2961,10 @@ class ContratLigne extends CommonObjectLine if (empty($this->localtax2_tx)) $this->localtax2_tx = 0; if (empty($this->remise_percent)) $this->remise_percent = 0; // For backward compatibility - if (empty($this->date_start)) $this->date_start=$this->date_ouverture_prevue; - if (empty($this->date_start_real)) $this->date_start=$this->date_ouverture; - if (empty($this->date_end)) $this->date_start=$this->date_fin_validite; - if (empty($this->date_end_real)) $this->date_start=$this->date_cloture; + if (empty($this->date_start)) $this->date_start = $this->date_ouverture_prevue; + if (empty($this->date_start_real)) $this->date_start = $this->date_ouverture; + if (empty($this->date_end)) $this->date_start = $this->date_fin_validite; + if (empty($this->date_end_real)) $this->date_start = $this->date_cloture; // Check parameters @@ -2976,14 +2976,14 @@ class ContratLigne extends CommonObjectLine // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. $localtaxes_type = getLocalTaxesFromRate($this->txtva, 0, $this->societe, $mysoc); - $tabprice=calcul_price_total($this->qty, $this->price_ht, $this->remise_percent, $this->tva_tx, $this->localtax1_tx, $this->localtax2_tx, 0, 'HT', 0, 1, $mysoc, $localtaxes_type); + $tabprice = calcul_price_total($this->qty, $this->price_ht, $this->remise_percent, $this->tva_tx, $this->localtax1_tx, $this->localtax2_tx, 0, 'HT', 0, 1, $mysoc, $localtaxes_type); $this->total_ht = $tabprice[0]; $this->total_tva = $tabprice[1]; $this->total_ttc = $tabprice[2]; - $this->total_localtax1= $tabprice[9]; - $this->total_localtax2= $tabprice[10]; + $this->total_localtax1 = $tabprice[9]; + $this->total_localtax2 = $tabprice[10]; - if (empty($this->pa_ht)) $this->pa_ht=0; + if (empty($this->pa_ht)) $this->pa_ht = 0; // if buy price not defined, define buyprice as configured in margin admin if ($this->pa_ht == 0) @@ -3006,52 +3006,52 @@ class ContratLigne extends CommonObjectLine // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET"; - $sql.= " fk_contrat=".$this->fk_contrat.","; - $sql.= " fk_product=".($this->fk_product?"'".$this->db->escape($this->fk_product)."'":'null').","; - $sql.= " statut=".$this->statut.","; - $sql.= " label='".$this->db->escape($this->label)."',"; - $sql.= " description='".$this->db->escape($this->description)."',"; - $sql.= " date_commande=".($this->date_commande!=''?"'".$this->db->idate($this->date_commande)."'":"null").","; - $sql.= " date_ouverture_prevue=".($this->date_ouverture_prevue!=''?"'".$this->db->idate($this->date_ouverture_prevue)."'":"null").","; - $sql.= " date_ouverture=".($this->date_ouverture!=''?"'".$this->db->idate($this->date_ouverture)."'":"null").","; - $sql.= " date_fin_validite=".($this->date_fin_validite!=''?"'".$this->db->idate($this->date_fin_validite)."'":"null").","; - $sql.= " date_cloture=".($this->date_cloture!=''?"'".$this->db->idate($this->date_cloture)."'":"null").","; - $sql.= " vat_src_code='".$this->db->escape($this->vat_src_code)."',"; - $sql.= " tva_tx=".price2num($this->tva_tx).","; - $sql.= " localtax1_tx=".price2num($this->localtax1_tx).","; - $sql.= " localtax2_tx=".price2num($this->localtax2_tx).","; - $sql.= " qty=".price2num($this->qty).","; - $sql.= " remise_percent=".price2num($this->remise_percent).","; - $sql.= " remise=".($this->remise?price2num($this->remise):"null").","; - $sql.= " fk_remise_except=".($this->fk_remise_except > 0?$this->fk_remise_except:"null").","; - $sql.= " subprice=".($this->subprice != '' ? $this->subprice : "null").","; - $sql.= " price_ht=".($this->price_ht != '' ? $this->price_ht : "null").","; - $sql.= " total_ht=".$this->total_ht.","; - $sql.= " total_tva=".$this->total_tva.","; - $sql.= " total_localtax1=".$this->total_localtax1.","; - $sql.= " total_localtax2=".$this->total_localtax2.","; - $sql.= " total_ttc=".$this->total_ttc.","; - $sql.= " fk_product_fournisseur_price=".(!empty($this->fk_fournprice)?$this->fk_fournprice:"NULL").","; - $sql.= " buy_price_ht='".price2num($this->pa_ht)."',"; - $sql.= " info_bits='".$this->db->escape($this->info_bits)."',"; - $sql.= " fk_user_author=".($this->fk_user_author >= 0?$this->fk_user_author:"NULL").","; - $sql.= " fk_user_ouverture=".($this->fk_user_ouverture > 0?$this->fk_user_ouverture:"NULL").","; - $sql.= " fk_user_cloture=".($this->fk_user_cloture > 0?$this->fk_user_cloture:"NULL").","; - $sql.= " commentaire='".$this->db->escape($this->commentaire)."',"; - $sql.= " fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit); - $sql.= " WHERE rowid=".$this->id; + $sql .= " fk_contrat=".$this->fk_contrat.","; + $sql .= " fk_product=".($this->fk_product ? "'".$this->db->escape($this->fk_product)."'" : 'null').","; + $sql .= " statut=".$this->statut.","; + $sql .= " label='".$this->db->escape($this->label)."',"; + $sql .= " description='".$this->db->escape($this->description)."',"; + $sql .= " date_commande=".($this->date_commande != '' ? "'".$this->db->idate($this->date_commande)."'" : "null").","; + $sql .= " date_ouverture_prevue=".($this->date_ouverture_prevue != '' ? "'".$this->db->idate($this->date_ouverture_prevue)."'" : "null").","; + $sql .= " date_ouverture=".($this->date_ouverture != '' ? "'".$this->db->idate($this->date_ouverture)."'" : "null").","; + $sql .= " date_fin_validite=".($this->date_fin_validite != '' ? "'".$this->db->idate($this->date_fin_validite)."'" : "null").","; + $sql .= " date_cloture=".($this->date_cloture != '' ? "'".$this->db->idate($this->date_cloture)."'" : "null").","; + $sql .= " vat_src_code='".$this->db->escape($this->vat_src_code)."',"; + $sql .= " tva_tx=".price2num($this->tva_tx).","; + $sql .= " localtax1_tx=".price2num($this->localtax1_tx).","; + $sql .= " localtax2_tx=".price2num($this->localtax2_tx).","; + $sql .= " qty=".price2num($this->qty).","; + $sql .= " remise_percent=".price2num($this->remise_percent).","; + $sql .= " remise=".($this->remise ?price2num($this->remise) : "null").","; + $sql .= " fk_remise_except=".($this->fk_remise_except > 0 ? $this->fk_remise_except : "null").","; + $sql .= " subprice=".($this->subprice != '' ? $this->subprice : "null").","; + $sql .= " price_ht=".($this->price_ht != '' ? $this->price_ht : "null").","; + $sql .= " total_ht=".$this->total_ht.","; + $sql .= " total_tva=".$this->total_tva.","; + $sql .= " total_localtax1=".$this->total_localtax1.","; + $sql .= " total_localtax2=".$this->total_localtax2.","; + $sql .= " total_ttc=".$this->total_ttc.","; + $sql .= " fk_product_fournisseur_price=".(!empty($this->fk_fournprice) ? $this->fk_fournprice : "NULL").","; + $sql .= " buy_price_ht='".price2num($this->pa_ht)."',"; + $sql .= " info_bits='".$this->db->escape($this->info_bits)."',"; + $sql .= " fk_user_author=".($this->fk_user_author >= 0 ? $this->fk_user_author : "NULL").","; + $sql .= " fk_user_ouverture=".($this->fk_user_ouverture > 0 ? $this->fk_user_ouverture : "NULL").","; + $sql .= " fk_user_cloture=".($this->fk_user_cloture > 0 ? $this->fk_user_cloture : "NULL").","; + $sql .= " commentaire='".$this->db->escape($this->commentaire)."',"; + $sql .= " fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit); + $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); $error++; } - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options) > 0) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; @@ -3059,39 +3059,39 @@ class ContratLigne extends CommonObjectLine } // If we change a planned date (start or end), sync dates for all services - if (! $error && ! empty($conf->global->CONTRACT_SYNC_PLANNED_DATE_OF_SERVICES)) + if (!$error && !empty($conf->global->CONTRACT_SYNC_PLANNED_DATE_OF_SERVICES)) { if ($this->date_ouverture_prevue != $this->oldcopy->date_ouverture_prevue) { - $sql ='UPDATE '.MAIN_DB_PREFIX.'contratdet SET'; - $sql.= " date_ouverture_prevue = ".($this->date_ouverture_prevue!=''?"'".$this->db->idate($this->date_ouverture_prevue)."'":"null"); - $sql.= " WHERE fk_contrat = ".$this->fk_contrat; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'contratdet SET'; + $sql .= " date_ouverture_prevue = ".($this->date_ouverture_prevue != '' ? "'".$this->db->idate($this->date_ouverture_prevue)."'" : "null"); + $sql .= " WHERE fk_contrat = ".$this->fk_contrat; $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { $error++; - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); } } if ($this->date_fin_validite != $this->oldcopy->date_fin_validite) { - $sql ='UPDATE '.MAIN_DB_PREFIX.'contratdet SET'; - $sql.= " date_fin_validite = ".($this->date_fin_validite!=''?"'".$this->db->idate($this->date_fin_validite)."'":"null"); - $sql.= " WHERE fk_contrat = ".$this->fk_contrat; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'contratdet SET'; + $sql .= " date_fin_validite = ".($this->date_fin_validite != '' ? "'".$this->db->idate($this->date_fin_validite)."'" : "null"); + $sql .= " WHERE fk_contrat = ".$this->fk_contrat; $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { $error++; - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); } } } - if (! $error && ! $notrigger) { + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('LINECONTRACT_UPDATE', $user); + $result = $this->call_trigger('LINECONTRACT_UPDATE', $user); if ($result < 0) { $error++; $this->db->rollback(); @@ -3099,13 +3099,13 @@ class ContratLigne extends CommonObjectLine // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; } else { $this->db->rollback(); - $this->errors[]=$this->error; + $this->errors[] = $this->error; return -1; } } @@ -3125,16 +3125,16 @@ class ContratLigne extends CommonObjectLine // Mise a jour ligne en base $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET"; - $sql.= " total_ht=".price2num($this->total_ht, 'MT').""; - $sql.= ",total_tva=".price2num($this->total_tva, 'MT').""; - $sql.= ",total_localtax1=".price2num($this->total_localtax1, 'MT').""; - $sql.= ",total_localtax2=".price2num($this->total_localtax2, 'MT').""; - $sql.= ",total_ttc=".price2num($this->total_ttc, 'MT').""; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " total_ht=".price2num($this->total_ht, 'MT').""; + $sql .= ",total_tva=".price2num($this->total_tva, 'MT').""; + $sql .= ",total_localtax1=".price2num($this->total_localtax1, 'MT').""; + $sql .= ",total_localtax2=".price2num($this->total_localtax2, 'MT').""; + $sql .= ",total_ttc=".price2num($this->total_ttc, 'MT').""; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::update_total", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->db->commit(); @@ -3142,7 +3142,7 @@ class ContratLigne extends CommonObjectLine } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -2; } @@ -3161,43 +3161,43 @@ class ContratLigne extends CommonObjectLine // Insertion dans la base $sql = "INSERT INTO ".MAIN_DB_PREFIX."contratdet"; - $sql.= " (fk_contrat, label, description, fk_product, qty, vat_src_code, tva_tx,"; - $sql.= " localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, remise_percent, subprice,"; - $sql.= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc,"; - $sql.= " info_bits,"; - $sql.= " price_ht, remise, fk_product_fournisseur_price, buy_price_ht"; - if ($this->date_ouverture_prevue > 0) { $sql.= ",date_ouverture_prevue"; } - if ($this->date_fin_validite > 0) { $sql.= ",date_fin_validite"; } - $sql.= ") VALUES ($this->fk_contrat, '', '" . $this->db->escape($this->description) . "',"; - $sql.= ($this->fk_product>0 ? $this->fk_product : "null").","; - $sql.= " '".$this->db->escape($this->qty)."',"; - $sql.= " '".$this->db->escape($this->vat_src_code)."',"; - $sql.= " '".$this->db->escape($this->tva_tx)."',"; - $sql.= " '".$this->db->escape($this->localtax1_tx)."',"; - $sql.= " '".$this->db->escape($this->localtax2_tx)."',"; - $sql.= " '".$this->db->escape($this->localtax1_type)."',"; - $sql.= " '".$this->db->escape($this->localtax2_type)."',"; - $sql.= " ".price2num($this->remise_percent).",".price2num($this->subprice).","; - $sql.= " ".price2num($this->total_ht).",".price2num($this->total_tva).",".price2num($this->total_localtax1).",".price2num($this->total_localtax2).",".price2num($this->total_ttc).","; - $sql.= " '".$this->db->escape($this->info_bits)."',"; - $sql.= " ".price2num($this->price_ht).",".price2num($this->remise).","; - if ($this->fk_fournprice > 0) $sql.= ' '.$this->fk_fournprice.','; - else $sql.= ' null,'; - if ($this->pa_ht > 0) $sql.= ' '.price2num($this->pa_ht); - else $sql.= ' null'; - if ($this->date_ouverture > 0) { $sql.= ",'".$this->db->idate($this->date_ouverture)."'"; } - if ($this->date_cloture > 0) { $sql.= ",'".$this->db->idate($this->date_cloture)."'"; } - $sql.= ")"; + $sql .= " (fk_contrat, label, description, fk_product, qty, vat_src_code, tva_tx,"; + $sql .= " localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, remise_percent, subprice,"; + $sql .= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc,"; + $sql .= " info_bits,"; + $sql .= " price_ht, remise, fk_product_fournisseur_price, buy_price_ht"; + if ($this->date_ouverture_prevue > 0) { $sql .= ",date_ouverture_prevue"; } + if ($this->date_fin_validite > 0) { $sql .= ",date_fin_validite"; } + $sql .= ") VALUES ($this->fk_contrat, '', '".$this->db->escape($this->description)."',"; + $sql .= ($this->fk_product > 0 ? $this->fk_product : "null").","; + $sql .= " '".$this->db->escape($this->qty)."',"; + $sql .= " '".$this->db->escape($this->vat_src_code)."',"; + $sql .= " '".$this->db->escape($this->tva_tx)."',"; + $sql .= " '".$this->db->escape($this->localtax1_tx)."',"; + $sql .= " '".$this->db->escape($this->localtax2_tx)."',"; + $sql .= " '".$this->db->escape($this->localtax1_type)."',"; + $sql .= " '".$this->db->escape($this->localtax2_type)."',"; + $sql .= " ".price2num($this->remise_percent).",".price2num($this->subprice).","; + $sql .= " ".price2num($this->total_ht).",".price2num($this->total_tva).",".price2num($this->total_localtax1).",".price2num($this->total_localtax2).",".price2num($this->total_ttc).","; + $sql .= " '".$this->db->escape($this->info_bits)."',"; + $sql .= " ".price2num($this->price_ht).",".price2num($this->remise).","; + if ($this->fk_fournprice > 0) $sql .= ' '.$this->fk_fournprice.','; + else $sql .= ' null,'; + if ($this->pa_ht > 0) $sql .= ' '.price2num($this->pa_ht); + else $sql .= ' null'; + if ($this->date_ouverture > 0) { $sql .= ",'".$this->db->idate($this->date_ouverture)."'"; } + if ($this->date_cloture > 0) { $sql .= ",'".$this->db->idate($this->date_cloture)."'"; } + $sql .= ")"; dol_syslog(get_class($this)."::insert", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'contratdet'); // Insert of extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options) > 0) // For avoid conflicts if trigger used { $result = $this->insertExtraFields(); if ($result < 0) @@ -3224,7 +3224,7 @@ class ContratLigne extends CommonObjectLine else { $this->db->rollback(); - $this->error=$this->db->error()." sql=".$sql; + $this->error = $this->db->error()." sql=".$sql; return -1; } } @@ -3248,15 +3248,15 @@ class ContratLigne extends CommonObjectLine $this->db->begin(); - $sql = "UPDATE " . MAIN_DB_PREFIX . "contratdet SET statut = ".ContratLigne::STATUS_OPEN.","; - $sql .= " date_ouverture = " . (dol_strlen($date) != 0 ? "'" . $this->db->idate($date) . "'" : "null") . ","; - if ($date_end >= 0) $sql .= " date_fin_validite = " . (dol_strlen($date_end) != 0 ? "'" . $this->db->idate($date_end) . "'" : "null") . ","; - $sql .= " fk_user_ouverture = " . $user->id . ","; + $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET statut = ".ContratLigne::STATUS_OPEN.","; + $sql .= " date_ouverture = ".(dol_strlen($date) != 0 ? "'".$this->db->idate($date)."'" : "null").","; + if ($date_end >= 0) $sql .= " date_fin_validite = ".(dol_strlen($date_end) != 0 ? "'".$this->db->idate($date_end)."'" : "null").","; + $sql .= " fk_user_ouverture = ".$user->id.","; $sql .= " date_cloture = null,"; - $sql .= " commentaire = '" . $this->db->escape($comment) . "'"; - $sql .= " WHERE rowid = " . $this->id . " AND (statut = ".ContratLigne::STATUS_INITIAL." OR statut = ".ContratLigne::STATUS_CLOSED.")"; + $sql .= " commentaire = '".$this->db->escape($comment)."'"; + $sql .= " WHERE rowid = ".$this->id." AND (statut = ".ContratLigne::STATUS_INITIAL." OR statut = ".ContratLigne::STATUS_CLOSED.")"; - dol_syslog(get_class($this) . "::active_line", LOG_DEBUG); + dol_syslog(get_class($this)."::active_line", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { // Call trigger @@ -3264,7 +3264,7 @@ class ContratLigne extends CommonObjectLine if ($result < 0) $error++; // End call triggers - if (! $error) + if (!$error) { $this->statut = ContratLigne::STATUS_OPEN; $this->date_ouverture = $date; @@ -3314,16 +3314,16 @@ class ContratLigne extends CommonObjectLine $this->db->begin(); - $sql = "UPDATE " . MAIN_DB_PREFIX . "contratdet SET statut = ".ContratLigne::STATUS_CLOSED.","; - $sql .= " date_cloture = '" . $this->db->idate($date_end) . "',"; - $sql .= " fk_user_cloture = " . $user->id . ","; - $sql .= " commentaire = '" . $this->db->escape($comment) . "'"; - $sql .= " WHERE rowid = " . $this->id . " AND statut = ".ContratLigne::STATUS_OPEN; + $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET statut = ".ContratLigne::STATUS_CLOSED.","; + $sql .= " date_cloture = '".$this->db->idate($date_end)."',"; + $sql .= " fk_user_cloture = ".$user->id.","; + $sql .= " commentaire = '".$this->db->escape($comment)."'"; + $sql .= " WHERE rowid = ".$this->id." AND statut = ".ContratLigne::STATUS_OPEN; $resql = $this->db->query($sql); if ($resql) { - if (! $notrigger) + if (!$notrigger) { // Call trigger $result = $this->call_trigger('LINECONTRACT_CLOSE', $user); diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index f24105a93db..48deeba1565 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -39,39 +39,39 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; // Load translation files required by the page $langs->loadLangs(array('contracts', 'products', 'companies', 'compta')); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'contractlist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'contractlist'; // To manage different context of search -$search_name=GETPOST('search_name', 'alpha'); -$search_email=GETPOST('search_email', 'alpha'); -$search_town=GETPOST('search_town', 'alpha'); -$search_zip=GETPOST('search_zip', 'alpha'); -$search_state=trim(GETPOST("search_state", 'alpha')); -$search_country=GETPOST("search_country", 'int'); -$search_type_thirdparty=GETPOST("search_type_thirdparty", 'int'); -$search_contract=GETPOST('search_contract', 'alpha'); -$search_ref_customer=GETPOST('search_ref_customer', 'alpha'); -$search_ref_supplier=GETPOST('search_ref_supplier', 'alpha'); -$sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$search_status=GETPOST('search_status', 'alpha'); -$socid=GETPOST('socid', 'int'); -$search_user=GETPOST('search_user', 'int'); -$search_sale=GETPOST('search_sale', 'int'); -$search_product_category=GETPOST('search_product_category', 'int'); -$search_dfmonth=GETPOST('search_dfmonth', 'int'); -$search_dfyear=GETPOST('search_dfyear', 'int'); -$search_op2df=GETPOST('search_op2df', 'alpha'); -$day=GETPOST("day", "int"); -$year=GETPOST("year", "int"); -$month=GETPOST("month", "int"); +$search_name = GETPOST('search_name', 'alpha'); +$search_email = GETPOST('search_email', 'alpha'); +$search_town = GETPOST('search_town', 'alpha'); +$search_zip = GETPOST('search_zip', 'alpha'); +$search_state = trim(GETPOST("search_state", 'alpha')); +$search_country = GETPOST("search_country", 'int'); +$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); +$search_contract = GETPOST('search_contract', 'alpha'); +$search_ref_customer = GETPOST('search_ref_customer', 'alpha'); +$search_ref_supplier = GETPOST('search_ref_supplier', 'alpha'); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$search_status = GETPOST('search_status', 'alpha'); +$socid = GETPOST('socid', 'int'); +$search_user = GETPOST('search_user', 'int'); +$search_sale = GETPOST('search_sale', 'int'); +$search_product_category = GETPOST('search_product_category', 'int'); +$search_dfmonth = GETPOST('search_dfmonth', 'int'); +$search_dfyear = GETPOST('search_dfyear', 'int'); +$search_op2df = GETPOST('search_op2df', 'alpha'); +$day = GETPOST("day", "int"); +$year = GETPOST("year", "int"); +$month = GETPOST("month", "int"); $optioncss = GETPOST('optioncss', 'alpha'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -79,20 +79,20 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='c.ref'; -if (! $sortorder) $sortorder='DESC'; +if (!$sortfield) $sortfield = 'c.ref'; +if (!$sortorder) $sortorder = 'DESC'; // Security check -$id=GETPOST('id', 'int'); -if ($user->socid) $socid=$user->socid; +$id = GETPOST('id', 'int'); +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'contrat', $id); -$diroutputmassaction=$conf->contrat->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->contrat->dir_output.'/temp/massgeneration/'.$user->id; -$staticcontrat=new Contrat($db); -$staticcontratligne=new ContratLigne($db); +$staticcontrat = new Contrat($db); +$staticcontratligne = new ContratLigne($db); -if ($search_status == '') $search_status=1; +if ($search_status == '') $search_status = 1; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Contrat($db); @@ -102,7 +102,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label('contrat'); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( 'c.ref'=>'Ref', @@ -111,9 +111,9 @@ $fieldstosearchall = array( 's.nom'=>"ThirdParty", 'c.note_public'=>'NotePublic', ); -if (empty($user->socid)) $fieldstosearchall["c.note_private"]="NotePrivate"; +if (empty($user->socid)) $fieldstosearchall["c.note_private"] = "NotePrivate"; -$arrayfields=array( +$arrayfields = array( 'c.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'c.ref_customer'=>array('label'=>$langs->trans("RefCustomer"), 'checked'=>1), 'c.ref_supplier'=>array('label'=>$langs->trans("RefSupplier"), 'checked'=>1), @@ -133,10 +133,10 @@ $arrayfields=array( // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -147,11 +147,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Action */ -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('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; @@ -159,35 +159,35 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria 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 { - $day=''; - $month=''; - $year=''; - $search_dfmonth=''; - $search_dfyear=''; - $search_op2df=''; - $search_name=""; - $search_email=""; - $search_town=''; - $search_zip=""; - $search_state=""; - $search_type=''; - $search_country=''; - $search_contract=""; - $search_ref_customer=""; - $search_ref_supplier=""; - $search_user=''; - $search_sale=''; - $search_product_category=''; - $sall=""; - $search_status=""; - $toselect=''; - $search_array_options=array(); + $day = ''; + $month = ''; + $year = ''; + $search_dfmonth = ''; + $search_dfyear = ''; + $search_op2df = ''; + $search_name = ""; + $search_email = ""; + $search_town = ''; + $search_zip = ""; + $search_state = ""; + $search_type = ''; + $search_country = ''; + $search_contract = ""; + $search_ref_customer = ""; + $search_ref_supplier = ""; + $search_user = ''; + $search_sale = ''; + $search_product_category = ''; + $sall = ""; + $search_status = ""; + $toselect = ''; + $search_array_options = array(); } if (empty($reshook)) { - $objectclass='Contrat'; - $objectlabel='Contracts'; + $objectclass = 'Contrat'; + $objectlabel = 'Contracts'; $permissiontoread = $user->rights->contrat->lire; $permissiontodelete = $user->rights->contrat->supprimer; $uploaddir = $conf->contrat->dir_output; @@ -199,7 +199,7 @@ if (empty($reshook)) * View */ -$now=dol_now(); +$now = dol_now(); $form = new Form($db); $formfile = new FormFile($db); $formother = new FormOther($db); @@ -207,44 +207,44 @@ $socstatic = new Societe($db); $contracttmp = new Contrat($db); $sql = 'SELECT'; -$sql.= " c.rowid, c.ref, c.datec as date_creation, c.tms as date_update, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public,"; -$sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; -$sql.= " typent.code as typent_code,"; -$sql.= " state.code_departement as state_code, state.nom as state_name,"; -$sql.= " MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") as lower_planned_end_date,"; -$sql.= ' SUM('.$db->ifsql("cd.statut=0", 1, 0).') as nb_initial,'; -$sql.= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite >= '".$db->idate($now)."')", 1, 0).') as nb_running,'; -$sql.= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now)."')", 1, 0).') as nb_expired,'; -$sql.= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now - $conf->contrat->services->expires->warning_delay)."')", 1, 0).') as nb_late,'; -$sql.= ' SUM('.$db->ifsql("cd.statut=5", 1, 0).') as nb_closed'; +$sql .= " c.rowid, c.ref, c.datec as date_creation, c.tms as date_update, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public,"; +$sql .= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; +$sql .= " typent.code as typent_code,"; +$sql .= " state.code_departement as state_code, state.nom as state_name,"; +$sql .= " MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") as lower_planned_end_date,"; +$sql .= ' SUM('.$db->ifsql("cd.statut=0", 1, 0).') as nb_initial,'; +$sql .= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite >= '".$db->idate($now)."')", 1, 0).') as nb_running,'; +$sql .= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now)."')", 1, 0).') as nb_expired,'; +$sql .= ' SUM('.$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now - $conf->contrat->services->expires->warning_delay)."')", 1, 0).') as nb_late,'; +$sql .= ' SUM('.$db->ifsql("cd.statut=5", 1, 0).') as nb_closed'; // 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 : ''); +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 : ''); } // 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 ".MAIN_DB_PREFIX."societe as s"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; -if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= ", ".MAIN_DB_PREFIX."contrat as c"; -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 (c.rowid = ef.fk_object)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; -if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=cd.fk_product'; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql .= ", ".MAIN_DB_PREFIX."contrat as c"; +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 (c.rowid = ef.fk_object)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; +if ($search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=cd.fk_product'; if ($search_user > 0) { - $sql.=", ".MAIN_DB_PREFIX."element_contact as ec"; - $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; } -$sql.= " WHERE c.fk_soc = s.rowid "; -$sql.= ' AND c.entity IN ('.getEntity('contract').')'; -if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$search_product_category; -if ($socid) $sql.= " AND s.rowid = ".$db->escape($socid); -if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -$sql.= dolSqlDateFilter('c.date_contrat', $day, $month, $year); +$sql .= " WHERE c.fk_soc = s.rowid "; +$sql .= ' AND c.entity IN ('.getEntity('contract').')'; +if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$search_product_category; +if ($socid) $sql .= " AND s.rowid = ".$db->escape($socid); +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +$sql .= dolSqlDateFilter('c.date_contrat', $day, $month, $year); if ($search_name) $sql .= natural_search('s.nom', $search_name); if ($search_email) $sql .= natural_search('s.email', $search_email); if ($search_contract) $sql .= natural_search(array('c.rowid', 'c.ref'), $search_contract); @@ -252,39 +252,39 @@ if (!empty($search_ref_customer)) $sql .= natural_search(array('c.ref_customer') if (!empty($search_ref_supplier)) $sql .= natural_search(array('c.ref_supplier'), $search_ref_supplier); if ($search_sale > 0) { - $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale; + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$search_sale; } if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); -if ($search_user > 0) $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='contrat' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user; +if ($search_user > 0) $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='contrat' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user; // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql.= " GROUP BY c.rowid, c.ref, c.datec, c.tms, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public,"; -$sql.= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; -$sql.= " typent.code,"; -$sql.= " state.code_departement, state.nom"; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= " GROUP BY c.rowid, c.ref, c.datec, c.tms, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public,"; +$sql .= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; +$sql .= " typent.code,"; +$sql .= " state.code_departement, state.nom"; // 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 : ''); +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 : ''); } // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListGroupBy', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; if ($search_dfyear > 0 && $search_op2df) { - if ($search_op2df == '<=') $sql.= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") <= '".$db->idate(dol_get_last_day($search_dfyear, $search_dfmonth, false))."'"; - elseif ($search_op2df == '>=') $sql.= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") >= '".$db->idate(dol_get_first_day($search_dfyear, $search_dfmonth, false))."'"; - else $sql.= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") <= '".$db->idate(dol_get_last_day($search_dfyear, $search_dfmonth, false))."' AND MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") >= '".$db->idate(dol_get_first_day($search_dfyear, $search_dfmonth, false))."'"; + if ($search_op2df == '<=') $sql .= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") <= '".$db->idate(dol_get_last_day($search_dfyear, $search_dfmonth, false))."'"; + elseif ($search_op2df == '>=') $sql .= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") >= '".$db->idate(dol_get_first_day($search_dfyear, $search_dfmonth, false))."'"; + else $sql .= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") <= '".$db->idate(dol_get_last_day($search_dfyear, $search_dfmonth, false))."' AND MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") >= '".$db->idate(dol_get_first_day($search_dfyear, $search_dfmonth, false))."'"; } -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); //print $sql; -$totalnboflines=0; -$result=$db->query($sql); +$totalnboflines = 0; +$result = $db->query($sql); if ($result) { $totalnboflines = $db->num_rows($result); @@ -302,10 +302,10 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit + 1, $offset); +$sql .= $db->plimit($limit + 1, $offset); -$resql=$db->query($sql); -if (! $resql) +$resql = $db->query($sql); +if (!$resql) { dol_print_error($db); exit; @@ -314,7 +314,7 @@ if (! $resql) $num = $db->num_rows($resql); // Direct jump if only one record found -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall && ! $page) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall && !$page) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -330,7 +330,7 @@ llxHeader('', $langs->trans("Contracts")); $i = 0; -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); if ($socid > 0) { @@ -339,40 +339,40 @@ if ($socid > 0) if (empty($search_name)) $search_name = $soc->name; } -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; -if ($sall != '') $param.='&sall='.urlencode($sall); -if ($search_contract != '') $param.='&search_contract='.urlencode($search_contract); -if ($search_name != '') $param.='&search_name='.urlencode($search_name); -if ($search_email != '') $param.='&search_email='.urlencode($search_email); -if ($search_ref_customer != '') $param.='&search_ref_customer='.urlencode($search_ref_customer); -if ($search_ref_supplier != '') $param.='&search_ref_supplier='.urlencode($search_ref_supplier); -if ($search_op2df != '') $param.='&search_op2df='.urlencode($search_op2df); -if ($search_dfyear != '') $param.='&search_dfyear='.urlencode($search_dfyear); -if ($search_dfmonth != '') $param.='&search_dfmonth='.urlencode($search_dfmonth); -if ($search_sale != '') $param.='&search_sale=' .urlencode($search_sale); -if ($search_user != '') $param.='&search_user=' .urlencode($search_user); -if ($search_product_category != '') $param.='&search_product_category=' .urlencode($search_product_category); -if ($show_files) $param.='&show_files=' .urlencode($show_files); -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; +if ($sall != '') $param .= '&sall='.urlencode($sall); +if ($search_contract != '') $param .= '&search_contract='.urlencode($search_contract); +if ($search_name != '') $param .= '&search_name='.urlencode($search_name); +if ($search_email != '') $param .= '&search_email='.urlencode($search_email); +if ($search_ref_customer != '') $param .= '&search_ref_customer='.urlencode($search_ref_customer); +if ($search_ref_supplier != '') $param .= '&search_ref_supplier='.urlencode($search_ref_supplier); +if ($search_op2df != '') $param .= '&search_op2df='.urlencode($search_op2df); +if ($search_dfyear != '') $param .= '&search_dfyear='.urlencode($search_dfyear); +if ($search_dfmonth != '') $param .= '&search_dfmonth='.urlencode($search_dfmonth); +if ($search_sale != '') $param .= '&search_sale='.urlencode($search_sale); +if ($search_user != '') $param .= '&search_user='.urlencode($search_user); +if ($search_product_category != '') $param .= '&search_product_category='.urlencode($search_product_category); +if ($show_files) $param .= '&show_files='.urlencode($show_files); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( 'generate_doc'=>$langs->trans("ReGeneratePDF"), 'builddoc'=>$langs->trans("PDFMerge"), 'presend'=>$langs->trans("SendByMail"), ); -if ($user->rights->contrat->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); -if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($user->rights->contrat->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); -$newcardbutton=''; +$newcardbutton = ''; if ($user->rights->contrat->creer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewContractSubscription'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contrat/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewContractSubscription'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contrat/card.php?action=create'); } print ''; @@ -387,133 +387,133 @@ print ''; print_barre_liste($langs->trans("ListOfContracts"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $totalnboflines, 'commercial', 0, $newcardbutton, '', $limit); -$topicmail="SendContractRef"; -$modelmail="contract"; -$objecttmp=new Contrat($db); -$trackid='con'.$object->id; +$topicmail = "SendContractRef"; +$modelmail = "contract"; +$objecttmp = new Contrat($db); +$trackid = 'con'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } -$moreforfilter=''; +$moreforfilter = ''; // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); - $moreforfilter.='
'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; + $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $moreforfilter .= '
'; } // If the user can view other users if ($user->rights->user->user->lire) { - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; - $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); - $moreforfilter.='
'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; + $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); + $moreforfilter .= '
'; } // If the user can view categories of products if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': '; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); - $moreforfilter.='
'; + $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter .= '
'; } -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '
'; print $moreforfilter; print '
'; } -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); print '
'; -print ''."\n"; +print '
'."\n"; print ''; -if (! empty($arrayfields['c.ref']['checked'])) +if (!empty($arrayfields['c.ref']['checked'])) { print ''; } -if (! empty($arrayfields['c.ref_customer']['checked'])) +if (!empty($arrayfields['c.ref_customer']['checked'])) { print ''; } -if (! empty($arrayfields['c.ref_supplier']['checked'])) +if (!empty($arrayfields['c.ref_supplier']['checked'])) { print ''; } -if (! empty($arrayfields['s.nom']['checked'])) +if (!empty($arrayfields['s.nom']['checked'])) { print ''; } -if (! empty($arrayfields['s.email']['checked'])) +if (!empty($arrayfields['s.email']['checked'])) { print ''; } // Town -if (! empty($arrayfields['s.town']['checked'])) print ''; +if (!empty($arrayfields['s.town']['checked'])) print ''; // Zip -if (! empty($arrayfields['s.zip']['checked'])) print ''; +if (!empty($arrayfields['s.zip']['checked'])) print ''; // State -if (! empty($arrayfields['state.nom']['checked'])) +if (!empty($arrayfields['state.nom']['checked'])) { print ''; } // Country -if (! empty($arrayfields['country.code_iso']['checked'])) +if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; } // Company type -if (! empty($arrayfields['typent.code']['checked'])) +if (!empty($arrayfields['typent.code']['checked'])) { print ''; } -if (! empty($arrayfields['sale_representative']['checked'])) +if (!empty($arrayfields['sale_representative']['checked'])) { print ''; } -if (! empty($arrayfields['c.date_contrat']['checked'])) +if (!empty($arrayfields['c.date_contrat']['checked'])) { // Date contract print ''; } // Date modification -if (! empty($arrayfields['c.tms']['checked'])) +if (!empty($arrayfields['c.tms']['checked'])) { print ''; } // First end date -if (! empty($arrayfields['lower_planned_end_date']['checked'])) +if (!empty($arrayfields['lower_planned_end_date']['checked'])) { print ''; - if (! empty($arrayfields['c.ref']['checked'])) + if (!empty($arrayfields['c.ref']['checked'])) { print ''; print ''; } - if (! empty($arrayfields['c.ref_customer']['checked'])) + if (!empty($arrayfields['c.ref_customer']['checked'])) { print ''; } - if (! empty($arrayfields['c.ref_supplier']['checked'])) + if (!empty($arrayfields['c.ref_supplier']['checked'])) { print ''; } - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print ''; } - if (! empty($arrayfields['s.email']['checked'])) + if (!empty($arrayfields['s.email']['checked'])) { print ''; } // Town - if (! empty($arrayfields['s.town']['checked'])) + if (!empty($arrayfields['s.town']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Zip - if (! empty($arrayfields['s.zip']['checked'])) + if (!empty($arrayfields['s.zip']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // State - if (! empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Country - if (! empty($arrayfields['country.code_iso']['checked'])) + if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Type ent - if (! empty($arrayfields['typent.code']['checked'])) + if (!empty($arrayfields['typent.code']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['sale_representative']['checked'])) + if (!empty($arrayfields['sale_representative']['checked'])) { // Sales representatives print ''; } // Date - if (! empty($arrayfields['c.date_contrat']['checked'])) + if (!empty($arrayfields['c.date_contrat']['checked'])) { print ''; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['c.datec']['checked'])) + if (!empty($arrayfields['c.datec']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date modification - if (! empty($arrayfields['c.tms']['checked'])) + if (!empty($arrayfields['c.tms']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date lower end date - if (! empty($arrayfields['lower_planned_end_date']['checked'])) + if (!empty($arrayfields['lower_planned_end_date']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Status - if (! empty($arrayfields['status']['checked'])) + if (!empty($arrayfields['status']['checked'])) { - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; } // Action column print ''; - if (! $i) $totalarray['nbfield']++; + 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 +$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 '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print ''; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT)); print ''; //print $langs->trans('Month').': '; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; //print ' '.$langs->trans('Year').': '; $syear = $year; @@ -524,26 +524,26 @@ if (! empty($arrayfields['c.date_contrat']['checked'])) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation -if (! empty($arrayfields['c.datec']['checked'])) +if (!empty($arrayfields['c.datec']['checked'])) { print ''; print ''; print ''; - $arrayofoperators=array('0'=>'','='=>'=','<='=>'<=','>='=>'>='); + $arrayofoperators = array('0'=>'', '='=>'=', '<='=>'<=', '>='=>'>='); print $form->selectarray('search_op2df', $arrayofoperators, $search_op2df, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth50imp'); print '
'; print $formother->select_month($search_dfmonth, 'search_dfmonth', 1, 0); @@ -603,17 +603,17 @@ while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - $contracttmp->ref=$obj->ref; - $contracttmp->id=$obj->rowid; - $contracttmp->ref_customer=$obj->ref_customer; - $contracttmp->ref_supplier=$obj->ref_supplier; + $contracttmp->ref = $obj->ref; + $contracttmp->id = $obj->rowid; + $contracttmp->ref_customer = $obj->ref_customer; + $contracttmp->ref_supplier = $obj->ref_supplier; if ($obj->socid > 0) { - $result=$socstatic->fetch($obj->socid); + $result = $socstatic->fetch($obj->socid); } print '
'; print $contracttmp->getNomUrl(1); @@ -624,23 +624,23 @@ while ($i < min($num, $limit)) print ''; } - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->contrat->dir_output . '/' . dol_sanitizeFileName($obj->ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->contrat->dir_output.'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; print $formfile->getDocumentsLink($contracttmp->element, $filename, $filedir); print ''.$contracttmp->getFormatedCustomerRef($obj->ref_customer).''.$obj->ref_supplier.''; //print ''.img_object($langs->trans("ShowCompany"),"company").' '.$obj->name.''; @@ -650,59 +650,59 @@ while ($i < min($num, $limit)) } print ''.$obj->email.''; print $obj->town; print ''; print $obj->zip; print '".$obj->state_name."'; - $tmparray=getCountry($obj->fk_pays, 'all'); + $tmparray = getCountry($obj->fk_pays, 'all'); print $tmparray['label']; print ''; - if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1); + if (count($typenArray) == 0) $typenArray = $formcompany->typent_array(1); print $typenArray[$obj->typent_code]; print ''; if ($obj->socid > 0) { - $listsalesrepresentatives=$socstatic->getSalesRepresentatives($user); + $listsalesrepresentatives = $socstatic->getSalesRepresentatives($user); if ($listsalesrepresentatives < 0) dol_print_error($db); - $nbofsalesrepresentative=count($listsalesrepresentatives); + $nbofsalesrepresentative = count($listsalesrepresentatives); if ($nbofsalesrepresentative > 3) { // We print only number print ''; @@ -711,17 +711,17 @@ while ($i < min($num, $limit)) } elseif ($nbofsalesrepresentative > 0) { - $userstatic=new User($db); - $j=0; - foreach($listsalesrepresentatives as $val) + $userstatic = new User($db); + $j = 0; + foreach ($listsalesrepresentatives as $val) { - $userstatic->id=$val['id']; - $userstatic->lastname=$val['lastname']; - $userstatic->firstname=$val['firstname']; - $userstatic->email=$val['email']; - $userstatic->statut=$val['statut']; - $userstatic->entity=$val['entity']; - $userstatic->photo=$val['photo']; + $userstatic->id = $val['id']; + $userstatic->lastname = $val['lastname']; + $userstatic->firstname = $val['firstname']; + $userstatic->email = $val['email']; + $userstatic->statut = $val['statut']; + $userstatic->entity = $val['entity']; + $userstatic->photo = $val['photo']; //print '
': print $userstatic->getNomUrl(-2); @@ -739,66 +739,66 @@ while ($i < min($num, $limit)) print '
'.dol_print_date($db->jdate($obj->date_contrat), 'day', 'tzuser').''; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; print dol_print_date($db->jdate($obj->lower_planned_end_date), 'day', 'tzuser'); print ''.($obj->nb_initial>0?$obj->nb_initial:'').''.($obj->nb_running>0?$obj->nb_running:'').''.($obj->nb_expired>0?$obj->nb_expired:'').''.($obj->nb_closed>0 ?$obj->nb_closed:'').''.($obj->nb_initial > 0 ? $obj->nb_initial : '').''.($obj->nb_running > 0 ? $obj->nb_running : '').''.($obj->nb_expired > 0 ? $obj->nb_expired : '').''.($obj->nb_closed > 0 ? $obj->nb_closed : '').''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; } print '
'; @@ -806,16 +806,16 @@ print '
'; print ''; -$hidegeneratedfilelistifempty=1; -if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; +$hidegeneratedfilelistifempty = 1; +if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; // Show list of available documents -$urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; -$urlsource.=str_replace('&', '&', $param); +$urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; +$urlsource .= str_replace('&', '&', $param); -$filedir=$diroutputmassaction; -$genallowed=$user->rights->contrat->lire; -$delallowed=$user->rights->contrat->lire; +$filedir = $diroutputmassaction; +$genallowed = $user->rights->contrat->lire; +$delallowed = $user->rights->contrat->lire; print $formfile->showdocuments('massfilesarea_contract', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index d40ed042350..6a26e9ef3a0 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -44,29 +44,29 @@ if (empty($objectclass) || empty($uploaddir)) } // For backward compatibility -if (! empty($permtoread) && empty($permissiontoread)) $permissiontoread = $permtoread; -if (! empty($permtocreate) && empty($permissiontoadd)) $permissiontoadd = $permtocreate; -if (! empty($permtodelete) && empty($permissiontodelete)) $permissiontoread = $permtodelete; +if (!empty($permtoread) && empty($permissiontoread)) $permissiontoread = $permtoread; +if (!empty($permtocreate) && empty($permissiontoadd)) $permissiontoadd = $permtocreate; +if (!empty($permtodelete) && empty($permissiontodelete)) $permissiontoread = $permtodelete; // Mass actions. Controls on number of lines checked. -$maxformassaction=(empty($conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS)?1000:$conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS); -if (! empty($massaction) && is_array($toselect) && count($toselect) < 1) +$maxformassaction = (empty($conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS) ? 1000 : $conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS); +if (!empty($massaction) && is_array($toselect) && count($toselect) < 1) { $error++; setEventMessages($langs->trans("NoRecordSelected"), null, "warnings"); } -if (! $error && is_array($toselect) && count($toselect) > $maxformassaction) +if (!$error && is_array($toselect) && count($toselect) > $maxformassaction) { setEventMessages($langs->trans('TooManyRecordForMassAction', $maxformassaction), null, 'errors'); $error++; } -if (! $error && $massaction == 'confirm_presend' && ! GETPOST('sendmail')) // If we do not choose button send (for example when we change template or limit), we must not send email, but keep on send email form +if (!$error && $massaction == 'confirm_presend' && !GETPOST('sendmail')) // If we do not choose button send (for example when we change template or limit), we must not send email, but keep on send email form { - $massaction='presend'; + $massaction = 'presend'; } -if (! $error && $massaction == 'confirm_presend') +if (!$error && $massaction == 'confirm_presend') { $resaction = ''; $nbsent = 0; @@ -74,35 +74,35 @@ if (! $error && $massaction == 'confirm_presend') $langs->load("mails"); include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $listofobjectid=array(); - $listofobjectthirdparties=array(); + $listofobjectid = array(); + $listofobjectthirdparties = array(); $listofobjectcontacts = array(); - $listofobjectref=array(); - $contactidtosend=array(); - $attachedfilesThirdpartyObj=array(); - $oneemailperrecipient=(GETPOST('oneemailperrecipient')=='on'?1:0); + $listofobjectref = array(); + $contactidtosend = array(); + $attachedfilesThirdpartyObj = array(); + $oneemailperrecipient = (GETPOST('oneemailperrecipient') == 'on' ? 1 : 0); - if (! $error) + if (!$error) { - $thirdparty=new Societe($db); + $thirdparty = new Societe($db); - $objecttmp=new $objectclass($db); - if ($objecttmp->element == 'expensereport') $thirdparty=new User($db); - if ($objecttmp->element == 'holiday') $thirdparty=new User($db); + $objecttmp = new $objectclass($db); + if ($objecttmp->element == 'expensereport') $thirdparty = new User($db); + if ($objecttmp->element == 'holiday') $thirdparty = new User($db); - foreach($toselect as $toselectid) + foreach ($toselect as $toselectid) { - $objecttmp=new $objectclass($db); // we must create new instance because instance is saved into $listofobjectref array for future use - $result=$objecttmp->fetch($toselectid); + $objecttmp = new $objectclass($db); // we must create new instance because instance is saved into $listofobjectref array for future use + $result = $objecttmp->fetch($toselectid); if ($result > 0) { - $listofobjectid[$toselectid]=$toselectid; + $listofobjectid[$toselectid] = $toselectid; - $thirdpartyid=($objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid); - if ($objecttmp->element == 'societe') $thirdpartyid=$objecttmp->id; - if ($objecttmp->element == 'expensereport') $thirdpartyid=$objecttmp->fk_user_author; - if ($objecttmp->element == 'holiday') $thirdpartyid=$objecttmp->fk_user; - if (empty($thirdpartyid)) $thirdpartyid=0; + $thirdpartyid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid); + if ($objecttmp->element == 'societe') $thirdpartyid = $objecttmp->id; + if ($objecttmp->element == 'expensereport') $thirdpartyid = $objecttmp->fk_user_author; + if ($objecttmp->element == 'holiday') $thirdpartyid = $objecttmp->fk_user; + if (empty($thirdpartyid)) $thirdpartyid = 0; if ($objectclass == 'Facture') { $tmparraycontact = array(); @@ -114,8 +114,8 @@ if (! $error && $massaction == 'confirm_presend') } } - $listofobjectthirdparties[$thirdpartyid]=$thirdpartyid; - $listofobjectref[$thirdpartyid][$toselectid]=$objecttmp; + $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid; + $listofobjectref[$thirdpartyid][$toselectid] = $objecttmp; } } } @@ -125,31 +125,31 @@ if (! $error && $massaction == 'confirm_presend') { $error++; setEventMessages($langs->trans("NoSenderEmailDefined"), null, 'warnings'); - $massaction='presend'; + $massaction = 'presend'; } - $receiver=$_POST['receiver']; - if (! is_array($receiver)) + $receiver = $_POST['receiver']; + if (!is_array($receiver)) { - if (empty($receiver) || $receiver == '-1') $receiver=array(); - else $receiver=array($receiver); + if (empty($receiver) || $receiver == '-1') $receiver = array(); + else $receiver = array($receiver); } - if (! trim($_POST['sendto']) && count($receiver) == 0 && count($listofobjectthirdparties) == 1) // if only one recipient, receiver is mandatory + if (!trim($_POST['sendto']) && count($receiver) == 0 && count($listofobjectthirdparties) == 1) // if only one recipient, receiver is mandatory { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Recipient")), null, 'warnings'); - $massaction='presend'; + $massaction = 'presend'; } - if (! GETPOST('subject', 'none')) + if (!GETPOST('subject', 'none')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MailTopic")), null, 'warnings'); - $massaction='presend'; + $massaction = 'presend'; } // Loop on each recipient/thirdparty - if (! $error) + if (!$error) { foreach ($listofobjectthirdparties as $thirdpartyid) { @@ -160,21 +160,21 @@ if (! $error && $massaction == 'confirm_presend') exit; } - $sendto=''; - $sendtocc=''; - $sendtobcc=''; + $sendto = ''; + $sendtocc = ''; + $sendtobcc = ''; $sendtoid = array(); // Define $sendto - $tmparray=array(); + $tmparray = array(); if (trim($_POST['sendto'])) { // Recipients are provided into free text $tmparray[] = trim($_POST['sendto']); } - if (count($receiver)>0) + if (count($receiver) > 0) { - foreach($receiver as $key=>$val) + foreach ($receiver as $key=>$val) { // Recipient was provided from combo list if ($val == 'thirdparty') // Id of third party or user @@ -188,23 +188,23 @@ if (! $error && $massaction == 'confirm_presend') } } } - $sendto=implode(',', $tmparray); + $sendto = implode(',', $tmparray); // Define $sendtocc - $receivercc=$_POST['receivercc']; - if (! is_array($receivercc)) + $receivercc = $_POST['receivercc']; + if (!is_array($receivercc)) { - if ($receivercc == '-1') $receivercc=array(); - else $receivercc=array($receivercc); + if ($receivercc == '-1') $receivercc = array(); + else $receivercc = array($receivercc); } - $tmparray=array(); + $tmparray = array(); if (trim($_POST['sendtocc'])) { $tmparray[] = trim($_POST['sendtocc']); } if (count($receivercc) > 0) { - foreach($receivercc as $key=>$val) + foreach ($receivercc as $key=>$val) { // Recipient was provided from combo list if ($val == 'thirdparty') // Id of third party @@ -218,35 +218,35 @@ if (! $error && $massaction == 'confirm_presend') } } } - $sendtocc=implode(',', $tmparray); + $sendtocc = implode(',', $tmparray); //var_dump($listofobjectref);exit; - $listofqualifiedobj=array(); - $listofqualifiedref=array(); - $thirdpartywithoutemail=array(); + $listofqualifiedobj = array(); + $listofqualifiedref = array(); + $thirdpartywithoutemail = array(); - foreach($listofobjectref[$thirdpartyid] as $objectid => $objectobj) + foreach ($listofobjectref[$thirdpartyid] as $objectid => $objectobj) { //var_dump($thirdpartyid.' - '.$objectid.' - '.$objectobj->statut); if ($objectclass == 'Propal' && $objectobj->statut == Propal::STATUS_DRAFT) { $langs->load("errors"); $nbignored++; - $resaction.='
'.$langs->trans('ErrorOnlyProposalNotDraftCanBeSentInMassAction', $objectobj->ref).'

'; + $resaction .= '
'.$langs->trans('ErrorOnlyProposalNotDraftCanBeSentInMassAction', $objectobj->ref).'

'; continue; // Payment done or started or canceled } if ($objectclass == 'Commande' && $objectobj->statut == Commande::STATUS_DRAFT) { $langs->load("errors"); $nbignored++; - $resaction.='
'.$langs->trans('ErrorOnlyOrderNotDraftCanBeSentInMassAction', $objectobj->ref).'

'; + $resaction .= '
'.$langs->trans('ErrorOnlyOrderNotDraftCanBeSentInMassAction', $objectobj->ref).'

'; continue; } if ($objectclass == 'Facture' && $objectobj->statut == Facture::STATUS_DRAFT) { $langs->load("errors"); $nbignored++; - $resaction.='
'.$langs->trans('ErrorOnlyInvoiceValidatedCanBeSentInMassAction', $objectobj->ref).'

'; + $resaction .= '
'.$langs->trans('ErrorOnlyInvoiceValidatedCanBeSentInMassAction', $objectobj->ref).'

'; continue; // Payment done or started or canceled } @@ -269,7 +269,7 @@ if (! $error && $massaction == 'confirm_presend') { $emails_to_sends = array(); $objectobj->fetch_thirdparty(); - $contactidtosend=array(); + $contactidtosend = array(); foreach ($listofobjectcontacts[$objectid] as $contactemailid => $contactemailemail) { $emails_to_sends[] = $objectobj->thirdparty->contact_get_property($contactemailid, 'email'); if (!in_array($contactemailid, $contactidtosend)) { @@ -293,10 +293,10 @@ if (! $error && $massaction == 'confirm_presend') $nbignored++; if (empty($thirdpartywithoutemail[$objectobj->thirdparty->id])) { - $resaction.='
'.$langs->trans('NoRecipientEmail', $objectobj->thirdparty->name).'

'; + $resaction .= '
'.$langs->trans('NoRecipientEmail', $objectobj->thirdparty->name).'

'; } dol_syslog('No recipient for thirdparty: '.$objectobj->thirdparty->name, LOG_WARNING); - $thirdpartywithoutemail[$objectobj->thirdparty->id]=1; + $thirdpartywithoutemail[$objectobj->thirdparty->id] = 1; continue; } @@ -308,13 +308,13 @@ if (! $error && $massaction == 'confirm_presend') $subdir = ''; // TODO Set subdir to be compatible with multi levels dir trees // $subdir = get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element) - $filedir = $uploaddir . '/' . $subdir . dol_sanitizeFileName($objectobj->ref); - $file = $filedir . '/' . $filename; + $filedir = $uploaddir.'/'.$subdir.dol_sanitizeFileName($objectobj->ref); + $file = $filedir.'/'.$filename; // For supplier invoices, we use the file provided by supplier, not the one we generate if ($objectobj->element == 'invoice_supplier') { - $fileparams = dol_most_recent_file($uploaddir . '/' . get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element).$objectobj->ref, preg_quote($objectobj->ref, '/').'([^\-])+'); + $fileparams = dol_most_recent_file($uploaddir.'/'.get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element).$objectobj->ref, preg_quote($objectobj->ref, '/').'([^\-])+'); $file = $fileparams['fullname']; } @@ -323,7 +323,7 @@ if (! $error && $massaction == 'confirm_presend') if (dol_is_file($file)) { // Create form object - $attachedfilesThirdpartyObj[$thirdpartyid][$objectid]=array( + $attachedfilesThirdpartyObj[$thirdpartyid][$objectid] = array( 'paths'=>array($file), 'names'=>array($filename), 'mimes'=>array($mime) @@ -333,15 +333,15 @@ if (! $error && $massaction == 'confirm_presend') { $nbignored++; $langs->load("errors"); - $resaction.='
'.$langs->trans('ErrorCantReadFile', $file).'

'; + $resaction .= '
'.$langs->trans('ErrorCantReadFile', $file).'

'; dol_syslog('Failed to read file: '.$file, LOG_WARNING); continue; } } // Object of thirdparty qualified, we add it - $listofqualifiedobj[$objectid]=$objectobj; - $listofqualifiedref[$objectid]=$objectobj->ref; + $listofqualifiedobj[$objectid] = $objectobj; + $listofqualifiedref[$objectid] = $objectobj->ref; //var_dump($listofqualifiedref); @@ -354,21 +354,21 @@ if (! $error && $massaction == 'confirm_presend') $fromtype = GETPOST('fromtype'); if ($fromtype === 'user') { - $from = $user->getFullName($langs) .' <'.$user->email.'>'; + $from = $user->getFullName($langs).' <'.$user->email.'>'; } elseif ($fromtype === 'company') { - $from = $conf->global->MAIN_INFO_SOCIETE_NOM .' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; + $from = $conf->global->MAIN_INFO_SOCIETE_NOM.' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; } elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) { - $tmp=explode(',', $user->email_aliases); + $tmp = explode(',', $user->email_aliases); $from = trim($tmp[($reg[1] - 1)]); } elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) { - $tmp=explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES); + $tmp = explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES); $from = trim($tmp[($reg[1] - 1)]); } elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) { - $sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1]; + $sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1]; $resql = $db->query($sql); $obj = $db->fetch_object($resql); if ($obj) @@ -377,7 +377,7 @@ if (! $error && $massaction == 'confirm_presend') } } else { - $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>'; + $from = $_POST['fromname'].' <'.$_POST['frommail'].'>'; } $replyto = $from; @@ -385,30 +385,30 @@ if (! $error && $massaction == 'confirm_presend') $message = GETPOST('message', 'none'); $sendtobcc = GETPOST('sendtoccc'); - if ($objectclass == 'Propal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO)); - if ($objectclass == 'Commande') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO)); - if ($objectclass == 'Facture') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO)); - if ($objectclass == 'Supplier_Proposal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO)); - if ($objectclass == 'CommandeFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO)); - if ($objectclass == 'FactureFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO)); - if ($objectclass == 'Project') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO)); + if ($objectclass == 'Propal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO)); + if ($objectclass == 'Commande') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO)); + if ($objectclass == 'Facture') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO)); + if ($objectclass == 'Supplier_Proposal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO)); + if ($objectclass == 'CommandeFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO)); + if ($objectclass == 'FactureFournisseur') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO)); + if ($objectclass == 'Project') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO)); // $listofqualifiedobj is array with key = object id and value is instance of qualified objects, for the current thirdparty (but thirdparty property is not loaded yet) // $looparray will be an array with number of email to send for the current thirdparty (so 1 or n if n object for same thirdparty) - $looparray=array(); - if (! $oneemailperrecipient) + $looparray = array(); + if (!$oneemailperrecipient) { $looparray = $listofqualifiedobj; foreach ($looparray as $key => $objecttmp) { - $looparray[$key]->thirdparty = $thirdparty; // Force thirdparty on object + $looparray[$key]->thirdparty = $thirdparty; // Force thirdparty on object } } else { - $objectforloop=new $objectclass($db); - $objectforloop->thirdparty = $thirdparty; // Force thirdparty on object (even if object was not loaded) - $looparray[0]=$objectforloop; + $objectforloop = new $objectclass($db); + $objectforloop->thirdparty = $thirdparty; // Force thirdparty on object (even if object was not loaded) + $looparray[0] = $objectforloop; } //var_dump($looparray);exit; dol_syslog("We have set an array of ".count($looparray)." emails to send. oneemailperrecipient=".$oneemailperrecipient); @@ -416,39 +416,39 @@ if (! $error && $massaction == 'confirm_presend') foreach ($looparray as $objectid => $objecttmp) // $objecttmp is a real object or an empty object if we choose to send one email per thirdparty instead of one per object { // Make substitution in email content - if (! empty($conf->projet->enabled) && method_exists($objecttmp, 'fetch_projet') && is_null($objecttmp->project)) + if (!empty($conf->projet->enabled) && method_exists($objecttmp, 'fetch_projet') && is_null($objecttmp->project)) { $objecttmp->fetch_projet(); } - $substitutionarray=getCommonSubstitutionArray($langs, 0, null, $objecttmp); + $substitutionarray = getCommonSubstitutionArray($langs, 0, null, $objecttmp); $substitutionarray['__ID__'] = ($oneemailperrecipient ? join(', ', array_keys($listofqualifiedobj)) : $objecttmp->id); $substitutionarray['__REF__'] = ($oneemailperrecipient ? join(', ', $listofqualifiedref) : $objecttmp->ref); $substitutionarray['__EMAIL__'] = $thirdparty->email; $substitutionarray['__CHECK_READ__'] = ''; - $parameters=array('mode'=>'formemail'); + $parameters = array('mode'=>'formemail'); - if (! empty($listofobjectthirdparties)) { + if (!empty($listofobjectthirdparties)) { $parameters['listofobjectthirdparties'] = $listofobjectthirdparties; } - if (! empty($listofobjectref)) { + if (!empty($listofobjectref)) { $parameters['listofobjectref'] = $listofobjectref; } complete_substitutions_array($substitutionarray, $langs, $objecttmp, $parameters); - $subjectreplaced=make_substitutions($subject, $substitutionarray); - $messagereplaced=make_substitutions($message, $substitutionarray); + $subjectreplaced = make_substitutions($subject, $substitutionarray); + $messagereplaced = make_substitutions($message, $substitutionarray); - $attachedfiles=array('paths'=>array(), 'names'=>array(), 'mimes'=>array()); + $attachedfiles = array('paths'=>array(), 'names'=>array(), 'mimes'=>array()); if ($oneemailperrecipient) { // if "one email per recipient" is check we must collate $attachedfiles by thirdparty if (is_array($attachedfilesThirdpartyObj[$thirdparty->id]) && count($attachedfilesThirdpartyObj[$thirdparty->id])) { - foreach ($attachedfilesThirdpartyObj[$thirdparty->id] as $keyObjId => $objAttachedFiles){ + foreach ($attachedfilesThirdpartyObj[$thirdparty->id] as $keyObjId => $objAttachedFiles) { // Create form object - $attachedfiles=array( + $attachedfiles = array( 'paths'=>array_merge($attachedfiles['paths'], $objAttachedFiles['paths']), 'names'=>array_merge($attachedfiles['names'], $objAttachedFiles['names']), 'mimes'=>array_merge($attachedfiles['mimes'], $objAttachedFiles['mimes']) @@ -456,10 +456,10 @@ if (! $error && $massaction == 'confirm_presend') } } } - elseif (!empty($attachedfilesThirdpartyObj[$thirdparty->id][$objectid])){ + elseif (!empty($attachedfilesThirdpartyObj[$thirdparty->id][$objectid])) { // Create form object // if "one email per recipient" isn't check we must separate $attachedfiles by object - $attachedfiles=$attachedfilesThirdpartyObj[$thirdparty->id][$objectid]; + $attachedfiles = $attachedfilesThirdpartyObj[$thirdparty->id][$objectid]; } $filepath = $attachedfiles['paths']; @@ -469,22 +469,22 @@ if (! $error && $massaction == 'confirm_presend') // Define the trackid when emails sent from the mass action if ($oneemailperrecipient) { - $trackid='thi'.$thirdparty->id; - if ($objecttmp->element == 'expensereport') $trackid='use'.$thirdparty->id; - if ($objecttmp->element == 'holiday') $trackid='use'.$thirdparty->id; + $trackid = 'thi'.$thirdparty->id; + if ($objecttmp->element == 'expensereport') $trackid = 'use'.$thirdparty->id; + if ($objecttmp->element == 'holiday') $trackid = 'use'.$thirdparty->id; } else { - $trackid=strtolower(get_class($objecttmp)); - if (get_class($objecttmp)=='Contrat') $trackid='con'; - if (get_class($objecttmp)=='Propal') $trackid='pro'; - if (get_class($objecttmp)=='Commande') $trackid='ord'; - if (get_class($objecttmp)=='Facture') $trackid='inv'; - if (get_class($objecttmp)=='Supplier_Proposal') $trackid='spr'; - if (get_class($objecttmp)=='CommandeFournisseur') $trackid='sor'; - if (get_class($objecttmp)=='FactureFournisseur') $trackid='sin'; + $trackid = strtolower(get_class($objecttmp)); + if (get_class($objecttmp) == 'Contrat') $trackid = 'con'; + if (get_class($objecttmp) == 'Propal') $trackid = 'pro'; + if (get_class($objecttmp) == 'Commande') $trackid = 'ord'; + if (get_class($objecttmp) == 'Facture') $trackid = 'inv'; + if (get_class($objecttmp) == 'Supplier_Proposal') $trackid = 'spr'; + if (get_class($objecttmp) == 'CommandeFournisseur') $trackid = 'sor'; + if (get_class($objecttmp) == 'FactureFournisseur') $trackid = 'sin'; - $trackid.=$objecttmp->id; + $trackid .= $objecttmp->id; } //var_dump($filepath); //var_dump($trackid);exit; @@ -495,21 +495,21 @@ if (! $error && $massaction == 'confirm_presend') $mailfile = new CMailFile($subjectreplaced, $sendto, $from, $messagereplaced, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1, '', '', $trackid); if ($mailfile->error) { - $resaction.='
'.$mailfile->error.'
'; + $resaction .= '
'.$mailfile->error.'
'; } else { - $result=$mailfile->sendfile(); + $result = $mailfile->sendfile(); if ($result) { - $resaction.=$langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)).'
'; // Must not contain " + $resaction .= $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)).'
'; // Must not contain " - $error=0; + $error = 0; // Insert logs into agenda - foreach($listofqualifiedobj as $objid2 => $objectobj2) + foreach ($listofqualifiedobj as $objid2 => $objectobj2) { - if ((! $oneemailperrecipient) && $objid2 != $objectid) continue; // We discard this pass to avoid duplicate with other pass in looparray at higher level + if ((!$oneemailperrecipient) && $objid2 != $objectid) continue; // We discard this pass to avoid duplicate with other pass in looparray at higher level dol_syslog("Try to insert email event into agenda for objid=".$objid2." => objectobj=".get_class($objectobj2)); @@ -520,24 +520,24 @@ if (! $error && $massaction == 'confirm_presend') if ($objectclass == 'CommandeFournisseur') $actiontypecode='AC_SUP_ORD'; if ($objectclass == 'FactureFournisseur') $actiontypecode='AC_SUP_INV';*/ - $actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; + $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; if ($message) { - if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subjectreplaced); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); + if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subjectreplaced); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); $actionmsg = dol_concatdesc($actionmsg, $messagereplaced); } - $actionmsg2=''; + $actionmsg2 = ''; // Initialisation donnees - $objectobj2->sendtoid = (empty($contactidtosend)?0:$contactidtosend); - $objectobj2->actionmsg = $actionmsg; // Long text + $objectobj2->sendtoid = (empty($contactidtosend) ? 0 : $contactidtosend); + $objectobj2->actionmsg = $actionmsg; // Long text $objectobj2->actionmsg2 = $actionmsg2; // Short text $objectobj2->fk_element = $objid2; $objectobj2->elementtype = $objectobj2->element; - $triggername = strtoupper(get_class($objectobj2)) .'_SENTBYMAIL'; + $triggername = strtoupper(get_class($objectobj2)).'_SENTBYMAIL'; if ($triggername == 'SOCIETE_SENTBYMAIL') $triggername = 'COMPANY_SENTBYMAIL'; if ($triggername == 'CONTRAT_SENTBYMAIL') $triggername = 'CONTRACT_SENTBYMAIL'; if ($triggername == 'COMMANDE_SENTBYMAIL') $triggername = 'ORDER_SENTBYMAIL'; @@ -547,13 +547,13 @@ if (! $error && $massaction == 'confirm_presend') if ($triggername == 'FACTUREFOURNISSEUR_SENTBYMAIL') $triggername = 'BILL_SUPPLIER_SENTBYMAIL'; if ($triggername == 'SUPPLIERPROPOSAL_SENTBYMAIL') $triggername = 'PROPOSAL_SUPPLIER_SENTBYMAIL'; - if (! empty($triggername)) + if (!empty($triggername)) { // Appel des triggers - include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"; - $interface=new Interfaces($db); - $result=$interface->run_triggers($triggername, $objectobj2, $user, $langs, $conf); - if ($result < 0) { $error++; $errors=$interface->errors; } + include_once DOL_DOCUMENT_ROOT."/core/class/interfaces.class.php"; + $interface = new Interfaces($db); + $result = $interface->run_triggers($triggername, $objectobj2, $user, $langs, $conf); + if ($result < 0) { $error++; $errors = $interface->errors; } // Fin appel triggers if ($error) @@ -563,7 +563,7 @@ if (! $error && $massaction == 'confirm_presend') } } - $nbsent++; // Nb of object sent + $nbsent++; // Nb of object sent } } else @@ -571,12 +571,12 @@ if (! $error && $massaction == 'confirm_presend') $langs->load("other"); if ($mailfile->error) { - $resaction.=$langs->trans('ErrorFailedToSendMail', $from, $sendto); - $resaction.='
'.$mailfile->error.'
'; + $resaction .= $langs->trans('ErrorFailedToSendMail', $from, $sendto); + $resaction .= '
'.$mailfile->error.'
'; } else { - $resaction.='
No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS
'; + $resaction .= '
No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS
'; } } } @@ -584,15 +584,15 @@ if (! $error && $massaction == 'confirm_presend') } } - $resaction.=($resaction?'
':$resaction); - $resaction.=''.$langs->trans("ResultOfMailSending").':
'."\n"; - $resaction.=$langs->trans("NbSelected").': '.count($toselect)."\n
"; - $resaction.=$langs->trans("NbIgnored").': '.($nbignored?$nbignored:0)."\n
"; - $resaction.=$langs->trans("NbSent").': '.($nbsent?$nbsent:0)."\n
"; + $resaction .= ($resaction ? '
' : $resaction); + $resaction .= ''.$langs->trans("ResultOfMailSending").':
'."\n"; + $resaction .= $langs->trans("NbSelected").': '.count($toselect)."\n
"; + $resaction .= $langs->trans("NbIgnored").': '.($nbignored ? $nbignored : 0)."\n
"; + $resaction .= $langs->trans("NbSent").': '.($nbsent ? $nbsent : 0)."\n
"; if ($nbsent) { - $action=''; // Do not show form post if there was at least one successfull sent + $action = ''; // Do not show form post if there was at least one successfull sent //setEventMessages($langs->trans("EMailSentToNRecipients", $nbsent.'/'.count($toselect)), null, 'mesgs'); setEventMessages($langs->trans("EMailSentForNElements", $nbsent.'/'.count($toselect)), null, 'mesgs'); setEventMessages($resaction, null, 'mesgs'); @@ -603,8 +603,8 @@ if (! $error && $massaction == 'confirm_presend') setEventMessages($resaction, null, 'warnings'); } - $action='list'; - $massaction=''; + $action = 'list'; + $massaction = ''; } } @@ -621,7 +621,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders $db->begin(); - foreach($orders as $id_order) + foreach ($orders as $id_order) { $cmd = new Commande($db); if ($cmd->fetch($id_order) <= 0) continue; @@ -636,8 +636,8 @@ if ($massaction == 'confirm_createbills') // Create bills from orders $objecttmp->type = Facture::TYPE_STANDARD; $objecttmp->cond_reglement_id = $cmd->cond_reglement_id; $objecttmp->mode_reglement_id = $cmd->mode_reglement_id; - $objecttmp->fk_project = $cmd->fk_project; - $objecttmp->multicurrency_code = $cmd->multicurrency_code; + $objecttmp->fk_project = $cmd->fk_project; + $objecttmp->multicurrency_code = $cmd->multicurrency_code; if (empty($createbills_onebythird)) $objecttmp->ref_client = $cmd->ref_client; $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); @@ -650,33 +650,33 @@ if ($massaction == 'confirm_createbills') // Create bills from orders $objecttmp->origin = 'commande'; $objecttmp->origin_id = $id_order; - $objecttmp->array_options = $cmd->array_options; // Copy extrafields + $objecttmp->array_options = $cmd->array_options; // Copy extrafields $res = $objecttmp->create($user); - if($res > 0) $nb_bills_created++; + if ($res > 0) $nb_bills_created++; } if ($objecttmp->id > 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; - $sql.= "fk_source"; - $sql.= ", sourcetype"; - $sql.= ", fk_target"; - $sql.= ", targettype"; - $sql.= ") VALUES ("; - $sql.= $id_order; - $sql.= ", '".$objecttmp->origin."'"; - $sql.= ", ".$objecttmp->id; - $sql.= ", '".$objecttmp->element."'"; - $sql.= ")"; + $sql .= "fk_source"; + $sql .= ", sourcetype"; + $sql .= ", fk_target"; + $sql .= ", targettype"; + $sql .= ") VALUES ("; + $sql .= $id_order; + $sql .= ", '".$objecttmp->origin."'"; + $sql .= ", ".$objecttmp->id; + $sql .= ", '".$objecttmp->element."'"; + $sql .= ")"; - if (! $db->query($sql)) + if (!$db->query($sql)) { $error++; } - if (! $error) + if (!$error) { $lines = $cmd->lines; if (empty($lines) && method_exists($cmd, 'fetch_lines')) @@ -685,33 +685,33 @@ if ($massaction == 'confirm_createbills') // Create bills from orders $lines = $cmd->lines; } - $fk_parent_line=0; - $num=count($lines); + $fk_parent_line = 0; + $num = count($lines); - for ($i=0;$i<$num;$i++) + for ($i = 0; $i < $num; $i++) { - $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); + $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle); // If we build one invoice for several order, we must put the invoice of order on the line - if (! empty($createbills_onebythird)) + if (!empty($createbills_onebythird)) { - $desc=dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day', $langs)); + $desc = dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day', $langs)); } if ($lines[$i]->subprice < 0) { // Negative line, we create a discount line $discount = new DiscountAbsolute($db); - $discount->fk_soc=$objecttmp->socid; - $discount->amount_ht=abs($lines[$i]->total_ht); - $discount->amount_tva=abs($lines[$i]->total_tva); - $discount->amount_ttc=abs($lines[$i]->total_ttc); - $discount->tva_tx=$lines[$i]->tva_tx; - $discount->fk_user=$user->id; - $discount->description=$desc; - $discountid=$discount->create($user); + $discount->fk_soc = $objecttmp->socid; + $discount->amount_ht = abs($lines[$i]->total_ht); + $discount->amount_tva = abs($lines[$i]->total_tva); + $discount->amount_ttc = abs($lines[$i]->total_ttc); + $discount->tva_tx = $lines[$i]->tva_tx; + $discount->fk_user = $user->id; + $discount->description = $desc; + $discountid = $discount->create($user); if ($discountid > 0) { - $result=$objecttmp->insert_discount($discountid); + $result = $objecttmp->insert_discount($discountid); //$result=$discount->link_to_invoice($lineid,$id); } else @@ -724,17 +724,17 @@ if ($massaction == 'confirm_createbills') // Create bills from orders else { // Positive line - $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); + $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); // Date start - $date_start=false; - if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue; - if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel; - if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start; + $date_start = false; + if ($lines[$i]->date_debut_prevue) $date_start = $lines[$i]->date_debut_prevue; + if ($lines[$i]->date_debut_reel) $date_start = $lines[$i]->date_debut_reel; + if ($lines[$i]->date_start) $date_start = $lines[$i]->date_start; //Date end - $date_end=false; - if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue; - if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; - if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; + $date_end = false; + if ($lines[$i]->date_fin_prevue) $date_end = $lines[$i]->date_fin_prevue; + if ($lines[$i]->date_fin_reel) $date_end = $lines[$i]->date_fin_reel; + if ($lines[$i]->date_end) $date_end = $lines[$i]->date_end; // Reset fk_parent_line for no child products and special product if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { @@ -776,11 +776,11 @@ if ($massaction == 'confirm_createbills') // Create bills from orders ); if ($result > 0) { - $lineid=$result; + $lineid = $result; } else { - $lineid=0; + $lineid = 0; $error++; break; } @@ -796,7 +796,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders //$cmd->classifyBilled($user); // Disabled. This behavior must be set or not using the workflow module. - if(!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $objecttmp; + if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $objecttmp; else $TFact[$objecttmp->id] = $objecttmp; } @@ -804,11 +804,11 @@ if ($massaction == 'confirm_createbills') // Create bills from orders $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird; $toselect = array(); - if (! $error && $validate_invoices) + if (!$error && $validate_invoices) { $massaction = $action = 'builddoc'; - foreach($TAllFact as &$objecttmp) + foreach ($TAllFact as &$objecttmp) { $result = $objecttmp->validate($user); if ($result <= 0) @@ -836,36 +836,36 @@ if ($massaction == 'confirm_createbills') // Create bills from orders $massaction = $action = 'confirm_createbills'; } - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs'); // Make a redirect to avoid to bill twice if we make a refresh or back - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($sall) $param.='&sall='.urlencode($sall); - if ($socid > 0) $param.='&socid='.urlencode($socid); - if ($viewstatut != '') $param.='&viewstatut='.urlencode($viewstatut); - if ($search_orderday) $param.='&search_orderday='.urlencode($search_orderday); - if ($search_ordermonth) $param.='&search_ordermonth='.urlencode($search_ordermonth); - if ($search_orderyear) $param.='&search_orderyear='.urlencode($search_orderyear); - if ($search_deliveryday) $param.='&search_deliveryday='.urlencode($search_deliveryday); - if ($search_deliverymonth) $param.='&search_deliverymonth='.urlencode($search_deliverymonth); - if ($search_deliveryyear) $param.='&search_deliveryyear='.urlencode($search_deliveryyear); - if ($search_ref) $param.='&search_ref='.urlencode($search_ref); - if ($search_company) $param.='&search_company='.urlencode($search_company); - if ($search_ref_customer) $param.='&search_ref_customer='.urlencode($search_ref_customer); - if ($search_user > 0) $param.='&search_user='.urlencode($search_user); - if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale); - if ($search_total_ht != '') $param.='&search_total_ht='.urlencode($search_total_ht); - if ($search_total_vat != '') $param.='&search_total_vat='.urlencode($search_total_vat); - if ($search_total_ttc != '') $param.='&search_total_ttc='.urlencode($search_total_ttc); - if ($search_project_ref >= 0) $param.="&search_project_ref=".urlencode($search_project_ref); - if ($show_files) $param.='&show_files=' .urlencode($show_files); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); - if ($billed != '') $param.='&billed='.urlencode($billed); + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($sall) $param .= '&sall='.urlencode($sall); + if ($socid > 0) $param .= '&socid='.urlencode($socid); + if ($viewstatut != '') $param .= '&viewstatut='.urlencode($viewstatut); + if ($search_orderday) $param .= '&search_orderday='.urlencode($search_orderday); + if ($search_ordermonth) $param .= '&search_ordermonth='.urlencode($search_ordermonth); + if ($search_orderyear) $param .= '&search_orderyear='.urlencode($search_orderyear); + if ($search_deliveryday) $param .= '&search_deliveryday='.urlencode($search_deliveryday); + if ($search_deliverymonth) $param .= '&search_deliverymonth='.urlencode($search_deliverymonth); + if ($search_deliveryyear) $param .= '&search_deliveryyear='.urlencode($search_deliveryyear); + if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); + if ($search_company) $param .= '&search_company='.urlencode($search_company); + if ($search_ref_customer) $param .= '&search_ref_customer='.urlencode($search_ref_customer); + if ($search_user > 0) $param .= '&search_user='.urlencode($search_user); + if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); + if ($search_total_ht != '') $param .= '&search_total_ht='.urlencode($search_total_ht); + if ($search_total_vat != '') $param .= '&search_total_vat='.urlencode($search_total_vat); + if ($search_total_ttc != '') $param .= '&search_total_ttc='.urlencode($search_total_ttc); + if ($search_project_ref >= 0) $param .= "&search_project_ref=".urlencode($search_project_ref); + if ($show_files) $param .= '&show_files='.urlencode($show_files); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + if ($billed != '') $param .= '&billed='.urlencode($billed); header("Location: ".$_SERVER['PHP_SELF'].'?'.$param); exit; @@ -873,9 +873,9 @@ if ($massaction == 'confirm_createbills') // Create bills from orders else { $db->rollback(); - $action='create'; - $_GET["origin"]=$_POST["origin"]; - $_GET["originid"]=$_POST["originid"]; + $action = 'create'; + $_GET["origin"] = $_POST["origin"]; + $_GET["originid"] = $_POST["originid"]; setEventMessages("Error", null, 'errors'); $error++; } @@ -929,7 +929,7 @@ if (!$error && $massaction == 'cancelorders') } -if (! $error && $massaction == "builddoc" && $permissiontoread && ! GETPOST('button_search')) +if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('button_search')) { if (empty($diroutputmassaction)) { @@ -941,34 +941,34 @@ if (! $error && $massaction == "builddoc" && $permissiontoread && ! GETPOST('but require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - $objecttmp=new $objectclass($db); - $listofobjectid=array(); - $listofobjectthirdparties=array(); - $listofobjectref=array(); - foreach($toselect as $toselectid) + $objecttmp = new $objectclass($db); + $listofobjectid = array(); + $listofobjectthirdparties = array(); + $listofobjectref = array(); + foreach ($toselect as $toselectid) { - $objecttmp=new $objectclass($db); // must create new instance because instance is saved into $listofobjectref array for future use - $result=$objecttmp->fetch($toselectid); + $objecttmp = new $objectclass($db); // must create new instance because instance is saved into $listofobjectref array for future use + $result = $objecttmp->fetch($toselectid); if ($result > 0) { - $listofobjectid[$toselectid]=$toselectid; - $thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid; - $listofobjectthirdparties[$thirdpartyid]=$thirdpartyid; - $listofobjectref[$toselectid]=$objecttmp->ref; + $listofobjectid[$toselectid] = $toselectid; + $thirdpartyid = $objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid; + $listofobjectthirdparties[$thirdpartyid] = $thirdpartyid; + $listofobjectref[$toselectid] = $objecttmp->ref; } } - $arrayofinclusion=array(); - foreach($listofobjectref as $tmppdf) $arrayofinclusion[]='^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'\.pdf$'; - foreach($listofobjectref as $tmppdf) $arrayofinclusion[]='^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'_[a-zA-Z0-9-_]+\.pdf$'; // To include PDF generated from ODX files + $arrayofinclusion = array(); + foreach ($listofobjectref as $tmppdf) $arrayofinclusion[] = '^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'\.pdf$'; + foreach ($listofobjectref as $tmppdf) $arrayofinclusion[] = '^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'_[a-zA-Z0-9-_]+\.pdf$'; // To include PDF generated from ODX files $listoffiles = dol_dir_list($uploaddir, 'all', 1, implode('|', $arrayofinclusion), '\.meta$|\.png', 'date', SORT_DESC, 0, true); // build list of files with full path $files = array(); - foreach($listofobjectref as $basename) + foreach ($listofobjectref as $basename) { $basename = dol_sanitizeFileName($basename); - foreach($listoffiles as $filefound) + foreach ($listoffiles as $filefound) { if (strstr($filefound["name"], $basename)) { @@ -980,10 +980,10 @@ if (! $error && $massaction == "builddoc" && $permissiontoread && ! GETPOST('but // Define output language (Here it is not used because we do only merging existing PDF) $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang=GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$objecttmp->thirdparty->default_lang; - if (! empty($newlang)) { + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $objecttmp->thirdparty->default_lang; + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -994,32 +994,32 @@ if (! $error && $massaction == "builddoc" && $permissiontoread && ! GETPOST('but dol_mkdir($diroutputmassaction); // Defined name of merged file - $filename=strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel))); - $filename=preg_replace('/\s/', '_', $filename); + $filename = strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel))); + $filename = preg_replace('/\s/', '_', $filename); // Save merged file if (in_array($objecttmp->element, array('facture', 'facture_fournisseur')) && $search_status == Facture::STATUS_VALIDATED) { - if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); - else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); + if ($option == 'late') $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); + else $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); } - if ($year) $filename.='_'.$year; - if ($month) $filename.='_'.$month; + if ($year) $filename .= '_'.$year; + if ($month) $filename .= '_'.$month; - if (count($files)>0) + if (count($files) > 0) { - $now=dol_now(); - $file=$diroutputmassaction.'/'.$filename.'_'.dol_print_date($now, 'dayhourlog').'.pdf'; + $now = dol_now(); + $file = $diroutputmassaction.'/'.$filename.'_'.dol_print_date($now, 'dayhourlog').'.pdf'; $input_files = ''; - foreach($files as $f) { - $input_files.=' '.escapeshellarg($f); + foreach ($files as $f) { + $input_files .= ' '.escapeshellarg($f); } $cmd = 'pdftk '.escapeshellarg($input_files).' cat output '.escapeshellarg($file); exec($cmd); - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); $langs->load("exports"); @@ -1032,12 +1032,12 @@ if (! $error && $massaction == "builddoc" && $permissiontoread && ! GETPOST('but } else { // Create empty PDF - $formatarray=pdf_getFormat(); + $formatarray = pdf_getFormat(); $page_largeur = $formatarray['width']; $page_hauteur = $formatarray['height']; $format = array($page_largeur, $page_hauteur); - $pdf=pdf_getInstance($format); + $pdf = pdf_getInstance($format); if (class_exists('TCPDF')) { @@ -1046,10 +1046,10 @@ if (! $error && $massaction == "builddoc" && $permissiontoread && ! GETPOST('but } $pdf->SetFont(pdf_getPDFFont($outputlangs)); - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); // Add all others - foreach($files as $file) + foreach ($files as $file) { // Charge un document PDF depuis un fichier. $pagecount = $pdf->setSourceFile($file); @@ -1066,23 +1066,23 @@ if (! $error && $massaction == "builddoc" && $permissiontoread && ! GETPOST('but dol_mkdir($diroutputmassaction); // Defined name of merged file - $filename=strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel))); - $filename=preg_replace('/\s/', '_', $filename); + $filename = strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel))); + $filename = preg_replace('/\s/', '_', $filename); // Save merged file if (in_array($objecttmp->element, array('facture', 'facture_fournisseur')) && $search_status == Facture::STATUS_VALIDATED) { - if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); - else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); + if ($option == 'late') $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late"))); + else $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))); } - if ($year) $filename.='_'.$year; - if ($month) $filename.='_'.$month; + if ($year) $filename .= '_'.$year; + if ($month) $filename .= '_'.$month; if ($pagecount) { - $now=dol_now(); - $file=$diroutputmassaction.'/'.$filename.'_'.dol_print_date($now, 'dayhourlog').'.pdf'; + $now = dol_now(); + $file = $diroutputmassaction.'/'.$filename.'_'.dol_print_date($now, 'dayhourlog').'.pdf'; $pdf->Output($file, 'F'); - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); $langs->load("exports"); @@ -1102,38 +1102,38 @@ if ($action == 'remove_file') $langs->load("other"); $upload_dir = $diroutputmassaction; - $file = $upload_dir . '/' . GETPOST('file'); - $ret=dol_delete_file($file); + $file = $upload_dir.'/'.GETPOST('file'); + $ret = dol_delete_file($file); if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs'); else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors'); - $action=''; + $action = ''; } // Validate records -if (! $error && $massaction == 'validate' && $permissiontoadd) +if (!$error && $massaction == 'validate' && $permissiontoadd) { - $objecttmp=new $objectclass($db); + $objecttmp = new $objectclass($db); - if ($objecttmp->element == 'invoice' && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL)) + if ($objecttmp->element == 'invoice' && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) { $langs->load("errors"); setEventMessages($langs->trans('ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'), null, 'errors'); $error++; } - if ($objecttmp->element == 'invoice_supplier' && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) + if ($objecttmp->element == 'invoice_supplier' && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL)) { $langs->load("errors"); setEventMessages($langs->trans('ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'), null, 'errors'); $error++; } - if (! $error) + if (!$error) { $db->begin(); $nbok = 0; - foreach($toselect as $toselectid) + foreach ($toselect as $toselectid) { - $result=$objecttmp->fetch($toselectid); + $result = $objecttmp->fetch($toselectid); if ($result > 0) { //if (in_array($objecttmp->element, array('societe','member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1); @@ -1162,7 +1162,7 @@ if (! $error && $massaction == 'validate' && $permissiontoadd) } } - if (! $error) + if (!$error) { if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); @@ -1212,15 +1212,15 @@ if (!$error && $massaction == 'closed' && $objectclass == "Propal" && $permissio } } // Delete record from mass action (massaction = 'delete' for direct delete, action/confirm='delete'/'yes' with a confirmation step before) -if (! $error && ($massaction == 'delete' || ($action == 'delete' && $confirm == 'yes')) && $permissiontodelete) +if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == 'yes')) && $permissiontodelete) { $db->begin(); - $objecttmp=new $objectclass($db); + $objecttmp = new $objectclass($db); $nbok = 0; - foreach($toselect as $toselectid) + foreach ($toselect as $toselectid) { - $result=$objecttmp->fetch($toselectid); + $result = $objecttmp->fetch($toselectid); if ($result > 0) { // Refuse deletion for some objects/status @@ -1228,7 +1228,7 @@ if (! $error && ($massaction == 'delete' || ($action == 'delete' && $confirm == { $langs->load("errors"); $nbignored++; - $resaction.='
'.$langs->trans('ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).'

'; + $resaction .= '
'.$langs->trans('ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).'

'; continue; } @@ -1263,7 +1263,7 @@ if (! $error && ($massaction == 'delete' || ($action == 'delete' && $confirm == } } - if (! $error) + if (!$error) { if ($nbok > 1) setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs'); else setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs'); @@ -1278,36 +1278,36 @@ if (! $error && ($massaction == 'delete' || ($action == 'delete' && $confirm == // Generate document foreach object according to model linked to object // @TODO : propose model selection -if (! $error && $massaction == 'generate_doc' && $permissiontoread) +if (!$error && $massaction == 'generate_doc' && $permissiontoread) { $db->begin(); - $objecttmp=new $objectclass($db); + $objecttmp = new $objectclass($db); $nbok = 0; - foreach($toselect as $toselectid) + foreach ($toselect as $toselectid) { - $result=$objecttmp->fetch($toselectid); + $result = $objecttmp->fetch($toselectid); if ($result > 0) { $outputlangs = $langs; - $newlang=''; + $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang=GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) $newlang=$objecttmp->thirdparty->default_lang; // for proposal, order, invoice, ... - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->default_lang)) $newlang=$objecttmp->default_lang; // for thirdparty - if (! empty($newlang)) + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) $newlang = $objecttmp->thirdparty->default_lang; // for proposal, order, invoice, ... + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->default_lang)) $newlang = $objecttmp->default_lang; // for thirdparty + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } // To be sure vars is defined - if (empty($hidedetails)) $hidedetails=0; - if (empty($hidedesc)) $hidedesc=0; - if (empty($hideref)) $hideref=0; - if (empty($moreparams)) $moreparams=null; + if (empty($hidedetails)) $hidedetails = 0; + if (empty($hidedesc)) $hidedesc = 0; + if (empty($hideref)) $hideref = 0; + if (empty($moreparams)) $moreparams = null; - $result= $objecttmp->generateDocument($objecttmp->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + $result = $objecttmp->generateDocument($objecttmp->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); if ($result <= 0) { @@ -1325,7 +1325,7 @@ if (! $error && $massaction == 'generate_doc' && $permissiontoread) } } - if (! $error) + if (!$error) { if ($nbok > 1) setEventMessages($langs->trans("RecordsGenerated", $nbok), null, 'mesgs'); else setEventMessages($langs->trans("RecordGenerated", $nbok), null, 'mesgs'); @@ -1337,10 +1337,10 @@ if (! $error && $massaction == 'generate_doc' && $permissiontoread) } } -$parameters['toselect']=$toselect; -$parameters['uploaddir']=$uploaddir; -$parameters['massaction']=$massaction; -$parameters['diroutputmassaction']=$diroutputmassaction; +$parameters['toselect'] = $toselect; +$parameters['uploaddir'] = $uploaddir; +$parameters['massaction'] = $massaction; +$parameters['diroutputmassaction'] = $diroutputmassaction; -$reshook=$hookmanager->executeHooks('doMassActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$reshook = $hookmanager->executeHooks('doMassActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index 9140b9b9d43..91c6ab23910 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -34,9 +34,9 @@ include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; */ class box_contacts extends ModeleBoxes { - public $boxcode="lastcontacts"; - public $boximg="object_contact"; - public $boxlabel="BoxLastContacts"; + public $boxcode = "lastcontacts"; + public $boximg = "object_contact"; + public $boxlabel = "BoxLastContacts"; public $depends = array("societe"); /** @@ -62,7 +62,7 @@ class box_contacts extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->societe->lire && $user->rights->societe->contact->lire); + $this->hidden = !($user->rights->societe->lire && $user->rights->societe->contact->lire); } /** @@ -76,46 +76,46 @@ class box_contacts extends ModeleBoxes global $user, $langs, $conf; $langs->load("boxes"); - $this->max=$max; + $this->max = $max; $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedContacts", $max)); if ($user->rights->societe->lire && $user->rights->societe->contact->lire) { $sql = "SELECT sp.rowid as id, sp.lastname, sp.firstname, sp.civility as civility_id, sp.datec, sp.tms, sp.fk_soc, sp.statut as status"; - $sql.= ", sp.address, sp.zip, sp.town, sp.phone, sp.phone_perso, sp.phone_mobile, sp.email as spemail"; - $sql.= ", s.nom as socname, s.name_alias, s.email as semail"; - $sql.= ", s.client, s.fournisseur, s.code_client, s.code_fournisseur"; - $sql.= ", co.label as country, co.code as country_code"; - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON sp.fk_pays = co.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid"; - if (! $user->rights->societe->client->voir && ! $user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE sp.entity IN (".getEntity('socpeople').")"; - if (! $user->rights->societe->client->voir && ! $user->socid) $sql.= " AND sp.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($user->socid) $sql.= " AND sp.fk_soc = ".$user->socid; - $sql.= " ORDER BY sp.tms DESC"; - $sql.= $this->db->plimit($max, 0); + $sql .= ", sp.address, sp.zip, sp.town, sp.phone, sp.phone_perso, sp.phone_mobile, sp.email as spemail"; + $sql .= ", s.nom as socname, s.name_alias, s.email as semail"; + $sql .= ", s.client, s.fournisseur, s.code_client, s.code_fournisseur"; + $sql .= ", co.label as country, co.code as country_code"; + $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON sp.fk_pays = co.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE sp.entity IN (".getEntity('socpeople').")"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND sp.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND sp.fk_soc = ".$user->socid; + $sql .= " ORDER BY sp.tms DESC"; + $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); - $contactstatic=new Contact($this->db); - $societestatic=new Societe($this->db); + $contactstatic = new Contact($this->db); + $societestatic = new Societe($this->db); $line = 0; while ($line < $num) { $objp = $this->db->fetch_object($result); - $datec=$this->db->jdate($objp->datec); - $datem=$this->db->jdate($objp->tms); + $datec = $this->db->jdate($objp->datec); + $datem = $this->db->jdate($objp->tms); - $contactstatic->id=$objp->id; - $contactstatic->lastname=$objp->lastname; - $contactstatic->firstname=$objp->firstname; - $contactstatic->civility_id=$objp->civility_id; - $contactstatic->statut=$objp->status; + $contactstatic->id = $objp->id; + $contactstatic->lastname = $objp->lastname; + $contactstatic->firstname = $objp->firstname; + $contactstatic->civility_id = $objp->civility_id; + $contactstatic->statut = $objp->status; $contactstatic->phone_pro = $objp->phone; $contactstatic->phone_perso = $objp->phone_perso; $contactstatic->phone_mobile = $objp->phone_mobile; @@ -161,7 +161,7 @@ class box_contacts extends ModeleBoxes $line++; } - if ($num==0) + if ($num == 0) $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', 'text'=> ''.$langs->trans("NoRecordedContacts").'', diff --git a/htdocs/core/boxes/box_last_modified_ticket.php b/htdocs/core/boxes/box_last_modified_ticket.php index 18c2ebfe340..f6bbbb76854 100644 --- a/htdocs/core/boxes/box_last_modified_ticket.php +++ b/htdocs/core/boxes/box_last_modified_ticket.php @@ -23,7 +23,7 @@ * \ingroup ticket * \brief This box shows latest modified tickets */ -require_once DOL_DOCUMENT_ROOT . "/core/boxes/modules_boxes.php"; +require_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; /** * Class to manage the box @@ -86,23 +86,23 @@ class box_last_modified_ticket extends ModeleBoxes if ($user->rights->ticket->read) { $sql = "SELECT t.rowid as id, t.ref, t.track_id, t.fk_soc, t.fk_user_create, t.fk_user_assign, t.subject, t.message, t.fk_statut, t.type_code, t.category_code, t.severity_code, t.datec, t.date_read, t.date_close, t.origin_email "; - $sql.= ", type.label as type_label, category.label as category_label, severity.label as severity_label"; - $sql.= ", s.nom as company_name, s.email as socemail, s.client, s.fournisseur"; - $sql.= " FROM ".MAIN_DB_PREFIX."ticket as t"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code=t.type_code"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code=t.category_code"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc"; + $sql .= ", type.label as type_label, category.label as category_label, severity.label as severity_label"; + $sql .= ", s.nom as company_name, s.email as socemail, s.client, s.fournisseur"; + $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code=t.type_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code=t.category_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc"; - $sql.= " WHERE t.entity = ".$conf->entity; + $sql .= " WHERE t.entity = ".$conf->entity; // $sql.= " AND e.rowid = er.fk_event"; //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($user->socid) { - $sql.= " AND t.fk_soc= ".$user->socid; + $sql .= " AND t.fk_soc= ".$user->socid; } - $sql.= " ORDER BY t.tms DESC, t.rowid DESC "; - $sql.= $this->db->plimit($max, 0); + $sql .= " ORDER BY t.tms DESC, t.rowid DESC "; + $sql .= $this->db->plimit($max, 0); $resql = $this->db->query($sql); if ($resql) { @@ -112,9 +112,9 @@ class box_last_modified_ticket extends ModeleBoxes while ($i < $num) { $objp = $this->db->fetch_object($resql); - $datec=$this->db->jdate($objp->datec); - $dateterm=$this->db->jdate($objp->fin_validite); - $dateclose=$this->db->jdate($objp->date_cloture); + $datec = $this->db->jdate($objp->datec); + $dateterm = $this->db->jdate($objp->fin_validite); + $dateclose = $this->db->jdate($objp->date_cloture); $late = ''; $ticket = new Ticket($this->db); @@ -136,7 +136,7 @@ class box_last_modified_ticket extends ModeleBoxes } - $r=0; + $r = 0; // Ticket $this->info_box_contents[$i][0] = array( @@ -149,7 +149,7 @@ class box_last_modified_ticket extends ModeleBoxes // Subject $this->info_box_contents[$i][$r] = array( 'td' => 'class="nowrap"', - 'text' => $objp->subject, // Some event have no ref + 'text' => $objp->subject, // Some event have no ref 'url' => DOL_URL_ROOT."/ticket/card.php?track_id=".$objp->track_id, ); $r++; @@ -180,8 +180,8 @@ class box_last_modified_ticket extends ModeleBoxes $i++; } - if ($num==0) { - $this->info_box_contents[$i][0] = array('td' => 'class="center"','text'=>$langs->trans("BoxLastModifiedTicketNoRecordedTickets")); + if ($num == 0) { + $this->info_box_contents[$i][0] = array('td' => 'class="center"', 'text'=>$langs->trans("BoxLastModifiedTicketNoRecordedTickets")); } } else { dol_print_error($this->db); diff --git a/htdocs/core/boxes/box_last_ticket.php b/htdocs/core/boxes/box_last_ticket.php index 4a0842139d6..0ac4557431b 100644 --- a/htdocs/core/boxes/box_last_ticket.php +++ b/htdocs/core/boxes/box_last_ticket.php @@ -23,7 +23,7 @@ * \ingroup ticket * \brief This box shows latest created tickets */ -require_once DOL_DOCUMENT_ROOT . "/core/boxes/modules_boxes.php"; +require_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; /** * Class to manage the box @@ -88,17 +88,17 @@ class box_last_ticket extends ModeleBoxes $sql = "SELECT t.rowid as id, t.ref, t.track_id, t.fk_soc, t.fk_user_create, t.fk_user_assign, t.subject, t.message, t.fk_statut, t.type_code, t.category_code, t.severity_code, t.datec, t.date_read, t.date_close, t.origin_email "; $sql .= ", type.label as type_label, category.label as category_label, severity.label as severity_label"; $sql .= ", s.nom as company_name, s.email as socemail, s.client, s.fournisseur"; - $sql .= " FROM " . MAIN_DB_PREFIX . "ticket as t"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_ticket_type as type ON type.code=t.type_code"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_ticket_category as category ON category.code=t.category_code"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_ticket_severity as severity ON severity.code=t.severity_code"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid=t.fk_soc"; + $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code=t.type_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code=t.category_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc"; - $sql .= " WHERE t.entity = " . $conf->entity; + $sql .= " WHERE t.entity = ".$conf->entity; // $sql.= " AND e.rowid = er.fk_event"; //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($user->socid) { - $sql .= " AND t.fk_soc= " . $user->socid; + $sql .= " AND t.fk_soc= ".$user->socid; } //$sql.= " AND t.fk_statut > 9"; @@ -151,7 +151,7 @@ class box_last_ticket extends ModeleBoxes $this->info_box_contents[$i][$r] = array( 'td' => '', 'text' => $objp->subject, // Some event have no ref - 'url' => DOL_URL_ROOT."/ticket/card.php?track_id=" . $objp->track_id, + 'url' => DOL_URL_ROOT."/ticket/card.php?track_id=".$objp->track_id, ); $r++; diff --git a/htdocs/core/boxes/box_lastlogin.php b/htdocs/core/boxes/box_lastlogin.php index 7a6c74e216c..6af4468c669 100644 --- a/htdocs/core/boxes/box_lastlogin.php +++ b/htdocs/core/boxes/box_lastlogin.php @@ -30,9 +30,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_lastlogin extends ModeleBoxes { - public $boxcode="lastlogin"; - public $boximg="object_user"; - public $boxlabel='BoxLoginInformation'; + public $boxcode = "lastlogin"; + public $boximg = "object_user"; + public $boxlabel = 'BoxLoginInformation'; public $depends = array("user"); /** @@ -57,7 +57,7 @@ class box_lastlogin extends ModeleBoxes { global $conf; - $this->db=$db; + $this->db = $db; } /** @@ -76,7 +76,7 @@ class box_lastlogin extends ModeleBoxes 'limit'=> dol_strlen($textHead), ); - $line=0; + $line = 0; $this->info_box_contents[$line][0] = array( 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', 'text' => $langs->trans("User"), @@ -87,13 +87,13 @@ class box_lastlogin extends ModeleBoxes 'asis' => 1 ); - $line=1; + $line = 1; $this->info_box_contents[$line][0] = array( 'td' => '', 'text' => $langs->trans("PreviousConnexion"), ); - if ($user->datepreviouslogin) $tmp= dol_print_date($user->datepreviouslogin, "dayhour", 'tzuser'); - else $tmp= $langs->trans("Unknown"); + if ($user->datepreviouslogin) $tmp = dol_print_date($user->datepreviouslogin, "dayhour", 'tzuser'); + else $tmp = $langs->trans("Unknown"); $this->info_box_contents[$line][1] = array( 'td' => '', 'text' => $tmp, diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php index 582b5101aa1..e80c2a57214 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.php @@ -30,10 +30,10 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; class box_services_expired extends ModeleBoxes { - public $boxcode="expiredservices"; // id of box - public $boximg="object_contract"; - public $boxlabel="BoxOldestExpiredServices"; - public $depends = array("contrat"); // conf->propal->enabled + public $boxcode = "expiredservices"; // id of box + public $boximg = "object_contract"; + public $boxlabel = "BoxOldestExpiredServices"; + public $depends = array("contrat"); // conf->propal->enabled /** * @var DoliDB Database handler. @@ -58,7 +58,7 @@ class box_services_expired extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->contrat->lire); + $this->hidden = !($user->rights->contrat->lire); } /** @@ -71,11 +71,11 @@ class box_services_expired extends ModeleBoxes { global $user, $langs, $conf; - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; - $now=dol_now(); + $now = dol_now(); $this->info_box_head = array('text' => $langs->trans("BoxLastExpiredServices", $max)); @@ -83,19 +83,19 @@ class box_services_expired extends ModeleBoxes { // Select contracts with at least one expired service $sql = "SELECT "; - $sql.= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.ref_customer, c.ref_supplier,"; - $sql.= " s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; - $sql.= " MIN(cd.date_fin_validite) as date_line, COUNT(cd.rowid) as nb_services"; - $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe s, ".MAIN_DB_PREFIX."contratdet as cd"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE cd.statut = 4 AND cd.date_fin_validite <= '".$this->db->idate($now)."'"; - $sql.= " AND c.entity = ".$conf->entity; - $sql.= " AND c.fk_soc=s.rowid AND cd.fk_contrat=c.rowid AND c.statut > 0"; - if ($user->socid) $sql.=' AND c.fk_soc = '.$user->socid; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - $sql.= " GROUP BY c.rowid, c.ref, c.statut, c.date_contrat, c.ref_customer, c.ref_supplier, s.nom, s.rowid"; - $sql.= " ORDER BY date_line ASC"; - $sql.= $this->db->plimit($max, 0); + $sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.ref_customer, c.ref_supplier,"; + $sql .= " s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; + $sql .= " MIN(cd.date_fin_validite) as date_line, COUNT(cd.rowid) as nb_services"; + $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe s, ".MAIN_DB_PREFIX."contratdet as cd"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE cd.statut = 4 AND cd.date_fin_validite <= '".$this->db->idate($now)."'"; + $sql .= " AND c.entity = ".$conf->entity; + $sql .= " AND c.fk_soc=s.rowid AND cd.fk_contrat=c.rowid AND c.statut > 0"; + if ($user->socid) $sql .= ' AND c.fk_soc = '.$user->socid; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + $sql .= " GROUP BY c.rowid, c.ref, c.statut, c.date_contrat, c.ref_customer, c.ref_supplier, s.nom, s.rowid"; + $sql .= " ORDER BY date_line ASC"; + $sql .= $this->db->plimit($max, 0); $resql = $this->db->query($sql); if ($resql) @@ -109,7 +109,7 @@ class box_services_expired extends ModeleBoxes while ($i < $num) { - $late=''; + $late = ''; $objp = $this->db->fetch_object($resql); @@ -129,8 +129,8 @@ class box_services_expired extends ModeleBoxes $contract->ref_customer = $objp->ref_customer; $contract->ref_supplier = $objp->ref_supplier; - $dateline=$this->db->jdate($objp->date_line); - if (($dateline + $conf->contrat->services->expires->warning_delay) < $now) $late=img_warning($langs->trans("Late")); + $dateline = $this->db->jdate($objp->date_line); + if (($dateline + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late")); $this->info_box_contents[$i][] = array( 'td' => 'class="nowraponall"', @@ -159,7 +159,7 @@ class box_services_expired extends ModeleBoxes $i++; } - if ($num==0) + if ($num == 0) { $langs->load("contracts"); $this->info_box_contents[$i][] = array( diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 4a55fa24bb3..eb4db331296 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -43,7 +43,7 @@ class FormFile public $error; public $numoffiles; - public $infofiles; // Used to return informations by function getDocumentsLink + public $infofiles; // Used to return informations by function getDocumentsLink /** @@ -54,7 +54,7 @@ class FormFile public function __construct($db) { $this->db = $db; - $this->numoffiles=0; + $this->numoffiles = 0; } @@ -83,17 +83,17 @@ class FormFile public function form_attach_new_file($url, $title = '', $addcancel = 0, $sectionid = 0, $perm = 1, $size = 50, $object = '', $options = '', $useajax = 1, $savingdocmask = '', $linkfiles = 1, $htmlname = 'formuserfile', $accept = '', $sectiondir = '', $usewithoutform = 0) { // phpcs:enable - global $conf,$langs, $hookmanager; + global $conf, $langs, $hookmanager; $hookmanager->initHooks(array('formfile')); // Deprecation warning if ($useajax == 2) { - dol_syslog(__METHOD__ . ": using 2 for useajax is deprecated and should be not used", LOG_WARNING); + dol_syslog(__METHOD__.": using 2 for useajax is deprecated and should be not used", LOG_WARNING); } - if (! empty($conf->browser->layout) && $conf->browser->layout != 'classic') $useajax=0; + if (!empty($conf->browser->layout) && $conf->browser->layout != 'classic') $useajax = 0; - if ((! empty($conf->global->MAIN_USE_JQUERY_FILEUPLOAD) && $useajax) || ($useajax==2)) + if ((!empty($conf->global->MAIN_USE_JQUERY_FILEUPLOAD) && $useajax) || ($useajax == 2)) { // TODO: Check this works with 2 forms on same page // TODO: Check this works with GED module, otherwise, force useajax to 0 @@ -108,12 +108,12 @@ class FormFile return 1; } - $maxlength=$size; + $maxlength = $size; $out = "\n\n\n"; - if (empty($title)) $title=$langs->trans("AttachANewFile"); - if ($title != 'none') $out.=load_fiche_titre($title, null, null); + if (empty($title)) $title = $langs->trans("AttachANewFile"); + if ($title != 'none') $out .= load_fiche_titre($title, null, null); if (empty($usewithoutform)) // Try to avoid this and set instead the form by the caller. { @@ -128,33 +128,33 @@ class FormFile $out .= ''; $out .= ''; - if (! empty($options)) $out .= ''; + if (!empty($options)) $out .= ''; $out .= ''; - if (! empty($options)) $out .= ''; + if (!empty($options)) $out .= ''; $out .= ''; @@ -239,18 +239,18 @@ class FormFile $out .= '
'; $out .= '
'; - if (! empty($conf->global->OPTIMIZEFORTEXTBROWSER)) $out .= ' '; + if (!empty($conf->global->OPTIMIZEFORTEXTBROWSER)) $out .= ' '; $out .= ''; $out .= '
'; $out .= '
'; - if (! empty($conf->global->OPTIMIZEFORTEXTBROWSER)) $out .= ' '; + if (!empty($conf->global->OPTIMIZEFORTEXTBROWSER)) $out .= ' '; $out .= ''; - $out .= ''; - $out .= ''; + $out .= ''; + $out .= ''; $out .= '
'; $out .= '
'; $out .= 'global->MAIN_UPLOAD_DOC) || empty($perm)?' disabled':''); + $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm) ? ' disabled' : ''); $out .= '>'; $out .= '
'; $out .= '
'; @@ -263,11 +263,11 @@ class FormFile $out .= "\n\n"; } - $parameters = array('socid'=>(isset($GLOBALS['socid'])?$GLOBALS['socid']:''), 'id'=>(isset($GLOBALS['id'])?$GLOBALS['id']:''), 'url'=>$url, 'perm'=>$perm); + $parameters = array('socid'=>(isset($GLOBALS['socid']) ? $GLOBALS['socid'] : ''), 'id'=>(isset($GLOBALS['id']) ? $GLOBALS['id'] : ''), 'url'=>$url, 'perm'=>$perm); $res = $hookmanager->executeHooks('formattachOptions', $parameters, $object); if (empty($res)) { - print '
'; + print '
'; print $out; print '
'; } @@ -303,7 +303,7 @@ class FormFile public function show_documents($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed = 0, $modelselected = '', $allowgenifempty = 1, $forcenomultilang = 0, $iconPDF = 0, $notused = 0, $noform = 0, $param = '', $title = '', $buttonlabel = '', $codelang = '') { // phpcs:enable - $this->numoffiles=0; + $this->numoffiles = 0; print $this->showdocuments($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed, $modelselected, $allowgenifempty, $forcenomultilang, $iconPDF, $notused, $noform, $param, $title, $buttonlabel, $codelang); return $this->numoffiles; } @@ -336,57 +336,57 @@ class FormFile public function showdocuments($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed = 0, $modelselected = '', $allowgenifempty = 1, $forcenomultilang = 0, $iconPDF = 0, $notused = 0, $noform = 0, $param = '', $title = '', $buttonlabel = '', $codelang = '', $morepicto = '', $object = null, $hideifempty = 0) { // Deprecation warning - if (! empty($iconPDF)) { - dol_syslog(__METHOD__ . ": passing iconPDF parameter is deprecated", LOG_WARNING); + if (!empty($iconPDF)) { + dol_syslog(__METHOD__.": passing iconPDF parameter is deprecated", LOG_WARNING); } global $langs, $conf, $user, $hookmanager; global $form; - if (! is_object($form)) $form=new Form($this->db); + if (!is_object($form)) $form = new Form($this->db); include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // For backward compatibility - if (! empty($iconPDF)) { + if (!empty($iconPDF)) { return $this->getDocumentsLink($modulepart, $modulesubdir, $filedir); } // Add entity in $param if not already exists if (!preg_match('/entity\=[0-9]+/', $param)) { - $param.= 'entity='.(!empty($object->entity)?$object->entity:$conf->entity); + $param .= 'entity='.(!empty($object->entity) ? $object->entity : $conf->entity); } - $printer=0; + $printer = 0; if (in_array($modulepart, array('facture', 'supplier_proposal', 'propal', 'proposal', 'order', 'commande', 'expedition', 'commande_fournisseur', 'expensereport', 'livraison', 'ticket'))) // The direct print feature is implemented only for such elements { - $printer = (!empty($user->rights->printing->read) && !empty($conf->printing->enabled))?true:false; + $printer = (!empty($user->rights->printing->read) && !empty($conf->printing->enabled)) ?true:false; } $hookmanager->initHooks(array('formfile')); // Get list of files - $file_list=null; - if (! empty($filedir)) + $file_list = null; + if (!empty($filedir)) { - $file_list=dol_dir_list($filedir, 'files', 0, '', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC); + $file_list = dol_dir_list($filedir, 'files', 0, '', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC); } if ($hideifempty && empty($file_list)) return ''; - $out=''; - $forname='builddoc'; - $headershown=0; - $showempty=0; - $i=0; + $out = ''; + $forname = 'builddoc'; + $headershown = 0; + $showempty = 0; + $i = 0; - $out.= "\n".''."\n"; + $out .= "\n".''."\n"; //print 'filedir='.$filedir; if (preg_match('/massfilesarea_/', $modulepart)) { - $out.='

'."\n"; - $title=$langs->trans("MassFilesArea").' ('.$langs->trans("Hide").')'; - $title.=''; } - $titletoshow=$langs->trans("Documents"); - if (! empty($title)) $titletoshow=$title; + $titletoshow = $langs->trans("Documents"); + if (!empty($title)) $titletoshow = $title; // Show table if ($genallowed) { - $modellist=array(); + $modellist = array(); if ($modulepart == 'company') { - $showempty=1; - if (is_array($genallowed)) $modellist=$genallowed; + $showempty = 1; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/societe/modules_societe.class.php'; - $modellist=ModeleThirdPartyDoc::liste_modeles($this->db); + $modellist = ModeleThirdPartyDoc::liste_modeles($this->db); } } elseif ($modulepart == 'propal') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php'; - $modellist=ModelePDFPropales::liste_modeles($this->db); + $modellist = ModelePDFPropales::liste_modeles($this->db); } } elseif ($modulepart == 'supplier_proposal') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_proposal/modules_supplier_proposal.php'; - $modellist=ModelePDFSupplierProposal::liste_modeles($this->db); + $modellist = ModelePDFSupplierProposal::liste_modeles($this->db); } } elseif ($modulepart == 'commande') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php'; - $modellist=ModelePDFCommandes::liste_modeles($this->db); + $modellist = ModelePDFCommandes::liste_modeles($this->db); } } elseif ($modulepart == 'expedition') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php'; - $modellist=ModelePDFExpedition::liste_modeles($this->db); + $modellist = ModelePDFExpedition::liste_modeles($this->db); } } elseif ($modulepart == 'reception') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/reception/modules_reception.php'; @@ -472,195 +472,195 @@ class FormFile } elseif ($modulepart == 'livraison') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/livraison/modules_livraison.php'; - $modellist=ModelePDFDeliveryOrder::liste_modeles($this->db); + $modellist = ModelePDFDeliveryOrder::liste_modeles($this->db); } } elseif ($modulepart == 'ficheinter') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/fichinter/modules_fichinter.php'; - $modellist=ModelePDFFicheinter::liste_modeles($this->db); + $modellist = ModelePDFFicheinter::liste_modeles($this->db); } } elseif ($modulepart == 'facture') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; - $modellist=ModelePDFFactures::liste_modeles($this->db); + $modellist = ModelePDFFactures::liste_modeles($this->db); } } elseif ($modulepart == 'contract') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/contract/modules_contract.php'; - $modellist=ModelePDFContract::liste_modeles($this->db); + $modellist = ModelePDFContract::liste_modeles($this->db); } } elseif ($modulepart == 'project') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php'; - $modellist=ModelePDFProjects::liste_modeles($this->db); + $modellist = ModelePDFProjects::liste_modeles($this->db); } } elseif ($modulepart == 'project_task') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php'; - $modellist=ModelePDFTask::liste_modeles($this->db); + $modellist = ModelePDFTask::liste_modeles($this->db); } } elseif ($modulepart == 'product') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/product/modules_product.class.php'; - $modellist=ModelePDFProduct::liste_modeles($this->db); + $modellist = ModelePDFProduct::liste_modeles($this->db); } } elseif ($modulepart == 'product_batch') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/product_batch/modules_product_batch.class.php'; - $modellist=ModelePDFProductBatch::liste_modeles($this->db); + $modellist = ModelePDFProductBatch::liste_modeles($this->db); } } elseif ($modulepart == 'stock') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/stock/modules_stock.php'; - $modellist=ModelePDFStock::liste_modeles($this->db); + $modellist = ModelePDFStock::liste_modeles($this->db); } } elseif ($modulepart == 'movement') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/stock/modules_movement.php'; - $modellist=ModelePDFMovement::liste_modeles($this->db); + $modellist = ModelePDFMovement::liste_modeles($this->db); } } elseif ($modulepart == 'export') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php'; - $modellist=ModeleExports::liste_modeles($this->db); + $modellist = ModeleExports::liste_modeles($this->db); } } elseif ($modulepart == 'commande_fournisseur' || $modulepart == 'supplier_order') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_order/modules_commandefournisseur.php'; - $modellist=ModelePDFSuppliersOrders::liste_modeles($this->db); + $modellist = ModelePDFSuppliersOrders::liste_modeles($this->db); } } elseif ($modulepart == 'facture_fournisseur' || $modulepart == 'supplier_invoice') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_invoice/modules_facturefournisseur.php'; - $modellist=ModelePDFSuppliersInvoices::liste_modeles($this->db); + $modellist = ModelePDFSuppliersInvoices::liste_modeles($this->db); } } elseif ($modulepart == 'supplier_payment') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_payment/modules_supplier_payment.php'; - $modellist=ModelePDFSuppliersPayments::liste_modeles($this->db); + $modellist = ModelePDFSuppliersPayments::liste_modeles($this->db); } } elseif ($modulepart == 'remisecheque') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/cheque/modules_chequereceipts.php'; - $modellist=ModeleChequeReceipts::liste_modeles($this->db); + $modellist = ModeleChequeReceipts::liste_modeles($this->db); } } elseif ($modulepart == 'donation') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/dons/modules_don.php'; - $modellist=ModeleDon::liste_modeles($this->db); + $modellist = ModeleDon::liste_modeles($this->db); } } elseif ($modulepart == 'member') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/member/modules_cards.php'; - $modellist=ModelePDFCards::liste_modeles($this->db); + $modellist = ModelePDFCards::liste_modeles($this->db); } } elseif ($modulepart == 'agenda' || $modulepart == 'actions') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/action/modules_action.php'; - $modellist=ModeleAction::liste_modeles($this->db); + $modellist = ModeleAction::liste_modeles($this->db); } } elseif ($modulepart == 'expensereport') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/expensereport/modules_expensereport.php'; - $modellist=ModeleExpenseReport::liste_modeles($this->db); + $modellist = ModeleExpenseReport::liste_modeles($this->db); } } elseif ($modulepart == 'unpaid') { - $modellist=''; + $modellist = ''; } elseif ($modulepart == 'user') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/user/modules_user.class.php'; - $modellist=ModelePDFUser::liste_modeles($this->db); + $modellist = ModelePDFUser::liste_modeles($this->db); } } elseif ($modulepart == 'usergroup') { - if (is_array($genallowed)) $modellist=$genallowed; + if (is_array($genallowed)) $modellist = $genallowed; else { include_once DOL_DOCUMENT_ROOT.'/core/modules/usergroup/modules_usergroup.class.php'; - $modellist=ModelePDFUserGroup::liste_modeles($this->db); + $modellist = ModelePDFUserGroup::liste_modeles($this->db); } } else @@ -668,29 +668,29 @@ class FormFile $submodulepart = $modulepart; // modulepart = 'nameofmodule' or 'nameofmodule:nameofsubmodule' - $tmp=explode(':', $modulepart); - if (! empty($tmp[1])) { - $modulepart=$tmp[0]; - $submodulepart=$tmp[1]; + $tmp = explode(':', $modulepart); + if (!empty($tmp[1])) { + $modulepart = $tmp[0]; + $submodulepart = $tmp[1]; } // For normalized standard modules - $file=dol_buildpath('/core/modules/'.$modulepart.'/modules_'.$submodulepart.'.php', 0); + $file = dol_buildpath('/core/modules/'.$modulepart.'/modules_'.$submodulepart.'.php', 0); if (file_exists($file)) { - $res=include_once $file; + $res = include_once $file; } // For normalized external modules. else { - $file=dol_buildpath('/'.$modulepart.'/core/modules/'.$modulepart.'/modules_'.$submodulepart.'.php', 0); - $res=include_once $file; + $file = dol_buildpath('/'.$modulepart.'/core/modules/'.$modulepart.'/modules_'.$submodulepart.'.php', 0); + $res = include_once $file; } - $class='ModelePDF'.ucfirst($submodulepart); + $class = 'ModelePDF'.ucfirst($submodulepart); if (class_exists($class)) { - $modellist=call_user_func($class.'::liste_modeles', $this->db); + $modellist = call_user_func($class.'::liste_modeles', $this->db); } else { @@ -700,80 +700,80 @@ class FormFile } // Set headershown to avoid to have table opened a second time later - $headershown=1; + $headershown = 1; - if (empty($buttonlabel)) $buttonlabel=$langs->trans('Generate'); + if (empty($buttonlabel)) $buttonlabel = $langs->trans('Generate'); - if ($conf->browser->layout == 'phone') $urlsource.='#'.$forname.'_form'; // So we switch to form after a generation - if (empty($noform)) $out.= '
'; - $out.= ''; - $out.= ''; + if ($conf->browser->layout == 'phone') $urlsource .= '#'.$forname.'_form'; // So we switch to form after a generation + if (empty($noform)) $out .= ''; + $out .= ''; + $out .= ''; - $out.= load_fiche_titre($titletoshow, '', ''); - $out.= '
'; - $out.= '
'.$options.''.$options.''; - $max=$conf->global->MAIN_UPLOAD_DOC; // In Kb - $maxphp=@ini_get('upload_max_filesize'); // In unknown - if (preg_match('/k$/i', $maxphp)) $maxphp=$maxphp*1; - if (preg_match('/m$/i', $maxphp)) $maxphp=$maxphp*1024; - if (preg_match('/g$/i', $maxphp)) $maxphp=$maxphp*1024*1024; - if (preg_match('/t$/i', $maxphp)) $maxphp=$maxphp*1024*1024*1024; - $maxphp2=@ini_get('post_max_size'); // In unknown - if (preg_match('/k$/i', $maxphp2)) $maxphp2=$maxphp2*1; - if (preg_match('/m$/i', $maxphp2)) $maxphp2=$maxphp2*1024; - if (preg_match('/g$/i', $maxphp2)) $maxphp2=$maxphp2*1024*1024; - if (preg_match('/t$/i', $maxphp2)) $maxphp2=$maxphp2*1024*1024*1024; + $max = $conf->global->MAIN_UPLOAD_DOC; // In Kb + $maxphp = @ini_get('upload_max_filesize'); // In unknown + if (preg_match('/k$/i', $maxphp)) $maxphp = $maxphp * 1; + if (preg_match('/m$/i', $maxphp)) $maxphp = $maxphp * 1024; + if (preg_match('/g$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024; + if (preg_match('/t$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024 * 1024; + $maxphp2 = @ini_get('post_max_size'); // In unknown + if (preg_match('/k$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1; + if (preg_match('/m$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024; + if (preg_match('/g$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024 * 1024; + if (preg_match('/t$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024 * 1024 * 1024; // Now $max and $maxphp and $maxphp2 are in Kb $maxmin = $max; $maxphptoshow = $maxphptoshowparam = ''; if ($maxphp > 0) { - $maxmin=min($max, $maxphp); + $maxmin = min($max, $maxphp); $maxphptoshow = $maxphp; $maxphptoshowparam = 'upload_max_filesize'; } if ($maxphp2 > 0) { - $maxmin=min($max, $maxphp2); + $maxmin = min($max, $maxphp2); if ($maxphp2 < $maxphp) { $maxphptoshow = $maxphp2; @@ -165,17 +165,17 @@ class FormFile if ($maxmin > 0) { // MAX_FILE_SIZE doit précéder le champ input de type file - $out .= ''; + $out .= ''; } $out .= 'global->MAIN_DISABLE_MULTIPLE_FILEUPLOAD) || $conf->browser->layout != 'classic')?' name="userfile"':' name="userfile[]" multiple'); - $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm)?' disabled':''); - $out .= (!empty($accept)?' accept="'.$accept.'"':' accept=""'); + $out .= ((!empty($conf->global->MAIN_DISABLE_MULTIPLE_FILEUPLOAD) || $conf->browser->layout != 'classic') ? ' name="userfile"' : ' name="userfile[]" multiple'); + $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm) ? ' disabled' : ''); + $out .= (!empty($accept) ? ' accept="'.$accept.'"' : ' accept=""'); $out .= '>'; $out .= ' '; $out .= 'global->MAIN_UPLOAD_DOC) || empty($perm)?' disabled':''); + $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm) ? ' disabled' : ''); $out .= '>'; if ($addcancel) @@ -184,7 +184,7 @@ class FormFile $out .= ''; } - if (! empty($conf->global->MAIN_UPLOAD_DOC)) + if (!empty($conf->global->MAIN_UPLOAD_DOC)) { if ($perm) { @@ -202,10 +202,10 @@ class FormFile if ($savingdocmask) { //add a global variable for disable the auto renaming on upload - $rename=(empty($conf->global->MAIN_DOC_UPLOAD_NOT_RENAME_BY_DEFAULT)?'checked':''); + $rename = (empty($conf->global->MAIN_DOC_UPLOAD_NOT_RENAME_BY_DEFAULT) ? 'checked' : ''); $out .= '
'.$options.''.$options.''; $out .= ' '.$langs->trans("SaveUploadedFileWithMask", preg_replace('/__file__/', $langs->transnoentitiesnoconv("OriginFileName"), $savingdocmask), $langs->transnoentitiesnoconv("OriginFileName")); $out .= '
'; + $out .= load_fiche_titre($titletoshow, '', ''); + $out .= '
'; + $out .= '
'; - $out.= ''; + $out .= ''; - $addcolumforpicto=($delallowed || $printer || $morepicto); - $colspan = (3+($addcolumforpicto?1:0)); $colspanmore = 0; + $addcolumforpicto = ($delallowed || $printer || $morepicto); + $colspan = (3 + ($addcolumforpicto ? 1 : 0)); $colspanmore = 0; - $out.= ''; + if (!$allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') $genbutton = ''; + if (empty($modellist) && !$showempty && $modulepart != 'unpaid') $genbutton = ''; + $out .= $genbutton; + $out .= ''; if (!empty($hookmanager->hooks['formfile'])) { - foreach($hookmanager->hooks['formfile'] as $module) + foreach ($hookmanager->hooks['formfile'] as $module) { if (method_exists($module, 'formBuilddocLineOptions')) { @@ -782,116 +782,116 @@ class FormFile } } } - $out.= ''; + $out .= ''; // Execute hooks - $parameters=array('colspan'=>($colspan+$colspanmore), 'socid'=>(isset($GLOBALS['socid'])?$GLOBALS['socid']:''), 'id'=>(isset($GLOBALS['id'])?$GLOBALS['id']:''), 'modulepart'=>$modulepart); + $parameters = array('colspan'=>($colspan + $colspanmore), 'socid'=>(isset($GLOBALS['socid']) ? $GLOBALS['socid'] : ''), 'id'=>(isset($GLOBALS['id']) ? $GLOBALS['id'] : ''), 'modulepart'=>$modulepart); if (is_object($hookmanager)) { $reshook = $hookmanager->executeHooks('formBuilddocOptions', $parameters, $GLOBALS['object']); - $out.= $hookmanager->resPrint; + $out .= $hookmanager->resPrint; } } // Get list of files - if (! empty($filedir)) + if (!empty($filedir)) { $link_list = array(); if (is_object($object)) { - require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; $link = new Link($this->db); $sortfield = $sortorder = null; $res = $link->fetchAll($link_list, $object->element, $object->id, $sortfield, $sortorder); } - $out.= ''."\n"; + $out .= ''."\n"; // Show title of array if not already shown - if ((! empty($file_list) || ! empty($link_list) || preg_match('/^massfilesarea/', $modulepart)) - && ! $headershown) + if ((!empty($file_list) || !empty($link_list) || preg_match('/^massfilesarea/', $modulepart)) + && !$headershown) { - $headershown=1; - $out.= '
'.$titletoshow.'
'."\n"; - $out.= '
'; - $out.= '
'; + $out .= ''; // Model - if (! empty($modellist)) + if (!empty($modellist)) { asort($modellist); - $out.= ''.$langs->trans('Model').' '; + $out .= ''.$langs->trans('Model').' '; if (is_array($modellist) && count($modellist) == 1) // If there is only one element { - $arraykeys=array_keys($modellist); - $modelselected=$arraykeys[0]; + $arraykeys = array_keys($modellist); + $modelselected = $arraykeys[0]; } - $out.= $form->selectarray('model', $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100'); + $out .= $form->selectarray('model', $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100'); if ($conf->use_javascript_ajax) { - $out.= ajax_combobox('model'); + $out .= ajax_combobox('model'); } } else { - $out.= '
'.$langs->trans("Files").'
'; + $out .= '
'.$langs->trans("Files").'
'; } // Language code (if multilang) - if (($allowgenifempty || (is_array($modellist) && count($modellist) > 0)) && $conf->global->MAIN_MULTILANGS && ! $forcenomultilang && (! empty($modellist) || $showempty)) + if (($allowgenifempty || (is_array($modellist) && count($modellist) > 0)) && $conf->global->MAIN_MULTILANGS && !$forcenomultilang && (!empty($modellist) || $showempty)) { include_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; - $formadmin=new FormAdmin($this->db); - $defaultlang=$codelang?$codelang:$langs->getDefaultLang(); - $morecss='maxwidth150'; - if ($conf->browser->layout == 'phone') $morecss='maxwidth100'; - $out.= $formadmin->select_language($defaultlang, 'lang_id', 0, 0, 0, 0, 0, $morecss); + $formadmin = new FormAdmin($this->db); + $defaultlang = $codelang ? $codelang : $langs->getDefaultLang(); + $morecss = 'maxwidth150'; + if ($conf->browser->layout == 'phone') $morecss = 'maxwidth100'; + $out .= $formadmin->select_language($defaultlang, 'lang_id', 0, 0, 0, 0, 0, $morecss); } else { - $out.= ' '; + $out .= ' '; } // Button $genbutton = 'dol_no_mouse_hover) && $modulepart != 'unpaid') + $genbutton .= ' type="submit" value="'.$buttonlabel.'"'; + if (!$allowgenifempty && !is_array($modellist) && empty($modellist)) $genbutton .= ' disabled'; + $genbutton .= '>'; + if ($allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') { $langs->load("errors"); - $genbutton.= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated")); + $genbutton .= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated")); } - if (! $allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') $genbutton=''; - if (empty($modellist) && ! $showempty && $modulepart != 'unpaid') $genbutton=''; - $out.= $genbutton; - $out.= '
'."\n"; + $headershown = 1; + $out .= '
'.$titletoshow.'
'."\n"; + $out .= '
'; + $out .= '
'."\n"; } // Loop on each file found if (is_array($file_list)) { - foreach($file_list as $file) + foreach ($file_list as $file) { // Define relative path for download link (depends on module) - $relativepath=$file["name"]; // Cas general - if ($modulesubdir) $relativepath=$modulesubdir."/".$file["name"]; // Cas propal, facture... - if ($modulepart == 'export') $relativepath = $file["name"]; // Other case + $relativepath = $file["name"]; // Cas general + if ($modulesubdir) $relativepath = $modulesubdir."/".$file["name"]; // Cas propal, facture... + if ($modulepart == 'export') $relativepath = $file["name"]; // Other case - $out.= ''; + $out .= ''; $documenturl = DOL_URL_ROOT.'/document.php'; - if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl=$conf->global->DOL_URL_ROOT_DOCUMENT_PHP; // To use another wrapper + if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl = $conf->global->DOL_URL_ROOT_DOCUMENT_PHP; // To use another wrapper // Show file name with link to download - $out.= ''; + $mime = dol_mimetype($relativepath, '', 0); + if (preg_match('/text/', $mime)) $out .= ' target="_blank"'; + $out .= '>'; + $out .= img_mime($file["name"], $langs->trans("File").': '.$file["name"]); + $out .= dol_trunc($file["name"], 150); + $out .= ''."\n"; + $out .= $this->showPreview($file, $modulepart, $relativepath, 0, $param); + $out .= ''; // Show file size - $size=(! empty($file['size'])?$file['size']:dol_filesize($filedir."/".$file["name"])); - $out.= ''; + $size = (!empty($file['size']) ? $file['size'] : dol_filesize($filedir."/".$file["name"])); + $out .= ''; // Show file date - $date=(! empty($file['date'])?$file['date']:dol_filemtime($filedir."/".$file["name"])); - $out.= ''; + $date = (!empty($file['date']) ? $file['date'] : dol_filemtime($filedir."/".$file["name"])); + $out .= ''; if ($delallowed || $printer || $morepicto) { - $out.= ''; + $out .= ''; } if (is_object($hookmanager)) { - $parameters=array('colspan'=>($colspan+$colspanmore), 'socid'=>(isset($GLOBALS['socid'])?$GLOBALS['socid']:''),'id'=>(isset($GLOBALS['id'])?$GLOBALS['id']:''),'modulepart'=>$modulepart,'relativepath'=>$relativepath); + $parameters = array('colspan'=>($colspan + $colspanmore), 'socid'=>(isset($GLOBALS['socid']) ? $GLOBALS['socid'] : ''), 'id'=>(isset($GLOBALS['id']) ? $GLOBALS['id'] : ''), 'modulepart'=>$modulepart, 'relativepath'=>$relativepath); $res = $hookmanager->executeHooks('formBuilddocLineOptions', $parameters, $file); if (empty($res)) { - $out.= $hookmanager->resPrint; // Complete line - $out.= ''; + $out .= $hookmanager->resPrint; // Complete line + $out .= ''; } else { - $out = $hookmanager->resPrint; // Replace all $out + $out = $hookmanager->resPrint; // Replace all $out } } } @@ -901,42 +901,42 @@ class FormFile // Loop on each link found if (is_array($link_list)) { - $colspan=2; + $colspan = 2; - foreach($link_list as $file) + foreach ($link_list as $file) { - $out.=''; - $out.=''; - $out.=''; - if ($delallowed || $printer || $morepicto) $out.=''; - $out.=''."\n"; + $out .= ''; + $out .= ''; + $out .= ''; + if ($delallowed || $printer || $morepicto) $out .= ''; + $out .= ''."\n"; } $this->numoffiles++; } if (count($file_list) == 0 && count($link_list) == 0 && $headershown) { - $out.=''."\n"; + $out .= ''."\n"; } } if ($headershown) { // Affiche pied du tableau - $out.= "
'; - $out.= 'trans("File").': '.$file["name"]); - $out.= dol_trunc($file["name"], 150); - $out.= ''."\n"; - $out.= $this->showPreview($file, $modulepart, $relativepath, 0, $param); - $out.= ''.dol_print_size($size, 1, 1).''.dol_print_size($size, 1, 1).''.dol_print_date($date, 'dayhour', 'tzuser').''.dol_print_date($date, 'dayhour', 'tzuser').''; + $out .= ''; if ($delallowed) { $tmpurlsource = preg_replace('/#[a-zA-Z0-9_]*$/', '', $urlsource); - $out.= 'trans("Delete"), 'delete').''; + $out .= '">'.img_picto($langs->trans("Delete"), 'delete').''; } if ($printer) { //$out.= ''; - $out.= ''.img_picto($langs->trans("PrintFile", $relativepath), 'printer.png').''; + $out .= ''.img_picto($langs->trans("PrintFile", $relativepath), 'printer.png').''; } if ($morepicto) { - $morepicto=preg_replace('/__FILENAMEURLENCODED__/', urlencode($relativepath), $morepicto); - $out.=$morepicto; + $morepicto = preg_replace('/__FILENAMEURLENCODED__/', urlencode($relativepath), $morepicto); + $out .= $morepicto; } - $out.='
'; - $out.=''; - $out.=$file->label; - $out.=''; - $out.=''; - $out.=dol_print_date($file->datea, 'dayhour'); - $out.='
'; + $out .= ''; + $out .= $file->label; + $out .= ''; + $out .= ''; + $out .= dol_print_date($file->datea, 'dayhour'); + $out .= '
'.$langs->trans("None").'
'.$langs->trans("None").'
\n"; - $out.= "
\n"; + $out .= "\n"; + $out .= "
\n"; if ($genallowed) { - if (empty($noform)) $out.= ''."\n"; + if (empty($noform)) $out .= ''."\n"; } } - $out.= ''."\n"; + $out .= ''."\n"; //return ($i?$i:$headershown); return $out; } @@ -958,21 +958,21 @@ class FormFile include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $out=''; - $this->infofiles=array('nboffiles'=>0,'extensions'=>array(),'files'=>array()); + $out = ''; + $this->infofiles = array('nboffiles'=>0, 'extensions'=>array(), 'files'=>array()); $entity = 1; // Without multicompany // Get object entity - if (! empty($conf->multicompany->enabled)) + if (!empty($conf->multicompany->enabled)) { preg_match('/\/([0-9]+)\/[^\/]+\/'.preg_quote($modulesubdir, '/').'$/', $filedir, $regs); - $entity = ((! empty($regs[1]) && $regs[1] > 1) ? $regs[1] : 1); // If entity id not found in $filedir this is entity 1 by default + $entity = ((!empty($regs[1]) && $regs[1] > 1) ? $regs[1] : 1); // If entity id not found in $filedir this is entity 1 by default } // Get list of files starting with name of ref (but not followed by "-" to discard uploaded files and get only generated files) // @TODO Why not showing by default all files by just removing the '[^\-]+' at end of regex ? - if (! empty($conf->global->MAIN_SHOW_ALL_FILES_ON_DOCUMENT_TOOLTIP)) + if (!empty($conf->global->MAIN_SHOW_ALL_FILES_ON_DOCUMENT_TOOLTIP)) { $filterforfilesearch = preg_quote(basename($modulesubdir), '/'); } @@ -980,70 +980,70 @@ class FormFile { $filterforfilesearch = preg_quote(basename($modulesubdir), '/').'[^\-]+'; } - $file_list=dol_dir_list($filedir, 'files', 0, $filterforfilesearch, '\.meta$|\.png$'); // We also discard .meta and .png preview + $file_list = dol_dir_list($filedir, 'files', 0, $filterforfilesearch, '\.meta$|\.png$'); // We also discard .meta and .png preview //var_dump($file_list); // For ajax treatment - $out.= ''."\n"; - if (! empty($file_list)) + $out .= ''."\n"; + if (!empty($file_list)) { - $out='
'; - if (! $found) $out=''; + if (!$found) $out = ''; } else { @@ -1098,21 +1098,21 @@ class FormFile if ($disablecrop == -1) { - $disablecrop=1; - if (in_array($modulepart, array('bank','bom','expensereport','holiday','member','project','product','produit','service','societe','tax','ticket','user'))) $disablecrop=0; + $disablecrop = 1; + if (in_array($modulepart, array('bank', 'bom', 'expensereport', 'holiday', 'member', 'project', 'product', 'produit', 'service', 'societe', 'tax', 'ticket', 'user'))) $disablecrop = 0; } // Define relative path used to store the file if (empty($relativepath)) { - $relativepath=(! empty($object->ref)?dol_sanitizeFileName($object->ref):'').'/'; - if ($object->element == 'invoice_supplier') $relativepath=get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').$relativepath; // TODO Call using a defined value for $relativepath - if ($object->element == 'project_task') $relativepath='Call_not_supported_._Call_function_using_a_defined_relative_path_.'; + $relativepath = (!empty($object->ref) ?dol_sanitizeFileName($object->ref) : '').'/'; + if ($object->element == 'invoice_supplier') $relativepath = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').$relativepath; // TODO Call using a defined value for $relativepath + if ($object->element == 'project_task') $relativepath = 'Call_not_supported_._Call_function_using_a_defined_relative_path_.'; } // For backward compatiblity, we detect file stored into an old path - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO) && $filearray[0]['level1name'] == 'photos') + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO) && $filearray[0]['level1name'] == 'photos') { - $relativepath=preg_replace('/^.*\/produit\//', '', $filearray[0]['path']).'/'; + $relativepath = preg_replace('/^.*\/produit\//', '', $filearray[0]['path']).'/'; } // Defined relative dir to DOL_DATA_ROOT $relativedir = ''; @@ -1123,13 +1123,13 @@ class FormFile } $hookmanager->initHooks(array('formfile')); - $parameters=array( + $parameters = array( 'filearray' => $filearray, 'modulepart'=> $modulepart, 'param' => $param, 'forcedownload' => $forcedownload, - 'relativepath' => $relativepath, // relative filename to module dir - 'relativedir' => $relativedir, // relative dirname to DOL_DATA_ROOT + 'relativepath' => $relativepath, // relative filename to module dir + 'relativedir' => $relativedir, // relative dirname to DOL_DATA_ROOT 'permtodelete' => $permonobject, 'useinecm' => $useinecm, 'textifempty' => $textifempty, @@ -1137,7 +1137,7 @@ class FormFile 'title' => $title, 'url' => $url ); - $reshook=$hookmanager->executeHooks('showFilesList', $parameters, $object); + $reshook = $hookmanager->executeHooks('showFilesList', $parameters, $object); if (isset($reshook) && $reshook != '') // null or '' for bypass { @@ -1145,34 +1145,34 @@ class FormFile } else { - if (! is_object($form)) + if (!is_object($form)) { - include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; // The compoent may be included into ajax page that does not include the Form class - $form=new Form($this->db); + include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; // The compoent may be included into ajax page that does not include the Form class + $form = new Form($this->db); } - if (! preg_match('/&id=/', $param) && isset($object->id)) $param.='&id='.$object->id; - $relativepathwihtoutslashend=preg_replace('/\/$/', '', $relativepath); - if ($relativepathwihtoutslashend) $param.= '&file='.urlencode($relativepathwihtoutslashend); + if (!preg_match('/&id=/', $param) && isset($object->id)) $param .= '&id='.$object->id; + $relativepathwihtoutslashend = preg_replace('/\/$/', '', $relativepath); + if ($relativepathwihtoutslashend) $param .= '&file='.urlencode($relativepathwihtoutslashend); if ($permtoeditline < 0) // Old behaviour for backward compatibility. New feature should call method with value 0 or 1 { - $permtoeditline=0; - if (in_array($modulepart, array('product','produit','service'))) + $permtoeditline = 0; + if (in_array($modulepart, array('product', 'produit', 'service'))) { - if ($user->rights->produit->creer && $object->type == Product::TYPE_PRODUCT) $permtoeditline=1; - if ($user->rights->service->creer && $object->type == Product::TYPE_SERVICE) $permtoeditline=1; + if ($user->rights->produit->creer && $object->type == Product::TYPE_PRODUCT) $permtoeditline = 1; + if ($user->rights->service->creer && $object->type == Product::TYPE_SERVICE) $permtoeditline = 1; } } if (empty($conf->global->MAIN_UPLOAD_DOC)) { - $permtoeditline=0; - $permonobject=0; + $permtoeditline = 0; + $permonobject = 0; } // Show list of existing files - if ((empty($useinecm) || $useinecm == 6) && $title != 'none') print load_fiche_titre($title?$title:$langs->trans("AttachedFiles")); - if (empty($url)) $url=$_SERVER["PHP_SELF"]; + if ((empty($useinecm) || $useinecm == 6) && $title != 'none') print load_fiche_titre($title ? $title : $langs->trans("AttachedFiles")); + if (empty($url)) $url = $_SERVER["PHP_SELF"]; print ''."\n"; if (GETPOST('action', 'aZ09') == 'editfile' && $permtoeditline) @@ -1187,7 +1187,7 @@ class FormFile print '
'; print ''."\n"; - if (! empty($addfilterfields)) + if (!empty($addfilterfields)) { print ''; print ''; @@ -1196,7 +1196,7 @@ class FormFile if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6) print ''; print ''; print ''; - if (! $disablemove) print ''; + if (!$disablemove) print ''; print "\n"; } @@ -1205,10 +1205,10 @@ class FormFile print_liste_field_titre('Documents2', $url, "name", "", $param, '', $sortfield, $sortorder, 'left '); print_liste_field_titre('Size', $url, "size", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre('Date', $url, "date", "", $param, '', $sortfield, $sortorder, 'center '); - if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6) print_liste_field_titre('', $url, "", "", $param, '', $sortfield, $sortorder, 'center '); // Preview + if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6) print_liste_field_titre('', $url, "", "", $param, '', $sortfield, $sortorder, 'center '); // Preview print_liste_field_titre(''); print_liste_field_titre(''); - if (! $disablemove) print_liste_field_titre(''); + if (!$disablemove) print_liste_field_titre(''); print "\n"; // Get list of files stored into database for same relative directory @@ -1219,29 +1219,29 @@ class FormFile //var_dump($sortfield.' - '.$sortorder); if ($sortfield && $sortorder) // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name) { - $filearray=dol_sort_array($filearray, $sortfield, $sortorder); + $filearray = dol_sort_array($filearray, $sortfield, $sortorder); } } - $nboffiles=count($filearray); + $nboffiles = count($filearray); if ($nboffiles > 0) include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; - $i=0; $nboflines = 0; $lastrowid=0; - foreach($filearray as $key => $file) // filearray must be only files here + $i = 0; $nboflines = 0; $lastrowid = 0; + foreach ($filearray as $key => $file) // filearray must be only files here { if ($file['name'] != '.' && $file['name'] != '..' - && ! preg_match('/\.meta$/i', $file['name'])) + && !preg_match('/\.meta$/i', $file['name'])) { if ($filearray[$key]['rowid'] > 0) $lastrowid = $filearray[$key]['rowid']; - $filepath=$relativepath.$file['name']; + $filepath = $relativepath.$file['name']; - $editline=0; + $editline = 0; $nboflines++; print ''."\n"; // Do we have entry into database ? print ''."\n"; - print ''; + print ''; // File name print '\n"; @@ -1287,10 +1287,10 @@ class FormFile print ''; // Date - print ''; // 140px = width for date with PM format + print ''; // 140px = width for date with PM format // Preview - if (empty($useinecm) || $useinecm == 4 || $useinecm == 5|| $useinecm == 6) + if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6) { $fileinfo = pathinfo($file['name']); print ''; // Actions buttons - if (! $editline) + if (!$editline) { // Delete or view link // ($param must start with &) @@ -1370,10 +1370,10 @@ class FormFile } if (empty($useinecm) || $useinecm == 2 || $useinecm == 6) { - $newmodulepart=$modulepart; - if (in_array($modulepart, array('product','produit','service'))) $newmodulepart='produit|service'; + $newmodulepart = $modulepart; + if (in_array($modulepart, array('product', 'produit', 'service'))) $newmodulepart = 'produit|service'; - if (! $disablecrop && image_format_supported($file['name']) > 0) + if (!$disablecrop && image_format_supported($file['name']) > 0) { if ($permtoeditline) { @@ -1384,17 +1384,17 @@ class FormFile if ($permtoeditline) { - $paramsectiondir=(in_array($modulepart, array('medias','ecm'))?'§ion_dir='.urlencode($relativepath):''); - print ''.img_edit('default', 0, 'class="paddingrightonly"').''; + $paramsectiondir = (in_array($modulepart, array('medias', 'ecm')) ? '§ion_dir='.urlencode($relativepath) : ''); + print ''.img_edit('default', 0, 'class="paddingrightonly"').''; } } if ($permonobject) { - $useajax=1; - if (! empty($conf->dol_use_jmobile)) $useajax=0; - if (empty($conf->use_javascript_ajax)) $useajax=0; - if (! empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax=0; - print ''.img_delete().''; + $useajax = 1; + if (!empty($conf->dol_use_jmobile)) $useajax = 0; + if (empty($conf->use_javascript_ajax)) $useajax = 0; + if (!empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax = 0; + print ''.img_delete().''; } print ""; @@ -1405,13 +1405,13 @@ class FormFile if ($i > 0) { print 'id.'">'.img_up('default', 0, 'imgupforline').''; } - if ($i < $nboffiles-1) { + if ($i < $nboffiles - 1) { print 'id.'">'.img_down('default', 0, 'imgdownforline').''; } print ''; } else { - print 'browser->layout != 'phone' && empty($disablemove)) ?' class="linecolmove tdlineupdown center"':' class="linecolmove center"').'>'; + print 'browser->layout != 'phone' && empty($disablemove)) ? ' class="linecolmove tdlineupdown center"' : ' class="linecolmove center"').'>'; print ''; } } @@ -1432,8 +1432,8 @@ class FormFile } if ($nboffiles == 0) { - $colspan='6'; - if (empty($disablemove)) $colspan++; // 6 columns or 7 + $colspan = '6'; + if (empty($disablemove)) $colspan++; // 6 columns or 7 print ''; @@ -2092,16 +2092,16 @@ elseif (! empty($object->id)) print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); print ''; if ($action != 'editmulticurrencyrate' && $object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) - print ''; + print ''; print '
'; @@ -1250,7 +1250,7 @@ class FormFile //print "XX".$file['name']; //$file['name'] must be utf8 print ''; print img_mime($file['name'], $file['name'].' ('.dol_print_size($file['size'], 0, 0).')', 'inline-block valignbottom paddingright'); @@ -1259,11 +1259,11 @@ class FormFile if (GETPOST('action', 'aZ09') == 'editfile' && $file['name'] == basename(GETPOST('urlfile', 'alpha'))) { print ''; - $section_dir=dirname(GETPOST('urlfile', 'alpha')); + $section_dir = dirname(GETPOST('urlfile', 'alpha')); print ''; print ''; print ''; - $editline=1; + $editline = 1; } else { @@ -1271,7 +1271,7 @@ class FormFile print ''; } // Preview link - if (! $editline) print $this->showPreview($file, $modulepart, $filepath, 0, '&entity='.(! empty($object->entity)?$object->entity:$conf->entity)); + if (!$editline) print $this->showPreview($file, $modulepart, $filepath, 0, '&entity='.(!empty($object->entity) ? $object->entity : $conf->entity)); print "'.dol_print_date($file['date'], "dayhour", "tzuser").''.dol_print_date($file['date'], "dayhour", "tzuser").''; @@ -1298,23 +1298,23 @@ class FormFile { if ($useinecm == 5 || $useinecm == 6) { - $smallfile=getImageFileNameForSize($file['name'], ''); // There is no thumb for ECM module and Media filemanager, so we use true image + $smallfile = getImageFileNameForSize($file['name'], ''); // There is no thumb for ECM module and Media filemanager, so we use true image } else { - $smallfile=getImageFileNameForSize($file['name'], '_small'); // For new thumbs using same ext (in lower case however) than original + $smallfile = getImageFileNameForSize($file['name'], '_small'); // For new thumbs using same ext (in lower case however) than original } - if (! dol_is_file($file['path'].'/'.$smallfile)) $smallfile=getImageFileNameForSize($file['name'], '_small', '.png'); // For backward compatibility of old thumbs that were created with filename in lower case and with .png extension + if (!dol_is_file($file['path'].'/'.$smallfile)) $smallfile = getImageFileNameForSize($file['name'], '_small', '.png'); // For backward compatibility of old thumbs that were created with filename in lower case and with .png extension //print $file['path'].'/'.$smallfile.'
'; - $urlforhref=getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity)?$object->entity:$conf->entity)); + $urlforhref = getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity) ? $object->entity : $conf->entity)); if (empty($urlforhref)) { - $urlforhref=DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity)?$object->entity:$conf->entity).'&file='.urlencode($relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension'])); + $urlforhref = DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity).'&file='.urlencode($relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension'])); print ''; } else { print ''; } - print ''; + print ''; print ''; } else print ' '; @@ -1328,24 +1328,24 @@ class FormFile if ($editline) { print $langs->trans("FileSharedViaALink").' '; - print ' '; + print ' '; } else { if ($file['share']) { // Define $urlwithroot - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current //print ''.$langs->trans("Hash").' : '.$file['share'].''; - $forcedownload=0; - $paramlink=''; - if (! empty($file['share'])) $paramlink.=($paramlink?'&':'').'hashp='.$file['share']; // Hash for public share - if ($forcedownload) $paramlink.=($paramlink?'&':'').'attachment=1'; + $forcedownload = 0; + $paramlink = ''; + if (!empty($file['share'])) $paramlink .= ($paramlink ? '&' : '').'hashp='.$file['share']; // Hash for public share + if ($forcedownload) $paramlink .= ($paramlink ? '&' : '').'attachment=1'; - $fulllink=$urlwithroot.'/document.php'.($paramlink?'?'.$paramlink:''); + $fulllink = $urlwithroot.'/document.php'.($paramlink ? '?'.$paramlink : ''); print img_picto($langs->trans("FileSharedViaALink"), 'globe').' '; print ''; @@ -1359,7 +1359,7 @@ class FormFile print '
'; if (empty($textifempty)) print $langs->trans("NoFileFound"); else print $textifempty; @@ -1443,9 +1443,9 @@ class FormFile print ''; if ($nboflines > 1 && is_object($object)) { - if (! empty($conf->use_javascript_ajax) && $permtoeditline) { + if (!empty($conf->use_javascript_ajax) && $permtoeditline) { $table_element_line = 'ecm_files'; - include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } } @@ -1491,9 +1491,9 @@ class FormFile // Show list of documents if (empty($useinecm) || $useinecm == 6) print load_fiche_titre($langs->trans("AttachedFiles")); - if (empty($url)) $url=$_SERVER["PHP_SELF"]; + if (empty($url)) $url = $_SERVER["PHP_SELF"]; - if (! empty($addfilterfields)) + if (!empty($addfilterfields)) { print '
'; print ''; @@ -1503,7 +1503,7 @@ class FormFile print '
'; print ''."\n"; - if (! empty($addfilterfields)) + if (!empty($addfilterfields)) { print ''; print ''; @@ -1512,15 +1512,15 @@ class FormFile print ''; // Action column print ''; print "\n"; } print ''; - $sortref="fullname"; - if ($modulepart == 'invoice_supplier') $sortref='level1name'; + $sortref = "fullname"; + if ($modulepart == 'invoice_supplier') $sortref = 'level1name'; print_liste_field_titre("Ref", $url, $sortref, "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Documents2", $url, "name", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Size", $url, "size", "", $param, '', $sortfield, $sortorder, 'right '); @@ -1532,115 +1532,115 @@ class FormFile if ($modulepart == 'company') { include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $object_instance=new Societe($this->db); + $object_instance = new Societe($this->db); } elseif ($modulepart == 'invoice') { include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $object_instance=new Facture($this->db); + $object_instance = new Facture($this->db); } elseif ($modulepart == 'invoice_supplier') { include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $object_instance=new FactureFournisseur($this->db); + $object_instance = new FactureFournisseur($this->db); } elseif ($modulepart == 'propal') { include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - $object_instance=new Propal($this->db); + $object_instance = new Propal($this->db); } elseif ($modulepart == 'supplier_proposal') { include_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; - $object_instance=new SupplierProposal($this->db); + $object_instance = new SupplierProposal($this->db); } elseif ($modulepart == 'order') { include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - $object_instance=new Commande($this->db); + $object_instance = new Commande($this->db); } elseif ($modulepart == 'order_supplier') { include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; - $object_instance=new CommandeFournisseur($this->db); + $object_instance = new CommandeFournisseur($this->db); } elseif ($modulepart == 'contract') { include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; - $object_instance=new Contrat($this->db); + $object_instance = new Contrat($this->db); } elseif ($modulepart == 'product') { include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - $object_instance=new Product($this->db); + $object_instance = new Product($this->db); } elseif ($modulepart == 'tax') { include_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; - $object_instance=new ChargeSociales($this->db); + $object_instance = new ChargeSociales($this->db); } elseif ($modulepart == 'project') { include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - $object_instance=new Project($this->db); + $object_instance = new Project($this->db); } elseif ($modulepart == 'fichinter') { include_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; - $object_instance=new Fichinter($this->db); + $object_instance = new Fichinter($this->db); } elseif ($modulepart == 'user') { include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; - $object_instance=new User($this->db); + $object_instance = new User($this->db); } elseif ($modulepart == 'expensereport') { include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; - $object_instance=new ExpenseReport($this->db); + $object_instance = new ExpenseReport($this->db); } elseif ($modulepart == 'holiday') { include_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; - $object_instance=new Holiday($this->db); + $object_instance = new Holiday($this->db); } elseif ($modulepart == 'banque') { include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $object_instance=new Account($this->db); + $object_instance = new Account($this->db); } - foreach($filearray as $key => $file) + foreach ($filearray as $key => $file) { if (!is_dir($file['name']) && $file['name'] != '.' && $file['name'] != '..' && $file['name'] != 'CVS' - && ! preg_match('/\.meta$/i', $file['name'])) + && !preg_match('/\.meta$/i', $file['name'])) { // Define relative path used to store the file - $relativefile=preg_replace('/'.preg_quote($upload_dir.'/', '/').'/', '', $file['fullname']); + $relativefile = preg_replace('/'.preg_quote($upload_dir.'/', '/').'/', '', $file['fullname']); - $id=0; $ref=''; $label=''; + $id = 0; $ref = ''; $label = ''; // To show ref or specific information according to view to show (defined by $module) - if ($modulepart == 'company' || $modulepart == 'tax') { preg_match('/(\d+)\/[^\/]+$/', $relativefile, $reg); $id=(isset($reg[1])?$reg[1]:''); } - elseif ($modulepart == 'invoice_supplier') { preg_match('/([^\/]+)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); if (is_numeric($ref)) { $id=$ref; $ref=''; } } // $ref may be also id with old supplier invoices - elseif ($modulepart == 'user' || $modulepart == 'holiday') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $id=(isset($reg[1])?$reg[1]:''); } + if ($modulepart == 'company' || $modulepart == 'tax') { preg_match('/(\d+)\/[^\/]+$/', $relativefile, $reg); $id = (isset($reg[1]) ? $reg[1] : ''); } + elseif ($modulepart == 'invoice_supplier') { preg_match('/([^\/]+)\/[^\/]+$/', $relativefile, $reg); $ref = (isset($reg[1]) ? $reg[1] : ''); if (is_numeric($ref)) { $id = $ref; $ref = ''; } } // $ref may be also id with old supplier invoices + elseif ($modulepart == 'user' || $modulepart == 'holiday') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $id = (isset($reg[1]) ? $reg[1] : ''); } elseif (in_array($modulepart, array('invoice', 'propal', 'supplier_proposal', 'order', 'order_supplier', 'contract', 'product', 'project', 'fichinter', 'expensereport', 'banque'))) { - preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); + preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = (isset($reg[1]) ? $reg[1] : ''); } else { //print 'Error: Value for modulepart = '.$modulepart.' is not yet implemented in function list_of_autoecmfiles'."\n"; } - if (! $id && ! $ref) continue; - $found=0; - if (! empty($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) + if (!$id && !$ref) continue; + $found = 0; + if (!empty($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) { - $found=1; + $found = 1; } else { @@ -1659,24 +1659,24 @@ class FormFile } if ($result > 0) { // Save object loaded into a cache - $found=1; $this->cache_objects[$modulepart.'_'.$id.'_'.$ref] = clone $object_instance; + $found = 1; $this->cache_objects[$modulepart.'_'.$id.'_'.$ref] = clone $object_instance; } - if ($result == 0) { $found=1; $this->cache_objects[$modulepart.'_'.$id.'_'.$ref]='notfound'; unset($filearray[$key]); } + if ($result == 0) { $found = 1; $this->cache_objects[$modulepart.'_'.$id.'_'.$ref] = 'notfound'; unset($filearray[$key]); } } - if (! $found > 0 || ! is_object($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) continue; // We do not show orphelins files + if (!$found > 0 || !is_object($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) continue; // We do not show orphelins files print ''."\n"; print ''; print '
'; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; if ($found > 0 && is_object($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) print $this->cache_objects[$modulepart.'_'.$id.'_'.$ref]->getNomUrl(1, 'document'); - else print $langs->trans("ObjectDeleted", ($id?$id:$ref)); + else print $langs->trans("ObjectDeleted", ($id ? $id : $ref)); //$modulesubdir=dol_sanitizeFileName($ref); - $modulesubdir=dirname($relativefile); + $modulesubdir = dirname($relativefile); //$filedir=$conf->$modulepart->dir_output . '/' . dol_sanitizeFileName($obj->ref); - $filedir=$file['path']; + $filedir = $file['path']; //$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; //print $formfile->getDocumentsLink($modulepart, $filename, $filedir); @@ -1719,7 +1719,7 @@ class FormFile print "
"; print '
'; - if (! empty($addfilterfields)) print '
'; + if (!empty($addfilterfields)) print ''; // Fin de zone } @@ -1745,7 +1745,7 @@ class FormFile $mul_upload_max_filesize = ($mul_upload_max_filesize == 'M' ? 1048576 : ($mul_upload_max_filesize == 'K' ? 1024 : ($mul_upload_max_filesize == 'G' ? 1073741824 : 1))); $upload_max_filesize = $mul_upload_max_filesize * (int) $upload_max_filesize; // Max file size - $max_file_size = (($post_max_size < $upload_max_filesize) ? $post_max_size : $upload_max_filesize); + $max_file_size = (($post_max_size < $upload_max_filesize) ? $post_max_size : $upload_max_filesize); // Include main include DOL_DOCUMENT_ROOT.'/core/tpl/ajax/fileupload_main.tpl.php'; @@ -1771,7 +1771,7 @@ class FormFile $langs->load("link"); - require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; $link = new Link($this->db); $links = array(); if ($sortfield == "name") { @@ -1782,14 +1782,14 @@ class FormFile $sortfield = null; } $res = $link->fetchAll($links, $object->element, $object->id, $sortfield, $sortorder); - $param .= (isset($object->id)?'&id=' . $object->id : ''); + $param .= (isset($object->id) ? '&id='.$object->id : ''); print ''."\n"; // Show list of associated links print load_fiche_titre($langs->trans("LinkedFiles")); - print '
'; + print ''; print ''; print ''; @@ -1850,36 +1850,36 @@ class FormFile if ($action == 'update' && $selected === $link->id) { print ''; print ''; - print ''; + print ''; print ''; print ''; } else { print ''."\n"; print ''; - print ''; + print ''; print ''; print ''; // Relative and absolute discounts - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $filterabsolutediscount = "fk_invoice_supplier_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice $filtercreditnote = "fk_invoice_supplier_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice } else { @@ -2014,11 +2014,11 @@ elseif (! empty($object->id)) $absolute_discount = price2num($absolute_discount, 'MT'); $absolute_creditnote = price2num($absolute_creditnote, 'MT'); - print ''; @@ -2063,7 +2063,7 @@ elseif (! empty($object->id)) print ''; // Multicurrency - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { // Multicurrency code print ''; @@ -2072,13 +2072,13 @@ elseif (! empty($object->id)) print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); print ''; if ($action != 'editmulticurrencycode' && $object->statut == $object::STATUS_DRAFT) - print ''; + print ''; print '
'; - print ''; - print ''; + print ''; + print ''; print ''; - print $langs->trans('Link') . ': '; + print $langs->trans('Link').': '; print ''; - print $langs->trans('Label') . ': '; + print $langs->trans('Label').': '; print '' . dol_print_date(dol_now(), "dayhour", "tzuser") . ''.dol_print_date(dol_now(), "dayhour", "tzuser").''; - print ''; - print ''; + print ''; + print ''; print ''; print img_picto('', 'globe').' '; - print ''; + print ''; print dol_escape_htmltag($link->label); print ''; print '' . dol_print_date($link->datea, "dayhour", "tzuser") . ''.dol_print_date($link->datea, "dayhour", "tzuser").''; - print '' . img_edit() . ''; // id= is included into $param + print ''.img_edit().''; // id= is included into $param if ($permissiontodelete) { - print '   ' . img_delete() . ''; // id= is included into $param + print '   '.img_delete().''; // id= is included into $param } else { print ' '; } @@ -1915,21 +1915,21 @@ class FormFile { global $langs, $conf; - $out=''; - if ($conf->browser->layout != 'phone' && ! empty($conf->use_javascript_ajax)) + $out = ''; + if ($conf->browser->layout != 'phone' && !empty($conf->use_javascript_ajax)) { - $urladvancedpreview=getAdvancedPreviewUrl($modulepart, $relativepath, 1, $param); // Return if a file is qualified for preview. + $urladvancedpreview = getAdvancedPreviewUrl($modulepart, $relativepath, 1, $param); // Return if a file is qualified for preview. if (count($urladvancedpreview)) { - $out.= ''; + $out .= ''; //$out.= ''; if (empty($ruleforpicto)) { //$out.= img_picto($langs->trans('Preview').' '.$file['name'], 'detail'); - $out.=''; + $out .= ''; } - else $out.= img_mime($relativepath, $langs->trans('Preview').' '.$file['name']); - $out.= ''; + else $out .= img_mime($relativepath, $langs->trans('Preview').' '.$file['name']); + $out .= ''; } } return $out; diff --git a/htdocs/core/class/interfaces.class.php b/htdocs/core/class/interfaces.class.php index bdcfe6bbf75..c5b499c78e1 100644 --- a/htdocs/core/class/interfaces.class.php +++ b/htdocs/core/class/interfaces.class.php @@ -36,7 +36,7 @@ class Interfaces */ public $db; - public $dir; // Directory with all core and external triggers files + public $dir; // Directory with all core and external triggers files /** * @var string[] Error codes (or messages) @@ -69,18 +69,18 @@ class Interfaces { // phpcs:enable // Check parameters - if (! is_object($object) || ! is_object($conf)) // Error + if (!is_object($object) || !is_object($conf)) // Error { - $this->error='function run_triggers called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf); + $this->error = 'function run_triggers called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf); dol_syslog(get_class($this).'::run_triggers '.$this->error, LOG_ERR); - $this->errors[]=$this->error; + $this->errors[] = $this->error; return -1; } - if (! is_object($langs)) // Warning + if (!is_object($langs)) // Warning { dol_syslog(get_class($this).'::run_triggers was called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf), LOG_WARNING); } - if (! is_object($user)) // Warning + if (!is_object($user)) // Warning { dol_syslog(get_class($this).'::run_triggers was called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf), LOG_WARNING); global $db; @@ -93,44 +93,44 @@ class Interfaces $files = array(); $modules = array(); $orders = array(); - $i=0; + $i = 0; - $dirtriggers=array_merge(array('/core/triggers'), $conf->modules_parts['triggers']); - foreach($dirtriggers as $reldir) + $dirtriggers = array_merge(array('/core/triggers'), $conf->modules_parts['triggers']); + foreach ($dirtriggers as $reldir) { - $dir=dol_buildpath($reldir, 0); - $newdir=dol_osencode($dir); + $dir = dol_buildpath($reldir, 0); + $newdir = dol_osencode($dir); //print "xx".$dir;exit; // Check if directory exists (we do not use dol_is_dir to avoir loading files.lib.php at each call) - if (! is_dir($newdir)) continue; + if (!is_dir($newdir)) continue; - $handle=opendir($newdir); + $handle = opendir($newdir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { if (is_readable($newdir."/".$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php$/i', $file, $reg)) { - $part1=$reg[1]; - $part2=$reg[2]; - $part3=$reg[3]; + $part1 = $reg[1]; + $part2 = $reg[2]; + $part3 = $reg[3]; $nbfile++; // Check if trigger file is disabled by name if (preg_match('/NORUN$/i', $file)) continue; // Check if trigger file is for a particular module - $qualified=true; + $qualified = true; if (strtolower($reg[2]) != 'all') { - $module=preg_replace('/^mod/i', '', $reg[2]); - $constparam='MAIN_MODULE_'.strtoupper($module); - if (empty($conf->global->$constparam)) $qualified=false; + $module = preg_replace('/^mod/i', '', $reg[2]); + $constparam = 'MAIN_MODULE_'.strtoupper($module); + if (empty($conf->global->$constparam)) $qualified = false; } - if (! $qualified) + if (!$qualified) { //dol_syslog(get_class($this)."::run_triggers action=".$action." Triggers for file '".$file."' need module to be enabled", LOG_DEBUG); continue; @@ -150,7 +150,7 @@ class Interfaces include_once $newdir.'/'.$file; //print 'Done for '.$modName."\n"; } - catch(Exception $e) + catch (Exception $e) { dol_syslog('ko for '.$modName." ".$e->getMessage()."\n", LOG_ERR); } @@ -158,7 +158,7 @@ class Interfaces $modules[$i] = $modName; $files[$i] = $file; $fullpathfiles[$modName] = $newdir.'/'.$file; - $orders[$i] = $part1.'_'.$part2.'_'.$part3; // Set sort criteria value + $orders[$i] = $part1.'_'.$part2.'_'.$part3; // Set sort criteria value $i++; } @@ -177,17 +177,17 @@ class Interfaces $objMod = new $modName($this->db); if ($objMod) { - $result=0; + $result = 0; if (method_exists($objMod, 'runTrigger')) // New method to implement { //dol_syslog(get_class($this)."::run_triggers action=".$action." Launch runTrigger for file '".$files[$key]."'", LOG_DEBUG); - $result=$objMod->runTrigger($action, $object, $user, $langs, $conf); + $result = $objMod->runTrigger($action, $object, $user, $langs, $conf); } elseif (method_exists($objMod, 'run_trigger')) // Deprecated method { dol_syslog(get_class($this)."::run_triggers action=".$action." Launch old method run_trigger (rename your trigger into runTrigger) for file '".$files[$key]."'", LOG_WARNING); - $result=$objMod->run_trigger($action, $object, $user, $langs, $conf); + $result = $objMod->run_trigger($action, $object, $user, $langs, $conf); } else { @@ -211,8 +211,8 @@ class Interfaces //dol_syslog("Error in trigger ".$action." - Nb of error string returned = ".count($objMod->errors), LOG_ERR); $nbtotal++; $nbko++; - if (! empty($objMod->errors)) $this->errors=array_merge($this->errors, $objMod->errors); - elseif (! empty($objMod->error)) $this->errors[]=$objMod->error; + if (!empty($objMod->errors)) $this->errors = array_merge($this->errors, $objMod->errors); + elseif (!empty($objMod->error)) $this->errors[] = $objMod->error; //dol_syslog("Error in trigger ".$action." - Nb of error string returned = ".count($this->errors), LOG_ERR); } } @@ -253,32 +253,32 @@ class Interfaces $orders = array(); $i = 0; - $dirtriggers=array_merge(array('/core/triggers/'), $conf->modules_parts['triggers']); + $dirtriggers = array_merge(array('/core/triggers/'), $conf->modules_parts['triggers']); if (is_array($forcedirtriggers)) { - $dirtriggers=$forcedirtriggers; + $dirtriggers = $forcedirtriggers; } - foreach($dirtriggers as $reldir) + foreach ($dirtriggers as $reldir) { - $dir=dol_buildpath($reldir, 0); - $newdir=dol_osencode($dir); + $dir = dol_buildpath($reldir, 0); + $newdir = dol_osencode($dir); // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php at each call) - if (! is_dir($newdir)) continue; + if (!is_dir($newdir)) continue; - $handle=opendir($newdir); + $handle = opendir($newdir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { if (is_readable($newdir.'/'.$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/', $file, $reg)) { if (preg_match('/\.back$/', $file)) continue; - $part1=$reg[1]; - $part2=$reg[2]; - $part3=$reg[3]; + $part1 = $reg[1]; + $part2 = $reg[2]; + $part3 = $reg[3]; $modName = 'Interface'.ucfirst($reg[3]); //print "file=$file"; print "modName=$modName"; exit; @@ -295,9 +295,9 @@ class Interfaces $files[$i] = $file; $fullpath[$i] = $dir.'/'.$file; $relpath[$i] = preg_replace('/^\//', '', $reldir).'/'.$file; - $iscoreorexternal[$i] = ($reldir == '/core/triggers/'?'internal':'external'); + $iscoreorexternal[$i] = ($reldir == '/core/triggers/' ? 'internal' : 'external'); $modules[$i] = $modName; - $orders[$i] = $part1.'_'.$part2.'_'.$part3; // Set sort criteria value + $orders[$i] = $part1.'_'.$part2.'_'.$part3; // Set sort criteria value $i++; } @@ -317,7 +317,7 @@ class Interfaces $modName = $modules[$key]; if (empty($modName)) continue; - if (! class_exists($modName)) + if (!class_exists($modName)) { print 'Error: A trigger file was found but its class "'.$modName.'" was not found.'."
\n"; continue; @@ -326,24 +326,24 @@ class Interfaces $objMod = new $modName($db); // Define disabledbyname and disabledbymodule - $disabledbyname=0; - $disabledbymodule=1; - $module=''; + $disabledbyname = 0; + $disabledbymodule = 1; + $module = ''; // Check if trigger file is disabled by name - if (preg_match('/NORUN$/i', $files[$key])) $disabledbyname=1; + if (preg_match('/NORUN$/i', $files[$key])) $disabledbyname = 1; // Check if trigger file is for a particular module if (preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/i', $files[$key], $reg)) { - $module=preg_replace('/^mod/i', '', $reg[2]); - $constparam='MAIN_MODULE_'.strtoupper($module); - if (strtolower($module) == 'all') $disabledbymodule=0; - elseif (empty($conf->global->$constparam)) $disabledbymodule=2; - $triggers[$j]['module']=strtolower($module); + $module = preg_replace('/^mod/i', '', $reg[2]); + $constparam = 'MAIN_MODULE_'.strtoupper($module); + if (strtolower($module) == 'all') $disabledbymodule = 0; + elseif (empty($conf->global->$constparam)) $disabledbymodule = 2; + $triggers[$j]['module'] = strtolower($module); } // We set info of modules - $triggers[$j]['picto'] = $objMod->picto?img_object('', $objMod->picto, 'class="valignmiddle pictomodule "'):img_object('', 'generic', 'class="valignmiddle pictomodule "'); + $triggers[$j]['picto'] = $objMod->picto ?img_object('', $objMod->picto, 'class="valignmiddle pictomodule "') : img_object('', 'generic', 'class="valignmiddle pictomodule "'); $triggers[$j]['file'] = $files[$key]; $triggers[$j]['fullpath'] = $fullpath[$key]; $triggers[$j]['relpath'] = $relpath[$key]; @@ -352,19 +352,19 @@ class Interfaces $triggers[$j]['status'] = img_picto($langs->trans("Active"), 'tick'); if ($disabledbyname > 0 || $disabledbymodule > 1) $triggers[$j]['status'] = ''; - $text =''.$langs->trans("Description").':
'; - $text.=$objMod->getDesc().'
'; - $text.='
'.$langs->trans("Status").':
'; + $text = ''.$langs->trans("Description").':
'; + $text .= $objMod->getDesc().'
'; + $text .= '
'.$langs->trans("Status").':
'; if ($disabledbyname == 1) { - $text.=$langs->trans("TriggerDisabledByName").'
'; - if ($disabledbymodule == 2) $text.=$langs->trans("TriggerDisabledAsModuleDisabled", $module).'
'; + $text .= $langs->trans("TriggerDisabledByName").'
'; + if ($disabledbymodule == 2) $text .= $langs->trans("TriggerDisabledAsModuleDisabled", $module).'
'; } else { - if ($disabledbymodule == 0) $text.=$langs->trans("TriggerAlwaysActive").'
'; - if ($disabledbymodule == 1) $text.=$langs->trans("TriggerActiveAsModuleActive", $module).'
'; - if ($disabledbymodule == 2) $text.=$langs->trans("TriggerDisabledAsModuleDisabled", $module).'
'; + if ($disabledbymodule == 0) $text .= $langs->trans("TriggerAlwaysActive").'
'; + if ($disabledbymodule == 1) $text .= $langs->trans("TriggerActiveAsModuleActive", $module).'
'; + if ($disabledbymodule == 2) $text .= $langs->trans("TriggerDisabledAsModuleDisabled", $module).'
'; } $triggers[$j]['info'] = $text; diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index f395475faf7..e3289f2c8e0 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -32,19 +32,19 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/cron.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","cron","bills","members")); +$langs->loadLangs(array("admin", "cron", "bills", "members")); if (!$user->rights->cron->read) accessforbidden(); -$action=GETPOST('action', 'alpha'); -$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) -$confirm=GETPOST('confirm', 'alpha'); -$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'cronjoblist'; // To manage different context of search +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) +$confirm = GETPOST('confirm', 'alpha'); +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'cronjoblist'; // To manage different context of search -$id=GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -52,16 +52,16 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='t.status,t.priority'; -if (! $sortorder) $sortorder='DESC,ASC'; +if (!$sortfield) $sortfield = 't.status,t.priority'; +if (!$sortorder) $sortorder = 'DESC,ASC'; -$search_status=(GETPOSTISSET('search_status')?GETPOST('search_status', 'int'):GETPOST('status', 'int')); +$search_status = (GETPOSTISSET('search_status') ?GETPOST('search_status', 'int') : GETPOST('status', 'int')); //Search criteria -$search_label=GETPOST("search_label", 'alpha'); +$search_label = GETPOST("search_label", 'alpha'); $securitykey = GETPOST('securitykey', 'alpha'); -$diroutputmassaction=$conf->cronjob->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->cronjob->dir_output.'/temp/massgeneration/'.$user->id; $object = new Cronjob($db); @@ -72,7 +72,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); @@ -80,11 +80,11 @@ $search_array_options=$extrafields->getOptionalsFromPost($object->table_element, * 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 +$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)) @@ -95,21 +95,21 @@ if (empty($reshook)) // Purge search criteria 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_label=''; - $search_status=-1; - $toselect=''; - $search_array_options=array(); + $search_label = ''; + $search_status = -1; + $toselect = ''; + $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { - $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } - $filter=array(); + $filter = array(); if (!empty($search_label)) { - $filter['t.label']=$search_label; + $filter['t.label'] = $search_label; } // Delete jobs @@ -117,7 +117,7 @@ if (empty($reshook)) { //Delete cron task $object = new Cronjob($db); - $object->id=$id; + $object->id = $id; $result = $object->delete($user); if ($result < 0) { @@ -128,19 +128,19 @@ if (empty($reshook)) // Execute jobs if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->execute) { - if (! empty($conf->global->CRON_KEY) && $conf->global->CRON_KEY != $securitykey) + if (!empty($conf->global->CRON_KEY) && $conf->global->CRON_KEY != $securitykey) { setEventMessages('Security key '.$securitykey.' is wrong', null, 'errors'); - $action=''; + $action = ''; } else { $object = new Cronjob($db); $job = $object->fetch($id); - $now = dol_now(); // Date we start + $now = dol_now(); // Date we start - $resrunjob = $object->run_jobs($user->login); // Return -1 if KO, 1 if OK + $resrunjob = $object->run_jobs($user->login); // Return -1 if KO, 1 if OK if ($resrunjob < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -154,39 +154,39 @@ if (empty($reshook)) if ($object->lastresult >= 0) setEventMessages($langs->trans("JobFinished"), null, 'mesgs'); else setEventMessages($langs->trans("JobFinished"), null, 'errors'); } - $action=''; + $action = ''; } else { setEventMessages($object->error, $object->errors, 'errors'); - $action=''; + $action = ''; } - $param='&search_status='.urlencode($search_status); - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($search_label) $param.='&search_label='.urlencode($search_label); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + $param = '&search_status='.urlencode($search_status); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($search_label) $param .= '&search_label='.urlencode($search_label); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - header("Location: ".DOL_URL_ROOT.'/cron/list.php?'.$param.($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'')); // Make a redirect to avoid to run twice the job when using back + header("Location: ".DOL_URL_ROOT.'/cron/list.php?'.$param.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '')); // Make a redirect to avoid to run twice the job when using back exit; } } // Mass actions - $objectclass='CronJob'; - $objectlabel='CronJob'; + $objectclass = 'CronJob'; + $objectlabel = 'CronJob'; $permissiontoread = $user->rights->cron->read; - $permissiontoadd = $user->rights->cron->create?$user->rights->cron->create:$user->rights->cron->write; + $permissiontoadd = $user->rights->cron->create ? $user->rights->cron->create : $user->rights->cron->write; $permissiontodelete = $user->rights->cron->delete; $uploaddir = $conf->cron->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; if ($permissiontoadd) { $tmpcron = new Cronjob($db); - foreach($toselect as $id) + foreach ($toselect as $id) { $result = $tmpcron->fetch($id); if ($result) @@ -213,67 +213,67 @@ if (empty($reshook)) $form = new Form($db); $cronjob = new Cronjob($db); -$pagetitle=$langs->trans("CronList"); +$pagetitle = $langs->trans("CronList"); llxHeader('', $pagetitle); $sql = "SELECT"; -$sql.= " t.rowid,"; -$sql.= " t.tms,"; -$sql.= " t.datec,"; -$sql.= " t.jobtype,"; -$sql.= " t.label,"; -$sql.= " t.command,"; -$sql.= " t.classesname,"; -$sql.= " t.objectname,"; -$sql.= " t.methodename,"; -$sql.= " t.params,"; -$sql.= " t.md5params,"; -$sql.= " t.module_name,"; -$sql.= " t.priority,"; -$sql.= " t.processing,"; -$sql.= " t.datelastrun,"; -$sql.= " t.datenextrun,"; -$sql.= " t.dateend,"; -$sql.= " t.datestart,"; -$sql.= " t.lastresult,"; -$sql.= " t.datelastresult,"; -$sql.= " t.lastoutput,"; -$sql.= " t.unitfrequency,"; -$sql.= " t.frequency,"; -$sql.= " t.status,"; -$sql.= " t.fk_user_author,"; -$sql.= " t.fk_user_mod,"; -$sql.= " t.note,"; -$sql.= " t.maxrun,"; -$sql.= " t.nbrun,"; -$sql.= " t.libname,"; -$sql.= " t.test"; -$sql.= " FROM ".MAIN_DB_PREFIX."cronjob as t"; -$sql.= " WHERE entity IN (0,".$conf->entity.")"; -if ($search_status >= 0 && $search_status < 2 && $search_status != '') $sql.= " AND t.status = ".(empty($search_status)?'0':'1'); +$sql .= " t.rowid,"; +$sql .= " t.tms,"; +$sql .= " t.datec,"; +$sql .= " t.jobtype,"; +$sql .= " t.label,"; +$sql .= " t.command,"; +$sql .= " t.classesname,"; +$sql .= " t.objectname,"; +$sql .= " t.methodename,"; +$sql .= " t.params,"; +$sql .= " t.md5params,"; +$sql .= " t.module_name,"; +$sql .= " t.priority,"; +$sql .= " t.processing,"; +$sql .= " t.datelastrun,"; +$sql .= " t.datenextrun,"; +$sql .= " t.dateend,"; +$sql .= " t.datestart,"; +$sql .= " t.lastresult,"; +$sql .= " t.datelastresult,"; +$sql .= " t.lastoutput,"; +$sql .= " t.unitfrequency,"; +$sql .= " t.frequency,"; +$sql .= " t.status,"; +$sql .= " t.fk_user_author,"; +$sql .= " t.fk_user_mod,"; +$sql .= " t.note,"; +$sql .= " t.maxrun,"; +$sql .= " t.nbrun,"; +$sql .= " t.libname,"; +$sql .= " t.test"; +$sql .= " FROM ".MAIN_DB_PREFIX."cronjob as t"; +$sql .= " WHERE entity IN (0,".$conf->entity.")"; +if ($search_status >= 0 && $search_status < 2 && $search_status != '') $sql .= " AND t.status = ".(empty($search_status) ? '0' : '1'); //Manage filter -if (is_array($filter) && count($filter)>0) { - foreach($filter as $key => $value) { - $sql.= ' AND '.$key.' LIKE \'%'.$db->escape($value).'%\''; +if (is_array($filter) && count($filter) > 0) { + foreach ($filter as $key => $value) { + $sql .= ' AND '.$key.' LIKE \'%'.$db->escape($value).'%\''; } } $sqlwhere = array(); if (!empty($module_name)) { - $sqlwhere[]='(t.module_name='.$db->escape($module_name).')'; + $sqlwhere[] = '(t.module_name='.$db->escape($module_name).')'; } -if (count($sqlwhere)>0) { - $sql.= " WHERE ".implode(' AND ', $sqlwhere); +if (count($sqlwhere) > 0) { + $sql .= " WHERE ".implode(' AND ', $sqlwhere); } // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -288,21 +288,21 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); -$result=$db->query($sql); -if (! $result) dol_print_error($db); +$result = $db->query($sql); +if (!$result) dol_print_error($db); $num = $db->num_rows($result); -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); $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_status) $param.='&search_status='.urlencode($search_status); -if ($search_label) $param.='&search_label='.urlencode($search_label); -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_status) $param .= '&search_status='.urlencode($search_status); +if ($search_label) $param .= '&search_label='.urlencode($search_label); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -318,15 +318,15 @@ if ($action == 'execute') } // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), 'enable'=>$langs->trans("CronStatusActiveBtn"), 'disable'=>$langs->trans("CronStatusInactiveBtn"), ); -if ($user->rights->mymodule->delete) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); -if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($user->rights->mymodule->delete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); print ''."\n"; @@ -348,15 +348,15 @@ print_barre_liste($pagetitle, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $ print ''.$langs->trans('CronInfo').'
'; -$text =$langs->trans("HoursOnThisPageAreOnServerTZ").' '.$stringcurrentdate.'
'; -if (! empty($conf->global->CRON_WARNING_DELAY_HOURS)) $text.=$langs->trans("WarningCronDelayed", $conf->global->CRON_WARNING_DELAY_HOURS); +$text = $langs->trans("HoursOnThisPageAreOnServerTZ").' '.$stringcurrentdate.'
'; +if (!empty($conf->global->CRON_WARNING_DELAY_HOURS)) $text .= $langs->trans("WarningCronDelayed", $conf->global->CRON_WARNING_DELAY_HOURS); print info_admin($text); print '
'; -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=''; +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = ''; //$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); +$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; print ''; @@ -381,7 +381,7 @@ print ''; print ''; print ''; @@ -410,14 +410,14 @@ if ($num > 0) { // Loop on each job $now = dol_now(); - $i=0; + $i = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($result); if (empty($obj)) break; - if (! verifCond($obj->test)) continue; // Discard line with test = false + if (!verifCond($obj->test)) continue; // Discard line with test = false $object->id = $obj->rowid; $object->ref = $obj->rowid; @@ -438,7 +438,7 @@ if ($num > 0) // Label print ''; print ''; print ''; print ''; print ''; print ''; print ''; // Date start last run print ''; // Duration @@ -522,7 +522,7 @@ if ($num > 0) // Output of last run print ''; print ''; diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index eeb05e8926c..390a38dc203 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -33,11 +33,11 @@ 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("sendings","deliveries",'companies','bills')); +$langs->loadLangs(array("sendings", "deliveries", 'companies', 'bills')); -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'shipmentlist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'shipmentlist'; // To manage different context of search -$socid=GETPOST('socid', 'int'); +$socid = GETPOST('socid', 'int'); $action = GETPOST('action', 'alpha'); $massaction = GETPOST('massaction', 'alpha'); @@ -46,34 +46,34 @@ $toselect = GETPOST('toselect', 'array'); // Security check $expeditionid = GETPOST('id', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'expedition', $expeditionid, ''); $search_ref_exp = GETPOST("search_ref_exp", 'alpha'); $search_ref_liv = GETPOST('search_ref_liv', 'alpha'); $search_ref_customer = GETPOST('search_ref_customer', 'alpha'); $search_company = GETPOST("search_company", 'alpha'); -$search_town=GETPOST('search_town', 'alpha'); -$search_zip=GETPOST('search_zip', 'alpha'); -$search_state=trim(GETPOST("search_state")); -$search_country=GETPOST("search_country", 'int'); -$search_type_thirdparty=GETPOST("search_type_thirdparty", 'int'); -$search_billed=GETPOST("search_billed", 'int'); -$sall = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); +$search_town = GETPOST('search_town', 'alpha'); +$search_zip = GETPOST('search_zip', 'alpha'); +$search_state = trim(GETPOST("search_state")); +$search_country = GETPOST("search_country", 'int'); +$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); +$search_billed = GETPOST("search_billed", 'int'); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $optioncss = GETPOST('optioncss', 'alpha'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); -if (! $sortfield) $sortfield="e.ref"; -if (! $sortorder) $sortorder="DESC"; +if (!$sortfield) $sortfield = "e.ref"; +if (!$sortorder) $sortorder = "DESC"; if (empty($page) || $page == -1 || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -$viewstatut=GETPOST('viewstatut'); +$viewstatut = GETPOST('viewstatut'); $diroutputmassaction = $conf->expedition->dir_output.'/sending/temp/massgeneration/'.$user->id; @@ -86,7 +86,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -94,10 +94,10 @@ $fieldstosearchall = array( 's.nom'=>"ThirdParty", 'e.note_public'=>'NotePublic', ); -if (empty($user->socid)) $fieldstosearchall["e.note_private"]="NotePrivate"; +if (empty($user->socid)) $fieldstosearchall["e.note_private"] = "NotePrivate"; -$checkedtypetiers=0; -$arrayfields=array( +$checkedtypetiers = 0; +$arrayfields = array( 'e.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'e.ref_customer'=>array('label'=>$langs->trans("RefCustomer"), 'checked'=>1), 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), @@ -110,18 +110,18 @@ $arrayfields=array( 'e.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), 'e.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), 'e.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), - 'l.ref'=>array('label'=>$langs->trans("DeliveryRef"), 'checked'=>1, 'enabled'=>(empty($conf->livraison_bon->enabled)?0:1)), - 'l.date_delivery'=>array('label'=>$langs->trans("DateReceived"), 'checked'=>1, 'enabled'=>(empty($conf->livraison_bon->enabled)?0:1)), + 'l.ref'=>array('label'=>$langs->trans("DeliveryRef"), 'checked'=>1, 'enabled'=>(empty($conf->livraison_bon->enabled) ? 0 : 1)), + 'l.date_delivery'=>array('label'=>$langs->trans("DateReceived"), 'checked'=>1, 'enabled'=>(empty($conf->livraison_bon->enabled) ? 0 : 1)), 'e.billed'=>array('label'=>$langs->trans("Billed"), 'checked'=>1, 'position'=>1000, 'enabled'=>(!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) ); // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -133,11 +133,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); */ $error = 0; -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('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; @@ -145,20 +145,20 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria 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_ref_exp=''; - $search_ref_liv=''; - $search_ref_customer=''; - $search_company=''; - $search_town=''; - $search_zip=""; - $search_state=""; - $search_type=''; - $search_country=''; - $search_type_thirdparty=''; - $search_billed=''; - $viewstatut=''; + $search_ref_exp = ''; + $search_ref_liv = ''; + $search_ref_customer = ''; + $search_company = ''; + $search_town = ''; + $search_zip = ""; + $search_state = ""; + $search_type = ''; + $search_country = ''; + $search_type_thirdparty = ''; + $search_billed = ''; + $viewstatut = ''; $toselect = ''; - $search_array_options=array(); + $search_array_options = array(); } if (empty($reshook)) @@ -168,7 +168,7 @@ if (empty($reshook)) $permissiontoread = $user->rights->expedition->lire; $permissiontoadd = $user->rights->expedition->creer; $permissiontodelete = $user->rights->expedition->supprimer; - $uploaddir = $conf->expedition->dir_output . '/sending'; + $uploaddir = $conf->expedition->dir_output.'/sending'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -177,58 +177,58 @@ if (empty($reshook)) * View */ -$form=new Form($db); +$form = new Form($db); $formfile = new FormFile($db); -$companystatic=new Societe($db); -$shipment=new Expedition($db); -$formcompany=new FormCompany($db); +$companystatic = new Societe($db); +$shipment = new Expedition($db); +$formcompany = new FormCompany($db); -$helpurl='EN:Module_Shipments|FR:Module_Expéditions|ES:Módulo_Expediciones'; +$helpurl = 'EN:Module_Shipments|FR:Module_Expéditions|ES:Módulo_Expediciones'; llxHeader('', $langs->trans('ListOfSendings'), $helpurl); $sql = "SELECT e.rowid, e.ref, e.ref_customer, e.date_expedition as date_expedition, e.date_delivery as date_livraison, l.date_delivery as date_reception, e.fk_statut, e.billed,"; -$sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; -$sql.= " typent.code as typent_code,"; -$sql.= " state.code_departement as state_code, state.nom as state_name,"; -$sql.= ' e.date_creation as date_creation, e.tms as date_update'; +$sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; +$sql .= " typent.code as typent_code,"; +$sql .= " state.code_departement as state_code, state.nom as state_name,"; +$sql .= ' e.date_creation as date_creation, e.tms as date_update'; // 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 : ''); +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 : ''); } // 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 ".MAIN_DB_PREFIX."expedition as e"; -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 (e.rowid = ef.fk_object)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as ee ON e.rowid = ee.fk_source AND ee.sourcetype = 'shipping' AND ee.targettype = 'delivery'"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.rowid = ee.fk_target"; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= " FROM ".MAIN_DB_PREFIX."expedition as e"; +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 (e.rowid = ef.fk_object)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as ee ON e.rowid = ee.fk_source AND ee.sourcetype = 'shipping' AND ee.targettype = 'delivery'"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.rowid = ee.fk_target"; if (!$user->rights->societe->client->voir && !$socid) // Internal user with no permission to see all { - $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } -$sql.= " WHERE e.entity IN (".getEntity('expedition').")"; +$sql .= " WHERE e.entity IN (".getEntity('expedition').")"; if (!$user->rights->societe->client->voir && !$socid) // Internal user with no permission to see all { - $sql.= " AND e.fk_soc = sc.fk_soc"; - $sql.= " AND sc.fk_user = " .$user->id; + $sql .= " AND e.fk_soc = sc.fk_soc"; + $sql .= " AND sc.fk_user = ".$user->id; } if ($socid) { - $sql.= " AND e.fk_soc = ".$socid; + $sql .= " AND e.fk_soc = ".$socid; } if ($viewstatut <> '' && $viewstatut >= 0) { - $sql.= " AND e.fk_statut = ".$viewstatut; + $sql .= " AND e.fk_statut = ".$viewstatut; } -if ($search_ref_customer != '') $sql.=natural_search('e.ref_customer', $search_ref_customer); -if ($search_billed != '' && $search_billed >= 0) $sql.=' AND e.billed = '.$search_billed; -if ($search_town) $sql.= natural_search('s.town', $search_town); -if ($search_zip) $sql.= natural_search("s.zip", $search_zip); -if ($search_state) $sql.= natural_search("state.nom", $search_state); +if ($search_ref_customer != '') $sql .= natural_search('e.ref_customer', $search_ref_customer); +if ($search_billed != '' && $search_billed >= 0) $sql .= ' AND e.billed = '.$search_billed; +if ($search_town) $sql .= natural_search('s.town', $search_town); +if ($search_zip) $sql .= natural_search("s.zip", $search_zip); +if ($search_state) $sql .= natural_search("state.nom", $search_state); if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; if ($search_ref_exp) $sql .= natural_search('e.ref', $search_ref_exp); @@ -240,11 +240,11 @@ if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -258,10 +258,10 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit + 1, $offset); +$sql .= $db->plimit($limit + 1, $offset); //print $sql; -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -270,32 +270,32 @@ if ($resql) $expedition = new Expedition($db); - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($sall) $param.= "&sall=".urlencode($sall); - if ($search_ref_exp) $param.= "&search_ref_exp=".urlencode($search_ref_exp); - if ($search_ref_liv) $param.= "&search_ref_liv=".urlencode($search_ref_liv); - if ($search_ref_customer) $param.= "&search_ref_customer=".urlencode($search_ref_customer); - if ($search_company) $param.= "&search_company=".urlencode($search_company); - if ($search_town) $param.= '&search_town='.urlencode($search_town); - if ($search_zip) $param.= '&search_zip='.urlencode($search_zip); - if ($viewstatut != '') $param.= '&viewstatut='.urlencode($viewstatut); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($sall) $param .= "&sall=".urlencode($sall); + if ($search_ref_exp) $param .= "&search_ref_exp=".urlencode($search_ref_exp); + if ($search_ref_liv) $param .= "&search_ref_liv=".urlencode($search_ref_liv); + if ($search_ref_customer) $param .= "&search_ref_customer=".urlencode($search_ref_customer); + if ($search_company) $param .= "&search_company=".urlencode($search_company); + if ($search_town) $param .= '&search_town='.urlencode($search_town); + if ($search_zip) $param .= '&search_zip='.urlencode($search_zip); + if ($viewstatut != '') $param .= '&viewstatut='.urlencode($viewstatut); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - $arrayofmassactions = array( + $arrayofmassactions = array( 'builddoc' => $langs->trans("PDFMerge"), 'presend' => $langs->trans("SendByMail"), ); - if (in_array($massaction, array('presend'))) $arrayofmassactions=array(); + if (in_array($massaction, array('presend'))) $arrayofmassactions = array(); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); - $newcardbutton=''; + $newcardbutton = ''; if ($user->rights->expedition->creer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewSending'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/expedition/card.php?action=create2'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewSending'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/expedition/card.php?action=create2'); } $i = 0; @@ -318,89 +318,89 @@ if ($resql) if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } - $moreforfilter=''; - if (! empty($moreforfilter)) + $moreforfilter = ''; + if (!empty($moreforfilter)) { print '
'; print $moreforfilter; - $parameters=array('type'=>$type); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('type'=>$type); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); - if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);// This also change content of $arrayfields + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); + if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); // This also change content of $arrayfields print '
'; - print '
 '; print $form->selectarray('search_status', array('0'=>$langs->trans("Disabled"), '1'=>$langs->trans("Enabled")), $search_status, 1); print ''; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; - if (! empty($obj->label)) + if (!empty($obj->label)) { $object->ref = $langs->trans($obj->label); print $object->getNomUrl(0, '', 1); @@ -456,52 +456,52 @@ if ($num > 0) print ''; - if ($obj->jobtype=='method') + if ($obj->jobtype == 'method') { - $text=$langs->trans("CronClass"); - $texttoshow=$langs->trans('CronModule').': '.$obj->module_name.'
'; - $texttoshow.=$langs->trans('CronClass').': '. $obj->classesname.'
'; - $texttoshow.=$langs->trans('CronObject').': '. $obj->objectname.'
'; - $texttoshow.=$langs->trans('CronMethod').': '. $obj->methodename; - $texttoshow.='
'.$langs->trans('CronArgs').': '. $obj->params; - $texttoshow.='
'.$langs->trans('Comment').': '. $langs->trans($obj->note); + $text = $langs->trans("CronClass"); + $texttoshow = $langs->trans('CronModule').': '.$obj->module_name.'
'; + $texttoshow .= $langs->trans('CronClass').': '.$obj->classesname.'
'; + $texttoshow .= $langs->trans('CronObject').': '.$obj->objectname.'
'; + $texttoshow .= $langs->trans('CronMethod').': '.$obj->methodename; + $texttoshow .= '
'.$langs->trans('CronArgs').': '.$obj->params; + $texttoshow .= '
'.$langs->trans('Comment').': '.$langs->trans($obj->note); } - elseif ($obj->jobtype=='command') + elseif ($obj->jobtype == 'command') { - $text=$langs->trans('CronCommand'); - $texttoshow=$langs->trans('CronCommand').': '.dol_trunc($obj->command); - $texttoshow.='
'.$langs->trans('CronArgs').': '. $obj->params; - $texttoshow.='
'.$langs->trans('Comment').': '. $langs->trans($obj->note); + $text = $langs->trans('CronCommand'); + $texttoshow = $langs->trans('CronCommand').': '.dol_trunc($obj->command); + $texttoshow .= '
'.$langs->trans('CronArgs').': '.$obj->params; + $texttoshow .= '
'.$langs->trans('Comment').': '.$langs->trans($obj->note); } print $form->textwithpicto($text, $texttoshow, 1); print '
'; - if($obj->unitfrequency == "60") print $langs->trans('CronEach')." ".($obj->frequency)." ".$langs->trans('Minutes'); - if($obj->unitfrequency == "3600") print $langs->trans('CronEach')." ".($obj->frequency)." ".$langs->trans('Hours'); - if($obj->unitfrequency == "86400") print $langs->trans('CronEach')." ".($obj->frequency)." ".$langs->trans('Days'); - if($obj->unitfrequency == "604800") print $langs->trans('CronEach')." ".($obj->frequency)." ".$langs->trans('Weeks'); + if ($obj->unitfrequency == "60") print $langs->trans('CronEach')." ".($obj->frequency)." ".$langs->trans('Minutes'); + if ($obj->unitfrequency == "3600") print $langs->trans('CronEach')." ".($obj->frequency)." ".$langs->trans('Hours'); + if ($obj->unitfrequency == "86400") print $langs->trans('CronEach')." ".($obj->frequency)." ".$langs->trans('Days'); + if ($obj->unitfrequency == "604800") print $langs->trans('CronEach')." ".($obj->frequency)." ".$langs->trans('Weeks'); print ''; - if(!empty($obj->datestart)) {print dol_print_date($db->jdate($obj->datestart), 'dayhour');} + if (!empty($obj->datestart)) {print dol_print_date($db->jdate($obj->datestart), 'dayhour'); } print ''; - if(!empty($obj->dateend)) {print dol_print_date($db->jdate($obj->dateend), 'dayhour');} + if (!empty($obj->dateend)) {print dol_print_date($db->jdate($obj->dateend), 'dayhour'); } print ''; - if (!empty($obj->maxrun)) {print $obj->maxrun;} + if (!empty($obj->maxrun)) {print $obj->maxrun; } print ''; - if (!empty($obj->nbrun)) {print $obj->nbrun;} else {print '0';} + if (!empty($obj->nbrun)) {print $obj->nbrun; } else {print '0'; } print ''; - if (!empty($datelastrun)) {print dol_print_date($datelastrun, 'dayhoursec');} + if (!empty($datelastrun)) {print dol_print_date($datelastrun, 'dayhoursec'); } print ''; - if(!empty($obj->lastoutput)) {print dol_trunc(nl2br($obj->lastoutput), 50);} + if (!empty($obj->lastoutput)) {print dol_trunc(nl2br($obj->lastoutput), 50); } print ''; @@ -546,15 +546,15 @@ if ($num > 0) print ''; - $backtourl = urlencode($_SERVER["PHP_SELF"].'?'.$param.($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'')); + $backtourl = urlencode($_SERVER["PHP_SELF"].'?'.$param.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '')); if ($user->rights->cron->create) { - print "rowid."&action=edit".($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'').$param; + print "rowid."&action=edit".($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').$param; print "&backtourl=".$backtourl."\" title=\"".dol_escape_htmltag($langs->trans('Edit'))."\">".img_picto($langs->trans('Edit'), 'edit')."  "; } if ($user->rights->cron->delete) { - print "rowid."&action=delete".($page?'&page='.$page:'').($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'').$param; + print "rowid."&action=delete".($page ? '&page='.$page : '').($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').$param; print "\" title=\"".dol_escape_htmltag($langs->trans('CronDelete'))."\">".img_picto($langs->trans('CronDelete'), 'delete')."  "; } else { print "trans('NotEnoughPermissions'))."\">".img_picto($langs->trans('NotEnoughPermissions'), 'delete')."   "; @@ -563,9 +563,9 @@ if ($num > 0) { if (!empty($obj->status)) { print 'global->CRON_KEY)?'':'&securitykey='.$conf->global->CRON_KEY); - print ($sortfield?'&sortfield='.$sortfield:''); - print ($sortorder?'&sortorder='.$sortorder:''); + print (empty($conf->global->CRON_KEY) ? '' : '&securitykey='.$conf->global->CRON_KEY); + print ($sortfield ? '&sortfield='.$sortfield : ''); + print ($sortorder ? '&sortorder='.$sortorder : ''); print $param."\" title=\"".dol_escape_htmltag($langs->trans('CronExecute'))."\">".img_picto($langs->trans('CronExecute'), "play").''; } else { print ''.img_picto($langs->trans('JobDisabled'), "playdisabled").''; @@ -575,9 +575,9 @@ if ($num > 0) } if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print '   '; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print '   '; } print '
'."\n"; + print '
'."\n"; // Fields title search print ''; // Ref - if (! empty($arrayfields['e.ref']['checked'])) + if (!empty($arrayfields['e.ref']['checked'])) { print ''; } // Ref customer - if (! empty($arrayfields['e.ref_customer']['checked'])) + if (!empty($arrayfields['e.ref_customer']['checked'])) { print ''; } // Thirdparty - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print ''; } // Town - if (! empty($arrayfields['s.town']['checked'])) print ''; + if (!empty($arrayfields['s.town']['checked'])) print ''; // Zip - if (! empty($arrayfields['s.zip']['checked'])) print ''; + if (!empty($arrayfields['s.zip']['checked'])) print ''; // State - if (! empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print ''; } // Country - if (! empty($arrayfields['country.code_iso']['checked'])) + if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; } // Company type - if (! empty($arrayfields['typent.code']['checked'])) + if (!empty($arrayfields['typent.code']['checked'])) { print ''; } // Date delivery planned - if (! empty($arrayfields['e.date_delivery']['checked'])) + if (!empty($arrayfields['e.date_delivery']['checked'])) { print ''; } - if (! empty($arrayfields['l.ref']['checked'])) + if (!empty($arrayfields['l.ref']['checked'])) { // Delivery ref print ''; @@ -409,30 +409,30 @@ if ($resql) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['e.datec']['checked'])) + if (!empty($arrayfields['e.datec']['checked'])) { print ''; } // Date modification - if (! empty($arrayfields['e.tms']['checked'])) + if (!empty($arrayfields['e.tms']['checked'])) { print ''; } // Status - if (! empty($arrayfields['e.fk_statut']['checked'])) + if (!empty($arrayfields['e.fk_statut']['checked'])) { print ''; } // Status billed - if (! empty($arrayfields['e.billed']['checked'])) + if (!empty($arrayfields['e.billed']['checked'])) { print ''; print "\n"; print ''; - if (! empty($arrayfields['e.ref']['checked'])) print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['e.ref_customer']['checked'])) print_liste_field_titre($arrayfields['e.ref_customer']['label'], $_SERVER["PHP_SELF"], "e.ref_customer", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder, 'left '); - if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['e.date_delivery']['checked'])) print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['l.ref']['checked'])) print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"], "l.ref", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['l.date_delivery']['checked'])) print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"], "l.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['e.ref']['checked'])) print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['e.ref_customer']['checked'])) print_liste_field_titre($arrayfields['e.ref_customer']['label'], $_SERVER["PHP_SELF"], "e.ref_customer", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder, 'left '); + if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['e.date_delivery']['checked'])) print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['l.ref']['checked'])) print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"], "l.ref", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['l.date_delivery']['checked'])) print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"], "l.date_delivery", "", $param, '', $sortfield, $sortorder, 'center '); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['e.datec']['checked'])) print_liste_field_titre($arrayfields['e.datec']['label'], $_SERVER["PHP_SELF"], "e.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (! empty($arrayfields['e.tms']['checked'])) print_liste_field_titre($arrayfields['e.tms']['label'], $_SERVER["PHP_SELF"], "e.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (! empty($arrayfields['e.fk_statut']['checked'])) print_liste_field_titre($arrayfields['e.fk_statut']['label'], $_SERVER["PHP_SELF"], "e.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['e.billed']['checked'])) print_liste_field_titre($arrayfields['e.billed']['label'], $_SERVER["PHP_SELF"], "e.billed", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['e.datec']['checked'])) print_liste_field_titre($arrayfields['e.datec']['label'], $_SERVER["PHP_SELF"], "e.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['e.tms']['checked'])) print_liste_field_titre($arrayfields['e.tms']['label'], $_SERVER["PHP_SELF"], "e.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['e.fk_statut']['checked'])) print_liste_field_titre($arrayfields['e.fk_statut']['label'], $_SERVER["PHP_SELF"], "e.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['e.billed']['checked'])) print_liste_field_titre($arrayfields['e.billed']['label'], $_SERVER["PHP_SELF"], "e.billed", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; $typenArray = $formcompany->typent_array(1); - $i=0; - $totalarray=array(); + $i = 0; + $totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - $shipment->id=$obj->rowid; - $shipment->ref=$obj->ref; + $shipment->id = $obj->rowid; + $shipment->ref = $obj->ref; - $companystatic->id=$obj->socid; - $companystatic->ref=$obj->name; - $companystatic->name=$obj->name; + $companystatic->id = $obj->socid; + $companystatic->ref = $obj->name; + $companystatic->name = $obj->name; print ''; // Ref - if (! empty($arrayfields['e.ref']['checked'])) + if (!empty($arrayfields['e.ref']['checked'])) { print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Ref customer - if (! empty($arrayfields['e.ref_customer']['checked'])) + if (!empty($arrayfields['e.ref_customer']['checked'])) { print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Third party - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Town - if (! empty($arrayfields['s.town']['checked'])) + if (!empty($arrayfields['s.town']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Zip - if (! empty($arrayfields['s.zip']['checked'])) + if (!empty($arrayfields['s.zip']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // State - if (! empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Country - if (! empty($arrayfields['country.code_iso']['checked'])) + if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Type ent - if (! empty($arrayfields['typent.code']['checked'])) + if (!empty($arrayfields['typent.code']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date delivery planed - if (! empty($arrayfields['e.date_delivery']['checked'])) + if (!empty($arrayfields['e.date_delivery']['checked'])) { print '\n"; } - if (! empty($arrayfields['l.ref']['checked']) || ! empty($arrayfields['l.date_delivery']['checked'])) + if (!empty($arrayfields['l.ref']['checked']) || !empty($arrayfields['l.date_delivery']['checked'])) { $shipment->fetchObjectLinked($shipment->id, $shipment->element); - $receiving=''; - if (is_array($shipment->linkedObjects['delivery']) && count($shipment->linkedObjects['delivery']) > 0) $receiving=reset($shipment->linkedObjects['delivery']); + $receiving = ''; + if (is_array($shipment->linkedObjects['delivery']) && count($shipment->linkedObjects['delivery']) > 0) $receiving = reset($shipment->linkedObjects['delivery']); - if (! empty($arrayfields['l.ref']['checked'])) + if (!empty($arrayfields['l.ref']['checked'])) { // Ref print ''; } - if (! empty($arrayfields['l.date_delivery']['checked'])) + if (!empty($arrayfields['l.date_delivery']['checked'])) { // Date received print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date modification - if (! empty($arrayfields['e.tms']['checked'])) + if (!empty($arrayfields['e.tms']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Status - if (! empty($arrayfields['e.fk_statut']['checked'])) + if (!empty($arrayfields['e.fk_statut']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Billed - if (! empty($arrayfields['e.billed']['checked'])) + if (!empty($arrayfields['e.billed']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Action column print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "\n"; @@ -640,8 +640,8 @@ if ($resql) } $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 + $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 "
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print ''; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT)); print ' '; print ''; } - if (! empty($arrayfields['l.date_delivery']['checked'])) + if (!empty($arrayfields['l.date_delivery']['checked'])) { // Date received print ' '; print ''; print ''; - print $form->selectarray('viewstatut', array('0'=>$langs->trans('StatusSendingDraftShort'),'1'=>$langs->trans('StatusSendingValidatedShort'),'2'=>$langs->trans('StatusSendingProcessedShort')), $viewstatut, 1); + print $form->selectarray('viewstatut', array('0'=>$langs->trans('StatusSendingDraftShort'), '1'=>$langs->trans('StatusSendingValidatedShort'), '2'=>$langs->trans('StatusSendingProcessedShort')), $viewstatut, 1); print ''; print $form->selectyesno('search_billed', $search_billed, 1, 0, 1); @@ -440,121 +440,121 @@ if ($resql) } // Action column print ''; - $searchpicto=$form->showFilterAndCheckAddButtons(0); + $searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
"; print $shipment->getNomUrl(1); print ""; print $obj->ref_customer; print "'; print $companystatic->getNomUrl(1); print ''; print $obj->town; print ''; print $obj->zip; print '".$obj->state_name."'; - $tmparray=getCountry($obj->fk_pays, 'all'); + $tmparray = getCountry($obj->fk_pays, 'all'); print $tmparray['label']; print ''; if (isset($typenArray[$obj->typent_code])) print $typenArray[$obj->typent_code]; print ''; print dol_print_date($db->jdate($obj->date_livraison), "day"); @@ -565,13 +565,13 @@ if ($resql) print "'; @@ -579,7 +579,7 @@ if ($resql) print ''; @@ -591,48 +591,48 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['e.datec']['checked'])) + if (!empty($arrayfields['e.datec']['checked'])) { print ''; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''.$shipment->LibStatut($obj->fk_statut, 5).''.yn($obj->billed).''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; } print '
"; diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 91d0efec9cc..385277bb7d3 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -45,35 +45,35 @@ $action = GETPOST('action', 'aZ09'); $massaction = GETPOST('massaction', 'alpha'); $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); -$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button $toselect = GETPOST('toselect', 'array'); -$contextpage = GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'expensereportlist'; +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'expensereportlist'; $childids = $user->getAllChildIds(1); // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'expensereport', '', ''); $id = GETPOST('id', 'int'); // If we are on the view of a specific user if ($id > 0) { - $canread=0; - if ($id == $user->id) $canread=1; - if (! empty($user->rights->expensereport->readall)) $canread=1; - if (! empty($user->rights->expensereport->lire) && in_array($id, $childids)) $canread=1; - if (! $canread) + $canread = 0; + if ($id == $user->id) $canread = 1; + if (!empty($user->rights->expensereport->readall)) $canread = 1; + if (!empty($user->rights->expensereport->lire) && in_array($id, $childids)) $canread = 1; + if (!$canread) { accessforbidden(); } } -$diroutputmassaction=$conf->expensereport->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->expensereport->dir_output.'/temp/massgeneration/'.$user->id; // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -81,17 +81,17 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortorder) $sortorder="DESC"; -if (!$sortfield) $sortfield="d.date_debut"; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "d.date_debut"; -$sall = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_ref = GETPOST('search_ref', 'alpha'); $search_user = GETPOST('search_user', 'int'); $search_amount_ht = GETPOST('search_amount_ht', 'alpha'); $search_amount_vat = GETPOST('search_amount_vat', 'alpha'); $search_amount_ttc = GETPOST('search_amount_ttc', 'alpha'); -$search_status = (GETPOST('search_status', 'intcomma')!=''?GETPOST('search_status', 'intcomma'):GETPOST('statut', 'intcomma')); +$search_status = (GETPOST('search_status', 'intcomma') != '' ?GETPOST('search_status', 'intcomma') : GETPOST('statut', 'intcomma')); $month_start = GETPOST("month_start", "int"); $year_start = GETPOST("year_start", "int"); $day_start = GETPOST("day_start", "int"); @@ -100,8 +100,8 @@ $month_end = GETPOST("month_end", "int"); $year_end = GETPOST("year_end", "int"); $optioncss = GETPOST('optioncss', 'alpha'); -if ($search_status == '') $search_status=-1; -if ($search_user == '') $search_user=-1; +if ($search_status == '') $search_status = -1; +if ($search_user == '') $search_user = -1; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new ExpenseReport($db); @@ -111,7 +111,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label('expensereport'); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" @@ -122,9 +122,9 @@ $fieldstosearchall = array( 'u.firstname'=>"Firstname", 'u.login'=>"Login", ); -if (empty($user->socid)) $fieldstosearchall["d.note_private"]="NotePrivate"; +if (empty($user->socid)) $fieldstosearchall["d.note_private"] = "NotePrivate"; -$arrayfields=array( +$arrayfields = array( 'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'user'=>array('label'=>$langs->trans("User"), 'checked'=>1), 'd.date_debut'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1), @@ -141,14 +141,14 @@ $arrayfields=array( // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } -$canedituser=(! empty($user->admin) || $user->rights->user->user->creer); +$canedituser = (!empty($user->admin) || $user->rights->user->user->creer); $objectuser = new User($db); @@ -157,11 +157,11 @@ $objectuser = new User($db); * 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('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) @@ -172,35 +172,35 @@ if (empty($reshook)) // Purge search criteria 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_ref=""; - $search_user=""; - $search_amount_ht=""; - $search_amount_vat=""; - $search_amount_ttc=""; - $search_status=""; - $month_start=""; - $year_start=""; - $month_end=""; - $year_end=""; + $search_ref = ""; + $search_user = ""; + $search_amount_ht = ""; + $search_amount_vat = ""; + $search_amount_ttc = ""; + $search_status = ""; + $month_start = ""; + $year_start = ""; + $month_end = ""; + $year_end = ""; $day_end = ""; - $toselect=''; - $search_array_options=array(); + $toselect = ''; + $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { - $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='ExpenseReport'; - $objectlabel='ExpenseReport'; + $objectclass = 'ExpenseReport'; + $objectlabel = 'ExpenseReport'; $permissiontoread = $user->rights->expensereport->lire; $permissiontodelete = $user->rights->expensereport->supprimer; $uploaddir = $conf->expensereport->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; - if ($action == 'update' && ! $cancel) + if ($action == 'update' && !$cancel) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -277,49 +277,49 @@ if ($id > 0) } $sql = "SELECT d.rowid, d.ref, d.fk_user_author, d.total_ht, d.total_tva, d.total_ttc, d.fk_statut as status,"; -$sql.= " d.date_debut, d.date_fin, d.date_create, d.tms as date_modif, d.date_valid, d.date_approve, d.note_private, d.note_public,"; -$sql.= " u.rowid as id_user, u.firstname, u.lastname, u.login, u.email, u.statut, u.photo"; +$sql .= " d.date_debut, d.date_fin, d.date_create, d.tms as date_modif, d.date_valid, d.date_approve, d.note_private, d.note_public,"; +$sql .= " u.rowid as id_user, u.firstname, u.lastname, u.login, u.email, u.statut, u.photo"; // 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 : ''); +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 : ''); } // 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 ".MAIN_DB_PREFIX."expensereport as d"; -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 (d.rowid = ef.fk_object)"; -$sql.= ", ".MAIN_DB_PREFIX."user as u"; -$sql.= " WHERE d.fk_user_author = u.rowid AND d.entity IN (".getEntity('expensereport').")"; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as d"; +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 (d.rowid = ef.fk_object)"; +$sql .= ", ".MAIN_DB_PREFIX."user as u"; +$sql .= " WHERE d.fk_user_author = u.rowid AND d.entity IN (".getEntity('expensereport').")"; // Search all -if (!empty($sall)) $sql.= natural_search(array_keys($fieldstosearchall), $sall); +if (!empty($sall)) $sql .= natural_search(array_keys($fieldstosearchall), $sall); // Ref -if (!empty($search_ref)) $sql.= natural_search('d.ref', $search_ref); +if (!empty($search_ref)) $sql .= natural_search('d.ref', $search_ref); // Date Start -$sql.= dolSqlDateFilter("d.date_debut", $day_start, $month_start, $year_start); +$sql .= dolSqlDateFilter("d.date_debut", $day_start, $month_start, $year_start); // Date End -$sql.= dolSqlDateFilter("d.date_fin", $day_end, $month_end, $year_end); +$sql .= dolSqlDateFilter("d.date_fin", $day_end, $month_end, $year_end); -if ($search_amount_ht != '') $sql.= natural_search('d.total_ht', $search_amount_ht, 1); -if ($search_amount_ttc != '') $sql.= natural_search('d.total_ttc', $search_amount_ttc, 1); +if ($search_amount_ht != '') $sql .= natural_search('d.total_ht', $search_amount_ht, 1); +if ($search_amount_ttc != '') $sql .= natural_search('d.total_ttc', $search_amount_ttc, 1); // User -if ($search_user != '' && $search_user >= 0) $sql.= " AND u.rowid = '".$db->escape($search_user)."'"; +if ($search_user != '' && $search_user >= 0) $sql .= " AND u.rowid = '".$db->escape($search_user)."'"; // Status -if ($search_status != '' && $search_status >= 0) $sql.=" AND d.fk_statut IN (".$db->escape($search_status).")"; +if ($search_status != '' && $search_status >= 0) $sql .= " AND d.fk_statut IN (".$db->escape($search_status).")"; // RESTRICT RIGHTS if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) { - $sql.= " AND d.fk_user_author IN (".join(',', $childids).")\n"; + $sql .= " AND d.fk_user_author IN (".join(',', $childids).")\n"; } // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -334,7 +334,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); //print $sql; $resql = $db->query($sql); @@ -342,37 +342,37 @@ if ($resql) { $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($sall) $param.="&sall=".urlencode($sall); - if ($search_ref) $param.="&search_ref=".urlencode($search_ref); - if ($search_user) $param.="&search_user=".urlencode($search_user); - if ($search_amount_ht) $param.="&search_amount_ht=".urlencode($search_amount_ht); - if ($search_amount_ttc) $param.="&search_amount_ttc=".urlencode($search_amount_ttc); - if ($search_status >= 0) $param.="&search_status=".urlencode($search_status); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($sall) $param .= "&sall=".urlencode($sall); + if ($search_ref) $param .= "&search_ref=".urlencode($search_ref); + if ($search_user) $param .= "&search_user=".urlencode($search_user); + if ($search_amount_ht) $param .= "&search_amount_ht=".urlencode($search_amount_ht); + if ($search_amount_ttc) $param .= "&search_amount_ttc=".urlencode($search_amount_ttc); + if ($search_status >= 0) $param .= "&search_status=".urlencode($search_status); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available - $arrayofmassactions = array( + $arrayofmassactions = array( 'generate_doc'=>$langs->trans("ReGeneratePDF"), 'builddoc'=>$langs->trans("PDFMerge"), 'presend'=>$langs->trans("SendByMail"), ); - if ($user->rights->expensereport->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); - if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + if ($user->rights->expensereport->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); + if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); // Lines of title fields print ''."\n"; if ($optioncss != '') print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -449,7 +449,7 @@ if ($resql) $childids = $user->getAllChildIds(1); - $canedit=((in_array($user_id, $childids) && $user->rights->expensereport->creer) + $canedit = ((in_array($user_id, $childids) && $user->rights->expensereport->creer) || ($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->expensereport->writeall_advance)); // Buttons for actions @@ -471,58 +471,58 @@ if ($resql) { $title = $langs->trans("ListTripsAndExpenses"); - $newcardbutton=''; + $newcardbutton = ''; if ($user->rights->expensereport->creer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewTrip'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/expensereport/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewTrip'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/expensereport/card.php?action=create'); } print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit); } - $topicmail="SendExpenseReport"; - $modelmail="expensereport"; - $objecttmp=new ExpenseReport($db); - $trackid='exp'.$object->id; + $topicmail = "SendExpenseReport"; + $modelmail = "expensereport"; + $objecttmp = new ExpenseReport($db); + $trackid = 'exp'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } - $moreforfilter=''; + $moreforfilter = ''; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - if (! empty($moreforfilter)) + if (!empty($moreforfilter)) { print '
'; print $moreforfilter; print '
'; } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - $selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; - print ''."\n"; + print '
'."\n"; // Filters print ''; - if (! empty($arrayfields['d.ref']['checked'])) + if (!empty($arrayfields['d.ref']['checked'])) { print ''; } // User - if (! empty($arrayfields['user']['checked'])) + if (!empty($arrayfields['user']['checked'])) { if ($user->rights->expensereport->readall || $user->rights->expensereport->lire_tous) { @@ -534,10 +534,10 @@ if ($resql) } } // Date start - if (! empty($arrayfields['d.date_debut']['checked'])) + if (!empty($arrayfields['d.date_debut']['checked'])) { print ''; } // Date end - if (! empty($arrayfields['d.date_fin']['checked'])) + if (!empty($arrayfields['d.date_fin']['checked'])) { print ''; } // Date valid - if (! empty($arrayfields['d.date_valid']['checked'])) + if (!empty($arrayfields['d.date_valid']['checked'])) { print ''; } // Date approve - if (! empty($arrayfields['d.date_approve']['checked'])) + if (!empty($arrayfields['d.date_approve']['checked'])) { print ''; } // Amount with no tax - if (! empty($arrayfields['d.total_ht']['checked'])) + if (!empty($arrayfields['d.total_ht']['checked'])) { print ''; } - if (! empty($arrayfields['d.total_vat']['checked'])) + if (!empty($arrayfields['d.total_vat']['checked'])) { print ''; } // Amount with all taxes - if (! empty($arrayfields['d.total_ttc']['checked'])) + if (!empty($arrayfields['d.total_ttc']['checked'])) { print ''; } @@ -590,23 +590,23 @@ if ($resql) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['d.date_create']['checked'])) + if (!empty($arrayfields['d.date_create']['checked'])) { print ''; } // Date modification - if (! empty($arrayfields['d.tms']['checked'])) + if (!empty($arrayfields['d.tms']['checked'])) { print ''; } // Status - if (! empty($arrayfields['d.fk_statut']['checked'])) + if (!empty($arrayfields['d.fk_statut']['checked'])) { print ''; print "\n"; print ''; - if (! empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], "d.ref", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['user']['checked'])) print_liste_field_titre($arrayfields['user']['label'], $_SERVER["PHP_SELF"], "u.lastname", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['d.date_debut']['checked'])) print_liste_field_titre($arrayfields['d.date_debut']['label'], $_SERVER["PHP_SELF"], "d.date_debut", "", $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['d.date_fin']['checked'])) print_liste_field_titre($arrayfields['d.date_fin']['label'], $_SERVER["PHP_SELF"], "d.date_fin", "", $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['d.date_valid']['checked'])) print_liste_field_titre($arrayfields['d.date_valid']['label'], $_SERVER["PHP_SELF"], "d.date_valid", "", $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['d.date_approve']['checked'])) print_liste_field_titre($arrayfields['d.date_approve']['label'], $_SERVER["PHP_SELF"], "d.date_approve", "", $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['d.total_ht']['checked'])) print_liste_field_titre($arrayfields['d.total_ht']['label'], $_SERVER["PHP_SELF"], "d.total_ht", "", $param, 'align="right"', $sortfield, $sortorder); - if (! empty($arrayfields['d.total_vat']['checked'])) print_liste_field_titre($arrayfields['d.total_vat']['label'], $_SERVER["PHP_SELF"], "d.total_tva", "", $param, 'align="right"', $sortfield, $sortorder); - if (! empty($arrayfields['d.total_ttc']['checked'])) print_liste_field_titre($arrayfields['d.total_ttc']['label'], $_SERVER["PHP_SELF"], "d.total_ttc", "", $param, 'align="right"', $sortfield, $sortorder); + if (!empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], "d.ref", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['user']['checked'])) print_liste_field_titre($arrayfields['user']['label'], $_SERVER["PHP_SELF"], "u.lastname", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['d.date_debut']['checked'])) print_liste_field_titre($arrayfields['d.date_debut']['label'], $_SERVER["PHP_SELF"], "d.date_debut", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['d.date_fin']['checked'])) print_liste_field_titre($arrayfields['d.date_fin']['label'], $_SERVER["PHP_SELF"], "d.date_fin", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['d.date_valid']['checked'])) print_liste_field_titre($arrayfields['d.date_valid']['label'], $_SERVER["PHP_SELF"], "d.date_valid", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['d.date_approve']['checked'])) print_liste_field_titre($arrayfields['d.date_approve']['label'], $_SERVER["PHP_SELF"], "d.date_approve", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['d.total_ht']['checked'])) print_liste_field_titre($arrayfields['d.total_ht']['label'], $_SERVER["PHP_SELF"], "d.total_ht", "", $param, 'align="right"', $sortfield, $sortorder); + if (!empty($arrayfields['d.total_vat']['checked'])) print_liste_field_titre($arrayfields['d.total_vat']['label'], $_SERVER["PHP_SELF"], "d.total_tva", "", $param, 'align="right"', $sortfield, $sortorder); + if (!empty($arrayfields['d.total_ttc']['checked'])) print_liste_field_titre($arrayfields['d.total_ttc']['label'], $_SERVER["PHP_SELF"], "d.total_ttc", "", $param, 'align="right"', $sortfield, $sortorder); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['d.date_create']['checked'])) print_liste_field_titre($arrayfields['d.date_create']['label'], $_SERVER["PHP_SELF"], "d.date_create", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); - if (! empty($arrayfields['d.tms']['checked'])) print_liste_field_titre($arrayfields['d.tms']['label'], $_SERVER["PHP_SELF"], "d.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); - if (! empty($arrayfields['d.fk_statut']['checked'])) print_liste_field_titre($arrayfields['d.fk_statut']['label'], $_SERVER["PHP_SELF"], "d.fk_statut", "", $param, 'align="right"', $sortfield, $sortorder); + if (!empty($arrayfields['d.date_create']['checked'])) print_liste_field_titre($arrayfields['d.date_create']['label'], $_SERVER["PHP_SELF"], "d.date_create", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + if (!empty($arrayfields['d.tms']['checked'])) print_liste_field_titre($arrayfields['d.tms']['label'], $_SERVER["PHP_SELF"], "d.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + if (!empty($arrayfields['d.fk_statut']['checked'])) print_liste_field_titre($arrayfields['d.fk_statut']['label'], $_SERVER["PHP_SELF"], "d.fk_statut", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; @@ -646,33 +646,33 @@ if ($resql) $total_total_ttc = 0; $total_total_tva = 0; - $expensereportstatic=new ExpenseReport($db); + $expensereportstatic = new ExpenseReport($db); $usertmp = new User($db); if ($num > 0) { - $i=0; - $totalarray=array(); + $i = 0; + $totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - $expensereportstatic->id=$obj->rowid; - $expensereportstatic->ref=$obj->ref; - $expensereportstatic->status=$obj->status; - $expensereportstatic->date_debut=$db->jdate($obj->date_debut); - $expensereportstatic->date_fin=$db->jdate($obj->date_fin); - $expensereportstatic->date_create=$db->jdate($obj->date_create); - $expensereportstatic->date_modif=$db->jdate($obj->date_modif); - $expensereportstatic->date_valid=$db->jdate($obj->date_valid); - $expensereportstatic->date_approve=$db->jdate($obj->date_approve); - $expensereportstatic->note_private=$obj->note_private; - $expensereportstatic->note_public=$obj->note_public; + $expensereportstatic->id = $obj->rowid; + $expensereportstatic->ref = $obj->ref; + $expensereportstatic->status = $obj->status; + $expensereportstatic->date_debut = $db->jdate($obj->date_debut); + $expensereportstatic->date_fin = $db->jdate($obj->date_fin); + $expensereportstatic->date_create = $db->jdate($obj->date_create); + $expensereportstatic->date_modif = $db->jdate($obj->date_modif); + $expensereportstatic->date_valid = $db->jdate($obj->date_valid); + $expensereportstatic->date_approve = $db->jdate($obj->date_approve); + $expensereportstatic->note_private = $obj->note_private; + $expensereportstatic->note_public = $obj->note_public; print ''; // Ref - if (! empty($arrayfields['d.ref']['checked'])) { + if (!empty($arrayfields['d.ref']['checked'])) { print ''; @@ -1614,12 +1614,12 @@ if ($action=='create') // Payment term print ''; // Payment mode print ''; // Planned delivery date @@ -1627,29 +1627,29 @@ if ($action=='create') print $langs->trans('DateDeliveryPlanned'); print ''; print ''; // Bank Account - if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER) && ! empty($conf->banque->enabled)) + if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER) && !empty($conf->banque->enabled)) { $langs->load("bank"); - print ''; } // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); $langs->load('projects'); - print ''; } @@ -1660,12 +1660,12 @@ if ($action=='create') print ''; print ''; print ''; } // Multicurrency - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print ''; print ''; @@ -1690,42 +1690,42 @@ if ($action=='create') //print ''; print ''; - if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) { - print "\n"; + if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { + print "\n"; print "\n"; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - print ''; - print ''; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''; + print ''; $newclassname = $classname; - print ''; - print ''; - print '"; + print ''; + print ''; + print '"; if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE { - print '"; + print '"; } if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 IRPF { - print '"; + print '"; } - print '"; + print '"; if (!empty($conf->multicurrency->enabled)) { - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; } } // Other options - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) @@ -1741,13 +1741,13 @@ if ($action=='create') print '
'; print ''; print '     '; - print ''; + print ''; print '
'; print "\n"; // Show origin lines - if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) + if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { $title = $langs->trans('ProductsAndServices'); print load_fiche_titre($title); @@ -1759,30 +1759,30 @@ if ($action=='create') print '
'; print ''; print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { print ''; } @@ -546,10 +546,10 @@ if ($resql) print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { print ''; } print ''; @@ -557,7 +557,7 @@ if ($resql) print ''; //print ''; @@ -565,7 +565,7 @@ if ($resql) print ''; //print ''; @@ -573,16 +573,16 @@ if ($resql) print ''; print ''; print ''; select_expensereport_statut($search_status, 'search_status', 1, 1); @@ -614,31 +614,31 @@ if ($resql) } // Action column print ''; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; print ''; print ''; } @@ -819,8 +819,8 @@ if ($resql) $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 + $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 '
'; @@ -809,8 +809,8 @@ if ($resql) } else { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print '
'.$langs->trans("NoRecordFound").'
'."\n"; @@ -830,16 +830,16 @@ if ($resql) if (empty($id)) { - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->expensereport->lire; - $delallowed=$user->rights->expensereport->creer; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->expensereport->lire; + $delallowed = $user->rights->expensereport->creer; print $formfile->showdocuments('massfilesarea_expensereport', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index eeebd317977..9564481eab4 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -32,39 +32,39 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -if (!empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; -if (!empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php'; +if (!empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +if (!empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; // Load translation files required by the page $langs->loadLangs(array('companies', 'bills', 'interventions')); if (!empty($conf->projet->enabled)) $langs->load("projects"); if (!empty($conf->contrat->enabled)) $langs->load("contracts"); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'interventionlist'; +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'interventionlist'; -$search_ref=GETPOST('search_ref')?GETPOST('search_ref', 'alpha'):GETPOST('search_inter', 'alpha'); -$search_company=GETPOST('search_company', 'alpha'); -$search_desc=GETPOST('search_desc', 'alpha'); -$search_projet_ref=GETPOST('search_projet_ref', 'alpha'); -$search_contrat_ref=GETPOST('search_contrat_ref', 'alpha'); -$search_status=GETPOST('search_status', 'alpha'); -$sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); +$search_ref = GETPOST('search_ref') ?GETPOST('search_ref', 'alpha') : GETPOST('search_inter', 'alpha'); +$search_company = GETPOST('search_company', 'alpha'); +$search_desc = GETPOST('search_desc', 'alpha'); +$search_projet_ref = GETPOST('search_projet_ref', 'alpha'); +$search_contrat_ref = GETPOST('search_contrat_ref', 'alpha'); +$search_status = GETPOST('search_status', 'alpha'); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $optioncss = GETPOST('optioncss', 'alpha'); -$socid=GETPOST('socid', 'int'); +$socid = GETPOST('socid', 'int'); // Security check $id = GETPOST('id', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'ficheinter', $id, 'fichinter'); -$diroutputmassaction=$conf->ficheinter->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->ficheinter->dir_output.'/temp/massgeneration/'.$user->id; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -72,12 +72,12 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="DESC"; -if (! $sortfield) +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) { //if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) $sortfield="fd.date"; //else - $sortfield="f.ref"; + $sortfield = "f.ref"; } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -89,7 +89,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label('fichinter'); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -98,30 +98,30 @@ $fieldstosearchall = array( 'f.description'=>'Description', 'f.note_public'=>'NotePublic', ); -if (empty($user->socid)) $fieldstosearchall["f.note_private"]="NotePrivate"; -if (! empty($conf->global->FICHINTER_DISABLE_DETAILS)) unset($fieldstosearchall['f.description']); +if (empty($user->socid)) $fieldstosearchall["f.note_private"] = "NotePrivate"; +if (!empty($conf->global->FICHINTER_DISABLE_DETAILS)) unset($fieldstosearchall['f.description']); // Definition of fields for list -$arrayfields=array( +$arrayfields = array( 'f.ref'=>array('label'=>'Ref', 'checked'=>1), 's.nom'=>array('label'=>'ThirdParty', 'checked'=>1), - 'pr.ref'=>array('label'=>'Project', 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled)?0:1)), - 'c.ref'=>array('label'=>'Contract', 'checked'=>1, 'enabled'=>(empty($conf->contrat->enabled)?0:1)), + 'pr.ref'=>array('label'=>'Project', 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)), + 'c.ref'=>array('label'=>'Contract', 'checked'=>1, 'enabled'=>(empty($conf->contrat->enabled) ? 0 : 1)), 'f.description'=>array('label'=>'Description', 'checked'=>1), 'f.datec'=>array('label'=>'DateCreation', 'checked'=>0, 'position'=>500), 'f.tms'=>array('label'=>'DateModificationShort', 'checked'=>0, 'position'=>500), 'f.fk_statut'=>array('label'=>'Status', 'checked'=>1, 'position'=>1000), - 'fd.description'=>array('label'=>"DescriptionOfLine", 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS)?1:0), - 'fd.date'=>array('label'=>'DateOfLine', 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS)?1:0), - 'fd.duree'=>array('label'=>'DurationOfLine', 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS)?1:0), + 'fd.description'=>array('label'=>"DescriptionOfLine", 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS) ? 1 : 0), + 'fd.date'=>array('label'=>'DateOfLine', 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS) ? 1 : 0), + 'fd.duree'=>array('label'=>'DurationOfLine', 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS) ? 1 : 0), ); // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -132,11 +132,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; } -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) @@ -147,19 +147,19 @@ if (empty($reshook)) // Purge search criteria 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_ref=""; - $search_company=""; - $search_projet_ref=""; - $search_contrat_ref=""; - $search_desc=""; - $search_status=""; - $toselect=''; - $search_array_options=array(); + $search_ref = ""; + $search_company = ""; + $search_projet_ref = ""; + $search_contrat_ref = ""; + $search_desc = ""; + $search_status = ""; + $toselect = ''; + $search_array_options = array(); } // Mass actions - $objectclass='Fichinter'; - $objectlabel='Interventions'; + $objectclass = 'Fichinter'; + $objectlabel = 'Interventions'; $permissiontoread = $user->rights->ficheinter->lire; $permissiontodelete = $user->rights->ficheinter->supprimer; $uploaddir = $conf->ficheinter->dir_output; @@ -172,29 +172,29 @@ if (empty($reshook)) * View */ -$now=dol_now(); +$now = dol_now(); $form = new Form($db); $formfile = new FormFile($db); -$objectstatic=new Fichinter($db); -$companystatic=new Societe($db); +$objectstatic = new Fichinter($db); +$companystatic = new Societe($db); if (!empty($conf->projet->enabled)) { - $projetstatic=new Project($db); + $projetstatic = new Project($db); } if (!empty($conf->contrat->enabled)) { - $contratstatic=new Contrat($db); + $contratstatic = new Contrat($db); } -$title=$langs->trans("ListOfInterventions"); +$title = $langs->trans("ListOfInterventions"); llxHeader('', $title); -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -$atleastonefieldinlines=0; -foreach($arrayfields as $tmpkey => $tmpval) +$atleastonefieldinlines = 0; +foreach ($arrayfields as $tmpkey => $tmpval) { - if (preg_match('/^fd\./', $tmpkey) && ! empty($arrayfields[$tmpkey]['checked'])) + if (preg_match('/^fd\./', $tmpkey) && !empty($arrayfields[$tmpkey]['checked'])) { $atleastonefieldinlines++; break; @@ -202,9 +202,9 @@ foreach($arrayfields as $tmpkey => $tmpval) } $sql = "SELECT"; -$sql.= " f.ref, f.rowid, f.fk_statut, f.description, f.datec as date_creation, f.tms as date_update, f.note_private,"; -if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) $sql.= "fd.rowid as lineid, fd.description as descriptiondetail, fd.date as dp, fd.duree,"; -$sql.= " s.nom as name, s.rowid as socid, s.client"; +$sql .= " f.ref, f.rowid, f.fk_statut, f.description, f.datec as date_creation, f.tms as date_update, f.note_private,"; +if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) $sql .= "fd.rowid as lineid, fd.description as descriptiondetail, fd.date as dp, fd.duree,"; +$sql .= " s.nom as name, s.rowid as socid, s.client"; if (!empty($conf->projet->enabled)) { $sql .= ", pr.rowid as projet_id, pr.ref as projet_ref, pr.title as projet_title"; } @@ -212,26 +212,26 @@ if (!empty($conf->contrat->enabled)) { $sql .= ", c.rowid as contrat_id, c.ref as contrat_ref, c.ref_customer as contrat_ref_supplier, c.ref_supplier as contrat_ref_supplier"; } // 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 : ''); +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 : ''); } // 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 ".MAIN_DB_PREFIX."fichinter as f"; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f"; if (!empty($conf->projet->enabled)) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr on f.fk_projet = pr.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr on f.fk_projet = pr.rowid"; } if (!empty($conf->contrat->enabled)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contrat as c on f.fk_contrat = c.rowid"; } -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 (f.rowid = ef.fk_object)"; -if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as fd ON fd.fk_fichinter = f.rowid"; -if (! $user->rights->societe->client->voir && empty($socid)) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= ", ".MAIN_DB_PREFIX."societe as s"; -$sql.= " WHERE f.entity IN (".getEntity('intervention').")"; -$sql.= " AND f.fk_soc = s.rowid"; +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 (f.rowid = ef.fk_object)"; +if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as fd ON fd.fk_fichinter = f.rowid"; +if (!$user->rights->societe->client->voir && empty($socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql .= ", ".MAIN_DB_PREFIX."societe as s"; +$sql .= " WHERE f.entity IN (".getEntity('intervention').")"; +$sql .= " AND f.fk_soc = s.rowid"; if ($search_ref) { $sql .= natural_search('f.ref', $search_ref); } @@ -251,20 +251,20 @@ if ($search_desc) { if ($search_status != '' && $search_status >= 0) { $sql .= ' AND f.fk_statut = '.$search_status; } -if (! $user->rights->societe->client->voir && empty($socid)) - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; +if (!$user->rights->societe->client->voir && empty($socid)) + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($socid) - $sql.= " AND s.rowid = " . $socid; + $sql .= " AND s.rowid = ".$socid; if ($sall) { $sql .= natural_search(array_keys($fieldstosearchall), $sall); } // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -279,15 +279,15 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); //print $sql; -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); if ($socid > 0) { @@ -296,32 +296,32 @@ if ($resql) if (empty($search_company)) $search_company = $soc->name; } - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($sall) $param.="&sall=".urlencode($sall); - if ($socid) $param.="&socid=".urlencode($socid); - if ($search_ref) $param.="&search_ref=".urlencode($search_ref); - if ($search_company) $param.="&search_company=".urlencode($search_company); - if ($search_desc) $param.="&search_desc=".urlencode($search_desc); - if ($search_status != '' && $search_status > -1) $param.="&search_status=".urlencode($search_status); - if ($show_files) $param.='&show_files='.urlencode($show_files); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($sall) $param .= "&sall=".urlencode($sall); + if ($socid) $param .= "&socid=".urlencode($socid); + if ($search_ref) $param .= "&search_ref=".urlencode($search_ref); + if ($search_company) $param .= "&search_company=".urlencode($search_company); + if ($search_desc) $param .= "&search_desc=".urlencode($search_desc); + if ($search_status != '' && $search_status > -1) $param .= "&search_status=".urlencode($search_status); + if ($show_files) $param .= '&show_files='.urlencode($show_files); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available - $arrayofmassactions = array( + $arrayofmassactions = array( 'generate_doc'=>$langs->trans("ReGeneratePDF"), 'builddoc'=>$langs->trans("PDFMerge"), //'presend'=>$langs->trans("SendByMail"), ); - if ($user->rights->ficheinter->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); - if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + if ($user->rights->ficheinter->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); + if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); - $newcardbutton=''; - $morehtmlcenter.= dolGetButtonTitle($langs->trans('NewIntervention'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/fichinter/card.php?action=create', '', $user->rights->ficheinter->creer); + $newcardbutton = ''; + $morehtmlcenter .= dolGetButtonTitle($langs->trans('NewIntervention'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/fichinter/card.php?action=create', '', $user->rights->ficheinter->creer); // Lines of title fields print ''."\n"; @@ -336,63 +336,63 @@ if ($resql) print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'commercial', 0, $newcardbutton, '', $limit); - $topicmail="Information"; - $modelmail="intervention"; - $objecttmp=new Fichinter($db); - $trackid='int'.$object->id; + $topicmail = "Information"; + $modelmail = "intervention"; + $objecttmp = new Fichinter($db); + $trackid = 'int'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } - $moreforfilter=''; + $moreforfilter = ''; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - if (! empty($moreforfilter)) + if (!empty($moreforfilter)) { print '
'; print $moreforfilter; print '
'; } - if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); print '
'; - print ''."\n"; + print '
'."\n"; print ''; - if (! empty($arrayfields['f.ref']['checked'])) + if (!empty($arrayfields['f.ref']['checked'])) { print ''; } - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print ''; } - if (! empty($arrayfields['pr.ref']['checked'])) + if (!empty($arrayfields['pr.ref']['checked'])) { print ''; } - if (! empty($arrayfields['c.ref']['checked'])) + if (!empty($arrayfields['c.ref']['checked'])) { print ''; } - if (! empty($arrayfields['f.description']['checked'])) + if (!empty($arrayfields['f.description']['checked'])) { print ''; } - if (! empty($arrayfields['f.tms']['checked'])) + if (!empty($arrayfields['f.tms']['checked'])) { // Date modification print ''; } // Status - if (! empty($arrayfields['f.fk_statut']['checked'])) + if (!empty($arrayfields['f.fk_statut']['checked'])) { print ''; } // Fields of detail line - if (! empty($arrayfields['fd.description']['checked'])) + if (!empty($arrayfields['fd.description']['checked'])) { print ''; } - if (! empty($arrayfields['fd.date']['checked'])) + if (!empty($arrayfields['fd.date']['checked'])) { print ''; } - if (! empty($arrayfields['fd.duree']['checked'])) + if (!empty($arrayfields['fd.duree']['checked'])) { print ''; } print ''; print "\n"; print ''; - if (! empty($arrayfields['f.ref']['checked'])) print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['pr.ref']['checked'])) print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], "pr.ref", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['c.ref']['checked'])) print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['f.description']['checked'])) print_liste_field_titre($arrayfields['f.description']['label'], $_SERVER["PHP_SELF"], "f.description", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['f.ref']['checked'])) print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['pr.ref']['checked'])) print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], "pr.ref", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['c.ref']['checked'])) print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['f.description']['checked'])) print_liste_field_titre($arrayfields['f.description']['label'], $_SERVER["PHP_SELF"], "f.description", "", $param, '', $sortfield, $sortorder); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (! empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['fd.description']['checked'])) print_liste_field_titre($arrayfields['fd.description']['label'], $_SERVER["PHP_SELF"], ''); - if (! empty($arrayfields['fd.date']['checked'])) print_liste_field_titre($arrayfields['fd.date']['label'], $_SERVER["PHP_SELF"], "fd.date", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['fd.duree']['checked'])) print_liste_field_titre($arrayfields['fd.duree']['label'], $_SERVER["PHP_SELF"], "fd.duree", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['fd.description']['checked'])) print_liste_field_titre($arrayfields['fd.description']['label'], $_SERVER["PHP_SELF"], ''); + if (!empty($arrayfields['fd.date']['checked'])) print_liste_field_titre($arrayfields['fd.date']['label'], $_SERVER["PHP_SELF"], "fd.date", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['fd.duree']['checked'])) print_liste_field_titre($arrayfields['fd.duree']['label'], $_SERVER["PHP_SELF"], "fd.duree", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; $total = 0; $i = 0; - $totalarray=array(); + $totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - $objectstatic->id=$obj->rowid; - $objectstatic->ref=$obj->ref; - $objectstatic->statut=$obj->fk_statut; + $objectstatic->id = $obj->rowid; + $objectstatic->ref = $obj->ref; + $objectstatic->statut = $obj->fk_statut; print ''; - if (! empty($arrayfields['f.ref']['checked'])) + if (!empty($arrayfields['f.ref']['checked'])) { print "'; // Warning - $warnornote=''; + $warnornote = ''; //if ($obj->fk_statut == 1 && $db->jdate($obj->dfv) < ($now - $conf->fichinter->warning_delay)) $warnornote.=img_warning($langs->trans("Late")); - if (! empty($obj->note_private)) + if (!empty($obj->note_private)) { - $warnornote.=($warnornote?' ':''); - $warnornote.= ''; - $warnornote.= ''.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').''; - $warnornote.= ''; + $warnornote .= ($warnornote ? ' ' : ''); + $warnornote .= ''; + $warnornote .= ''.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').''; + $warnornote .= ''; } if ($warnornote) { @@ -627,8 +627,8 @@ if ($resql) $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 + $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 '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; @@ -402,86 +402,86 @@ if ($resql) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['f.datec']['checked'])) + if (!empty($arrayfields['f.datec']['checked'])) { // Date creation print ''; print ''; print ''; - $tmp = $objectstatic->LibStatut(0); // To load $this->statuts_short - $liststatus=$objectstatic->statuts_short; - if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1 + $tmp = $objectstatic->LibStatut(0); // To load $this->statuts_short + $liststatus = $objectstatic->statuts_short; + if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1 print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 1); print '   '; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
"; @@ -491,14 +491,14 @@ if ($resql) print $objectstatic->getNomUrl(1); print '
'."\n"; @@ -636,16 +636,16 @@ if ($resql) print "\n"; - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->ficheinter->lire; - $delallowed=$user->rights->ficheinter->creer; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->ficheinter->lire; + $delallowed = $user->rights->ficheinter->creer; print $formfile->showdocuments('massfilesarea_interventions', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 4c6e98eda78..9701f43d993 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -41,30 +41,30 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; -if (! empty($conf->supplier_proposal->enabled)) - require_once DOL_DOCUMENT_ROOT . '/supplier_proposal/class/supplier_proposal.class.php'; +if (!empty($conf->supplier_proposal->enabled)) + require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; if (!empty($conf->product->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; if (!empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } -require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP +require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP if (!empty($conf->variants->enabled)) { require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php'; } -$langs->loadLangs(array('admin','orders','sendings','companies','bills','propal','supplier_proposal','deliveries','products','stocks','productbatch')); +$langs->loadLangs(array('admin', 'orders', 'sendings', 'companies', 'bills', 'propal', 'supplier_proposal', 'deliveries', 'products', 'stocks', 'productbatch')); if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); -$comclientid = GETPOST('comid', 'int'); -$socid = GETPOST('socid', 'int'); -$projectid = GETPOST('projectid', 'int'); +$comclientid = GETPOST('comid', 'int'); +$socid = GETPOST('socid', 'int'); +$projectid = GETPOST('projectid', 'int'); $cancel = GETPOST('cancel', 'alpha'); $lineid = GETPOST('lineid', 'int'); @@ -73,19 +73,19 @@ $origin = GETPOST('origin', 'alpha'); $originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility //PDF -$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); -$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); -$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); +$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); +$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); +$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); -$datelivraison=dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), GETPOST('liv_sec', 'int'), GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); +$datelivraison = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), GETPOST('liv_sec', 'int'), GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); // Security check -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('ordersuppliercard','globalcard')); +$hookmanager->initHooks(array('ordersuppliercard', 'globalcard')); $object = new CommandeFournisseur($db); $extrafields = new ExtraFields($db); @@ -94,58 +94,58 @@ $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); // Load object -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $ret = $object->fetch($id, $ref); if ($ret < 0) dol_print_error($db, $object->error); $ret = $object->fetch_thirdparty(); if ($ret < 0) dol_print_error($db, $object->error); } -elseif (! empty($socid) && $socid > 0) +elseif (!empty($socid) && $socid > 0) { $fourn = new Fournisseur($db); - $ret=$fourn->fetch($socid); + $ret = $fourn->fetch($socid); if ($ret < 0) dol_print_error($db, $object->error); $object->socid = $fourn->id; $ret = $object->fetch_thirdparty(); if ($ret < 0) dol_print_error($db, $object->error); } -$permissionnote=$user->rights->fournisseur->commande->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink=$user->rights->fournisseur->commande->creer; // Used by the include of actions_dellink.inc.php -$permissiontoedit=$user->rights->fournisseur->commande->creer; // Used by the include of actions_lineupdown.inc.php -$permissiontoadd=$user->rights->fournisseur->commande->creer; // Used by the include of actions_addupdatedelete.inc.php +$permissionnote = $user->rights->fournisseur->commande->creer; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->fournisseur->commande->creer; // Used by the include of actions_dellink.inc.php +$permissiontoedit = $user->rights->fournisseur->commande->creer; // Used by the include of actions_lineupdown.inc.php +$permissiontoadd = $user->rights->fournisseur->commande->creer; // Used by the include of actions_addupdatedelete.inc.php /* * Actions */ -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { if ($cancel) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } - $action=''; + $action = ''; } - include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once - include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once - include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once if ($action == 'setref_supplier' && $user->rights->fournisseur->commande->creer) { - $result=$object->setValueFrom('ref_supplier', GETPOST('ref_supplier', 'alpha'), '', null, 'text', '', $user, 'ORDER_SUPPLIER_MODIFY'); + $result = $object->setValueFrom('ref_supplier', GETPOST('ref_supplier', 'alpha'), '', null, 'text', '', $user, 'ORDER_SUPPLIER_MODIFY'); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -159,7 +159,7 @@ if (empty($reshook)) // payment conditions if ($action == 'setconditions' && $user->rights->fournisseur->commande->creer) { - $result=$object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); + $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -183,55 +183,55 @@ if (empty($reshook)) // bank account if ($action == 'setbankaccount' && $user->rights->fournisseur->commande->creer) { - $result=$object->setBankAccount(GETPOST('fk_account', 'int')); + $result = $object->setBankAccount(GETPOST('fk_account', 'int')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // date of delivery if ($action == 'setdate_livraison' && $user->rights->fournisseur->commande->creer) { - $result=$object->set_date_livraison($user, $datelivraison); + $result = $object->set_date_livraison($user, $datelivraison); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // Set project - if ($action == 'classin' && $user->rights->fournisseur->commande->creer) + if ($action == 'classin' && $user->rights->fournisseur->commande->creer) { - $result=$object->setProject($projectid); + $result = $object->setProject($projectid); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // Edit Thirdparty - if (! empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) && $action == 'set_thirdparty' && $user->rights->fournisseur->commande->creer && $object->statut == CommandeFournisseur::STATUS_DRAFT) + if (!empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) && $action == 'set_thirdparty' && $user->rights->fournisseur->commande->creer && $object->statut == CommandeFournisseur::STATUS_DRAFT) { $new_socid = GETPOST('new_socid', 'int'); - if(! empty($new_socid) && $new_socid != $object->thirdparty->id) { + if (!empty($new_socid) && $new_socid != $object->thirdparty->id) { $db->begin(); // Update supplier $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur'; $sql .= ' SET fk_soc='.$new_socid; - $sql.= ' WHERE fk_soc='.$object->thirdparty->id; - $sql.= ' AND rowid='.$object->id; + $sql .= ' WHERE fk_soc='.$object->thirdparty->id; + $sql .= ' AND rowid='.$object->id; $res = $db->query($sql); - if(! $res) $db->rollback(); + if (!$res) $db->rollback(); else { $db->commit(); // Replace prices for each lines by new supplier prices - foreach($object->lines as $l) { + foreach ($object->lines as $l) { $sql = 'SELECT price, unitprice, tva_tx, ref_fourn'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price'; - $sql.= ' WHERE fk_product='.$l->fk_product; - $sql.= ' AND fk_soc='.$new_socid; - $sql.= ' ORDER BY unitprice ASC'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price'; + $sql .= ' WHERE fk_product='.$l->fk_product; + $sql .= ' AND fk_soc='.$new_socid; + $sql .= ' ORDER BY unitprice ASC'; $resql = $db->query($sql); - if($resql) { + if ($resql) { $num_row = $db->num_rows($resql); - if(empty($num_row)) { + if (empty($num_row)) { // No product price for this supplier ! $l->subprice = 0; $l->total_ht = 0; @@ -246,7 +246,7 @@ if (empty($reshook)) $l->subprice = $obj->unitprice; $l->total_ht = $obj->price; $l->tva_tx = $obj->tva_tx; - $l->total_tva = $l->total_ht * ($obj->tva_tx/100); + $l->total_tva = $l->total_ht * ($obj->tva_tx / 100); $l->total_ttc = $l->total_ht + $l->total_tva; $l->ref_supplier = $obj->ref_fourn; $l->update(); @@ -274,21 +274,21 @@ if (empty($reshook)) { if (in_array($object->statut, array(1, 2, 3, 4, 5, 6, 7, 9))) { - if ($object->statut == 1) $newstatus=0; // Validated->Draft - elseif ($object->statut == 2) $newstatus=0; // Approved->Draft - elseif ($object->statut == 3) $newstatus=2; // Ordered->Approved - elseif ($object->statut == 4) $newstatus=3; + if ($object->statut == 1) $newstatus = 0; // Validated->Draft + elseif ($object->statut == 2) $newstatus = 0; // Approved->Draft + elseif ($object->statut == 3) $newstatus = 2; // Ordered->Approved + elseif ($object->statut == 4) $newstatus = 3; elseif ($object->statut == 5) { //$newstatus=2; // Ordered // TODO Can we set it to submited ? //$newstatus=3; // Submited // TODO If there is at least one reception, we can set to Received->Received partially - $newstatus=4; // Received partially + $newstatus = 4; // Received partially } - elseif ($object->statut == 6) $newstatus=2; // Canceled->Approved - elseif ($object->statut == 7) $newstatus=3; // Canceled->Process running - elseif ($object->statut == 9) $newstatus=1; // Refused->Validated + elseif ($object->statut == 6) $newstatus = 2; // Canceled->Approved + elseif ($object->statut == 7) $newstatus = 3; // Canceled->Process running + elseif ($object->statut == 9) $newstatus = 1; // Refused->Validated else $newstatus = 2; //print "old status = ".$object->statut.' new status = '.$newstatus; @@ -299,18 +299,18 @@ if (empty($reshook)) { // Currently the "Re-open" also remove the billed flag because there is no button "Set unpaid" yet. $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur'; - $sql.= ' SET billed = 0'; - $sql.= ' WHERE rowid = '.$object->id; + $sql .= ' SET billed = 0'; + $sql .= ' WHERE rowid = '.$object->id; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($newstatus == 0) { $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur'; - $sql.= ' SET fk_user_approve = null, fk_user_approve2 = null, date_approve = null, date_approve2 = null'; - $sql.= ' WHERE rowid = '.$object->id; + $sql .= ' SET fk_user_approve = null, fk_user_approve2 = null, date_approve = null, date_approve2 = null'; + $sql .= ' WHERE rowid = '.$object->id; - $resql=$db->query($sql); + $resql = $db->query($sql); } $db->commit(); @@ -332,7 +332,7 @@ if (empty($reshook)) */ if ($action == 'classifybilled' && $user->rights->fournisseur->commande->creer) { - $ret=$object->classifyBilled($user); + $ret = $object->classifyBilled($user); if ($ret < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -347,26 +347,26 @@ if (empty($reshook)) $error = 0; // Set if we used free entry or predefined product - $predef=''; - $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); - $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); - $date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); + $predef = ''; + $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); + $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); + $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); $prod_entry_mode = GETPOST('prod_entry_mode'); if ($prod_entry_mode == 'free') { - $idprod=0; + $idprod = 0; $price_ht = GETPOST('price_ht'); $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); } else { - $idprod=GETPOST('idprod', 'int'); + $idprod = GETPOST('idprod', 'int'); $price_ht = ''; $tva_tx = ''; } $qty = GETPOST('qty'.$predef); - $remise_percent=GETPOST('remise_percent'.$predef); + $remise_percent = GETPOST('remise_percent'.$predef); $price_ht_devise = GETPOST('multicurrency_price_ht'); // Extrafields @@ -376,31 +376,31 @@ if (empty($reshook)) if (is_array($extralabelsline)) { // Get extra fields foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); + unset($_POST["options_".$key]); } } - if ($prod_entry_mode =='free' && GETPOST('price_ht') < 0 && $qty < 0) + if ($prod_entry_mode == 'free' && GETPOST('price_ht') < 0 && $qty < 0) { setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPrice'), $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; } - if ($prod_entry_mode =='free' && ! GETPOST('idprodfournprice') && GETPOST('type') < 0) + if ($prod_entry_mode == 'free' && !GETPOST('idprodfournprice') && GETPOST('type') < 0) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); $error++; } - if ($prod_entry_mode =='free' && GETPOST('price_ht')==='' && GETPOST('price_ttc')==='' && $price_ht_devise === '') // Unit price can be 0 but not '' + if ($prod_entry_mode == 'free' && GETPOST('price_ht') === '' && GETPOST('price_ttc') === '' && $price_ht_devise === '') // Unit price can be 0 but not '' { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('UnitPrice')), null, 'errors'); $error++; } - if ($prod_entry_mode =='free' && ! GETPOST('dp_desc')) + if ($prod_entry_mode == 'free' && !GETPOST('dp_desc')) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors'); $error++; } - if (! GETPOST('qty')) + if (!GETPOST('qty')) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; @@ -415,7 +415,7 @@ if (empty($reshook)) $idprod = $res->fk_product_child; } else { setEventMessages($langs->trans('ErrorProductCombinationNotFound'), null, 'errors'); - $error ++; + $error++; } } } @@ -427,18 +427,18 @@ if (empty($reshook)) { $productsupplier = new ProductFournisseur($db); - $idprod=0; - if (GETPOST('idprodfournprice', 'alpha') == -1 || GETPOST('idprodfournprice', 'alpha') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) + $idprod = 0; + if (GETPOST('idprodfournprice', 'alpha') == -1 || GETPOST('idprodfournprice', 'alpha') == '') $idprod = -99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice', 'alpha'), $reg)) { - $idprod=$reg[1]; - $res=$productsupplier->fetch($idprod); // Load product from its id + $idprod = $reg[1]; + $res = $productsupplier->fetch($idprod); // Load product from its id // Call to init some price properties of $productsupplier // So if a supplier price already exists for another thirdparty (first one found), we use it as reference price - if (! empty($conf->global->SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER)) + if (!empty($conf->global->SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER)) { $fksoctosearch = 0; - $productsupplier->get_buyprice(0, -1, $idprod, 'none', $fksoctosearch); // We force qty to -1 to be sure to find if a supplier price exist + $productsupplier->get_buyprice(0, -1, $idprod, 'none', $fksoctosearch); // We force qty to -1 to be sure to find if a supplier price exist if ($productsupplier->fourn_socid != $socid) // The price we found is for another supplier, so we clear supplier price { $productsupplier->ref_supplier = ''; @@ -447,15 +447,15 @@ if (empty($reshook)) else { $fksoctosearch = $object->thirdparty->id; - $productsupplier->get_buyprice(0, -1, $idprod, 'none', $fksoctosearch); // We force qty to -1 to be sure to find if a supplier price exist + $productsupplier->get_buyprice(0, -1, $idprod, 'none', $fksoctosearch); // We force qty to -1 to be sure to find if a supplier price exist } } elseif (GETPOST('idprodfournprice', 'alpha') > 0) { - $qtytosearch=$qty; // Just to see if a price exists for the quantity. Not used to found vat. + $qtytosearch = $qty; // Just to see if a price exists for the quantity. Not used to found vat. //$qtytosearch=-1; // We force qty to -1 to be sure to find if a supplier price exist - $idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice', 'alpha'), $qtytosearch); - $res=$productsupplier->fetch($idprod); + $idprod = $productsupplier->get_buyprice(GETPOST('idprodfournprice', 'alpha'), $qtytosearch); + $res = $productsupplier->fetch($idprod); } if ($idprod > 0) @@ -463,27 +463,27 @@ if (empty($reshook)) $label = $productsupplier->label; // if we use supplier description of the products - if(!empty($productsupplier->desc_supplier) && !empty($conf->global->PRODUIT_FOURN_TEXTS)) { + if (!empty($productsupplier->desc_supplier) && !empty($conf->global->PRODUIT_FOURN_TEXTS)) { $desc = $productsupplier->desc_supplier; } else $desc = $productsupplier->description; if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); $type = $productsupplier->type; - $price_base_type = ($productsupplier->fourn_price_base_type?$productsupplier->fourn_price_base_type:'HT'); + $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT'); $ref_supplier = $productsupplier->ref_supplier; - $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); + $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); - if (empty($tva_tx)) $tva_npr=0; - $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); - $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); + if (empty($tva_tx)) $tva_npr = 0; + $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); + $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); $pu = $productsupplier->fourn_pu; - if (empty($pu)) $pu = 0; // If pu is '' or null, we force to have a numeric value + if (empty($pu)) $pu = 0; // If pu is '' or null, we force to have a numeric value - $result=$object->addline( + $result = $object->addline( $desc, $pu, $qty, @@ -491,7 +491,7 @@ if (empty($reshook)) $localtax1_tx, $localtax2_tx, $idprod, - 0, // We already have the $idprod always defined + 0, // We already have the $idprod always defined $ref_supplier, $remise_percent, $price_base_type, @@ -530,13 +530,13 @@ if (empty($reshook)) $type = GETPOST('type'); $ref_supplier = GETPOST('fourn_ref', 'alpha'); - $fk_unit= GETPOST('units', 'alpha'); + $fk_unit = GETPOST('units', 'alpha'); - $tva_tx = price2num($tva_tx); // When vat is text input field + $tva_tx = price2num($tva_tx); // When vat is text input field // Local Taxes - $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); - $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); + $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); + $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); if ($price_ht !== '') { @@ -554,11 +554,11 @@ if (empty($reshook)) } //print "xx".$tva_tx; exit; - if (! $error && $result > 0) + if (!$error && $result > 0) { $db->commit(); - $ret=$object->fetch($object->id); // Reload to get new records + $ret = $object->fetch($object->id); // Reload to get new records // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) @@ -567,14 +567,14 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) dol_print_error($db, $result); } @@ -622,9 +622,9 @@ if (empty($reshook)) /* * Updating a line in the order */ - if ($action == 'updateline' && $user->rights->fournisseur->commande->creer && ! GETPOST('cancel', 'alpha')) + if ($action == 'updateline' && $user->rights->fournisseur->commande->creer && !GETPOST('cancel', 'alpha')) { - $vat_rate=(GETPOST('tva_tx')?GETPOST('tva_tx'):0); + $vat_rate = (GETPOST('tva_tx') ?GETPOST('tva_tx') : 0); if ($lineid) { @@ -634,16 +634,16 @@ if (empty($reshook)) } $productsupplier = new ProductFournisseur($db); - if (! empty($conf->global->SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY)) + if (!empty($conf->global->SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY)) { - if ($line->fk_product > 0 && $productsupplier->get_buyprice(0, price2num($_POST['qty']), $line->fk_product, 'none', GETPOST('socid', 'int')) < 0 ) + if ($line->fk_product > 0 && $productsupplier->get_buyprice(0, price2num($_POST['qty']), $line->fk_product, 'none', GETPOST('socid', 'int')) < 0) { setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'warnings'); } } - $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); - $date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); + $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); + $date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); // Define info_bits $info_bits = 0; @@ -683,11 +683,11 @@ if (empty($reshook)) // Unset extrafield POST Data if (is_array($extralabelsline)) { foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); + unset($_POST["options_".$key]); } } - $result = $object->updateline( + $result = $object->updateline( $lineid, $_POST['product_desc'], $ht, @@ -698,7 +698,7 @@ if (empty($reshook)) $localtax2_rate, $price_base_type, 0, - isset($_POST["type"])?$_POST["type"]:$line->product_type, + isset($_POST["type"]) ? $_POST["type"] : $line->product_type, false, $date_start, $date_end, @@ -735,7 +735,7 @@ if (empty($reshook)) unset($_POST['date_endmonth']); unset($_POST['date_endyear']); - if ($result >= 0) + if ($result >= 0) { // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) @@ -744,14 +744,14 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) dol_print_error($db, $result); } } @@ -775,7 +775,7 @@ if (empty($reshook)) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -791,19 +791,19 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); /* Fix bug 1485 : Reset action to avoid asking again confirmation on failure */ - $action=''; + $action = ''; } } // Validate if ($action == 'confirm_valid' && $confirm == 'yes' && - ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->commande->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->supplier_order_advance->validate))) + ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->commande->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_order_advance->validate))) ) { - $object->date_commande=dol_now(); + $object->date_commande = dol_now(); $result = $object->valid($user); - if ($result >= 0) + if ($result >= 0) { // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) @@ -812,14 +812,14 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) dol_print_error($db, $result); } } @@ -829,40 +829,40 @@ if (empty($reshook)) } // If we have permission, and if we don't need to provide the idwarehouse, we go directly on approved step - if (empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE) && $user->rights->fournisseur->commande->approuver && ! (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $object->hasProductsOrServices(1))) + if (empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE) && $user->rights->fournisseur->commande->approuver && !(!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $object->hasProductsOrServices(1))) { - $action='confirm_approve'; // can make standard or first level approval also if permission is set + $action = 'confirm_approve'; // can make standard or first level approval also if permission is set } } if (($action == 'confirm_approve' || $action == 'confirm_approve2') && $confirm == 'yes' && $user->rights->fournisseur->commande->approuver) { - $idwarehouse=GETPOST('idwarehouse', 'int'); + $idwarehouse = GETPOST('idwarehouse', 'int'); - $qualified_for_stock_change=0; + $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $qualified_for_stock_change=$object->hasProductsOrServices(2); + $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { - $qualified_for_stock_change=$object->hasProductsOrServices(1); + $qualified_for_stock_change = $object->hasProductsOrServices(1); } // Check parameters - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $qualified_for_stock_change) // warning name of option should be STOCK_CALCULATE_ON_SUPPLIER_APPROVE_ORDER + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $qualified_for_stock_change) // warning name of option should be STOCK_CALCULATE_ON_SUPPLIER_APPROVE_ORDER { - if (! $idwarehouse || $idwarehouse == -1) + if (!$idwarehouse || $idwarehouse == -1) { $error++; setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); - $action=''; + $action = ''; } } - if (! $error) + if (!$error) { - $result = $object->approve($user, $idwarehouse, ($action=='confirm_approve2'?1:0)); + $result = $object->approve($user, $idwarehouse, ($action == 'confirm_approve2' ? 1 : 0)); if ($result > 0) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { @@ -870,7 +870,7 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -886,7 +886,7 @@ if (empty($reshook)) } } - if ($action == 'confirm_refuse' && $confirm == 'yes' && $user->rights->fournisseur->commande->approuver) + if ($action == 'confirm_refuse' && $confirm == 'yes' && $user->rights->fournisseur->commande->approuver) { $result = $object->refuse($user); if ($result > 0) @@ -910,7 +910,7 @@ if (empty($reshook)) } } - if ($action == 'confirm_commande' && $confirm == 'yes' && $user->rights->fournisseur->commande->commander) + if ($action == 'confirm_commande' && $confirm == 'yes' && $user->rights->fournisseur->commande->commander) { $result = $object->commande($user, $_REQUEST["datecommande"], $_REQUEST["methode"], $_REQUEST['comment']); if ($result > 0) @@ -921,7 +921,7 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } @@ -940,7 +940,7 @@ if (empty($reshook)) if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fournisseur->commande->supprimer) { - $result=$object->delete($user); + $result = $object->delete($user); if ($result > 0) { header("Location: ".DOL_URL_ROOT.'/fourn/commande/list.php?restore_lastsearch_values=1'); @@ -955,7 +955,7 @@ if (empty($reshook)) // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->fournisseur->commande->creer) { - if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) + if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } @@ -965,7 +965,7 @@ if (empty($reshook)) { $orig = clone $object; - $result=$object->createFromClone($user, $socid); + $result = $object->createFromClone($user, $socid); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); @@ -975,7 +975,7 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); $object = $orig; - $action=''; + $action = ''; } } } @@ -988,14 +988,14 @@ if (empty($reshook)) { $date_liv = dol_mktime(GETPOST('rehour'), GETPOST('remin'), GETPOST('resec'), GETPOST("remonth"), GETPOST("reday"), GETPOST("reyear")); - $result = $object->Livraison($user, $date_liv, GETPOST("type"), GETPOST("comment")); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + $result = $object->Livraison($user, $date_liv, GETPOST("type"), GETPOST("comment")); // GETPOST("type") is 'tot', 'par', 'nev', 'can' if ($result > 0) { $langs->load("deliveries"); setEventMessages($langs->trans("DeliveryStateSaved"), null); $action = ''; } - elseif($result == -3) + elseif ($result == -3) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -1010,9 +1010,9 @@ if (empty($reshook)) } } - if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->fournisseur->commande->commander) + if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->fournisseur->commande->commander) { - $result = $object->cancel($user); + $result = $object->cancel($user); if ($result > 0) { header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); @@ -1028,9 +1028,9 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - $trigger_name='ORDER_SUPPLIER_SENTBYMAIL'; - $autocopy='MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO'; - $trackid='sor'.$object->id; + $trigger_name = 'ORDER_SUPPLIER_SENTBYMAIL'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO'; + $trackid = 'sor'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; // Actions to build doc @@ -1047,12 +1047,12 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; - if (! $error) + if (!$error) { // Actions on extra fields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$object->insertExtraFields('ORDER_SUPPLIER_MODIFY'); + $result = $object->insertExtraFields('ORDER_SUPPLIER_MODIFY'); if ($result < 0) { $error++; @@ -1070,16 +1070,16 @@ if (empty($reshook)) */ if ($action == 'add' && $user->rights->fournisseur->commande->creer) { - $error=0; + $error = 0; - if ($socid <1) + if ($socid < 1) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Supplier')), null, 'errors'); - $action='create'; + $action = 'create'; $error++; } - if (! $error) + if (!$error) { $db->begin(); @@ -1099,16 +1099,16 @@ if (empty($reshook)) $object->fk_project = GETPOST('projectid'); // Fill array 'array_options' with data from add form - if (! $error) + if (!$error) { $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; } - if (! $error) + if (!$error) { // If creation from another object of another module (Example: origin=propal, originid=1) - if (! empty($origin) && ! empty($originid)) + if (!empty($origin) && !empty($originid)) { if ($origin == 'propal' || $origin == 'proposal') { @@ -1133,18 +1133,18 @@ if (empty($reshook)) // Possibility to add external linked objects with hooks $object->linked_objects [$object->origin] = $object->origin_id; $other_linked_objects = GETPOST('other_linked_objects', 'array'); - if (! empty($other_linked_objects)) { + if (!empty($other_linked_objects)) { $object->linked_objects = array_merge($object->linked_objects, $other_linked_objects); } $id = $object->create($user); if ($id > 0) { - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $srcobject = new $classname($db); - dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); + dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); $result = $srcobject->fetch($object->origin_id); if ($result > 0) { @@ -1161,14 +1161,14 @@ if (empty($reshook)) $fk_parent_line = 0; $num = count($lines); - for($i = 0; $i < $num; $i ++) + for ($i = 0; $i < $num; $i++) { if (empty($lines[$i]->subprice) || $lines[$i]->qty <= 0) continue; - $label = (! empty($lines[$i]->label) ? $lines[$i]->label : ''); - $desc = (! empty($lines[$i]->desc) ? $lines[$i]->desc : $lines[$i]->product_desc); - $product_type = (! empty($lines[$i]->product_type) ? $lines[$i]->product_type : 0); + $label = (!empty($lines[$i]->label) ? $lines[$i]->label : ''); + $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc : $lines[$i]->product_desc); + $product_type = (!empty($lines[$i]->product_type) ? $lines[$i]->product_type : 0); // Reset fk_parent_line for no child products and special product if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { @@ -1202,11 +1202,11 @@ if (empty($reshook)) $tva_tx = $lines[$i]->tva_tx; - if ($origin=="commande") + if ($origin == "commande") { - $soc=new societe($db); + $soc = new societe($db); $soc->fetch($socid); - $tva_tx=get_default_tva($soc, $mysoc, $lines[$i]->fk_product, $product_fourn_price_id); + $tva_tx = get_default_tva($soc, $mysoc, $lines[$i]->fk_product, $product_fourn_price_id); } $result = $object->addline( @@ -1253,14 +1253,14 @@ if (empty($reshook)) $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been if ($reshook < 0) - $error ++; + $error++; } else { setEventMessages($srcobject->error, $srcobject->errors, 'errors'); - $error ++; + $error++; } } else { setEventMessages($object->error, $object->errors, 'errors'); - $error ++; + $error++; } } else @@ -1278,8 +1278,8 @@ if (empty($reshook)) { $langs->load("errors"); $db->rollback(); - $action='create'; - $_GET['socid']=$_POST['socid']; + $action = 'create'; + $_GET['socid'] = $_POST['socid']; } else { @@ -1290,7 +1290,7 @@ if (empty($reshook)) } } - if ($action == 'webservice' && GETPOST('mode', 'alpha') == "send" && ! GETPOST('cancel', 'alpha')) + if ($action == 'webservice' && GETPOST('mode', 'alpha') == "send" && !GETPOST('cancel', 'alpha')) { $ws_url = $object->thirdparty->webservices_url; $ws_key = $object->thirdparty->webservices_key; @@ -1300,8 +1300,8 @@ if (empty($reshook)) $ws_thirdparty = GETPOST('ws_thirdparty', 'int'); // NS and Authentication parameters - $ws_ns='http://www.dolibarr.org/ns/'; - $ws_authentication=array( + $ws_ns = 'http://www.dolibarr.org/ns/'; + $ws_authentication = array( 'dolibarrkey'=>$ws_key, 'sourceapplication'=>'DolibarrWebServiceClient', 'login'=>$ws_user, @@ -1319,12 +1319,12 @@ if (empty($reshook)) } else { //Create SOAP client and connect it to order $soapclient_order = new nusoap_client($ws_url."/webservices/server_order.php"); - $soapclient_order->soap_defencoding='UTF-8'; + $soapclient_order->soap_defencoding = 'UTF-8'; $soapclient_order->decodeUTF8(false); //Create SOAP client and connect it to product/service $soapclient_product = new nusoap_client($ws_url."/webservices/server_productorservice.php"); - $soapclient_product->soap_defencoding='UTF-8'; + $soapclient_product->soap_defencoding = 'UTF-8'; $soapclient_product->decodeUTF8(false); //Prepare the order lines from order @@ -1381,7 +1381,7 @@ if (empty($reshook)) } } - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->fournisseur->commande->creer) + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->fournisseur->commande->creer) { if ($action == 'addcontact') { @@ -1413,7 +1413,7 @@ if (empty($reshook)) // bascule du statut d'un contact elseif ($action == 'swapstatut' && $object->id > 0) { - $result=$object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOST('ligne')); } // Efface un contact @@ -1438,18 +1438,18 @@ if (empty($reshook)) * View */ -$form = new Form($db); +$form = new Form($db); $formfile = new FormFile($db); $formorder = new FormOrder($db); $productstatic = new Product($db); -if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } -$help_url='EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores'; +$help_url = 'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores'; llxHeader('', $langs->trans("Order"), $help_url); -$now=dol_now(); -if ($action=='create') +$now = dol_now(); +if ($action == 'create') { print load_fiche_titre($langs->trans('NewOrderSupplier')); @@ -1457,18 +1457,18 @@ if ($action=='create') $currency_code = $conf->currency; - $societe=''; - if ($socid>0) + $societe = ''; + if ($socid > 0) { - $societe=new Societe($db); + $societe = new Societe($db); $societe->fetch($socid); } - if (! empty($origin) && ! empty($originid)) + if (!empty($origin) && !empty($originid)) { // Parse element/subelement (ex: project_task) $element = $subelement = $origin; - $regs=array(); + $regs = array(); if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) { $element = $regs[1]; $subelement = $regs[2]; @@ -1491,7 +1491,7 @@ if ($action=='create') $subelement = 'supplier_proposal'; } - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $objectsrc = new $classname($db); $objectsrc->fetch($originid); @@ -1503,21 +1503,21 @@ if ($action=='create') $objectsrc->fetch_optionals($originid); $object->array_options = $objectsrc->array_options; - $projectid = (! empty($objectsrc->fk_project) ? $objectsrc->fk_project : ''); - $ref_client = (! empty($objectsrc->ref_client) ? $objectsrc->ref_client : ''); + $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project : ''); + $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client : ''); $soc = $objectsrc->client; - $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_id)?$soc->cond_reglement_id:0)); - $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); - $fk_account = (! empty($objectsrc->fk_account)?$objectsrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0)); - $availability_id = (!empty($objectsrc->availability_id)?$objectsrc->availability_id:(!empty($soc->availability_id)?$soc->availability_id:0)); - $shipping_method_id = (! empty($objectsrc->shipping_method_id)?$objectsrc->shipping_method_id:(! empty($soc->shipping_method_id)?$soc->shipping_method_id:0)); - $demand_reason_id = (!empty($objectsrc->demand_reason_id)?$objectsrc->demand_reason_id:(!empty($soc->demand_reason_id)?$soc->demand_reason_id:0)); - $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_supplier_percent)?$soc->remise_supplier_percent:0)); - $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; + $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0)); + $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0)); + $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0)); + $availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : (!empty($soc->availability_id) ? $soc->availability_id : 0)); + $shipping_method_id = (!empty($objectsrc->shipping_method_id) ? $objectsrc->shipping_method_id : (!empty($soc->shipping_method_id) ? $soc->shipping_method_id : 0)); + $demand_reason_id = (!empty($objectsrc->demand_reason_id) ? $objectsrc->demand_reason_id : (!empty($soc->demand_reason_id) ? $soc->demand_reason_id : 0)); + $remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_supplier_percent) ? $soc->remise_supplier_percent : 0)); + $remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : ''; - $datedelivery = (! empty($objectsrc->date_livraison) ? $objectsrc->date_livraison : ''); + $datedelivery = (!empty($objectsrc->date_livraison) ? $objectsrc->date_livraison : ''); if (!empty($conf->multicurrency->enabled)) { @@ -1525,11 +1525,11 @@ if ($action=='create') if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx; } - $note_private = $object->getDefaultCreateValueFor('note_private', (! empty($objectsrc->note_private) ? $objectsrc->note_private : null)); - $note_public = $object->getDefaultCreateValueFor('note_public', (! empty($objectsrc->note_public) ? $objectsrc->note_public : null)); + $note_private = $object->getDefaultCreateValueFor('note_private', (!empty($objectsrc->note_private) ? $objectsrc->note_private : null)); + $note_public = $object->getDefaultCreateValueFor('note_public', (!empty($objectsrc->note_public) ? $objectsrc->note_public : null)); // Object source contacts list - $srccontactslist = $objectsrc->liste_contact(- 1, 'external', 1); + $srccontactslist = $objectsrc->liste_contact(-1, 'external', 1); } else { @@ -1543,17 +1543,17 @@ if ($action=='create') } // If not defined, set default value from constant - if (empty($cond_reglement_id) && ! empty($conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_TERM_ID)) $cond_reglement_id=$conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_TERM_ID; - if (empty($mode_reglement_id) && ! empty($conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_MODE_ID)) $mode_reglement_id=$conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_MODE_ID; + if (empty($cond_reglement_id) && !empty($conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_TERM_ID)) $cond_reglement_id = $conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_TERM_ID; + if (empty($mode_reglement_id) && !empty($conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_MODE_ID)) $mode_reglement_id = $conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_MODE_ID; print '
'; print ''; print ''; - print '' . "\n"; - print ''; - print ''; - print ''; - if (!empty($currency_tx)) print ''; + print ''."\n"; + print ''; + print ''; + print ''; + if (!empty($currency_tx)) print ''; dol_fiche_head(''); @@ -1573,7 +1573,7 @@ if ($action=='create') } else { - print $form->select_company((empty($socid)?'':$socid), 'socid', 's.fournisseur=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); + print $form->select_company((empty($socid) ? '' : $socid), 'socid', 's.fournisseur=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); // reload page to retrieve customer informations if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) { @@ -1594,13 +1594,13 @@ if ($action=='create') if ($societe->id > 0) { // Discounts for third party - print '
' . $langs->trans('Discounts') . ''; + print '
'.$langs->trans('Discounts').''; $absolute_discount = $societe->getAvailableDiscounts('', '', 0, 1); $thirdparty = $societe; $discount_type = 1; - $backtopage = urlencode($_SERVER["PHP_SELF"] . '?socid=' . $thirdparty->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')); + $backtopage = urlencode($_SERVER["PHP_SELF"].'?socid='.$thirdparty->id.'&action='.$action.'&origin='.GETPOST('origin').'&originid='.GETPOST('originid')); include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; print '
'.$langs->trans('PaymentConditionsShort').''; - $form->select_conditions_paiements(isset($_POST['cond_reglement_id'])?$_POST['cond_reglement_id']:$cond_reglement_id, 'cond_reglement_id'); + $form->select_conditions_paiements(isset($_POST['cond_reglement_id']) ? $_POST['cond_reglement_id'] : $cond_reglement_id, 'cond_reglement_id'); print '
'.$langs->trans('PaymentMode').''; - $form->select_types_paiements(isset($_POST['mode_reglement_id'])?$_POST['mode_reglement_id']:$mode_reglement_id, 'mode_reglement_id'); + $form->select_types_paiements(isset($_POST['mode_reglement_id']) ? $_POST['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id'); print '
'; - $usehourmin=0; - if (! empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin=1; - print $form->selectDate($datelivraison?$datelivraison:-1, 'liv_', $usehourmin, $usehourmin, '', "set"); + $usehourmin = 0; + if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin = 1; + print $form->selectDate($datelivraison ? $datelivraison : -1, 'liv_', $usehourmin, $usehourmin, '', "set"); print '
' . $langs->trans('BankAccount') . ''; + print '
'.$langs->trans('BankAccount').''; $form->select_comptes($fk_account, 'fk_account', 0, '', 1); print '
' . $langs->trans('Project') . ''; - $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$societe->id:-1), $projectid, 'projectid', 0, 0, 1, 1); - print '   id).'">' . $langs->trans("AddProject") . ''; + print '
'.$langs->trans('Project').''; + $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1); + print '   id).'">'.$langs->trans("AddProject").''; print '
'; - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:'')); + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : '')); print '
'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).'
' . $langs->trans($newclassname) . '' . $objectsrc->getNomUrl(1) . '
' . $langs->trans('AmountHT') . '' . price($objectsrc->total_ht) . '
' . $langs->trans('AmountVAT') . '' . price($objectsrc->total_tva) . "
'.$langs->trans($newclassname).''.$objectsrc->getNomUrl(1).'
'.$langs->trans('AmountHT').''.price($objectsrc->total_ht).'
'.$langs->trans('AmountVAT').''.price($objectsrc->total_tva)."
' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($objectsrc->total_localtax1) . "
'.$langs->transcountry("AmountLT1", $mysoc->country_code).''.price($objectsrc->total_localtax1)."
' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($objectsrc->total_localtax2) . "
'.$langs->transcountry("AmountLT2", $mysoc->country_code).''.price($objectsrc->total_localtax2)."
' . $langs->trans('AmountTTC') . '' . price($objectsrc->total_ttc) . "
'.$langs->trans('AmountTTC').''.price($objectsrc->total_ttc)."
' . $langs->trans('MulticurrencyAmountHT') . '' . price($objectsrc->multicurrency_total_ht) . '
' . $langs->trans('MulticurrencyAmountVAT') . '' . price($objectsrc->multicurrency_total_tva) . '
' . $langs->trans('MulticurrencyAmountTTC') . '' . price($objectsrc->multicurrency_total_ttc) . '
'.$langs->trans('MulticurrencyAmountHT').''.price($objectsrc->multicurrency_total_ht).'
'.$langs->trans('MulticurrencyAmountVAT').''.price($objectsrc->multicurrency_total_tva).'
'.$langs->trans('MulticurrencyAmountTTC').''.price($objectsrc->multicurrency_total_ttc).'
'; } } -elseif (! empty($object->id)) +elseif (!empty($object->id)) { $result = $object->fetch($id, $ref); $societe = new Fournisseur($db); - $result=$societe->fetch($object->socid); + $result = $societe->fetch($object->socid); if ($result < 0) dol_print_error($db); - $author = new User($db); + $author = new User($db); $author->fetch($object->user_author_id); - $res=$object->fetch_optionals(); + $res = $object->fetch_optionals(); $head = ordersupplier_prepare_head($object); - $title=$langs->trans("SupplierOrder"); + $title = $langs->trans("SupplierOrder"); dol_fiche_head($head, 'card', $title, -1, 'order'); - $formconfirm=''; + $formconfirm = ''; // Confirmation de la suppression de la commande - if ($action == 'delete') + if ($action == 'delete') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 2); } @@ -1791,17 +1791,17 @@ elseif (! empty($object->id)) if ($action == 'clone') { // Create an array for form - $formquestion=array( - array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.fournisseur=1)')) + $formquestion = array( + array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.fournisseur=1)')) ); // Paiement incomplet. On demande si motif = escompte ou autre $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneOrder', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } // Confirmation de la validation - if ($action == 'valid') + if ($action == 'valid') { - $object->date_commande=dol_now(); + $object->date_commande = dol_now(); // We check if number is temporary number if (preg_match('/^[\(]?PROV/i', $object->ref) || empty($object->ref)) // empty should not happened, but when it occurs, the test save life @@ -1813,17 +1813,17 @@ elseif (! empty($object->id)) if ($newref < 0) { setEventMessages($object->error, $object->errors, 'errors'); - $action=''; + $action = ''; } else { - $text=$langs->trans('ConfirmValidateOrder', $newref); - if (! empty($conf->notification->enabled)) + $text = $langs->trans('ConfirmValidateOrder', $newref); + if (!empty($conf->notification->enabled)) { - require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php'; - $notify=new Notify($db); - $text.='
'; - $text.=$notify->confirmMessage('ORDER_SUPPLIER_VALIDATE', $object->socid, $object); + require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; + $notify = new Notify($db); + $text .= '
'; + $text .= $notify->confirmMessage('ORDER_SUPPLIER_VALIDATE', $object->socid, $object); } $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_valid', '', 0, 1); @@ -1831,59 +1831,59 @@ elseif (! empty($object->id)) } // Confirm approval - if ($action == 'approve' || $action == 'approve2') + if ($action == 'approve' || $action == 'approve2') { - $qualified_for_stock_change=0; + $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $qualified_for_stock_change=$object->hasProductsOrServices(2); + $qualified_for_stock_change = $object->hasProductsOrServices(2); } else { - $qualified_for_stock_change=$object->hasProductsOrServices(1); + $qualified_for_stock_change = $object->hasProductsOrServices(1); } - $formquestion=array(); - if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $qualified_for_stock_change) + $formquestion = array(); + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $qualified_for_stock_change) { $langs->load("stocks"); require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; - $formproduct=new FormProduct($db); - $forcecombo=0; - if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy - $formquestion=array( + $formproduct = new FormProduct($db); + $forcecombo = 0; + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + $formquestion = array( //'text' => $langs->trans("ConfirmClone"), //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), //array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockIncrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse', 'int'), 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) + array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockIncrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse', 'int'), 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) ); } - $text=$langs->trans("ConfirmApproveThisOrder", $object->ref); - if (! empty($conf->notification->enabled)) + $text = $langs->trans("ConfirmApproveThisOrder", $object->ref); + if (!empty($conf->notification->enabled)) { - require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php'; - $notify=new Notify($db); - $text.='
'; - $text.=$notify->confirmMessage('ORDER_SUPPLIER_APPROVE', $object->socid, $object); + require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; + $notify = new Notify($db); + $text .= '
'; + $text .= $notify->confirmMessage('ORDER_SUPPLIER_APPROVE', $object->socid, $object); } $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("ApproveThisOrder"), $text, "confirm_".$action, $formquestion, 1, 1, 240); } // Confirmation de la desapprobation - if ($action == 'refuse') + if ($action == 'refuse') { $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id", $langs->trans("DenyingThisOrder"), $langs->trans("ConfirmDenyingThisOrder", $object->ref), "confirm_refuse", '', 0, 1); } // Confirmation de l'annulation - if ($action == 'cancel') + if ($action == 'cancel') { $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id", $langs->trans("Cancel"), $langs->trans("ConfirmCancelThisOrder", $object->ref), "confirm_cancel", '', 0, 1); } // Confirmation de l'envoi de la commande - if ($action == 'commande') + if ($action == 'commande') { $date_com = dol_mktime(GETPOST('rehour'), GETPOST('remin'), GETPOST('resec'), GETPOST("remonth"), GETPOST("reday"), GETPOST("reyear")); $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id."&datecommande=".$date_com."&methode=".$_POST["methodecommande"]."&comment=".urlencode($_POST["comment"]), $langs->trans("MakeOrder"), $langs->trans("ConfirmMakeOrder", dol_print_date($date_com, 'day')), "confirm_commande", '', 0, 2); @@ -1897,10 +1897,10 @@ elseif (! empty($object->id)) if (!$formconfirm) { - $parameters=array('lineid'=>$lineid); + $parameters = array('lineid'=>$lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; - elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; } // Print form confirm @@ -1909,56 +1909,56 @@ elseif (! empty($object->id)) // Supplier order card - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
'; + $morehtmlref = '
'; // Ref supplier - $morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', null, null, '', 1); + $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty'); - if(! empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) && ! empty($user->rights->fournisseur->commande->creer) && $action == 'edit_thirdparty') { + $morehtmlref .= '
'.$langs->trans('ThirdParty'); + if (!empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) && !empty($user->rights->fournisseur->commande->creer) && $action == 'edit_thirdparty') { $morehtmlref .= ' : '; - $morehtmlref .= '
'; + $morehtmlref .= ''; $morehtmlref .= ''; - $morehtmlref .= ''; + $morehtmlref .= ''; $morehtmlref .= $form->select_company($object->thirdparty->id, 'new_socid', 's.fournisseur=1', '', 0, 0, array(), 0, 'minwidth300'); - $morehtmlref .= ''; + $morehtmlref .= ''; $morehtmlref .= '
'; } - if(empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) || $action != 'edit_thirdparty') { - if(! empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) && $object->statut == CommandeFournisseur::STATUS_DRAFT) { - $morehtmlref .= '' . img_edit($langs->transnoentitiesnoconv('SetThirdParty')) . ''; + if (empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) || $action != 'edit_thirdparty') { + if (!empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) && $object->statut == CommandeFournisseur::STATUS_DRAFT) { + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetThirdParty')).''; } $morehtmlref .= ' : '.$object->thirdparty->getNomUrl(1); - if(empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (' . $langs->trans("OtherOrders") . ')'; + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; } // Project - if(!empty($conf->projet->enabled)) { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref .= '
' . $langs->trans('Project') . ' '; - if($user->rights->fournisseur->commande->creer) { - if($action != 'classify') - $morehtmlref .= '' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if($action == 'classify') { + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->fournisseur->commande->creer) { + if ($action != 'classify') + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; + if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
'; + $morehtmlref .= ''; $morehtmlref .= ''; - $morehtmlref .= ''; + $morehtmlref .= ''; $morehtmlref .= $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; + $morehtmlref .= ''; $morehtmlref .= '
'; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if(!empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref .= ''; + $morehtmlref .= ''; $morehtmlref .= $proj->ref; $morehtmlref .= ''; } @@ -1967,7 +1967,7 @@ elseif (! empty($object->id)) } } } - $morehtmlref.='
'; + $morehtmlref .= '
'; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -2001,7 +2001,7 @@ elseif (! empty($object->id)) print '
' . $langs->trans('Discounts') . ''; + print '
'.$langs->trans('Discounts').''; $thirdparty = $societe; $discount_type = 1; - $backtopage = urlencode($_SERVER["PHP_SELF"] . '?id=' . $object->id); + $backtopage = urlencode($_SERVER["PHP_SELF"].'?id='.$object->id); include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; print '
id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'
'; print '
'; if ($action == 'editmulticurrencycode') { - $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code'); + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'multicurrency_code'); } else { - $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none'); + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'none'); } print '
id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'
'; print ''; if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { - if($action == 'actualizemulticurrencyrate') { + if ($action == 'actualizemulticurrencyrate') { list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); } - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { print '
        '; print ''.$langs->trans("ActualizeCurrency").''; @@ -2113,7 +2113,7 @@ elseif (! empty($object->id)) } // Bank Account - if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER) && ! empty($conf->banque->enabled)) + if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER) && !empty($conf->banque->enabled)) { print ''; print ''; } // Other attributes - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
'; @@ -2145,18 +2145,18 @@ elseif (! empty($object->id)) print '
'; print ''; print ''; - $usehourmin=0; - if (! empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin=1; - print $form->selectDate($object->date_livraison?$object->date_livraison:-1, 'liv_', $usehourmin, $usehourmin, '', "setdate_livraison"); + $usehourmin = 0; + if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin = 1; + print $form->selectDate($object->date_livraison ? $object->date_livraison : -1, 'liv_', $usehourmin, $usehourmin, '', "setdate_livraison"); print ''; print '
'; } else { - $usehourmin='day'; - if (! empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin='dayhour'; + $usehourmin = 'day'; + if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin = 'dayhour'; print $object->date_livraison ? dol_print_date($object->date_livraison, $usehourmin) : ' '; - if ($object->hasDelay() && ! empty($object->date_livraison)) { + if ($object->hasDelay() && !empty($object->date_livraison)) { print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); } } @@ -2186,13 +2186,13 @@ elseif (! empty($object->id)) } else { - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?id='.$object->id); + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); } print '
'; @@ -2206,25 +2206,25 @@ elseif (! empty($object->id)) if (!empty($conf->multicurrency->enabled)) { // Multicurrency Amount HT - print '' . $form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0) . ''; - print '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; + print ''.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).''; + print ''.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).''; print ''; // Multicurrency Amount VAT - print '' . $form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0) . ''; - print '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; + print ''.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).''; + print ''.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).''; print ''; // Multicurrency Amount TTC - print '' . $form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0) . ''; - print '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; + print ''.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).''; + print ''.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).''; print ''; } // Total $alert = ''; - if (! empty($conf->global->ORDER_MANAGE_MIN_AMOUNT) && $object->total_ht < $object->thirdparty->supplier_order_min_amount) { - $alert = ' ' . img_warning($langs->trans('OrderMinAmount').': '.price($object->thirdparty->supplier_order_min_amount)); + if (!empty($conf->global->ORDER_MANAGE_MIN_AMOUNT) && $object->total_ht < $object->thirdparty->supplier_order_min_amount) { + $alert = ' '.img_warning($langs->trans('OrderMinAmount').': '.price($object->thirdparty->supplier_order_min_amount)); } print ''.$langs->trans("AmountHT").''; print ''.price($object->total_ht, '', $langs, 1, -1, -1, $conf->currency).$alert.''; @@ -2235,13 +2235,13 @@ elseif (! empty($object->id)) print ''; // Amount Local Taxes - if ($mysoc->localtax1_assuj=="1" || $object->total_localtax1 != 0) //Localtax1 + if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) //Localtax1 { print ''.$langs->transcountry("AmountLT1", $mysoc->country_code).''; print ''.price($object->total_localtax1, '', $langs, 1, -1, -1, $conf->currency).''; print ''; } - if ($mysoc->localtax2_assuj=="1" || $object->total_localtax2 != 0) //Localtax2 + if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) //Localtax2 { print ''.$langs->transcountry("AmountLT2", $mysoc->country_code).''; print ''.price($object->total_localtax2, '', $langs, 1, -1, -1, $conf->currency).''; @@ -2266,14 +2266,14 @@ elseif (! empty($object->id)) print '

'; - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; $title = $langs->trans('ContactsAddresses'); include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; } - if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $blocname = 'notes'; $title = $langs->trans('Notes'); @@ -2286,16 +2286,16 @@ elseif (! empty($object->id)) //$result = $object->getLinesArray(); - print '
+ print ' - + '; - if (! empty($conf->use_javascript_ajax) && $object->statut == 0) { - include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + if (!empty($conf->use_javascript_ajax) && $object->statut == 0) { + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } print '
'; @@ -2303,13 +2303,13 @@ elseif (! empty($object->id)) // Add free products/services form global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax; - $forceall=1; $dateSelector=0; $inputalsopricewithtax=1; - $senderissupplier=2; // $senderissupplier=2 is same than 1 but disable test on minimum qty and disable autofill qty with minimum. + $forceall = 1; $dateSelector = 0; $inputalsopricewithtax = 1; + $senderissupplier = 2; // $senderissupplier=2 is same than 1 but disable test on minimum qty and disable autofill qty with minimum. //if (! empty($conf->global->SUPPLIER_ORDER_WITH_NOPRICEDEFINED)) $senderissupplier=2; - if (! empty($conf->global->SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY)) $senderissupplier=1; + if (!empty($conf->global->SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY)) $senderissupplier = 1; // Show object lines - if (! empty($object->lines)) + if (!empty($object->lines)) $ret = $object->printObjectLines($action, $societe, $mysoc, $lineid, 1); $num = count($object->lines); @@ -2345,15 +2345,15 @@ elseif (! empty($object->id)) // modified by hook if (empty($reshook)) { - $object->fetchObjectLinked(); // Links are used to show or not button, so we load them now. + $object->fetchObjectLinked(); // Links are used to show or not button, so we load them now. // Validate if ($object->statut == 0 && $num > 0) { - if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->commande->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->supplier_order_advance->validate))) + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->commande->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_order_advance->validate))) { - $tmpbuttonlabel=$langs->trans('Validate'); + $tmpbuttonlabel = $langs->trans('Validate'); if ($user->rights->fournisseur->commande->approuver && empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE)) $tmpbuttonlabel = $langs->trans("ValidateAndApprove"); print ''; @@ -2381,7 +2381,7 @@ elseif (! empty($object->id)) { if ($user->rights->fournisseur->commande->approuver) { - if (! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED && ! empty($object->user_approve_id)) + if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED && !empty($object->user_approve_id)) { print ''.$langs->trans("ApproveOrder").''; } @@ -2397,13 +2397,13 @@ elseif (! empty($object->id)) } // Second approval (if option SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED is set) - if (! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) + if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) { if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) { if ($user->rights->fournisseur->commande->approve2) { - if (! empty($object->user_approve_id2)) + if (!empty($object->user_approve_id2)) { print ''.$langs->trans("Approve2Order").''; } @@ -2444,20 +2444,20 @@ elseif (! empty($object->id)) // Reopen if (in_array($object->statut, array(CommandeFournisseur::STATUS_ACCEPTED))) { - $buttonshown=0; - if (! $buttonshown && $user->rights->fournisseur->commande->approuver) + $buttonshown = 0; + if (!$buttonshown && $user->rights->fournisseur->commande->approuver) { if (empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER_ONLY) - || (! empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER_ONLY) && $user->id == $object->user_approve_id)) + || (!empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER_ONLY) && $user->id == $object->user_approve_id)) { print ''.$langs->trans("Disapprove").''; $buttonshown++; } } - if (! $buttonshown && $user->rights->fournisseur->commande->approve2 && ! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)) + if (!$buttonshown && $user->rights->fournisseur->commande->approve2 && !empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)) { if (empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER2_ONLY) - || (! empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER2_ONLY) && $user->id == $object->user_approve_id2)) + || (!empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER2_ONLY) && $user->id == $object->user_approve_id2)) { print ''.$langs->trans("Disapprove").''; } @@ -2473,13 +2473,13 @@ elseif (! empty($object->id)) // Ship - if (! empty($conf->stock->enabled) && (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE))) + if (!empty($conf->stock->enabled) && (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE))) { - if (in_array($object->statut, array(3,4,5))) { + if (in_array($object->statut, array(3, 4, 5))) { if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->receptionner) { - print ''; + print ''; } else { - print ''; + print ''; } } } @@ -2508,7 +2508,7 @@ elseif (! empty($object->id)) // Create bill //if (! empty($conf->facture->enabled)) //{ - if (! empty($conf->fournisseur->enabled) && ($object->statut >= 2 && $object->statut != 7 && $object->billed != 1)) // statut 2 means approved, 7 means canceled + if (!empty($conf->fournisseur->enabled) && ($object->statut >= 2 && $object->statut != 7 && $object->billed != 1)) // statut 2 means approved, 7 means canceled { if ($user->rights->fournisseur->facture->creer) { @@ -2541,7 +2541,7 @@ elseif (! empty($object->id)) } // Create a remote order using WebService only if module is activated - if (! empty($conf->syncsupplierwebservices->enabled) && $object->statut >= 2) // 2 means accepted + if (!empty($conf->syncsupplierwebservices->enabled) && $object->statut >= 2) // 2 means accepted { print ''.$langs->trans('CreateRemoteOrder').''; } @@ -2562,7 +2562,7 @@ elseif (! empty($object->id)) } // Delete - if (! empty($user->rights->fournisseur->commande->supprimer) || ($object->statut == CommandeFournisseur::STATUS_DRAFT && ! empty($user->rights->fournisseur->commande->creer))) + if (!empty($user->rights->fournisseur->commande->supprimer) || ($object->statut == CommandeFournisseur::STATUS_DRAFT && !empty($user->rights->fournisseur->commande->creer))) { print ''.$langs->trans("Delete").''; } @@ -2585,7 +2585,7 @@ elseif (! empty($object->id)) //print ''.$langs->trans("ToOrder").''; print ''.$langs->trans("OrderDate").''; $date_com = dol_mktime(GETPOST('rehour', 'int'), GETPOST('remin', 'int'), GETPOST('resec', 'int'), GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - if (empty($date_com)) $date_com=dol_now(); + if (empty($date_com)) $date_com = dol_now(); print $form->selectDate($date_com, '', 1, 1, '', "commande", 1, 1); print ''; @@ -2612,25 +2612,25 @@ elseif (! empty($object->id)) // Generated documents $comfournref = dol_sanitizeFileName($object->ref); - $file = $conf->fournisseur->dir_output . '/commande/' . $comfournref . '/' . $comfournref . '.pdf'; - $relativepath = $comfournref.'/'.$comfournref.'.pdf'; - $filedir = $conf->fournisseur->dir_output . '/commande/' . $comfournref; - $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed=$user->rights->fournisseur->commande->lire; - $delallowed=$user->rights->fournisseur->commande->creer; + $file = $conf->fournisseur->dir_output.'/commande/'.$comfournref.'/'.$comfournref.'.pdf'; + $relativepath = $comfournref.'/'.$comfournref.'.pdf'; + $filedir = $conf->fournisseur->dir_output.'/commande/'.$comfournref; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + $genallowed = $user->rights->fournisseur->commande->lire; + $delallowed = $user->rights->fournisseur->commande->creer; print $formfile->showdocuments('commande_fournisseur', $comfournref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 0, 0, '', '', '', $object->thirdparty->default_lang); - $somethingshown=$formfile->numoffiles; + $somethingshown = $formfile->numoffiles; // Show links to link elements - $linktoelem = $form->showLinkToObjectBlock($object, null, array('supplier_order','order_supplier')); + $linktoelem = $form->showLinkToObjectBlock($object, null, array('supplier_order', 'order_supplier')); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); print '
'; if ($action == 'classifyreception') { - if ($user->rights->fournisseur->commande->receptionner && ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY)) + if ($user->rights->fournisseur->commande->receptionner && ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY)) { // Set status to received (action=livraison) print ''."\n"; @@ -2667,8 +2667,8 @@ elseif (! empty($object->id)) // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - $formactions=new FormActions($db); - $somethingshown = $formactions->showactions($object, 'order_supplier', $socid, 1, 'listaction'.($genallowed?'largetitle':'')); + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'order_supplier', $socid, 1, 'listaction'.($genallowed ? 'largetitle' : '')); print '
'; } @@ -2676,7 +2676,7 @@ elseif (! empty($object->id)) /* * Action webservice */ - if ($action == 'webservice' && GETPOST('mode', 'alpha') != "send" && ! GETPOST('cancel', 'alpha')) + if ($action == 'webservice' && GETPOST('mode', 'alpha') != "send" && !GETPOST('cancel', 'alpha')) { $mode = GETPOST('mode', 'alpha'); $ws_url = $object->thirdparty->webservices_url; @@ -2750,7 +2750,7 @@ elseif (! empty($object->id)) //Create SOAP client and connect it to user $soapclient_user = new nusoap_client($ws_url."/webservices/server_user.php"); - $soapclient_user->soap_defencoding='UTF-8'; + $soapclient_user->soap_defencoding = 'UTF-8'; $soapclient_user->decodeUTF8(false); //Get the thirdparty associated to user @@ -2773,7 +2773,7 @@ elseif (! empty($object->id)) { //Create SOAP client and connect it to product/service $soapclient_product = new nusoap_client($ws_url."/webservices/server_productorservice.php"); - $soapclient_product->soap_defencoding='UTF-8'; + $soapclient_product->soap_defencoding = 'UTF-8'; $soapclient_product->decodeUTF8(false); // Iterate each line and get the reference that uses the supplier of that product/service @@ -2821,9 +2821,9 @@ elseif (! empty($object->id)) $product_fourn = new ProductFournisseur($db); $product_fourn_list = $product_fourn->list_product_fournisseur_price($line->fk_product); - if (count($product_fourn_list)>0) + if (count($product_fourn_list) > 0) { - foreach($product_fourn_list as $product_fourn_line) + foreach ($product_fourn_list as $product_fourn_line) { //Only accept the line where the supplier is the same at this order and has the same ref if ($product_fourn_line->fourn_id == $object->socid && $product_fourn_line->fourn_ref == $ref_supplier) { @@ -2888,10 +2888,10 @@ elseif (! empty($object->id)) } // Presend form - $modelmail='order_supplier_send'; - $defaulttopic='SendOrderRef'; + $modelmail = 'order_supplier_send'; + $defaulttopic = 'SendOrderRef'; $diroutput = $conf->fournisseur->commande->dir_output; - $autocopy='MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO'; $trackid = 'sor'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 197d4562114..4582f76c8a6 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -42,61 +42,61 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; -$langs->loadLangs(array("orders","sendings",'deliveries','companies','compta','bills','projects','suppliers')); +$langs->loadLangs(array("orders", "sendings", 'deliveries', 'companies', 'compta', 'bills', 'projects', 'suppliers')); -$action=GETPOST('action', 'aZ09'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'supplierorderlist'; +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'supplierorderlist'; -$search_orderyear=GETPOST("search_orderyear", "int"); -$search_ordermonth=GETPOST("search_ordermonth", "int"); -$search_orderday=GETPOST("search_orderday", "int"); -$search_deliveryyear=GETPOST("search_deliveryyear", "int"); -$search_deliverymonth=GETPOST("search_deliverymonth", "int"); -$search_deliveryday=GETPOST("search_deliveryday", "int"); +$search_orderyear = GETPOST("search_orderyear", "int"); +$search_ordermonth = GETPOST("search_ordermonth", "int"); +$search_orderday = GETPOST("search_orderday", "int"); +$search_deliveryyear = GETPOST("search_deliveryyear", "int"); +$search_deliverymonth = GETPOST("search_deliverymonth", "int"); +$search_deliveryday = GETPOST("search_deliveryday", "int"); -$sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); -$search_product_category=GETPOST('search_product_category', 'int'); -$search_ref=GETPOST('search_ref', 'alpha'); -$search_refsupp=GETPOST('search_refsupp', 'alpha'); -$search_company=GETPOST('search_company', 'alpha'); -$search_town=GETPOST('search_town', 'alpha'); -$search_zip=GETPOST('search_zip', 'alpha'); -$search_state=trim(GETPOST("search_state", 'alpha')); -$search_country=GETPOST("search_country", 'int'); -$search_type_thirdparty=GETPOST("search_type_thirdparty", 'int'); -$search_user=GETPOST('search_user', 'int'); -$search_request_author=GETPOST('search_request_author', 'alpha'); -$search_ht=GETPOST('search_ht', 'alpha'); -$search_ttc=GETPOST('search_ttc', 'alpha'); -$search_status=(GETPOST('search_status', 'alpha')!=''?GETPOST('search_status', 'alpha'):GETPOST('statut', 'alpha')); // alpha and not intbecause it can be '6,7' +$search_product_category = GETPOST('search_product_category', 'int'); +$search_ref = GETPOST('search_ref', 'alpha'); +$search_refsupp = GETPOST('search_refsupp', 'alpha'); +$search_company = GETPOST('search_company', 'alpha'); +$search_town = GETPOST('search_town', 'alpha'); +$search_zip = GETPOST('search_zip', 'alpha'); +$search_state = trim(GETPOST("search_state", 'alpha')); +$search_country = GETPOST("search_country", 'int'); +$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); +$search_user = GETPOST('search_user', 'int'); +$search_request_author = GETPOST('search_request_author', 'alpha'); +$search_ht = GETPOST('search_ht', 'alpha'); +$search_ttc = GETPOST('search_ttc', 'alpha'); +$search_status = (GETPOST('search_status', 'alpha') != '' ?GETPOST('search_status', 'alpha') : GETPOST('statut', 'alpha')); // alpha and not intbecause it can be '6,7' $optioncss = GETPOST('optioncss', 'alpha'); $socid = GETPOST('socid', 'int'); -$search_sale=GETPOST('search_sale', 'int'); -$search_total_ht=GETPOST('search_total_ht', 'alpha'); -$search_total_vat=GETPOST('search_total_vat', 'alpha'); -$search_total_ttc=GETPOST('search_total_ttc', 'alpha'); +$search_sale = GETPOST('search_sale', 'int'); +$search_total_ht = GETPOST('search_total_ht', 'alpha'); +$search_total_vat = GETPOST('search_total_vat', 'alpha'); +$search_total_ttc = GETPOST('search_total_ttc', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); $search_billed = GETPOST('search_billed', 'int'); -$search_project_ref=GETPOST('search_project_ref', 'alpha'); -$search_btn=GETPOST('button_search', 'alpha'); -$search_remove_btn=GETPOST('button_removefilter', 'alpha'); +$search_project_ref = GETPOST('search_project_ref', 'alpha'); +$search_btn = GETPOST('button_search', 'alpha'); +$search_remove_btn = GETPOST('button_removefilter', 'alpha'); -$status=GETPOST('statut', 'alpha'); -$viewstatut=GETPOST('viewstatut'); +$status = GETPOST('statut', 'alpha'); +$viewstatut = GETPOST('viewstatut'); // Security check $orderid = GETPOST('orderid', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'fournisseur', $orderid, '', 'commande'); -$diroutputmassaction=$conf->fournisseur->commande->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->fournisseur->commande->dir_output.'/temp/massgeneration/'.$user->id; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -104,10 +104,10 @@ if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='cf.ref'; -if (! $sortorder) $sortorder='DESC'; +if (!$sortfield) $sortfield = 'cf.ref'; +if (!$sortorder) $sortorder = 'DESC'; -if ($search_status == '') $search_status=-1; +if ($search_status == '') $search_status = -1; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new CommandeFournisseur($db); @@ -117,7 +117,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label('commande_fournisseur'); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -127,10 +127,10 @@ $fieldstosearchall = array( 's.nom'=>"ThirdParty", 'cf.note_public'=>'NotePublic', ); -if (empty($user->socid)) $fieldstosearchall["cf.note_private"]="NotePrivate"; +if (empty($user->socid)) $fieldstosearchall["cf.note_private"] = "NotePrivate"; -$checkedtypetiers=0; -$arrayfields=array( +$checkedtypetiers = 0; +$arrayfields = array( 'cf.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'cf.ref_supplier'=>array('label'=>$langs->trans("RefOrderSupplierShort"), 'checked'=>1, 'enabled'=>1), 'p.project_ref'=>array('label'=>$langs->trans("ProjectRef"), 'checked'=>0, 'enabled'=>1), @@ -154,10 +154,10 @@ $arrayfields=array( // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -169,11 +169,11 @@ $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('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) @@ -184,45 +184,45 @@ if (empty($reshook)) // Purge search criteria 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_categ=''; - $search_user=''; - $search_sale=''; - $search_product_category=''; - $search_ref=''; - $search_refsupp=''; - $search_company=''; - $search_town=''; - $search_zip=""; - $search_state=""; - $search_type=''; - $search_country=''; - $search_type_thirdparty=''; - $search_request_author=''; - $search_total_ht=''; - $search_total_vat=''; - $search_total_ttc=''; - $search_project_ref=''; - $search_status=-1; - $search_orderyear=''; - $search_ordermonth=''; - $search_orderday=''; - $search_deliveryday=''; - $search_deliverymonth=''; - $search_deliveryyear=''; - $billed=''; - $search_billed=''; - $toselect=''; - $search_array_options=array(); + $search_categ = ''; + $search_user = ''; + $search_sale = ''; + $search_product_category = ''; + $search_ref = ''; + $search_refsupp = ''; + $search_company = ''; + $search_town = ''; + $search_zip = ""; + $search_state = ""; + $search_type = ''; + $search_country = ''; + $search_type_thirdparty = ''; + $search_request_author = ''; + $search_total_ht = ''; + $search_total_vat = ''; + $search_total_ttc = ''; + $search_project_ref = ''; + $search_status = -1; + $search_orderyear = ''; + $search_ordermonth = ''; + $search_orderday = ''; + $search_deliveryday = ''; + $search_deliverymonth = ''; + $search_deliveryyear = ''; + $billed = ''; + $search_billed = ''; + $toselect = ''; + $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { - $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='CommandeFournisseur'; - $objectlabel='SupplierOrders'; + $objectclass = 'CommandeFournisseur'; + $objectlabel = 'SupplierOrders'; $permissiontoread = $user->rights->fournisseur->commande->lire; $permissiontodelete = $user->rights->fournisseur->commande->supprimer; $uploaddir = $conf->fournisseur->commande->dir_output; @@ -242,18 +242,18 @@ if (empty($reshook)) $db->begin(); - foreach($orders as $id_order) { + foreach ($orders as $id_order) { $cmd = new Commande($db); - if($cmd->fetch($id_order) <= 0) continue; + if ($cmd->fetch($id_order) <= 0) continue; $object = new Facture($db); - if(!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $object = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order. + if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $object = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order. else { $object->socid = $cmd->socid; $object->type = Facture::TYPE_STANDARD; $object->cond_reglement_id = $cmd->cond_reglement_id; $object->mode_reglement_id = $cmd->mode_reglement_id; - $object->fk_project = $cmd->fk_project; + $object->fk_project = $cmd->fk_project; $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); if (empty($datefacture)) @@ -267,29 +267,29 @@ if (empty($reshook)) $res = $object->create($user); - if($res > 0) $nb_bills_created++; + if ($res > 0) $nb_bills_created++; } if ($object->id > 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; - $sql.= "fk_source"; - $sql.= ", sourcetype"; - $sql.= ", fk_target"; - $sql.= ", targettype"; - $sql.= ") VALUES ("; - $sql.= $id_order; - $sql.= ", '".$object->origin."'"; - $sql.= ", ".$object->id; - $sql.= ", '".$object->element."'"; - $sql.= ")"; + $sql .= "fk_source"; + $sql .= ", sourcetype"; + $sql .= ", fk_target"; + $sql .= ", targettype"; + $sql .= ") VALUES ("; + $sql .= $id_order; + $sql .= ", '".$object->origin."'"; + $sql .= ", ".$object->id; + $sql .= ", '".$object->element."'"; + $sql .= ")"; - if (! $db->query($sql)) + if (!$db->query($sql)) { $erorr++; } - if (! $error) + if (!$error) { $lines = $cmd->lines; if (empty($lines) && method_exists($cmd, 'fetch_lines')) @@ -298,27 +298,27 @@ if (empty($reshook)) $lines = $cmd->lines; } - $fk_parent_line=0; - $num=count($lines); + $fk_parent_line = 0; + $num = count($lines); - for ($i=0;$i<$num;$i++) + for ($i = 0; $i < $num; $i++) { - $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); + $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle); if ($lines[$i]->subprice < 0) { // Negative line, we create a discount line $discount = new DiscountAbsolute($db); - $discount->fk_soc=$object->socid; - $discount->amount_ht=abs($lines[$i]->total_ht); - $discount->amount_tva=abs($lines[$i]->total_tva); - $discount->amount_ttc=abs($lines[$i]->total_ttc); - $discount->tva_tx=$lines[$i]->tva_tx; - $discount->fk_user=$user->id; - $discount->description=$desc; - $discountid=$discount->create($user); + $discount->fk_soc = $object->socid; + $discount->amount_ht = abs($lines[$i]->total_ht); + $discount->amount_tva = abs($lines[$i]->total_tva); + $discount->amount_ttc = abs($lines[$i]->total_ttc); + $discount->tva_tx = $lines[$i]->tva_tx; + $discount->fk_user = $user->id; + $discount->description = $desc; + $discountid = $discount->create($user); if ($discountid > 0) { - $result=$object->insert_discount($discountid); + $result = $object->insert_discount($discountid); //$result=$discount->link_to_invoice($lineid,$id); } else @@ -331,17 +331,17 @@ if (empty($reshook)) else { // Positive line - $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); + $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); // Date start - $date_start=false; - if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue; - if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel; - if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start; + $date_start = false; + if ($lines[$i]->date_debut_prevue) $date_start = $lines[$i]->date_debut_prevue; + if ($lines[$i]->date_debut_reel) $date_start = $lines[$i]->date_debut_reel; + if ($lines[$i]->date_start) $date_start = $lines[$i]->date_start; //Date end - $date_end=false; - if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue; - if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; - if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; + $date_end = false; + if ($lines[$i]->date_fin_prevue) $date_end = $lines[$i]->date_fin_prevue; + if ($lines[$i]->date_fin_reel) $date_end = $lines[$i]->date_fin_reel; + if ($lines[$i]->date_end) $date_end = $lines[$i]->date_end; // Reset fk_parent_line for no child products and special product if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { @@ -375,11 +375,11 @@ if (empty($reshook)) ); if ($result > 0) { - $lineid=$result; + $lineid = $result; } else { - $lineid=0; + $lineid = 0; $error++; break; } @@ -393,9 +393,9 @@ if (empty($reshook)) } } - $cmd->classifyBilled($user); // TODO Move this in workflow like done for customer orders + $cmd->classifyBilled($user); // TODO Move this in workflow like done for customer orders - if(!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $object; + if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $object; else $TFact[$object->id] = $object; } @@ -403,10 +403,10 @@ if (empty($reshook)) $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird; $toselect = array(); - if (! $error && $validate_invoices) { + if (!$error && $validate_invoices) { $massaction = $action = 'builddoc'; - foreach($TAllFact as &$object) + foreach ($TAllFact as &$object) { $object->validate($user); if ($result <= 0) @@ -436,9 +436,9 @@ if (empty($reshook)) else { $db->rollback(); - $action='create'; - $_GET["origin"]=$_POST["origin"]; - $_GET["originid"]=$_POST["originid"]; + $action = 'create'; + $_GET["origin"] = $_POST["origin"]; + $_GET["originid"] = $_POST["originid"]; setEventMessages($object->error, $object->errors, 'errors'); $error++; } @@ -450,15 +450,15 @@ if (empty($reshook)) * View */ -$now=dol_now(); +$now = dol_now(); -$form=new Form($db); +$form = new Form($db); $thirdpartytmp = new Fournisseur($db); -$commandestatic=new CommandeFournisseur($db); +$commandestatic = new CommandeFournisseur($db); $formfile = new FormFile($db); $formorder = new FormOrder($db); $formother = new FormOther($db); -$formcompany=new FormCompany($db); +$formcompany = new FormCompany($db); $title = $langs->trans("SuppliersOrders"); if ($socid > 0) @@ -469,88 +469,88 @@ if ($socid > 0) } if ($status) { - if ($status == '1,2,3') $title.=' - '.$langs->trans("StatusOrderToProcessShort"); - if ($status == '6,7') $title.=' - '.$langs->trans("StatusOrderCanceled"); - else $title.=' - '.$commandestatic->LibStatut($status); + if ($status == '1,2,3') $title .= ' - '.$langs->trans("StatusOrderToProcessShort"); + if ($status == '6,7') $title .= ' - '.$langs->trans("StatusOrderCanceled"); + else $title .= ' - '.$commandestatic->LibStatut($status); } -if ($search_billed > 0) $title.=' - '.$langs->trans("Billed"); +if ($search_billed > 0) $title .= ' - '.$langs->trans("Billed"); //$help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes"; -$help_url=''; +$help_url = ''; // llxHeader('',$title,$help_url); $sql = 'SELECT'; if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; -$sql.= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, s.email,'; -$sql.= " typent.code as typent_code,"; -$sql.= " state.code_departement as state_code, state.nom as state_name,"; -$sql.= " cf.rowid, cf.ref, cf.ref_supplier, cf.fk_statut, cf.billed, cf.total_ht, cf.tva as total_tva, cf.total_ttc, cf.fk_user_author, cf.date_commande as date_commande, cf.date_livraison as date_delivery,"; -$sql.= ' cf.date_creation as date_creation, cf.tms as date_update,'; -$sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_title,"; -$sql.= " u.firstname, u.lastname, u.photo, u.login, u.email as user_email"; +$sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, s.email,'; +$sql .= " typent.code as typent_code,"; +$sql .= " state.code_departement as state_code, state.nom as state_name,"; +$sql .= " cf.rowid, cf.ref, cf.ref_supplier, cf.fk_statut, cf.billed, cf.total_ht, cf.tva as total_tva, cf.total_ttc, cf.fk_user_author, cf.date_commande as date_commande, cf.date_livraison as date_delivery,"; +$sql .= ' cf.date_creation as date_creation, cf.tms as date_update,'; +$sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_title,"; +$sql .= " u.firstname, u.lastname, u.photo, u.login, u.email as user_email"; // 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 : ''); +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 : ''); } // 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 ".MAIN_DB_PREFIX."societe as s"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; -$sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf"; -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 (cf.rowid = ef.fk_object)"; -if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseurdet as pd ON cf.rowid=pd.fk_commande'; -if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON cf.fk_user_author = u.rowid"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = cf.fk_projet"; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +$sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf"; +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 (cf.rowid = ef.fk_object)"; +if ($sall || $search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseurdet as pd ON cf.rowid=pd.fk_commande'; +if ($search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON cf.fk_user_author = u.rowid"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = cf.fk_projet"; // We'll need this table joined to the select in order to filter by sale -if ($search_sale > 0 || (!$user->rights->societe->client->voir && ! $socid)) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if ($search_user > 0) { - $sql.=", ".MAIN_DB_PREFIX."element_contact as ec"; - $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; } -$sql.= ' WHERE cf.fk_soc = s.rowid'; -$sql.= ' AND cf.entity IN ('.getEntity('supplier_order').')'; -if ($socid > 0) $sql.= " AND s.rowid = ".$socid; -if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; +$sql .= ' WHERE cf.fk_soc = s.rowid'; +$sql .= ' AND cf.entity IN ('.getEntity('supplier_order').')'; +if ($socid > 0) $sql .= " AND s.rowid = ".$socid; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($search_ref) $sql .= natural_search('cf.ref', $search_ref); -if ($search_refsupp) $sql.= natural_search("cf.ref_supplier", $search_refsupp); +if ($search_refsupp) $sql .= natural_search("cf.ref_supplier", $search_refsupp); if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); if ($search_company) $sql .= natural_search('s.nom', $search_company); -if ($search_request_author) $sql.=natural_search(array('u.lastname','u.firstname','u.login'), $search_request_author) ; +if ($search_request_author) $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_request_author); if ($search_billed != '' && $search_billed >= 0) $sql .= " AND cf.billed = ".$db->escape($search_billed); -if ($search_product_category > 0) $sql.= " AND cp.fk_categorie = ".$search_product_category; +if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$search_product_category; //Required triple check because statut=0 means draft filter if (GETPOST('statut', 'intcomma') !== '') $sql .= " AND cf.fk_statut IN (".$db->escape($db->escape(GETPOST('statut', 'intcomma'))).")"; if ($search_status != '' && $search_status >= 0) - $sql.=" AND cf.fk_statut IN (".$db->escape($search_status).")"; -$sql.= dolSqlDateFilter("cf.date_commande", $search_orderday, $search_ordermonth, $search_orderyear); -$sql.= dolSqlDateFilter("cf.date_livraison", $search_deliveryday, $search_deliverymonth, $search_deliveryyear); -if ($search_town) $sql.= natural_search('s.town', $search_town); -if ($search_zip) $sql.= natural_search("s.zip", $search_zip); -if ($search_state) $sql.= natural_search("state.nom", $search_state); + $sql .= " AND cf.fk_statut IN (".$db->escape($search_status).")"; +$sql .= dolSqlDateFilter("cf.date_commande", $search_orderday, $search_ordermonth, $search_orderyear); +$sql .= dolSqlDateFilter("cf.date_livraison", $search_deliveryday, $search_deliverymonth, $search_deliveryyear); +if ($search_town) $sql .= natural_search('s.town', $search_town); +if ($search_zip) $sql .= natural_search("s.zip", $search_zip); +if ($search_state) $sql .= natural_search("state.nom", $search_state); if ($search_country) $sql .= " AND s.fk_pays IN (".$db->escape($search_country).')'; if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->escape($search_type_thirdparty).')'; if ($search_company) $sql .= natural_search('s.nom', $search_company); -if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$db->escape($search_sale); -if ($search_user > 0) $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='supplier_order' AND tc.source='internal' AND ec.element_id = cf.rowid AND ec.fk_socpeople = ".$db->escape($search_user); -if ($search_total_ht != '') $sql.= natural_search('cf.total_ht', $search_total_ht, 1); -if ($search_total_vat != '') $sql.= natural_search('cf.tva', $search_total_vat, 1); -if ($search_total_ttc != '') $sql.= natural_search('cf.total_ttc', $search_total_ttc, 1); -if ($search_project_ref != '') $sql.= natural_search("p.ref", $search_project_ref); +if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$db->escape($search_sale); +if ($search_user > 0) $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='supplier_order' AND tc.source='internal' AND ec.element_id = cf.rowid AND ec.fk_socpeople = ".$db->escape($search_user); +if ($search_total_ht != '') $sql .= natural_search('cf.total_ht', $search_total_ht, 1); +if ($search_total_vat != '') $sql .= natural_search('cf.tva', $search_total_vat, 1); +if ($search_total_ttc != '') $sql .= natural_search('cf.total_ttc', $search_total_ttc, 1); +if ($search_project_ref != '') $sql .= natural_search("p.ref", $search_project_ref); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -564,7 +564,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); if ($resql) @@ -573,7 +573,7 @@ if ($resql) { $soc = new Societe($db); $soc->fetch($socid); - $title = $langs->trans('ListOfSupplierOrders') . ' - '.$soc->name; + $title = $langs->trans('ListOfSupplierOrders').' - '.$soc->name; } else { @@ -582,9 +582,9 @@ if ($resql) $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); - if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) + if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -594,48 +594,48 @@ if ($resql) llxHeader('', $title, $help_url); - $param=''; - if ($socid > 0) $param.='&socid='.$socid; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($sall) $param.="&search_all=".$sall; - if ($search_orderday) $param.='&search_orderday='.$search_orderday; - if ($search_ordermonth) $param.='&search_ordermonth='.$search_ordermonth; - if ($search_orderyear) $param.='&search_orderyear='.$search_orderyear; - if ($search_deliveryday) $param.='&search_deliveryday='.$search_deliveryday; - if ($search_deliverymonth) $param.='&search_deliverymonth='.$search_deliverymonth; - if ($search_deliveryyear) $param.='&search_deliveryyear='.$search_deliveryyear; - if ($search_ref) $param.='&search_ref='.$search_ref; - if ($search_company) $param.='&search_company='.$search_company; - if ($search_user > 0) $param.='&search_user='.$search_user; - if ($search_request_author) $param.='&search_request_author='.$search_request_author; - if ($search_sale > 0) $param.='&search_sale='.$search_sale; - if ($search_total_ht != '') $param.='&search_total_ht='.$search_total_ht; - if ($search_total_ttc != '') $param.="&search_total_ttc=".$search_total_ttc; - if ($search_refsupp) $param.="&search_refsupp=".$search_refsupp; - if ($search_status >= 0) $param.="&search_status=".$search_status; - if ($search_project_ref >= 0) $param.="&search_project_ref=".$search_project_ref; - if ($search_billed != '') $param.="&search_billed=".$search_billed; - if ($show_files) $param.='&show_files=' .$show_files; - if ($optioncss != '') $param.='&optioncss='.$optioncss; + $param = ''; + if ($socid > 0) $param .= '&socid='.$socid; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + if ($sall) $param .= "&search_all=".$sall; + if ($search_orderday) $param .= '&search_orderday='.$search_orderday; + if ($search_ordermonth) $param .= '&search_ordermonth='.$search_ordermonth; + if ($search_orderyear) $param .= '&search_orderyear='.$search_orderyear; + if ($search_deliveryday) $param .= '&search_deliveryday='.$search_deliveryday; + if ($search_deliverymonth) $param .= '&search_deliverymonth='.$search_deliverymonth; + if ($search_deliveryyear) $param .= '&search_deliveryyear='.$search_deliveryyear; + if ($search_ref) $param .= '&search_ref='.$search_ref; + if ($search_company) $param .= '&search_company='.$search_company; + if ($search_user > 0) $param .= '&search_user='.$search_user; + if ($search_request_author) $param .= '&search_request_author='.$search_request_author; + if ($search_sale > 0) $param .= '&search_sale='.$search_sale; + if ($search_total_ht != '') $param .= '&search_total_ht='.$search_total_ht; + if ($search_total_ttc != '') $param .= "&search_total_ttc=".$search_total_ttc; + if ($search_refsupp) $param .= "&search_refsupp=".$search_refsupp; + if ($search_status >= 0) $param .= "&search_status=".$search_status; + if ($search_project_ref >= 0) $param .= "&search_project_ref=".$search_project_ref; + if ($search_billed != '') $param .= "&search_billed=".$search_billed; + if ($show_files) $param .= '&show_files='.$show_files; + if ($optioncss != '') $param .= '&optioncss='.$optioncss; // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available - $arrayofmassactions = array( + $arrayofmassactions = array( 'generate_doc'=>$langs->trans("ReGeneratePDF"), 'builddoc'=>$langs->trans("PDFMerge"), 'presend'=>$langs->trans("SendByMail"), ); //if($user->rights->fournisseur->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); - if ($user->rights->fournisseur->commande->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); - if (in_array($massaction, array('presend','predelete','createbills'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + if ($user->rights->fournisseur->commande->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); + if (in_array($massaction, array('presend', 'predelete', 'createbills'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); - $newcardbutton=''; - if($user->rights->fournisseur->commande->creer) + $newcardbutton = ''; + if ($user->rights->fournisseur->commande->creer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/fourn/commande/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/fourn/commande/card.php?action=create'); } // Fields title search @@ -651,10 +651,10 @@ if ($resql) print ''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'commercial', 0, $newcardbutton, '', $limit); - $topicmail="SendOrderRef"; - $modelmail="order_supplier_send"; - $objecttmp=new CommandeFournisseur($db); - $trackid='sord'.$object->id; + $topicmail = "SendOrderRef"; + $modelmail = "order_supplier_send"; + $objecttmp = new CommandeFournisseur($db); + $trackid = 'sord'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($massaction == 'createbills') @@ -699,144 +699,144 @@ if ($resql) if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } - $moreforfilter=''; + $moreforfilter = ''; // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); - $moreforfilter.='
'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; + $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $moreforfilter .= '
'; } // If the user can view other users if ($user->rights->user->user->lire) { - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; - $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); - $moreforfilter.='
'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; + $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); + $moreforfilter .= '
'; } // If the user can view prospects other than his' if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': '; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); - $moreforfilter.='
'; + $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter .= '
'; } - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - if (! empty($moreforfilter)) + if (!empty($moreforfilter)) { print '
'; print $moreforfilter; print '
'; } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); print '
'; - print ''."\n"; + print '
'."\n"; print ''; // Ref - if (! empty($arrayfields['cf.ref']['checked'])) + if (!empty($arrayfields['cf.ref']['checked'])) { print ''; } // Ref customer - if (! empty($arrayfields['cf.ref_supplier']['checked'])) + if (!empty($arrayfields['cf.ref_supplier']['checked'])) { print ''; } // Project ref - if (! empty($arrayfields['p.project_ref']['checked'])) + if (!empty($arrayfields['p.project_ref']['checked'])) { print ''; } // Request author - if (! empty($arrayfields['u.login']['checked'])) + if (!empty($arrayfields['u.login']['checked'])) { print ''; } // Thirpdarty - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print ''; } // Town - if (! empty($arrayfields['s.town']['checked'])) print ''; + if (!empty($arrayfields['s.town']['checked'])) print ''; // Zip - if (! empty($arrayfields['s.zip']['checked'])) print ''; + if (!empty($arrayfields['s.zip']['checked'])) print ''; // State - if (! empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print ''; } // Country - if (! empty($arrayfields['country.code_iso']['checked'])) + if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; } // Company type - if (! empty($arrayfields['typent.code']['checked'])) + if (!empty($arrayfields['typent.code']['checked'])) { print ''; } // Date order - if (! empty($arrayfields['cf.date_commande']['checked'])) + if (!empty($arrayfields['cf.date_commande']['checked'])) { print ''; } // Date delivery - if (! empty($arrayfields['cf.date_delivery']['checked'])) + if (!empty($arrayfields['cf.date_delivery']['checked'])) { print ''; } - if (! empty($arrayfields['cf.total_ht']['checked'])) + if (!empty($arrayfields['cf.total_ht']['checked'])) { // Amount print ''; } - if (! empty($arrayfields['cf.total_vat']['checked'])) + if (!empty($arrayfields['cf.total_vat']['checked'])) { // Amount print ''; } - if (! empty($arrayfields['cf.total_ttc']['checked'])) + if (!empty($arrayfields['cf.total_ttc']['checked'])) { // Amount print ''; } // Date modification - if (! empty($arrayfields['cf.tms']['checked'])) + if (!empty($arrayfields['cf.tms']['checked'])) { print ''; } // Status - if (! empty($arrayfields['cf.fk_statut']['checked'])) + if (!empty($arrayfields['cf.fk_statut']['checked'])) { print ''; } // Status billed - if (! empty($arrayfields['cf.billed']['checked'])) + if (!empty($arrayfields['cf.billed']['checked'])) { print ''; print "\n"; print ''; - if (! empty($arrayfields['cf.ref']['checked'])) print_liste_field_titre($arrayfields['cf.ref']['label'], $_SERVER["PHP_SELF"], "cf.ref", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['cf.ref_supplier']['checked'])) print_liste_field_titre($arrayfields['cf.ref_supplier']['label'], $_SERVER["PHP_SELF"], "cf.ref_supplier", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['p.project_ref']['checked'])) print_liste_field_titre($arrayfields['p.project_ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], "u.login", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['cf.fk_author']['checked'])) print_liste_field_titre($arrayfields['cf.fk_author']['label'], $_SERVER["PHP_SELF"], "cf.fk_author", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['cf.date_commande']['checked'])) print_liste_field_titre($arrayfields['cf.date_commande']['label'], $_SERVER["PHP_SELF"], "cf.date_commande", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['cf.date_delivery']['checked'])) print_liste_field_titre($arrayfields['cf.date_delivery']['label'], $_SERVER["PHP_SELF"], 'cf.date_livraison', '', $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['cf.total_ht']['checked'])) print_liste_field_titre($arrayfields['cf.total_ht']['label'], $_SERVER["PHP_SELF"], "cf.total_ht", "", $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['cf.total_vat']['checked'])) print_liste_field_titre($arrayfields['cf.total_vat']['label'], $_SERVER["PHP_SELF"], "cf.tva", "", $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['cf.total_ttc']['checked'])) print_liste_field_titre($arrayfields['cf.total_ttc']['label'], $_SERVER["PHP_SELF"], "cf.total_ttc", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['cf.ref']['checked'])) print_liste_field_titre($arrayfields['cf.ref']['label'], $_SERVER["PHP_SELF"], "cf.ref", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['cf.ref_supplier']['checked'])) print_liste_field_titre($arrayfields['cf.ref_supplier']['label'], $_SERVER["PHP_SELF"], "cf.ref_supplier", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['p.project_ref']['checked'])) print_liste_field_titre($arrayfields['p.project_ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], "u.login", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['cf.fk_author']['checked'])) print_liste_field_titre($arrayfields['cf.fk_author']['label'], $_SERVER["PHP_SELF"], "cf.fk_author", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['cf.date_commande']['checked'])) print_liste_field_titre($arrayfields['cf.date_commande']['label'], $_SERVER["PHP_SELF"], "cf.date_commande", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['cf.date_delivery']['checked'])) print_liste_field_titre($arrayfields['cf.date_delivery']['label'], $_SERVER["PHP_SELF"], 'cf.date_livraison', '', $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['cf.total_ht']['checked'])) print_liste_field_titre($arrayfields['cf.total_ht']['label'], $_SERVER["PHP_SELF"], "cf.total_ht", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['cf.total_vat']['checked'])) print_liste_field_titre($arrayfields['cf.total_vat']['label'], $_SERVER["PHP_SELF"], "cf.tva", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['cf.total_ttc']['checked'])) print_liste_field_titre($arrayfields['cf.total_ttc']['label'], $_SERVER["PHP_SELF"], "cf.total_ttc", "", $param, '', $sortfield, $sortorder, 'right '); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['cf.datec']['checked'])) print_liste_field_titre($arrayfields['cf.datec']['label'], $_SERVER["PHP_SELF"], "cf.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (! empty($arrayfields['cf.tms']['checked'])) print_liste_field_titre($arrayfields['cf.tms']['label'], $_SERVER["PHP_SELF"], "cf.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (! empty($arrayfields['cf.fk_statut']['checked'])) print_liste_field_titre($arrayfields['cf.fk_statut']['label'], $_SERVER["PHP_SELF"], "cf.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['cf.billed']['checked'])) print_liste_field_titre($arrayfields['cf.billed']['label'], $_SERVER["PHP_SELF"], 'cf.billed', '', $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['cf.datec']['checked'])) print_liste_field_titre($arrayfields['cf.datec']['label'], $_SERVER["PHP_SELF"], "cf.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['cf.tms']['checked'])) print_liste_field_titre($arrayfields['cf.tms']['label'], $_SERVER["PHP_SELF"], "cf.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['cf.fk_statut']['checked'])) print_liste_field_titre($arrayfields['cf.fk_statut']['label'], $_SERVER["PHP_SELF"], "cf.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['cf.billed']['checked'])) print_liste_field_titre($arrayfields['cf.billed']['label'], $_SERVER["PHP_SELF"], 'cf.billed', '', $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; - $total=0; - $subtotal=0; - $productstat_cache=array(); + $total = 0; + $subtotal = 0; + $productstat_cache = array(); $userstatic = new User($db); - $objectstatic=new CommandeFournisseur($db); - $projectstatic=new Project($db); + $objectstatic = new CommandeFournisseur($db); + $projectstatic = new Project($db); - $i=0; - $totalarray=array(); + $i = 0; + $totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - $objectstatic->id=$obj->rowid; - $objectstatic->ref=$obj->ref; + $objectstatic->id = $obj->rowid; + $objectstatic->ref = $obj->ref; $objectstatic->ref_supplier = $obj->ref_supplier; $objectstatic->total_ht = $obj->total_ht; $objectstatic->total_tva = $obj->total_tva; @@ -941,36 +941,36 @@ if ($resql) print ''; // Ref - if (! empty($arrayfields['cf.ref']['checked'])) + if (!empty($arrayfields['cf.ref']['checked'])) { print ''."\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Ref Supplier - if (! empty($arrayfields['cf.ref_supplier']['checked'])) + if (!empty($arrayfields['cf.ref_supplier']['checked'])) { print ''."\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Project - if (! empty($arrayfields['p.project_ref']['checked'])) + if (!empty($arrayfields['p.project_ref']['checked'])) { - $projectstatic->id=$obj->project_id; - $projectstatic->ref=$obj->project_ref; - $projectstatic->title=$obj->project_title; + $projectstatic->id = $obj->project_id; + $projectstatic->ref = $obj->project_ref; + $projectstatic->title = $obj->project_title; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Author $userstatic->id = $obj->fk_user_author; @@ -979,15 +979,15 @@ if ($resql) $userstatic->login = $obj->login; $userstatic->photo = $obj->photo; $userstatic->email = $obj->user_email; - if (! empty($arrayfields['u.login']['checked'])) + if (!empty($arrayfields['u.login']['checked'])) { print '"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Thirdparty - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print '
'; print ''; print ''; print ''; print ''; print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print ''; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT)); print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; - $formother->select_year($search_orderyear?$search_orderyear:-1, 'search_orderyear', 1, 20, 5); + $formother->select_year($search_orderyear ? $search_orderyear : -1, 'search_orderyear', 1, 20, 5); print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; - $formother->select_year($search_deliveryyear?$search_deliveryyear:-1, 'search_deliveryyear', 1, 20, 5); + $formother->select_year($search_deliveryyear ? $search_deliveryyear : -1, 'search_deliveryyear', 1, 20, 5); print ''; print ''; print ''; print ''; print ''; @@ -847,30 +847,30 @@ if ($resql) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['cf.datec']['checked'])) + if (!empty($arrayfields['cf.datec']['checked'])) { print ''; print ''; print ''; - $formorder->selectSupplierOrderStatus((strstr($search_status, ',')?-1:$search_status), 1, 'search_status'); + $formorder->selectSupplierOrderStatus((strstr($search_status, ',') ?-1 : $search_status), 1, 'search_status'); print ''; print $form->selectyesno('search_billed', $search_billed, 1, 0, 1); @@ -878,59 +878,59 @@ if ($resql) } // Action column print ''; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; // Picto + Ref print $objectstatic->getNomUrl(1); // Other picto tool - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->fournisseur->commande->dir_output.'/' . dol_sanitizeFileName($obj->ref); + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->fournisseur->commande->dir_output.'/'.dol_sanitizeFileName($obj->ref); print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); print ''.$obj->ref_supplier.''; if ($obj->project_id > 0) print $projectstatic->getNomUrl(1); print ''; if ($userstatic->id) print $userstatic->getNomUrl(1); print "'; $thirdpartytmp->id = $obj->socid; @@ -1137,8 +1137,8 @@ if ($resql) include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; - $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); - $reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook + $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 "
\n"; @@ -1147,16 +1147,16 @@ if ($resql) $db->free($resql); - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->fournisseur->commande->lire; - $delallowed=$user->rights->fournisseur->commande->creer; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->fournisseur->commande->lire; + $delallowed = $user->rights->fournisseur->commande->creer; print $formfile->showdocuments('massfilesarea_supplier_order', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index ce212069238..05965067b55 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -49,59 +49,59 @@ if (!$user->rights->fournisseur->facture->lire) accessforbidden(); // Load translation files required by the page $langs->loadLangs(array('products', 'bills', 'companies', 'projects')); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $optioncss = GETPOST('optioncss', 'alpha'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'supplierinvoicelist'; +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'supplierinvoicelist'; $socid = GETPOST('socid', 'int'); // Security check if ($user->socid > 0) { - $action=''; + $action = ''; $_GET["action"] = ''; $socid = $user->socid; } -$mode=GETPOST("mode"); +$mode = GETPOST("mode"); -$search_all = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); +$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_label = GETPOST("search_label", "alpha"); $search_amount_no_tax = GETPOST("search_amount_no_tax", "alpha"); $search_amount_all_tax = GETPOST("search_amount_all_tax", "alpha"); -$search_product_category=GETPOST('search_product_category', 'int'); -$search_ref=GETPOST('sf_ref')?GETPOST('sf_ref', 'alpha'):GETPOST('search_ref', 'alpha'); -$search_refsupplier=GETPOST('search_refsupplier', 'alpha'); -$search_type=GETPOST('search_type', 'int'); -$search_project=GETPOST('search_project', 'alpha'); -$search_company=GETPOST('search_company', 'alpha'); -$search_montant_ht=GETPOST('search_montant_ht', 'alpha'); -$search_montant_vat=GETPOST('search_montant_vat', 'alpha'); -$search_montant_localtax1=GETPOST('search_montant_localtax1', 'alpha'); -$search_montant_localtax2=GETPOST('search_montant_localtax2', 'alpha'); -$search_montant_ttc=GETPOST('search_montant_ttc', 'alpha'); -$search_status=GETPOST('search_status', 'int'); -$search_paymentmode=GETPOST('search_paymentmode', 'int'); -$search_town=GETPOST('search_town', 'alpha'); -$search_zip=GETPOST('search_zip', 'alpha'); -$search_state=trim(GETPOST("search_state")); -$search_country=GETPOST("search_country", 'int'); -$search_type_thirdparty=GETPOST("search_type_thirdparty", 'int'); +$search_product_category = GETPOST('search_product_category', 'int'); +$search_ref = GETPOST('sf_ref') ?GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha'); +$search_refsupplier = GETPOST('search_refsupplier', 'alpha'); +$search_type = GETPOST('search_type', 'int'); +$search_project = GETPOST('search_project', 'alpha'); +$search_company = GETPOST('search_company', 'alpha'); +$search_montant_ht = GETPOST('search_montant_ht', 'alpha'); +$search_montant_vat = GETPOST('search_montant_vat', 'alpha'); +$search_montant_localtax1 = GETPOST('search_montant_localtax1', 'alpha'); +$search_montant_localtax2 = GETPOST('search_montant_localtax2', 'alpha'); +$search_montant_ttc = GETPOST('search_montant_ttc', 'alpha'); +$search_status = GETPOST('search_status', 'int'); +$search_paymentmode = GETPOST('search_paymentmode', 'int'); +$search_town = GETPOST('search_town', 'alpha'); +$search_zip = GETPOST('search_zip', 'alpha'); +$search_state = trim(GETPOST("search_state")); +$search_country = GETPOST("search_country", 'int'); +$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); $search_user = GETPOST('search_user', 'int'); $search_sale = GETPOST('search_sale', 'int'); -$day = GETPOST('day', 'int'); -$month = GETPOST('month', 'int'); -$year = GETPOST('year', 'int'); -$day_lim = GETPOST('day_lim', 'int'); +$day = GETPOST('day', 'int'); +$month = GETPOST('month', 'int'); +$year = GETPOST('year', 'int'); +$day_lim = GETPOST('day_lim', 'int'); $month_lim = GETPOST('month_lim', 'int'); $year_lim = GETPOST('year_lim', 'int'); $toselect = GETPOST('toselect', 'array'); -$search_btn=GETPOST('button_search', 'alpha'); -$search_remove_btn=GETPOST('button_removefilter', 'alpha'); +$search_btn = GETPOST('button_search', 'alpha'); +$search_remove_btn = GETPOST('button_removefilter', 'alpha'); $option = GETPOST('option'); if ($option == 'late') { @@ -109,20 +109,20 @@ if ($option == 'late') { } $filter = GETPOST('filtre', 'alpha'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page=GETPOST("page", 'int'); -if ($page == -1 || $page == null || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0 ; } -$offset = $limit * $page ; +$page = GETPOST("page", 'int'); +if ($page == -1 || $page == null || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="DESC"; -if (! $sortfield) $sortfield="f.datef,f.rowid"; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "f.datef,f.rowid"; -$diroutputmassaction=$conf->fournisseur->facture->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->fournisseur->facture->dir_output.'/temp/massgeneration/'.$user->id; -$now=dol_now(); +$now = dol_now(); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new FactureFournisseur($db); @@ -132,7 +132,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -142,10 +142,10 @@ $fieldstosearchall = array( 's.nom'=>"ThirdParty", 'f.note_public'=>'NotePublic', ); -if (empty($user->socid)) $fieldstosearchall["f.note_private"]="NotePrivate"; +if (empty($user->socid)) $fieldstosearchall["f.note_private"] = "NotePrivate"; -$checkedtypetiers=0; -$arrayfields=array( +$checkedtypetiers = 0; +$arrayfields = array( 'f.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'f.ref_supplier'=>array('label'=>$langs->trans("RefSupplier"), 'checked'=>1), 'f.type'=>array('label'=>$langs->trans("Type"), 'checked'=>0), @@ -162,8 +162,8 @@ $arrayfields=array( 'f.fk_mode_reglement'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>1), 'f.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1), 'f.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0), - 'f.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>$mysoc->localtax1_assuj=="1"), - 'f.total_localtax2'=>array('label'=>$langs->transcountry("AmountLT2", $mysoc->country_code), 'checked'=>0, 'enabled'=>$mysoc->localtax2_assuj=="1"), + 'f.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>$mysoc->localtax1_assuj == "1"), + 'f.total_localtax2'=>array('label'=>$langs->transcountry("AmountLT2", $mysoc->country_code), 'checked'=>0, 'enabled'=>$mysoc->localtax2_assuj == "1"), 'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0), 'dynamount_payed'=>array('label'=>$langs->trans("Payed"), 'checked'=>0), 'rtp'=>array('label'=>$langs->trans("Rest"), 'checked'=>0), @@ -174,10 +174,10 @@ $arrayfields=array( // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -188,11 +188,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; } -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) @@ -254,58 +254,58 @@ if (empty($reshook)) * View */ -$form=new Form($db); -$formother=new FormOther($db); +$form = new Form($db); +$formother = new FormOther($db); $formfile = new FormFile($db); -$bankaccountstatic=new Account($db); -$facturestatic=new FactureFournisseur($db); -$formcompany=new FormCompany($db); -$thirdparty=new Societe($db); +$bankaccountstatic = new Account($db); +$facturestatic = new FactureFournisseur($db); +$formcompany = new FormCompany($db); +$thirdparty = new Societe($db); // llxHeader('',$langs->trans("SuppliersInvoices"),'EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores'); $sql = "SELECT"; if ($search_all || $search_product_category > 0) $sql = 'SELECT DISTINCT'; -$sql.= " f.rowid as facid, f.ref, f.ref_supplier, f.type, f.datef, f.date_lim_reglement as datelimite, f.fk_mode_reglement,"; -$sql.= " f.total_ht, f.total_ttc, f.total_tva as total_vat, f.paye as paye, f.fk_statut as fk_statut, f.libelle as label, f.datec as date_creation, f.tms as date_update,"; -$sql.= " f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,"; -$sql.= " s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,"; -$sql.= " typent.code as typent_code,"; -$sql.= " state.code_departement as state_code, state.nom as state_name,"; -$sql.= " country.code as country_code,"; -$sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_label"; +$sql .= " f.rowid as facid, f.ref, f.ref_supplier, f.type, f.datef, f.date_lim_reglement as datelimite, f.fk_mode_reglement,"; +$sql .= " f.total_ht, f.total_ttc, f.total_tva as total_vat, f.paye as paye, f.fk_statut as fk_statut, f.libelle as label, f.datec as date_creation, f.tms as date_update,"; +$sql .= " f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,"; +$sql .= " s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,"; +$sql .= " typent.code as typent_code,"; +$sql .= " state.code_departement as state_code, state.nom as state_name,"; +$sql .= " country.code as country_code,"; +$sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_label"; // We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0) // TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field. -if (! $search_all) $sql.= ', SUM(pf.amount) as dynamount_payed'; +if (!$search_all) $sql .= ', SUM(pf.amount) as dynamount_payed'; // 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 : ''); +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 : ''); } // 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 '.MAIN_DB_PREFIX.'societe as s'; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; -$sql.= ', '.MAIN_DB_PREFIX.'facture_fourn as f'; -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 (f.rowid = ef.fk_object)"; -if (! $search_all) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid'; -if ($search_all || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det as pd ON f.rowid=pd.fk_facture_fourn'; -if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = f.fk_projet"; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s'; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +$sql .= ', '.MAIN_DB_PREFIX.'facture_fourn as f'; +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 (f.rowid = ef.fk_object)"; +if (!$search_all) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid'; +if ($search_all || $search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det as pd ON f.rowid=pd.fk_facture_fourn'; +if ($search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = f.fk_projet"; // We'll need this table joined to the select in order to filter by sale -if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if ($search_user > 0) { - $sql.=", ".MAIN_DB_PREFIX."element_contact as ec"; - $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; } -$sql.= ' WHERE f.fk_soc = s.rowid'; -$sql.= ' AND f.entity IN ('.getEntity('facture_fourn').')'; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$search_product_category; +$sql .= ' WHERE f.fk_soc = s.rowid'; +$sql .= ' AND f.entity IN ('.getEntity('facture_fourn').')'; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$search_product_category; if ($socid > 0) $sql .= ' AND s.rowid = '.$socid; if ($search_ref) { @@ -316,34 +316,34 @@ if ($search_ref) $sql .= natural_search('f.ref', $search_ref); if ($search_refsupplier) $sql .= natural_search('f.ref_supplier', $search_refsupplier); if ($search_type != '' && $search_type >= 0) { - if ($search_type == '0') $sql.=" AND f.type = 0"; // standard - if ($search_type == '1') $sql.=" AND f.type = 1"; // replacement - if ($search_type == '2') $sql.=" AND f.type = 2"; // credit note - if ($search_type == '3') $sql.=" AND f.type = 3"; // deposit + if ($search_type == '0') $sql .= " AND f.type = 0"; // standard + if ($search_type == '1') $sql .= " AND f.type = 1"; // replacement + if ($search_type == '2') $sql .= " AND f.type = 2"; // credit note + if ($search_type == '3') $sql .= " AND f.type = 3"; // deposit //if ($search_type == '4') $sql.=" AND f.type = 4"; // proforma //if ($search_type == '5') $sql.=" AND f.type = 5"; // situation } if ($search_project) $sql .= natural_search('p.ref', $search_project); if ($search_company) $sql .= natural_search('s.nom', $search_company); -if ($search_town) $sql.= natural_search('s.town', $search_town); -if ($search_zip) $sql.= natural_search("s.zip", $search_zip); -if ($search_state) $sql.= natural_search("state.nom", $search_state); +if ($search_town) $sql .= natural_search('s.town', $search_town); +if ($search_zip) $sql .= natural_search("s.zip", $search_zip); +if ($search_state) $sql .= natural_search("state.nom", $search_state); if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; -if ($search_montant_ht != '') $sql.= natural_search('f.total_ht', $search_montant_ht, 1); -if ($search_montant_vat != '') $sql.= natural_search('f.total_tva', $search_montant_vat, 1); -if ($search_montant_localtax1 != '') $sql.= natural_search('f.localtax1', $search_montant_localtax1, 1); -if ($search_montant_localtax2 != '') $sql.= natural_search('f.localtax2', $search_montant_localtax2, 1); -if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1); -if ($search_status != '' && $search_status >= 0) $sql.= " AND f.fk_statut = ".$db->escape($search_status); +if ($search_montant_ht != '') $sql .= natural_search('f.total_ht', $search_montant_ht, 1); +if ($search_montant_vat != '') $sql .= natural_search('f.total_tva', $search_montant_vat, 1); +if ($search_montant_localtax1 != '') $sql .= natural_search('f.localtax1', $search_montant_localtax1, 1); +if ($search_montant_localtax2 != '') $sql .= natural_search('f.localtax2', $search_montant_localtax2, 1); +if ($search_montant_ttc != '') $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1); +if ($search_status != '' && $search_status >= 0) $sql .= " AND f.fk_statut = ".$db->escape($search_status); if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".$search_paymentmode.""; -$sql.= dolSqlDateFilter("f.datef", $day, $month, $year); -$sql.= dolSqlDateFilter("f.date_lim_reglement", $day_lim, $month_lim, $year_lim); -if ($option == 'late') $sql.=" AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->fournisseur->warning_delay)."'"; +$sql .= dolSqlDateFilter("f.datef", $day, $month, $year); +$sql .= dolSqlDateFilter("f.date_lim_reglement", $day_lim, $month_lim, $year_lim); +if ($option == 'late') $sql .= " AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->fournisseur->warning_delay)."'"; if ($search_label) $sql .= natural_search('f.libelle', $search_label); if ($search_status != '' && $search_status >= 0) { - $sql.= " AND f.fk_statut = ".$search_status; + $sql .= " AND f.fk_statut = ".$search_status; } if ($filter && $filter != -1) { @@ -351,44 +351,44 @@ if ($filter && $filter != -1) foreach ($aFilter as $fil) { $filt = explode(':', $fil); - $sql .= ' AND ' . $db->escape(trim($filt[0])) . ' = ' . $db->escape(trim($filt[1])); + $sql .= ' AND '.$db->escape(trim($filt[0])).' = '.$db->escape(trim($filt[1])); } } -if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$db->escape($search_sale); +if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$db->escape($search_sale); if ($search_user > 0) { - $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='invoice_supplier' AND tc.source='internal' AND ec.element_id = f.rowid AND ec.fk_socpeople = ".$search_user; + $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='invoice_supplier' AND tc.source='internal' AND ec.element_id = f.rowid AND ec.fk_socpeople = ".$search_user; } // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -if (! $search_all) +if (!$search_all) { - $sql.= " GROUP BY f.rowid, f.ref, f.ref_supplier, f.type, f.datef, f.date_lim_reglement, f.fk_mode_reglement,"; - $sql.= " f.total_ht, f.total_ttc, f.total_tva, f.paye, f.fk_statut, f.libelle, f.datec, f.tms,"; - $sql.= " f.localtax1, f.localtax2,"; - $sql.= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,'; - $sql.= " typent.code,"; - $sql.= " state.code_departement, state.nom,"; - $sql.= ' country.code,'; - $sql.= " p.rowid, p.ref, p.title"; - if (! empty($extrafields->attributes[$object->table_element]['label'])) { + $sql .= " GROUP BY f.rowid, f.ref, f.ref_supplier, f.type, f.datef, f.date_lim_reglement, f.fk_mode_reglement,"; + $sql .= " f.total_ht, f.total_ttc, f.total_tva, f.paye, f.fk_statut, f.libelle, f.datec, f.tms,"; + $sql .= " f.localtax1, f.localtax2,"; + $sql .= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,'; + $sql .= " typent.code,"; + $sql .= " state.code_departement, state.nom,"; + $sql .= ' country.code,'; + $sql .= " p.rowid, p.ref, p.title"; + if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { //prevent error with sql_mode=only_full_group_by - $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ",ef.".$key : ''); + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ",ef.".$key : ''); } } } else { - $sql.= natural_search(array_keys($fieldstosearchall), $search_all); + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -402,7 +402,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); //print $sql; $resql = $db->query($sql); @@ -410,9 +410,9 @@ if ($resql) { $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); - if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) + if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { $obj = $db->fetch_object($resql); $id = $obj->facid; @@ -430,51 +430,51 @@ if ($resql) if (empty($search_company)) $search_company = $soc->name; } - $param='&socid='.$socid; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_all) $param.='&search_all='.urlencode($search_all); - if ($day) $param.='&day='.urlencode($day); - if ($month) $param.='&month='.urlencode($month); - if ($year) $param.='&year=' .urlencode($year); - if ($day_lim) $param.='&day_lim='.urlencode($day_lim); - if ($month_lim) $param.='&month_lim='.urlencode($month_lim); - if ($year_lim) $param.='&year_lim=' .urlencode($year_lim); - if ($search_ref) $param.='&search_ref='.urlencode($search_ref); - if ($search_refsupplier) $param.='&search_refsupplier='.urlencode($search_refsupplier); - if ($search_type != '') $param.='&search_type='.urlencode($search_type); - if ($search_label) $param.='&search_label='.urlencode($search_label); - if ($search_company) $param.='&search_company='.urlencode($search_company); - if ($search_montant_ht != '') $param.='&search_montant_ht='.urlencode($search_montant_ht); - if ($search_montant_vat != '') $param.='&search_montant_vat='.urlencode($search_montant_vat); - if ($search_montant_localtax1 != '') $param.='&search_montant_localtax1='.urlencode($search_montant_localtax1); - if ($search_montant_localtax2 != '') $param.='&search_montant_localtax2='.urlencode($search_montant_localtax2); - if ($search_montant_ttc != '') $param.='&search_montant_ttc='.urlencode($search_montant_ttc); - if ($search_amount_no_tax) $param.='&search_amount_no_tax='.urlencode($search_amount_no_tax); - if ($search_amount_all_tax) $param.='&search_amount_all_tax='.urlencode($search_amount_all_tax); - if ($search_status >= 0) $param.="&search_status=".urlencode($search_status); - if ($show_files) $param.='&show_files=' .$show_files; - if ($option) $param.="&option=".$option; - if ($optioncss != '') $param.='&optioncss='.$optioncss; + $param = '&socid='.$socid; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + if ($search_all) $param .= '&search_all='.urlencode($search_all); + if ($day) $param .= '&day='.urlencode($day); + if ($month) $param .= '&month='.urlencode($month); + if ($year) $param .= '&year='.urlencode($year); + if ($day_lim) $param .= '&day_lim='.urlencode($day_lim); + if ($month_lim) $param .= '&month_lim='.urlencode($month_lim); + if ($year_lim) $param .= '&year_lim='.urlencode($year_lim); + if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); + if ($search_refsupplier) $param .= '&search_refsupplier='.urlencode($search_refsupplier); + if ($search_type != '') $param .= '&search_type='.urlencode($search_type); + if ($search_label) $param .= '&search_label='.urlencode($search_label); + if ($search_company) $param .= '&search_company='.urlencode($search_company); + if ($search_montant_ht != '') $param .= '&search_montant_ht='.urlencode($search_montant_ht); + if ($search_montant_vat != '') $param .= '&search_montant_vat='.urlencode($search_montant_vat); + if ($search_montant_localtax1 != '') $param .= '&search_montant_localtax1='.urlencode($search_montant_localtax1); + if ($search_montant_localtax2 != '') $param .= '&search_montant_localtax2='.urlencode($search_montant_localtax2); + if ($search_montant_ttc != '') $param .= '&search_montant_ttc='.urlencode($search_montant_ttc); + if ($search_amount_no_tax) $param .= '&search_amount_no_tax='.urlencode($search_amount_no_tax); + if ($search_amount_all_tax) $param .= '&search_amount_all_tax='.urlencode($search_amount_all_tax); + if ($search_status >= 0) $param .= "&search_status=".urlencode($search_status); + if ($show_files) $param .= '&show_files='.$show_files; + if ($option) $param .= "&option=".$option; + if ($optioncss != '') $param .= '&optioncss='.$optioncss; // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available - $arrayofmassactions = array( + $arrayofmassactions = array( 'validate'=>$langs->trans("Validate"), 'generate_doc'=>$langs->trans("ReGeneratePDF"), //'builddoc'=>$langs->trans("PDFMerge"), //'presend'=>$langs->trans("SendByMail"), ); //if($user->rights->fournisseur->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); - if ($user->rights->fournisseur->facture->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); - if (in_array($massaction, array('presend','predelete','createbills'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + if ($user->rights->fournisseur->facture->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); + if (in_array($massaction, array('presend', 'predelete', 'createbills'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); - $newcardbutton=''; + $newcardbutton = ''; if ($user->rights->fournisseur->facture->creer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewBill'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/fourn/facture/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewBill'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/fourn/facture/card.php?action=create'); } $i = 0; @@ -489,12 +489,12 @@ if ($resql) print ''; print ''; - print_barre_liste($langs->trans("BillsSuppliers").($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'invoicing', 0, $newcardbutton, '', $limit); + print_barre_liste($langs->trans("BillsSuppliers").($socid ? ' '.$soc->name : ''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'invoicing', 0, $newcardbutton, '', $limit); - $topicmail="SendBillRef"; - $modelmail="invoice_supplier_send"; - $objecttmp=new FactureFournisseur($db); - $trackid='sinv'.$object->id; + $topicmail = "SendBillRef"; + $modelmail = "invoice_supplier_send"; + $objecttmp = new FactureFournisseur($db); + $trackid = 'sinv'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($massaction == 'createbills') @@ -539,40 +539,40 @@ if ($resql) if ($search_all) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; } // If the user can view prospects other than his' - $moreforfilter=''; + $moreforfilter = ''; if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); - $moreforfilter.='
'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; + $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $moreforfilter .= '
'; } // If the user can view prospects other than his' if ($user->rights->societe->client->voir || $socid) { - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; - $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); - $moreforfilter.='
'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; + $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); + $moreforfilter .= '
'; } // If the user can view prospects other than his' if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': '; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); - $moreforfilter.='
'; + $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter .= '
'; } - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; @@ -583,34 +583,34 @@ if ($resql) print '
'; } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); print '
'; - print ''."\n"; + print '
'."\n"; // Line for filters print ''; // Ref - if (! empty($arrayfields['f.ref']['checked'])) + if (!empty($arrayfields['f.ref']['checked'])) { print ''; } // Ref supplier - if (! empty($arrayfields['f.ref_supplier']['checked'])) + if (!empty($arrayfields['f.ref_supplier']['checked'])) { print ''; } // Type - if (! empty($arrayfields['f.type']['checked'])) + if (!empty($arrayfields['f.type']['checked'])) { print ''; } // Label - if (! empty($arrayfields['f.label']['checked'])) + if (!empty($arrayfields['f.label']['checked'])) { print ''; } // Date invoice - if (! empty($arrayfields['f.datef']['checked'])) + if (!empty($arrayfields['f.datef']['checked'])) { print ''; } // Date due - if (! empty($arrayfields['f.date_lim_reglement']['checked'])) + if (!empty($arrayfields['f.date_lim_reglement']['checked'])) { print ''; } // Project - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { print ''; } // Thirpdarty - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print ''; } // Town - if (! empty($arrayfields['s.town']['checked'])) print ''; + if (!empty($arrayfields['s.town']['checked'])) print ''; // Zip - if (! empty($arrayfields['s.zip']['checked'])) print ''; + if (!empty($arrayfields['s.zip']['checked'])) print ''; // State - if (! empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print ''; } // Country - if (! empty($arrayfields['country.code_iso']['checked'])) + if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; } // Company type - if (! empty($arrayfields['typent.code']['checked'])) + if (!empty($arrayfields['typent.code']['checked'])) { print ''; } // Payment mode - if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { print ''; } - if (! empty($arrayfields['f.total_ht']['checked'])) + if (!empty($arrayfields['f.total_ht']['checked'])) { // Amount without tax print ''; } - if (! empty($arrayfields['f.total_vat']['checked'])) + if (!empty($arrayfields['f.total_vat']['checked'])) { // Amount vat print ''; } - if (! empty($arrayfields['f.total_localtax1']['checked'])) + if (!empty($arrayfields['f.total_localtax1']['checked'])) { // Amount tax 1 print ''; } - if (! empty($arrayfields['f.total_localtax2']['checked'])) + if (!empty($arrayfields['f.total_localtax2']['checked'])) { // Amount tax 2 print ''; } - if (! empty($arrayfields['f.total_ttc']['checked'])) + if (!empty($arrayfields['f.total_ttc']['checked'])) { // Amount inc tac print ''; } - if (! empty($arrayfields['dynamount_payed']['checked'])) + if (!empty($arrayfields['dynamount_payed']['checked'])) { print ''; } - if (! empty($arrayfields['rtp']['checked'])) + if (!empty($arrayfields['rtp']['checked'])) { print ''; @@ -743,102 +743,102 @@ if ($resql) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['f.datec']['checked'])) + if (!empty($arrayfields['f.datec']['checked'])) { print ''; } // Date modification - if (! empty($arrayfields['f.tms']['checked'])) + if (!empty($arrayfields['f.tms']['checked'])) { print ''; } // Status - if (! empty($arrayfields['f.fk_statut']['checked'])) + if (!empty($arrayfields['f.fk_statut']['checked'])) { print ''; } // Action column print ''; print "\n"; print ''; - if (! empty($arrayfields['f.ref']['checked'])) print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER['PHP_SELF'], 'f.ref,f.rowid', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['f.ref_supplier']['checked'])) print_liste_field_titre($arrayfields['f.ref_supplier']['label'], $_SERVER["PHP_SELF"], 'f.ref_supplier', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['f.type']['checked'])) print_liste_field_titre($arrayfields['f.type']['label'], $_SERVER["PHP_SELF"], 'f.type', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['f.label']['checked'])) print_liste_field_titre($arrayfields['f.label']['label'], $_SERVER['PHP_SELF'], "f.libelle,f.rowid", '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['f.datef']['checked'])) print_liste_field_titre($arrayfields['f.datef']['label'], $_SERVER['PHP_SELF'], 'f.datef,f.rowid', '', $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['f.date_lim_reglement']['checked'])) print_liste_field_titre($arrayfields['f.date_lim_reglement']['label'], $_SERVER['PHP_SELF'], "f.date_lim_reglement", '', $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER['PHP_SELF'], "p.ref", '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], 's.nom', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_mode_reglement", "", $param, "", $sortfield, $sortorder); - if (! empty($arrayfields['f.total_ht']['checked'])) print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total_ht', '', $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['f.total_vat']['checked'])) print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.tva', '', $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['f.total_localtax1']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['f.total_localtax2']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax2']['label'], $_SERVER['PHP_SELF'], 'f.localtax2', '', $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.total_ttc', '', $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['f.ref']['checked'])) print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER['PHP_SELF'], 'f.ref,f.rowid', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['f.ref_supplier']['checked'])) print_liste_field_titre($arrayfields['f.ref_supplier']['label'], $_SERVER["PHP_SELF"], 'f.ref_supplier', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['f.type']['checked'])) print_liste_field_titre($arrayfields['f.type']['label'], $_SERVER["PHP_SELF"], 'f.type', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['f.label']['checked'])) print_liste_field_titre($arrayfields['f.label']['label'], $_SERVER['PHP_SELF'], "f.libelle,f.rowid", '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['f.datef']['checked'])) print_liste_field_titre($arrayfields['f.datef']['label'], $_SERVER['PHP_SELF'], 'f.datef,f.rowid', '', $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['f.date_lim_reglement']['checked'])) print_liste_field_titre($arrayfields['f.date_lim_reglement']['label'], $_SERVER['PHP_SELF'], "f.date_lim_reglement", '', $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER['PHP_SELF'], "p.ref", '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], 's.nom', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_mode_reglement", "", $param, "", $sortfield, $sortorder); + if (!empty($arrayfields['f.total_ht']['checked'])) print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total_ht', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['f.total_vat']['checked'])) print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.tva', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['f.total_localtax1']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['f.total_localtax2']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax2']['label'], $_SERVER['PHP_SELF'], 'f.localtax2', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.total_ttc', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - if (! empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "fk_statut,paye,type", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "fk_statut,paye,type", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; - $facturestatic=new FactureFournisseur($db); - $supplierstatic=new Fournisseur($db); - $projectstatic=new Project($db); + $facturestatic = new FactureFournisseur($db); + $supplierstatic = new Fournisseur($db); + $projectstatic = new Project($db); if ($num > 0) { - $i=0; - $totalarray=array(); + $i = 0; + $totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - $datelimit=$db->jdate($obj->datelimite); - $facturestatic->id=$obj->facid; - $facturestatic->ref=$obj->ref; - $facturestatic->type=$obj->type; - $facturestatic->ref_supplier=$obj->ref_supplier; + $datelimit = $db->jdate($obj->datelimite); + $facturestatic->id = $obj->facid; + $facturestatic->ref = $obj->ref; + $facturestatic->type = $obj->type; + $facturestatic->ref_supplier = $obj->ref_supplier; $facturestatic->date_echeance = $db->jdate($obj->datelimite); $facturestatic->statut = $obj->fk_statut; - $thirdparty->id=$obj->socid; - $thirdparty->name=$obj->name; - $thirdparty->client=$obj->client; - $thirdparty->fournisseur=$obj->fournisseur; - $thirdparty->code_client=$obj->code_client; - $thirdparty->code_compta_client=$obj->code_compta_client; - $thirdparty->code_fournisseur=$obj->code_fournisseur; - $thirdparty->code_compta_fournisseur=$obj->code_compta_fournisseur; - $thirdparty->email=$obj->email; - $thirdparty->country_code=$obj->country_code; + $thirdparty->id = $obj->socid; + $thirdparty->name = $obj->name; + $thirdparty->client = $obj->client; + $thirdparty->fournisseur = $obj->fournisseur; + $thirdparty->code_client = $obj->code_client; + $thirdparty->code_compta_client = $obj->code_compta_client; + $thirdparty->code_fournisseur = $obj->code_fournisseur; + $thirdparty->code_compta_fournisseur = $obj->code_compta_fournisseur; + $thirdparty->email = $obj->email; + $thirdparty->country_code = $obj->country_code; $paiement = $facturestatic->getSommePaiement(); $totalcreditnotes = $facturestatic->getSumCreditNotesUsed(); @@ -847,14 +847,14 @@ if ($resql) $remaintopay = $obj->total_ttc - $totalpay; //If invoice has been converted and the conversion has been used, we dont have remain to pay on invoice - if($facturestatic->type == FactureFournisseur::TYPE_CREDIT_NOTE) { - if($facturestatic->isCreditNoteUsed()){ - $remaintopay=-$facturestatic->getSumFromThisCreditNotesNotUsed(); + if ($facturestatic->type == FactureFournisseur::TYPE_CREDIT_NOTE) { + if ($facturestatic->isCreditNoteUsed()) { + $remaintopay = -$facturestatic->getSumFromThisCreditNotesNotUsed(); } } print ''; - if (! empty($arrayfields['f.ref']['checked'])) + if (!empty($arrayfields['f.ref']['checked'])) { print ''; // Other picto tool print '
'; print ''; print ''; print ''; print ''; - $listtype=array( + $listtype = array( FactureFournisseur::TYPE_STANDARD=>$langs->trans("InvoiceStandard"), FactureFournisseur::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"), FactureFournisseur::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"), @@ -627,114 +627,114 @@ if ($resql) print ''; print ''; print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; - $formother->select_year($year?$year:-1, 'year', 1, 20, 5); + $formother->select_year($year ? $year : -1, 'year', 1, 20, 5); print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; - $formother->select_year($year_lim?$year_lim:-1, 'year_lim', 1, 20, 5); - print '
'.$langs->trans("Late"); + $formother->select_year($year_lim ? $year_lim : -1, 'year_lim', 1, 20, 5); + print '
'.$langs->trans("Late"); print '
'; print ''; print ''; print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print ''; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT)); print ''; $form->select_types_paiements($search_paymentmode, 'search_paymentmode', '', 0, 1, 1, 10); print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; - $liststatus=array('0'=>$langs->trans("Draft"),'1'=>$langs->trans("Unpaid"), '2'=>$langs->trans("Paid")); + $liststatus = array('0'=>$langs->trans("Draft"), '1'=>$langs->trans("Unpaid"), '2'=>$langs->trans("Paid")); print $form->selectarray('search_status', $liststatus, $search_status, 1); print ''; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; @@ -868,54 +868,54 @@ if ($resql) //print ''; - $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->fournisseur->facture->dir_output.'/'.get_exdir($obj->facid, 2, 0, 0, $facturestatic, 'invoice_supplier').dol_sanitizeFileName($obj->ref); + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($obj->facid, 2, 0, 0, $facturestatic, 'invoice_supplier').dol_sanitizeFileName($obj->ref); $subdir = get_exdir($obj->facid, 2, 0, 0, $facturestatic, 'invoice_supplier').dol_sanitizeFileName($obj->ref); print $formfile->getDocumentsLink('facture_fournisseur', $subdir, $filedir); print '
'; print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Supplier ref - if (! empty($arrayfields['f.ref_supplier']['checked'])) + if (!empty($arrayfields['f.ref_supplier']['checked'])) { print ''; print $obj->ref_supplier; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Type - if (! empty($arrayfields['f.type']['checked'])) + if (!empty($arrayfields['f.type']['checked'])) { print ''; print $facturestatic->getLibType(); print ""; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Label - if (! empty($arrayfields['f.label']['checked'])) + if (!empty($arrayfields['f.label']['checked'])) { print ''; print $obj->label; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date - if (! empty($arrayfields['f.datef']['checked'])) + if (!empty($arrayfields['f.datef']['checked'])) { print ''; print dol_print_date($db->jdate($obj->datef), 'day'); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date limit - if (! empty($arrayfields['f.date_lim_reglement']['checked'])) + if (!empty($arrayfields['f.date_lim_reglement']['checked'])) { print ''.dol_print_date($datelimit, 'day'); if ($facturestatic->hasDelay()) @@ -1060,45 +1060,45 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['f.datec']['checked'])) + if (!empty($arrayfields['f.datec']['checked'])) { print ''; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date modification - if (! empty($arrayfields['f.tms']['checked'])) + if (!empty($arrayfields['f.tms']['checked'])) { print ''; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Status - if (! empty($arrayfields['f.fk_statut']['checked'])) + if (!empty($arrayfields['f.fk_statut']['checked'])) { print ''; // TODO $paiement is not yet defined print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $paiement, $obj->type); print ""; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Action column print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->facid, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->facid, $arrayofselected)) $selected = 1; + print ''; } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "\n"; @@ -1111,8 +1111,8 @@ if ($resql) $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 + $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 "\n"; @@ -1120,16 +1120,16 @@ if ($resql) print "\n"; - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->facture->lire; - $delallowed=$user->rights->facture->creer; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->facture->lire; + $delallowed = $user->rights->facture->creer; $title = ''; print $formfile->showdocuments('massfilesarea_supplier_invoice', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 4262280233c..da83eee70c9 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -42,23 +42,23 @@ $langs->loadLangs(array('users', 'holiday', 'hrm')); // Protection if external user if ($user->socid > 0) accessforbidden(); -$action = GETPOST('action', 'aZ09'); // The action 'add', 'create', 'edit', 'update', 'view', ... -$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) -$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? -$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation -$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button -$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'holidaylist'; // To manage different context of search +$action = GETPOST('action', 'aZ09'); // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'holidaylist'; // To manage different context of search -$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') $id = GETPOST('id', 'int'); $childids = $user->getAllChildIds(1); // Security check -$socid=0; +$socid = 0; if ($user->socid > 0) // Protection if external user { //$socid = $user->socid; @@ -68,21 +68,21 @@ $result = restrictedArea($user, 'holiday', '', ''); // If we are on the view of a specific user if ($id > 0) { - $canread=0; - if ($id == $user->id) $canread=1; - if (! empty($user->rights->holiday->read_all)) $canread=1; - if (! empty($user->rights->holiday->read) && in_array($id, $childids)) $canread=1; - if (! $canread) + $canread = 0; + if ($id == $user->id) $canread = 1; + if (!empty($user->rights->holiday->read_all)) $canread = 1; + if (!empty($user->rights->holiday->read) && in_array($id, $childids)) $canread = 1; + if (!$canread) { accessforbidden(); } } -$diroutputmassaction=$conf->holiday->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->holiday->dir_output.'/temp/massgeneration/'.$user->id; // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -90,10 +90,10 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortorder) $sortorder="DESC"; -if (!$sortfield) $sortfield="cp.rowid"; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "cp.rowid"; -$sall = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_ref = GETPOST('search_ref', 'alphanohtml'); $search_day_create = GETPOST('search_day_create', 'int'); $search_month_create = GETPOST('search_month_create', 'int'); @@ -110,14 +110,14 @@ $search_statut = GETPOST('search_statut', 'int'); $search_type = GETPOST('search_type', 'int'); // Initialize technical objects -$object=new Holiday($db); +$object = new Holiday($db); $extrafields = new ExtraFields($db); -$hookmanager->initHooks(array('holidaylist')); // Note that conf->hooks_modules contains array +$hookmanager->initHooks(array('holidaylist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -128,7 +128,7 @@ $fieldstosearchall = array( 'uu.login'=>'Login' ); -$arrayfields=array( +$arrayfields = array( 'cp.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'cp.fk_user'=>array('label'=>$langs->trans("Employee"), 'checked'=>1, 'position'=>20), 'cp.fk_validator'=>array('label'=>$langs->trans("ValidatorCP"), 'checked'=>1, 'position'=>30), @@ -145,10 +145,10 @@ $arrayfields=array( // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } @@ -158,11 +158,11 @@ if (is_array($extrafields->attributes[$object->table_element]['label']) && count * 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('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) @@ -171,31 +171,31 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - 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_ref=""; - $search_month_create=""; - $search_year_create=""; - $search_month_start=""; - $search_year_start=""; - $search_month_end=""; - $search_year_end=""; - $search_employee=""; - $search_valideur=""; - $search_statut=""; - $search_type=''; - $toselect=''; - $search_array_options=array(); + $search_ref = ""; + $search_month_create = ""; + $search_year_create = ""; + $search_month_start = ""; + $search_year_start = ""; + $search_month_end = ""; + $search_year_end = ""; + $search_employee = ""; + $search_valideur = ""; + $search_statut = ""; + $search_type = ''; + $toselect = ''; + $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { - $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='Holiday'; - $objectlabel='Holiday'; + $objectclass = 'Holiday'; + $objectlabel = 'Holiday'; $permissiontoread = $user->rights->holiday->read; $permissiontodelete = $user->rights->holiday->delete; $uploaddir = $conf->holiday->dir_output; @@ -214,7 +214,7 @@ $formother = new FormOther($db); $formfile = new FormFile($db); $fuser = new User($db); -$holidaystatic=new Holiday($db); +$holidaystatic = new Holiday($db); // Update sold $result = $object->updateBalance(); @@ -343,7 +343,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); //print $sql; @@ -352,45 +352,45 @@ if ($resql) { $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); - if ($search_ref) $param.='&search_ref='.urlencode($search_ref); - if ($search_day_create) $param.='&search_day_create='.urlencode($search_day_create); - if ($search_month_create) $param.='&search_month_create='.urlencode($search_month_create); - if ($search_year_create) $param.='&search_year_create='.urlencode($search_year_create); - if ($search_day_start) $param.='&search_day_start='.urlencode($search_day_start); - if ($search_month_start) $param.='&search_month_start='.urlencode($search_month_start); - if ($search_year_start) $param.='&search_year_start='.urlencode($search_year_start); - if ($search_day_end) $param.='&search_day_end='.urlencode($search_day_end); - if ($search_month_end) $param.='&search_month_end='.urlencode($search_month_end); - if ($search_year_end) $param.='&search_year_end='.urlencode($search_year_end); - if ($search_employee > 0) $param.='&search_employee='.urlencode($search_employee); - if ($search_valideur > 0) $param.='&search_valideur='.urlencode($search_valideur); - if ($search_type > 0) $param.='&search_type='.urlencode($search_type); - if ($search_statut > 0) $param.='&search_statut='.urlencode($search_statut); + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); + if ($search_day_create) $param .= '&search_day_create='.urlencode($search_day_create); + if ($search_month_create) $param .= '&search_month_create='.urlencode($search_month_create); + if ($search_year_create) $param .= '&search_year_create='.urlencode($search_year_create); + if ($search_day_start) $param .= '&search_day_start='.urlencode($search_day_start); + if ($search_month_start) $param .= '&search_month_start='.urlencode($search_month_start); + if ($search_year_start) $param .= '&search_year_start='.urlencode($search_year_start); + if ($search_day_end) $param .= '&search_day_end='.urlencode($search_day_end); + if ($search_month_end) $param .= '&search_month_end='.urlencode($search_month_end); + if ($search_year_end) $param .= '&search_year_end='.urlencode($search_year_end); + if ($search_employee > 0) $param .= '&search_employee='.urlencode($search_employee); + if ($search_valideur > 0) $param .= '&search_valideur='.urlencode($search_valideur); + if ($search_type > 0) $param .= '&search_type='.urlencode($search_type); + if ($search_statut > 0) $param .= '&search_statut='.urlencode($search_statut); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available - $arrayofmassactions = array( + $arrayofmassactions = array( //'generate_doc'=>$langs->trans("ReGeneratePDF"), //'builddoc'=>$langs->trans("PDFMerge"), //'presend'=>$langs->trans("SendByMail"), ); - if ($user->rights->holiday->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); - if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + if ($user->rights->holiday->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); + if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); // Lines of title fields print '
'."\n"; if ($optioncss != '') print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -422,7 +422,7 @@ if ($resql) print '
'; - $canedit=(($user->id == $user_id && $user->rights->holiday->write) || ($user->id != $user_id && $user->rights->holiday->write_all)); + $canedit = (($user->id == $user_id && $user->rights->holiday->write) || ($user->id != $user_id && $user->rights->holiday->write_all)); if ($canedit) { @@ -435,75 +435,75 @@ if ($resql) { $title = $langs->trans("ListeCP"); - $newcardbutton=''; + $newcardbutton = ''; if ($user->rights->holiday->write) { - $newcardbutton.= dolGetButtonTitle($langs->trans('MenuAddCP'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/holiday/card.php?action=request'); + $newcardbutton .= dolGetButtonTitle($langs->trans('MenuAddCP'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/holiday/card.php?action=request'); } print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_hrm.png', 0, $newcardbutton, '', $limit); } - $topicmail="Information"; - $modelmail="leaverequest"; - $objecttmp=new Holiday($db); - $trackid='leav'.$object->id; + $topicmail = "Information"; + $modelmail = "leaverequest"; + $objecttmp = new Holiday($db); + $trackid = 'leav'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } - $moreforfilter=''; + $moreforfilter = ''; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - if (! empty($moreforfilter)) + if (!empty($moreforfilter)) { print '
'; print $moreforfilter; print '
'; } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - $selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); $include = ''; - if (! empty($user->rights->holiday->read_all)) $include = 'hierarchyme'; // Can see all + if (!empty($user->rights->holiday->read_all)) $include = 'hierarchyme'; // Can see all print '
'; - print ''."\n"; + print '
'."\n"; // Filters print ''; - if (! empty($arrayfields['cp.ref']['checked'])) + if (!empty($arrayfields['cp.ref']['checked'])) { print ''; } - if (! empty($arrayfields['cp.fk_user']['checked'])) + if (!empty($arrayfields['cp.fk_user']['checked'])) { $morefilter = 'AND employee = 1'; - if (! empty($conf->global->HOLIDAY_FOR_NON_SALARIES_TOO)) $morefilter = ''; + if (!empty($conf->global->HOLIDAY_FOR_NON_SALARIES_TOO)) $morefilter = ''; // User - $disabled=0; + $disabled = 0; // If into the tab holiday of a user ($id is set in such a case) - if ($id && ! GETPOSTISSET('search_employee')) + if ($id && !GETPOSTISSET('search_employee')) { - $search_employee=$id; - $disabled=1; + $search_employee = $id; + $disabled = 1; } print ''; } @@ -532,19 +532,19 @@ if ($resql) } // Type - if (! empty($arrayfields['cp.fk_type']['checked'])) + if (!empty($arrayfields['cp.fk_type']['checked'])) { print ''; } // Start date - if (! empty($arrayfields['cp.date_debut']['checked'])) + if (!empty($arrayfields['cp.date_debut']['checked'])) { print ''; print "\n"; print ''; - if (! empty($arrayfields['cp.ref']['checked'])) print_liste_field_titre($arrayfields['cp.ref']['label'], $_SERVER["PHP_SELF"], "cp.ref", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['cp.fk_user']['checked'])) print_liste_field_titre($arrayfields['cp.fk_user']['label'], $_SERVER["PHP_SELF"], "cp.fk_user", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['cp.fk_validator']['checked'])) print_liste_field_titre($arrayfields['cp.fk_validator']['label'], $_SERVER["PHP_SELF"], "cp.fk_validator", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['cp.fk_type']['checked'])) print_liste_field_titre($arrayfields['cp.fk_type']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['duration']['checked'])) print_liste_field_titre($arrayfields['duration']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['cp.date_debut']['checked'])) print_liste_field_titre($arrayfields['cp.date_debut']['label'], $_SERVER["PHP_SELF"], "cp.date_debut", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['cp.date_fin']['checked'])) print_liste_field_titre($arrayfields['cp.date_fin']['label'], $_SERVER["PHP_SELF"], "cp.date_fin", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['cp.ref']['checked'])) print_liste_field_titre($arrayfields['cp.ref']['label'], $_SERVER["PHP_SELF"], "cp.ref", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['cp.fk_user']['checked'])) print_liste_field_titre($arrayfields['cp.fk_user']['label'], $_SERVER["PHP_SELF"], "cp.fk_user", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['cp.fk_validator']['checked'])) print_liste_field_titre($arrayfields['cp.fk_validator']['label'], $_SERVER["PHP_SELF"], "cp.fk_validator", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['cp.fk_type']['checked'])) print_liste_field_titre($arrayfields['cp.fk_type']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['duration']['checked'])) print_liste_field_titre($arrayfields['duration']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['cp.date_debut']['checked'])) print_liste_field_titre($arrayfields['cp.date_debut']['label'], $_SERVER["PHP_SELF"], "cp.date_debut", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['cp.date_fin']['checked'])) print_liste_field_titre($arrayfields['cp.date_fin']['label'], $_SERVER["PHP_SELF"], "cp.date_fin", "", $param, '', $sortfield, $sortorder, 'center '); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['cp.date_create']['checked'])) print_liste_field_titre($arrayfields['cp.date_create']['label'], $_SERVER["PHP_SELF"], "cp.date_create", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['cp.tms']['checked'])) print_liste_field_titre($arrayfields['cp.tms']['label'], $_SERVER["PHP_SELF"], "cp.tms", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['cp.statut']['checked'])) print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "cp.statut", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['cp.date_create']['checked'])) print_liste_field_titre($arrayfields['cp.date_create']['label'], $_SERVER["PHP_SELF"], "cp.date_create", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['cp.tms']['checked'])) print_liste_field_titre($arrayfields['cp.tms']['label'], $_SERVER["PHP_SELF"], "cp.tms", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['cp.statut']['checked'])) print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "cp.statut", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; - $listhalfday=array('morning'=>$langs->trans("Morning"),"afternoon"=>$langs->trans("Afternoon")); + $listhalfday = array('morning'=>$langs->trans("Morning"), "afternoon"=>$langs->trans("Afternoon")); // If we ask a dedicated card and not allow to see it, we force on user. - if ($id && empty($user->rights->holiday->read_all) && ! in_array($id, $childids)) { + if ($id && empty($user->rights->holiday->read_all) && !in_array($id, $childids)) { $langs->load("errors"); print ''; $result = 0; @@ -785,8 +785,8 @@ if ($resql) // Si il n'y a pas d'enregistrement suite à une recherche if ($num == 0) { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print ''; } @@ -819,16 +819,16 @@ function showMyBalance($holiday, $user_id) { global $conf, $langs; - $alltypeleaves=$holiday->getTypes(1, -1); // To have labels + $alltypeleaves = $holiday->getTypes(1, -1); // To have labels - $out=''; - $nb_holiday=0; - $typeleaves=$holiday->getTypes(1, 1); - foreach($typeleaves as $key => $val) + $out = ''; + $nb_holiday = 0; + $typeleaves = $holiday->getTypes(1, 1); + foreach ($typeleaves as $key => $val) { $nb_type = $holiday->getCPforUser($user_id, $val['rowid']); $nb_holiday += $nb_type; - $out .= ' - '.$val['label'].': '.($nb_type?price2num($nb_type):0).'
'; + $out .= ' - '.$val['label'].': '.($nb_type ?price2num($nb_type) : 0).'
'; } print $langs->trans('SoldeCPUser', round($nb_holiday, 5)).'
'; print $out; diff --git a/htdocs/modulebuilder/template/myobject_agenda.php b/htdocs/modulebuilder/template/myobject_agenda.php index f75e7d352f1..4a077e35b5b 100644 --- a/htdocs/modulebuilder/template/myobject_agenda.php +++ b/htdocs/modulebuilder/template/myobject_agenda.php @@ -23,19 +23,19 @@ */ // Load Dolibarr environment -$res=0; +$res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; // Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); +if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; +if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; +if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; +if (!$res) die("Include of main fails"); require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -45,27 +45,27 @@ dol_include_once('/mymodule/lib/mymodule_myobject.lib.php'); // Load translation files required by the page -$langs->loadLangs(array("mymodule@mymodule","other")); +$langs->loadLangs(array("mymodule@mymodule", "other")); // Get parameters -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); if (GETPOST('actioncode', 'array')) { - $actioncode=GETPOST('actioncode', 'array', 3); - if (! count($actioncode)) $actioncode='0'; + $actioncode = GETPOST('actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; } else { - $actioncode = GETPOST("actioncode", "alpha", 3)?GETPOST("actioncode", "alpha", 3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); } $search_agenda_label = GETPOST('search_agenda_label'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -73,41 +73,41 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='a.datep,a.id'; -if (! $sortorder) $sortorder='DESC,DESC'; +if (!$sortfield) $sortfield = 'a.datep,a.id'; +if (!$sortorder) $sortorder = 'DESC,DESC'; // Initialize technical objects $object = new MyObject($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('myobjectagenda','globalcard')); // Note that conf->hooks_modules contains array +$diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('myobjectagenda', 'globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); // Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity] . "/" . $object->id; +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals +if ($id > 0 || !empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity]."/".$object->id; // Security check - Protection if external user //if ($user->socid > 0) access_forbidden(); //if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'mymodule', $object->id); -$permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php /* * Actions */ -$parameters=array('id'=>$id); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$id); +$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)) { // Cancel - if (GETPOST('cancel', 'alpha') && ! empty($backtopage)) + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -116,8 +116,8 @@ if (empty($reshook)) // Purge search criteria 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 { - $actioncode=''; - $search_agenda_label=''; + $actioncode = ''; + $search_agenda_label = ''; } } @@ -131,12 +131,12 @@ $form = new Form($db); if ($object->id > 0) { - $title=$langs->trans("Agenda"); + $title = $langs->trans("Agenda"); //if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; $help_url = ''; llxHeader('', $title, $help_url); - if (! empty($conf->notification->enabled)) $langs->load("mails"); + if (!empty($conf->notification->enabled)) $langs->load("mails"); $head = myobjectPrepareHead($object); @@ -144,9 +144,9 @@ if ($object->id > 0) // Object card // ------------------------------------------------------------ - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
'; + $morehtmlref = '
'; /* // Ref customer $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); @@ -186,7 +186,7 @@ if ($object->id > 0) } } }*/ - $morehtmlref.='
'; + $morehtmlref .= '
'; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -205,16 +205,16 @@ if ($object->id > 0) // Actions buttons - $objthirdparty=$object; - $objcon=new stdClass(); + $objthirdparty = $object; + $objcon = new stdClass(); - $out='&origin='.$object->element.'&originid='.$object->id; - $permok=$user->rights->agenda->myactions->create; - if ((! empty($objthirdparty->id) || ! empty($objcon->id)) && $permok) + $out = '&origin='.$object->element.'&originid='.$object->id; + $permok = $user->rights->agenda->myactions->create; + if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { //$out.='trans("AddAnAction"),'filenew'); //$out.=""; @@ -223,9 +223,9 @@ if ($object->id > 0) print '
'; - if (! empty($conf->agenda->enabled)) + if (!empty($conf->agenda->enabled)) { - if (! empty($user->rights->agenda->myactions->create) || ! empty($user->rights->agenda->allactions->create)) + if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { print ''.$langs->trans("AddAction").''; } @@ -237,18 +237,18 @@ if ($object->id > 0) print '
'; - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - $param='&id='.$object->id.'&socid='.$socid; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + $param = '&id='.$object->id.'&socid='.$socid; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); //print load_fiche_titre($langs->trans("ActionsOnMyObject"), '', ''); // List of all actions - $filters=array(); - $filters['search_agenda_label']=$search_agenda_label; + $filters = array(); + $filters['search_agenda_label'] = $search_agenda_label; // TODO Replace this with same code than into list.php //show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); diff --git a/htdocs/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php index 9d0954d277e..5a58a068a64 100644 --- a/htdocs/modulebuilder/template/myobject_document.php +++ b/htdocs/modulebuilder/template/myobject_document.php @@ -23,19 +23,19 @@ */ // Load Dolibarr environment -$res=0; +$res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; // Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); +if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; +if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; +if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; +if (!$res) die("Include of main fails"); require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -45,12 +45,12 @@ dol_include_once('/mymodule/class/myobject.class.php'); dol_include_once('/mymodule/lib/mymodule_myobject.lib.php'); // Load translation files required by the page -$langs->loadLangs(array("mymodule@mymodule","companies","other","mails")); +$langs->loadLangs(array("mymodule@mymodule", "companies", "other", "mails")); -$action=GETPOST('action', 'aZ09'); -$confirm=GETPOST('confirm'); -$id=(GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm'); +$id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); $ref = GETPOST('ref', 'alpha'); // Get parameters @@ -61,30 +61,30 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="name"; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "name"; //if (! $sortfield) $sortfield="position_name"; // Initialize technical objects -$object=new MyObject($db); +$object = new MyObject($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('myobjectdocument','globalcard')); // Note that conf->hooks_modules contains array +$diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('myobjectdocument', 'globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); // Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals //if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity?$object->entity:$conf->entity] . "/myobject/" . dol_sanitizeFileName($object->id); -if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity?$object->entity:$conf->entity] . "/myobject/" . dol_sanitizeFileName($object->ref); +if ($id > 0 || !empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity ? $object->entity : $conf->entity]."/myobject/".dol_sanitizeFileName($object->ref); // Security check - Protection if external user //if ($user->socid > 0) access_forbidden(); //if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'mymodule', $object->id); -$permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php @@ -92,7 +92,7 @@ $permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the in * Actions */ -include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; +include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; /* @@ -101,8 +101,8 @@ include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; $form = new Form($db); -$title=$langs->trans("MyObject").' - '.$langs->trans("Files"); -$help_url=''; +$title = $langs->trans("MyObject").' - '.$langs->trans("Files"); +$help_url = ''; //$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); @@ -117,16 +117,16 @@ if ($object->id) // Build file list - $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); - $totalsize=0; - foreach($filearray as $key => $file) + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); + $totalsize = 0; + foreach ($filearray as $key => $file) { - $totalsize+=$file['size']; + $totalsize += $file['size']; } // Object card // ------------------------------------------------------------ - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -152,12 +152,12 @@ if ($object->id) $permission = 1; //$permtoedit = $user->rights->mymodule->myobject->write; $permtoedit = 1; - $param = '&id=' . $object->id; + $param = '&id='.$object->id; //$relativepathwithnofile='myobject/' . dol_sanitizeFileName($object->id).'/'; - $relativepathwithnofile='myobject/' . dol_sanitizeFileName($object->ref).'/'; + $relativepathwithnofile = 'myobject/'.dol_sanitizeFileName($object->ref).'/'; - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 0cfade3c8f8..923fc6e5744 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -42,47 +42,47 @@ //if (! defined("XFRAMEOPTIONS_ALLOWALL")) define('XFRAMEOPTIONS_ALLOWALL', '1'); // Do not add the HTTP header 'X-Frame-Options: SAMEORIGIN' but 'X-Frame-Options: ALLOWALL' // Load Dolibarr environment -$res=0; +$res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; // Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); +if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; +if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; +if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; +if (!$res) die("Include of main fails"); require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; // load mymodule libraries -require_once __DIR__ . '/class/myobject.class.php'; +require_once __DIR__.'/class/myobject.class.php'; // for other modules //dol_include_once('/othermodule/class/otherobject.class.php'); // Load translation files required by the page -$langs->loadLangs(array("mymodule@mymodule","other")); +$langs->loadLangs(array("mymodule@mymodule", "other")); -$action = GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... -$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) -$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? -$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation -$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button -$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'myobjectlist'; // To manage different context of search -$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -94,8 +94,8 @@ $pagenext = $page + 1; // Initialize technical objects $object = new MyObject($db); $extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('myobjectlist')); // Note that conf->hooks_modules contains array +$diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('myobjectlist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); @@ -104,12 +104,12 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. +if (!$sortorder) $sortorder = "ASC"; // Security check if (empty($conf->mymodule->enabled)) accessforbidden('Module not enabled'); -$socid=0; +$socid = 0; if ($user->socid > 0) // Protection if external user { //$socid = $user->socid; @@ -166,11 +166,11 @@ $permissiontodelete = $user->rights->mymodule->myobject->delete; * 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 +$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)) @@ -179,24 +179,24 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - 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 { - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $search[$key]=''; + $search[$key] = ''; } - $toselect=''; - $search_array_options=array(); + $toselect = ''; + $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { - $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='MyObject'; - $objectlabel='MyObject'; + $objectclass = 'MyObject'; + $objectlabel = 'MyObject'; $uploaddir = $conf->mymodule->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -207,49 +207,49 @@ if (empty($reshook)) * View */ -$form=new Form($db); +$form = new Form($db); -$now=dol_now(); +$now = dol_now(); //$help_url="EN:Module_MyObject|FR:Module_MyObject_FR|ES:Módulo_MyObject"; -$help_url=''; +$help_url = ''; $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("MyObjects")); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $sql.='t.'.$key.', '; + $sql .= 't.'.$key.', '; } // 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.', ' : ''); +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.', ' : ''); } // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=preg_replace('/^,/', '', $hookmanager->resPrint); -$sql =preg_replace('/,\s*$/', '', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -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 (t.rowid = ef.fk_object)"; -if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity($object->element).")"; -else $sql.=" WHERE 1 = 1"; -foreach($search as $key => $val) +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql = preg_replace('/,\s*$/', '', $sql); +$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +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 (t.rowid = ef.fk_object)"; +if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; +else $sql .= " WHERE 1 = 1"; +foreach ($search as $key => $val) { if ($key == 'status' && $search[$key] == -1) continue; - $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); - if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); } -if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; /* If a group by is required $sql.= " GROUP BY " @@ -267,7 +267,7 @@ $sql.=$hookmanager->resPrint; $sql=preg_replace('/,\s*$/','', $sql); */ -$sql.=$db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -288,10 +288,10 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) } else { - $sql.= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); - $resql=$db->query($sql); - if (! $resql) + $resql = $db->query($sql); + if (!$resql) { dol_print_error($db); exit; @@ -301,7 +301,7 @@ else } // Direct jump if only one record found -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && ! $page) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -330,30 +330,30 @@ jQuery(document).ready(function() { }); '; -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); -foreach($search as $key => $val) +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +foreach ($search as $key => $val) { - if (is_array($search[$key]) && count($search[$key])) foreach($search[$key] as $skey) $param.='&search_'.$key.'[]='.urlencode($skey); - else $param.= '&search_'.$key.'='.urlencode($search[$key]); + if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey); + else $param .= '&search_'.$key.'='.urlencode($search[$key]); } -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( //'validate'=>$langs->trans("Validate"), //'generate_doc'=>$langs->trans("ReGeneratePDF"), //'builddoc'=>$langs->trans("PDFMerge"), //'presend'=>$langs->trans("SendByMail"), ); -if ($permissiontodelete) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($permissiontodelete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); print ''; if ($optioncss != '') print ''; @@ -370,16 +370,16 @@ $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle' print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit); // Add code for pre mass action (confirmation or email presend form) -$topicmail="SendMyObjectRef"; -$modelmail="myobject"; -$objecttmp=new MyObject($db); -$trackid='xxxx'.$object->id; +$topicmail = "SendMyObjectRef"; +$modelmail = "myobject"; +$objecttmp = new MyObject($db); +$trackid = 'xxxx'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; } $moreforfilter = ''; @@ -387,39 +387,39 @@ $moreforfilter = ''; $moreforfilter.= $langs->trans('MyFilter') . ': '; $moreforfilter.= '';*/ -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '
'; print $moreforfilter; print '
'; } -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); -print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print '
'; print ''; print ''; @@ -512,16 +512,16 @@ if ($resql) } // Approver - if (! empty($arrayfields['cp.fk_validator']['checked'])) + if (!empty($arrayfields['cp.fk_validator']['checked'])) { if ($user->rights->holiday->read_all) { print ''; $validator = new UserGroup($db); - $excludefilter=$user->admin?'':'u.rowid <> '.$user->id; + $excludefilter = $user->admin ? '' : 'u.rowid <> '.$user->id; $valideurobjects = $validator->listUsersForGroup($excludefilter); $valideurarray = array(); - foreach($valideurobjects as $val) $valideurarray[$val->id]=$val->id; + foreach ($valideurobjects as $val) $valideurarray[$val->id] = $val->id; print $form->select_dolusers($search_valideur, "search_valideur", 1, "", 0, $valideurarray, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200'); print ''; if (empty($mysoc->country_id)) { - setEventMessages(null, array($langs->trans("ErrorSetACountryFirst"),$langs->trans("CompanyFoundation")), 'errors'); + setEventMessages(null, array($langs->trans("ErrorSetACountryFirst"), $langs->trans("CompanyFoundation")), 'errors'); } else { - $typeleaves=$holidaystatic->getTypes(1, -1); - $arraytypeleaves=array(); - foreach($typeleaves as $key => $val) + $typeleaves = $holidaystatic->getTypes(1, -1); + $arraytypeleaves = array(); + foreach ($typeleaves as $key => $val) { - $labeltoshow = ($langs->trans($val['code'])!=$val['code'] ? $langs->trans($val['code']) : $val['label']); + $labeltoshow = ($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']); //$labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')':''); - $arraytypeleaves[$val['rowid']]=$labeltoshow; + $arraytypeleaves[$val['rowid']] = $labeltoshow; } print $form->selectarray('search_type', $arraytypeleaves, $search_type, 1); } @@ -552,13 +552,13 @@ if ($resql) } // Duration - if (! empty($arrayfields['duration']['checked'])) + if (!empty($arrayfields['duration']['checked'])) { print ' '; print ''; @@ -567,7 +567,7 @@ if ($resql) } // End date - if (! empty($arrayfields['cp.date_fin']['checked'])) + if (!empty($arrayfields['cp.date_fin']['checked'])) { print ''; print ''; @@ -578,12 +578,12 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Create date - if (! empty($arrayfields['cp.date_create']['checked'])) + if (!empty($arrayfields['cp.date_create']['checked'])) { print ''; print ''; @@ -592,7 +592,7 @@ if ($resql) } // Create date - if (! empty($arrayfields['cp.tms']['checked'])) + if (!empty($arrayfields['cp.tms']['checked'])) { print ''; print ''; @@ -601,7 +601,7 @@ if ($resql) } // Status - if (! empty($arrayfields['cp.statut']['checked'])) + if (!empty($arrayfields['cp.statut']['checked'])) { print ''; $object->selectStatutCP($search_statut, 'search_statut'); @@ -610,37 +610,37 @@ if ($resql) // Action column print ''; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'.$langs->trans("NotEnoughPermissions").'
'.$langs->trans("NoRecordFound").'
'."\n"; +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '
'."\n"; // Fields title search // -------------------------------------------------------------------- print ''; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; @@ -429,12 +429,12 @@ foreach($object->fields as $key => $val) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; print ''."\n"; @@ -443,23 +443,23 @@ print ''."\n"; // Fields title label // -------------------------------------------------------------------- print ''; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n"; + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; @@ -467,56 +467,56 @@ print ''."\n"; // Detect if we need a fetch on each output line -$needToFetchEachLine=0; +$needToFetchEachLine = 0; if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object + if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object } } // Loop on record // -------------------------------------------------------------------- -$i=0; -$totalarray=array(); +$i = 0; +$totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) break; // Should not happen // Store properties in $object $object->id = $obj->rowid; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { if (property_exists($obj, $key)) $object->$key = $obj->$key; } // Show here line of result print ''; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; + if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield.=($cssforfield?' ':'').'right'; + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; if ($key == 'status') print $object->getLibStatut(5); - elseif (in_array($val['type'], array('date','datetime','timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); else print $object->showOutputField($val, $key, $obj->$key, ''); print ''; - if (! $i) $totalarray['nbfield']++; - if (! empty($val['isameasure'])) + if (!$i) $totalarray['nbfield']++; + if (!empty($val['isameasure'])) { - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; $totalarray['val']['t.'.$key] += $obj->$key; } } @@ -524,19 +524,19 @@ while ($i < min($num, $limit)) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print ''."\n"; @@ -549,16 +549,16 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found if ($num == 0) { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print ''; } $db->free($resql); -$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; + print ''; if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75'); else print ''; print ''; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; } print '
'.$langs->trans("NoRecordFound").'
'."\n"; @@ -568,19 +568,19 @@ print ''."\n"; if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$permissiontoread; - $delallowed=$permissiontoadd; + $filedir = $diroutputmassaction; + $genallowed = $permissiontoread; + $delallowed = $permissiontoadd; print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/modulebuilder/template/myobject_note.php b/htdocs/modulebuilder/template/myobject_note.php index 89a8ed5513b..f7440c71cf8 100644 --- a/htdocs/modulebuilder/template/myobject_note.php +++ b/htdocs/modulebuilder/template/myobject_note.php @@ -23,38 +23,38 @@ */ // Load Dolibarr environment -$res=0; +$res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; // Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); +if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php"; +if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php"; +if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php"; +if (!$res) die("Include of main fails"); dol_include_once('/mymodule/class/myobject.class.php'); dol_include_once('/mymodule/lib/mymodule_myobject.lib.php'); // Load translation files required by the page -$langs->loadLangs(array("mymodule@mymodule","companies")); +$langs->loadLangs(array("mymodule@mymodule", "companies")); // Get parameters -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); // Initialize technical objects -$object=new MyObject($db); +$object = new MyObject($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('myobjectnote','globalcard')); // Note that conf->hooks_modules contains array +$diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('myobjectnote', 'globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); @@ -64,11 +64,11 @@ $extrafields->fetch_name_optionals_label($object->table_element); //$result = restrictedArea($user, 'mymodule', $id); // Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity] . "/" . $object->id; +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals +if ($id > 0 || !empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity]."/".$object->id; -$permissionnote=$user->rights->mymodule->myobject->write; // Used by the include of actions_setnotes.inc.php -$permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php +$permissionnote = $user->rights->mymodule->myobject->write; // Used by the include of actions_setnotes.inc.php +$permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php @@ -76,7 +76,7 @@ $permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the in * Actions */ -include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once /* @@ -86,10 +86,10 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, $form = new Form($db); //$help_url='EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'; -$help_url=''; +$help_url = ''; llxHeader('', $langs->trans('MyObject'), $help_url); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $object->fetch_thirdparty(); @@ -99,9 +99,9 @@ if ($id > 0 || ! empty($ref)) // Object card // ------------------------------------------------------------ - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
'; + $morehtmlref = '
'; /* // Ref customer $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); @@ -141,7 +141,7 @@ if ($id > 0 || ! empty($ref)) } } }*/ - $morehtmlref.='
'; + $morehtmlref .= '
'; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -151,7 +151,7 @@ if ($id > 0 || ! empty($ref)) print '
'; - $cssclass="titlefield"; + $cssclass = "titlefield"; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; print '
'; diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php index 6124101cffa..4d3bb9cd313 100644 --- a/htdocs/mrp/mo_list.php +++ b/htdocs/mrp/mo_list.php @@ -48,28 +48,28 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; // load mrp libraries -require_once __DIR__ . '/class/mo.class.php'; +require_once __DIR__.'/class/mo.class.php'; // for other modules //dol_include_once('/othermodule/class/otherobject.class.php'); // Load translation files required by the page -$langs->loadLangs(array("mrp","other")); +$langs->loadLangs(array("mrp", "other")); -$action = GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... -$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) -$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? -$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation -$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button -$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'molist'; // To manage different context of search -$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'molist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -83,8 +83,8 @@ $pagenext = $page + 1; // Initialize technical objects $object = new Mo($db); $extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->mrp->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('molist')); // Note that conf->hooks_modules contains array +$diroutputmassaction = $conf->mrp->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('molist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); @@ -92,12 +92,12 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. +if (!$sortorder) $sortorder = "ASC"; // Security check if (empty($conf->mrp->enabled)) accessforbidden('Module not enabled'); -$socid=0; +$socid = 0; if ($user->socid > 0) // Protection if external user { //$socid = $user->socid; @@ -107,34 +107,34 @@ if ($user->socid > 0) // Protection if external user // Initialize array of search criterias -$search_all=trim(GETPOST("search_all", 'alpha')); -$search=array(); -foreach($object->fields as $key => $val) +$search_all = trim(GETPOST("search_all", 'alpha')); +$search = array(); +foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; + if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; } // Definition of fields for list -$arrayfields=array(); -foreach($object->fields as $key => $val) +$arrayfields = array(); +foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); } // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -146,11 +146,11 @@ $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 +$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)) @@ -159,24 +159,24 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - 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 { - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $search[$key]=''; + $search[$key] = ''; } - $toselect=''; - $search_array_options=array(); + $toselect = ''; + $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { - $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='Mo'; - $objectlabel='Mo'; + $objectclass = 'Mo'; + $objectlabel = 'Mo'; $permissiontoread = $user->rights->mrp->read; $permissiontodelete = $user->rights->mrp->delete; $uploaddir = $conf->mrp->dir_output; @@ -189,47 +189,47 @@ if (empty($reshook)) * View */ -$form=new Form($db); +$form = new Form($db); -$now=dol_now(); +$now = dol_now(); //$help_url="EN:Module_Mo|FR:Module_Mo_FR|ES:Módulo_Mo"; -$help_url=''; +$help_url = ''; $title = $langs->trans('ListOfManufacturingOrders'); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $sql.='t.'.$key.', '; + $sql .= 't.'.$key.', '; } // 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.', ' : ''); +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.', ' : ''); // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/, $/', '', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -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 (t.rowid = ef.fk_object)"; -if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity($object->element).")"; -else $sql.=" WHERE 1 = 1"; -foreach($search as $key => $val) +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql = preg_replace('/, $/', '', $sql); +$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +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 (t.rowid = ef.fk_object)"; +if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; +else $sql .= " WHERE 1 = 1"; +foreach ($search as $key => $val) { if ($key == 'status' && $search[$key] == -1) continue; - $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); - if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); } -if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; /* If a group by is required $sql.= " GROUP BY " @@ -247,7 +247,7 @@ $sql.=$hookmanager->resPrint; $sql=preg_replace('/, $/','', $sql); */ -$sql.=$db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -268,10 +268,10 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) } else { - $sql.= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); - $resql=$db->query($sql); - if (! $resql) + $resql = $db->query($sql); + if (!$resql) { dol_print_error($db); exit; @@ -281,7 +281,7 @@ else } // Direct jump if only one record found -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -310,30 +310,30 @@ jQuery(document).ready(function() { }); '; -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); -foreach($search as $key => $val) +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +foreach ($search as $key => $val) { - if (is_array($search[$key]) && count($search[$key])) foreach($search[$key] as $skey) $param.='&search_'.$key.'[]='.urlencode($skey); - else $param.= '&search_'.$key.'='.urlencode($search[$key]); + if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey); + else $param .= '&search_'.$key.'='.urlencode($search[$key]); } -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( //'validate'=>$langs->trans("Validate"), //'generate_doc'=>$langs->trans("ReGeneratePDF"), //'builddoc'=>$langs->trans("PDFMerge"), //'presend'=>$langs->trans("SendByMail"), ); -if ($user->rights->mrp->delete) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($user->rights->mrp->delete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '
'; if ($optioncss != '') print ''; @@ -350,16 +350,16 @@ $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle' print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'cubes', 0, $newcardbutton, '', $limit); // Add code for pre mass action (confirmation or email presend form) -$topicmail="SendMoRef"; -$modelmail="mo"; -$objecttmp=new Mo($db); -$trackid='xxxx'.$object->id; +$topicmail = "SendMoRef"; +$modelmail = "mo"; +$objecttmp = new Mo($db); +$trackid = 'xxxx'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; } $moreforfilter = ''; @@ -367,39 +367,39 @@ $moreforfilter = ''; $moreforfilter.= $langs->trans('MyFilter') . ': '; $moreforfilter.= '
';*/ -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '
'; print $moreforfilter; print '
'; } -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); -print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print ''."\n"; +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '
'."\n"; // Fields title search // -------------------------------------------------------------------- print ''; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; @@ -409,12 +409,12 @@ foreach($object->fields as $key => $val) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; print ''."\n"; @@ -423,23 +423,23 @@ print ''."\n"; // Fields title label // -------------------------------------------------------------------- print ''; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n"; + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; @@ -447,56 +447,56 @@ print ''."\n"; // Detect if we need a fetch on each output line -$needToFetchEachLine=0; +$needToFetchEachLine = 0; if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object + if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object } } // Loop on record // -------------------------------------------------------------------- -$i=0; -$totalarray=array(); +$i = 0; +$totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) break; // Should not happen // Store properties in $object $object->id = $obj->rowid; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { if (property_exists($obj, $key)) $object->$key = $obj->$key; } // Show here line of result print ''; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; + if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield.=($cssforfield?' ':'').'right'; + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; if ($key == 'status') print $object->getLibStatut(5); - elseif (in_array($val['type'], array('date','datetime','timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); else print $object->showOutputField($val, $key, $obj->$key, ''); print ''; - if (! $i) $totalarray['nbfield']++; - if (! empty($val['isameasure'])) + if (!$i) $totalarray['nbfield']++; + if (!empty($val['isameasure'])) { - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; $totalarray['val']['t.'.$key] += $obj->$key; } } @@ -504,19 +504,19 @@ while ($i < min($num, $limit)) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print ''; @@ -530,16 +530,16 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found if ($num == 0) { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print ''; } $db->free($resql); -$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; + print ''; if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75'); else print ''; print ''; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; } print '
'.$langs->trans("NoRecordFound").'
'."\n"; @@ -549,19 +549,19 @@ print ''."\n"; if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->mrp->read; - $delallowed=$user->rights->mrp->write; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->mrp->read; + $delallowed = $user->rights->mrp->write; print $formfile->showdocuments('massfilesarea_mrp', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index b772cef3705..6f5fd824b06 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -30,23 +30,23 @@ require_once DOL_DOCUMENT_ROOT."/opensurvey/class/opensurveysondage.class.php"; // Load translation files required by the page $langs->load("opensurvey"); -$action = GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... -$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) -$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? -$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation -$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button -$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'myobjectlist'; // To manage different context of search -$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$id=GETPOST('id', 'alpha'); +$id = GETPOST('id', 'alpha'); $search_ref = GETPOST('search_ref', 'alpha'); $search_title = GETPOST('search_title', 'alpha'); $search_status = GETPOST('search_status', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -107,11 +107,11 @@ $permissiontodelete = $user->rights->opensurvey->delete; * 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 +$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)) @@ -146,33 +146,33 @@ if (empty($reshook)) * View */ -$form=new Form($db); +$form = new Form($db); $now = dol_now(); //$help_url="EN:Module_MyObject|FR:Module_MyObject_FR|ES:Módulo_MyObject"; -$help_url=''; +$help_url = ''; $title = $langs->trans('OpenSurveyArea'); $sql = "SELECT p.id_sondage as rowid, p.fk_user_creat, p.format, p.date_fin, p.status, p.titre, p.nom_admin,"; -$sql.= " u.login, u.firstname, u.lastname"; -$sql.= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as p"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user u ON u.rowid = p.fk_user_creat"; -$sql.= " WHERE p.entity IN (".getEntity('survey').")"; -if ($search_status != '-1' && $search_status != '') $sql.=natural_search("p.status", $search_status, 2); -if ($search_expired == 'expired') $sql.=" AND p.date_fin < '".$db->idate($now)."'"; -if ($search_expired == 'opened') $sql.=" AND p.date_fin >= '".$db->idate($now)."'"; -if ($search_ref) $sql.=natural_search("p.id_sondage", $search_ref); -if ($search_title) $sql.=natural_search("p.titre", $search_title); +$sql .= " u.login, u.firstname, u.lastname"; +$sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as p"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user u ON u.rowid = p.fk_user_creat"; +$sql .= " WHERE p.entity IN (".getEntity('survey').")"; +if ($search_status != '-1' && $search_status != '') $sql .= natural_search("p.status", $search_status, 2); +if ($search_expired == 'expired') $sql .= " AND p.date_fin < '".$db->idate($now)."'"; +if ($search_expired == 'opened') $sql .= " AND p.date_fin >= '".$db->idate($now)."'"; +if ($search_ref) $sql .= natural_search("p.id_sondage", $search_ref); +if ($search_title) $sql .= natural_search("p.titre", $search_title); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.=$db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -193,10 +193,10 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) } else { - $sql.= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); - $resql=$db->query($sql); - if (! $resql) + $resql = $db->query($sql); + if (!$resql) { dol_print_error($db); exit; @@ -206,7 +206,7 @@ else } // Direct jump if only one record found -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -275,25 +275,25 @@ $moreforfilter = ''; $moreforfilter.= $langs->trans('MyFilter') . ': '; $moreforfilter.= '
';*/ -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '
'; print $moreforfilter; print '
'; } -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; //$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -$selectedfields=''; -$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); +$selectedfields = ''; +$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; -print ''."\n"; +print '
'."\n"; // Fields title search // -------------------------------------------------------------------- @@ -334,8 +334,8 @@ print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "p.status", $param, "", // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n"; @@ -345,27 +345,27 @@ print ''."\n"; // Loop on record // -------------------------------------------------------------------- -$i=0; -$totalarray=array(); +$i = 0; +$totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) break; // Should not happen - $sql2='select COUNT(*) as nb from '.MAIN_DB_PREFIX."opensurvey_user_studs where id_sondage='".$db->escape($obj->id_sondage)."'"; - $resql2=$db->query($sql2); + $sql2 = 'select COUNT(*) as nb from '.MAIN_DB_PREFIX."opensurvey_user_studs where id_sondage='".$db->escape($obj->id_sondage)."'"; + $resql2 = $db->query($sql2); if ($resql2) { - $obj2=$db->fetch_object($resql2); - $nbuser=$obj2->nb; + $obj2 = $db->fetch_object($resql2); + $nbuser = $obj2->nb; } else dol_print_error($db); - $opensurvey_static->id=$obj->rowid; - $opensurvey_static->ref=$obj->rowid; - $opensurvey_static->title=$obj->titre; - $opensurvey_static->status=$obj->status; - $opensurvey_static->date_fin=$db->jdate($obj->date_fin); + $opensurvey_static->id = $obj->rowid; + $opensurvey_static->ref = $obj->rowid; + $opensurvey_static->title = $obj->titre; + $opensurvey_static->status = $obj->status; + $opensurvey_static->date_fin = $db->jdate($obj->date_fin); // Show here line of result print ''; diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index ac2ac589200..843a7b6cb0a 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -29,22 +29,22 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; // Load translation files required by the page -$langs->loadLangs(array("stocks","other")); +$langs->loadLangs(array("stocks", "other")); -$action = GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... -$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) -$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? -$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation -$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button -$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'inventorylist'; // To manage different context of search -$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'inventorylist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -54,20 +54,20 @@ $pageprev = $page - 1; $pagenext = $page + 1; // Initialize technical objects -$object=new Inventory($db); +$object = new Inventory($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->inventory->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('inventorylist')); // Note that conf->hooks_modules contains array +$diroutputmassaction = $conf->inventory->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('inventorylist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. +if (!$sortorder) $sortorder = "ASC"; // Security check -$socid=0; +$socid = 0; if ($user->socid > 0) // Protection if external user { //$socid = $user->socid; @@ -83,34 +83,34 @@ else } // Initialize array of search criterias -$search_all=trim(GETPOST("search_all", 'alpha')); -$search=array(); -foreach($object->fields as $key => $val) +$search_all = trim(GETPOST("search_all", 'alpha')); +$search = array(); +foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; + if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; } // Definition of fields for list -$arrayfields=array(); -foreach($object->fields as $key => $val) +$arrayfields = array(); +foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); } // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -122,11 +122,11 @@ $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 +$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)) @@ -135,24 +135,24 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - 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 { - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $search[$key]=''; + $search[$key] = ''; } - $toselect=''; - $search_array_options=array(); + $toselect = ''; + $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { - $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='Inventory'; - $objectlabel='Inventory'; + $objectclass = 'Inventory'; + $objectlabel = 'Inventory'; $permissiontoread = $user->rights->stock->lire; $permissiontodelete = $user->rights->stock->supprimer; $uploaddir = $conf->stock->dir_output; @@ -165,48 +165,48 @@ if (empty($reshook)) * View */ -$form=new Form($db); +$form = new Form($db); -$now=dol_now(); +$now = dol_now(); //$help_url="EN:Module_Inventory|FR:Module_Inventory_FR|ES:Módulo_Inventory"; -$help_url=''; +$help_url = ''; $title = $langs->trans('ListOfInventories'); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $sql.='t.'.$key.', '; + $sql .= 't.'.$key.', '; } // 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.', ' : ''); +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.', ' : ''); } // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/,\s*$/', '', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -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 (t.rowid = ef.fk_object)"; -if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity($object->element).")"; -else $sql.=" WHERE 1 = 1"; -foreach($search as $key => $val) +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql = preg_replace('/,\s*$/', '', $sql); +$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +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 (t.rowid = ef.fk_object)"; +if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; +else $sql .= " WHERE 1 = 1"; +foreach ($search as $key => $val) { if ($key == 'status' && $search[$key] == -1) continue; - $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0); - if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); } -if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; /* If a group by is required $sql.= " GROUP BY " @@ -225,7 +225,7 @@ $sql.=$hookmanager->resPrint; $sql=preg_replace('/, $/','', $sql); */ -$sql.=$db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -246,10 +246,10 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) } else { - $sql.= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); - $resql=$db->query($sql); - if (! $resql) + $resql = $db->query($sql); + if (!$resql) { dol_print_error($db); exit; @@ -259,7 +259,7 @@ else } // Direct jump if only one record found -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -273,28 +273,28 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && llxHeader('', $title, $help_url); -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); -foreach($search as $key => $val) +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +foreach ($search as $key => $val) { - if (is_array($search[$key]) && count($search[$key])) foreach($search[$key] as $skey) $param.='&search_'.$key.'[]='.urlencode($skey); - else $param.= '&search_'.$key.'='.urlencode($search[$key]); + if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey); + else $param .= '&search_'.$key.'='.urlencode($search[$key]); } -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); -if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($user->rights->stock->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); print ''; if ($optioncss != '') print ''; @@ -311,16 +311,16 @@ $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle' print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'products', 0, $newcardbutton, '', $limit); // Add code for pre mass action (confirmation or email presend form) -$topicmail="Information"; -$modelmail="inventory"; -$objecttmp=new Inventory($db); -$trackid='inve'.$object->id; +$topicmail = "Information"; +$modelmail = "inventory"; +$objecttmp = new Inventory($db); +$trackid = 'inve'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } $moreforfilter = ''; @@ -328,39 +328,39 @@ $moreforfilter = ''; $moreforfilter.= $langs->trans('MyFilter') . ': '; $moreforfilter.= '';*/ -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '
'; print $moreforfilter; print '
'; } -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); -print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print '
'."\n"; +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '
'."\n"; // Fields title search // -------------------------------------------------------------------- print ''; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; @@ -370,12 +370,12 @@ foreach($object->fields as $key => $val) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; print ''."\n"; @@ -384,23 +384,23 @@ print ''."\n"; // Fields title label // -------------------------------------------------------------------- print ''; -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield.=($cssforfield?' ':'').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (!empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n"; + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; @@ -408,55 +408,55 @@ print ''."\n"; // Detect if we need a fetch on each output line -$needToFetchEachLine=0; +$needToFetchEachLine = 0; if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object + if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object } } // Loop on record // -------------------------------------------------------------------- -$i=0; -$totalarray=array(); +$i = 0; +$totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) break; // Should not happen // Store properties in $object $object->id = $obj->rowid; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { if (property_exists($obj, $key)) $object->$key = $obj->$key; } // Show here line of result print ''; - foreach($object->fields as $key => $val) + foreach ($object->fields as $key => $val) { - $cssforfield=(empty($val['css'])?'':$val['css']); - if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; + $cssforfield = (empty($val['css']) ? '' : $val['css']); + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; + if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield.=($cssforfield?' ':'').'right'; + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) + if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; if ($key == 'status') print $object->getLibStatut(5); - elseif (in_array($val['type'], array('date','datetime','timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); else print $object->showOutputField($val, $key, $obj->$key, ''); print ''; - if (! $i) $totalarray['nbfield']++; - if (! empty($val['isameasure'])) + if (!$i) $totalarray['nbfield']++; + if (!empty($val['isameasure'])) { - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; $totalarray['val']['t.'.$key] += $obj->$key; } } @@ -464,19 +464,19 @@ while ($i < min($num, $limit)) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print ''."\n"; @@ -490,16 +490,16 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found if ($num == 0) { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print ''; } $db->free($resql); -$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; + print ''; if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75'); else print ''; print ''; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; } print '
'.$langs->trans("NoRecordFound").'
'."\n"; @@ -509,19 +509,19 @@ print ''."\n"; if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->mymodule->read; - $delallowed=$user->rights->mymodule->create; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->mymodule->read; + $delallowed = $user->rights->mymodule->create; print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/product/list.php b/htdocs/product/list.php index d9369fcb148..33ad0b4806c 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -37,26 +37,26 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -if (! empty($conf->categorie->enabled)) +if (!empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; // Load translation files required by the page $langs->loadLangs(array('products', 'stocks', 'suppliers', 'companies')); -if (! empty($conf->productbatch->enabled)) $langs->load("productbatch"); +if (!empty($conf->productbatch->enabled)) $langs->load("productbatch"); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$search_ref=GETPOST("search_ref", 'alpha'); -$search_barcode=GETPOST("search_barcode", 'alpha'); -$search_label=GETPOST("search_label", 'alpha'); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$search_ref = GETPOST("search_ref", 'alpha'); +$search_barcode = GETPOST("search_barcode", 'alpha'); +$search_label = GETPOST("search_label", 'alpha'); $search_type = GETPOST("search_type", 'int'); $search_sale = GETPOST("search_sale", 'int'); -$search_vatrate=GETPOST("search_vatrate", 'alpha'); +$search_vatrate = GETPOST("search_vatrate", 'alpha'); $searchCategoryProductOperator = (GETPOST('search_category_product_operator', 'int') ? GETPOST('search_category_product_operator', 'int') : 0); $searchCategoryProductList = GETPOST('search_category_product_list', 'array'); $search_tosell = GETPOST("search_tosell", 'int'); @@ -69,49 +69,49 @@ $search_accountancy_code_sell_intra = GETPOST("search_accountancy_code_sell_intr $search_accountancy_code_sell_export = GETPOST("search_accountancy_code_sell_export", 'alpha'); $search_accountancy_code_buy = GETPOST("search_accountancy_code_buy", 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); -$type=GETPOST("type", "int"); +$type = GETPOST("type", "int"); //Show/hide child products -if (!empty($conf->variants->enabled) && ! empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) { +if (!empty($conf->variants->enabled) && !empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) { $show_childproducts = GETPOST('search_show_childproducts'); } else { $show_childproducts = ''; } -$diroutputmassaction=$conf->product->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->product->dir_output.'/temp/massgeneration/'.$user->id; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = (GETPOST("page", 'int')?GETPOST("page", 'int'):0); +$page = (GETPOST("page", 'int') ?GETPOST("page", 'int') : 0); 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="p.ref"; -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "p.ref"; +if (!$sortorder) $sortorder = "ASC"; // Initialize context for list -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'productservicelist'; -if ((string) $type == '1') { $contextpage='servicelist'; if ($search_type=='') $search_type='1'; } -if ((string) $type == '0') { $contextpage='productlist'; if ($search_type=='') $search_type='0'; } +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'productservicelist'; +if ((string) $type == '1') { $contextpage = 'servicelist'; if ($search_type == '') $search_type = '1'; } +if ((string) $type == '0') { $contextpage = 'productlist'; if ($search_type == '') $search_type = '0'; } // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks -$object=new Product($db); +$object = new Product($db); $hookmanager->initHooks(array('productservicelist')); $extrafields = new ExtraFields($db); -$form=new Form($db); +$form = new Form($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label('product'); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); -if (empty($action)) $action='list'; +if (empty($action)) $action = 'list'; // Get object canvas (By default, this is not defined, so standard usage of dolibarr) -$canvas=GETPOST("canvas"); -$objcanvas=null; -if (! empty($canvas)) +$canvas = GETPOST("canvas"); +$objcanvas = null; +if (!empty($canvas)) { require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db, $action); @@ -119,15 +119,15 @@ if (! empty($canvas)) } // Security check -if ($search_type=='0') $result=restrictedArea($user, 'produit', '', '', '', '', '', $objcanvas); -elseif ($search_type=='1') $result=restrictedArea($user, 'service', '', '', '', '', '', $objcanvas); -else $result=restrictedArea($user, 'produit|service', '', '', '', '', '', $objcanvas); +if ($search_type == '0') $result = restrictedArea($user, 'produit', '', '', '', '', '', $objcanvas); +elseif ($search_type == '1') $result = restrictedArea($user, 'service', '', '', '', '', '', $objcanvas); +else $result = restrictedArea($user, 'produit|service', '', '', '', '', '', $objcanvas); // Define virtualdiffersfromphysical -$virtualdiffersfromphysical=0; -if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || ! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) ) +$virtualdiffersfromphysical = 0; +if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION)) { - $virtualdiffersfromphysical=1; // According to increase/decrease stock options, virtual and physical stock may differs. + $virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs. } // List of fields to search into when doing a "search in all" @@ -140,52 +140,52 @@ $fieldstosearchall = array( ); // multilang -if (! empty($conf->global->MAIN_MULTILANGS)) +if (!empty($conf->global->MAIN_MULTILANGS)) { - $fieldstosearchall['pl.label']='ProductLabelTranslated'; - $fieldstosearchall['pl.description']='ProductDescriptionTranslated'; - $fieldstosearchall['pl.note']='ProductNoteTranslated'; + $fieldstosearchall['pl.label'] = 'ProductLabelTranslated'; + $fieldstosearchall['pl.description'] = 'ProductDescriptionTranslated'; + $fieldstosearchall['pl.note'] = 'ProductNoteTranslated'; } -if (! empty($conf->barcode->enabled)) { - $fieldstosearchall['p.barcode']='Gencod'; - $fieldstosearchall['pfp.barcode']='GencodBuyPrice'; +if (!empty($conf->barcode->enabled)) { + $fieldstosearchall['p.barcode'] = 'Gencod'; + $fieldstosearchall['pfp.barcode'] = 'GencodBuyPrice'; } // Personalized search criterias. Example: $conf->global->PRODUCT_QUICKSEARCH_ON_FIELDS = 'p.ref=ProductRef;p.label=ProductLabel' -if (! empty($conf->global->PRODUCT_QUICKSEARCH_ON_FIELDS)) $fieldstosearchall=dolExplodeIntoArray($conf->global->PRODUCT_QUICKSEARCH_ON_FIELDS); +if (!empty($conf->global->PRODUCT_QUICKSEARCH_ON_FIELDS)) $fieldstosearchall = dolExplodeIntoArray($conf->global->PRODUCT_QUICKSEARCH_ON_FIELDS); if (empty($conf->global->PRODUIT_MULTIPRICES)) { - $titlesellprice=$langs->trans("SellingPrice"); - if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + $titlesellprice = $langs->trans("SellingPrice"); + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { - $titlesellprice=$form->textwithpicto($langs->trans("SellingPrice"), $langs->trans("DefaultPriceRealPriceMayDependOnCustomer")); + $titlesellprice = $form->textwithpicto($langs->trans("SellingPrice"), $langs->trans("DefaultPriceRealPriceMayDependOnCustomer")); } } -$isInEEC=isInEEC($mysoc); +$isInEEC = isInEEC($mysoc); // Definition of fields for lists -$arrayfields=array( +$arrayfields = array( 'p.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), //'pfp.ref_fourn'=>array('label'=>$langs->trans("RefSupplier"), 'checked'=>1, 'enabled'=>(! empty($conf->barcode->enabled))), 'p.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), - 'p.fk_product_type'=>array('label'=>$langs->trans("Type"), 'checked'=>0, 'enabled'=>(! empty($conf->product->enabled) && ! empty($conf->service->enabled))), - 'p.barcode'=>array('label'=>$langs->trans("Gencod"), 'checked'=>1, 'enabled'=>(! empty($conf->barcode->enabled))), - 'p.duration'=>array('label'=>$langs->trans("Duration"), 'checked'=>($contextpage != 'productlist'), 'enabled'=>(! empty($conf->service->enabled) && (string) $type == '1')), - 'p.weight'=>array('label'=>$langs->trans("Weight"), 'checked'=>0, 'enabled'=>(! empty($conf->product->enabled))), - 'p.length'=>array('label'=>$langs->trans("Length"), 'checked'=>0, 'enabled'=>(! empty($conf->product->enabled) && ! empty($conf->global->PRODUCT_DISABLE_SIZE))), - 'p.surface'=>array('label'=>$langs->trans("Surface"), 'checked'=>0, 'enabled'=>(! empty($conf->product->enabled) && ! empty($conf->global->PRODUCT_DISABLE_SURFACE))), - 'p.volume'=>array('label'=>$langs->trans("Volume"), 'checked'=>0, 'enabled'=>(! empty($conf->product->enabled) && ! empty($conf->global->PRODUCT_DISABLE_VOLUME))), + 'p.fk_product_type'=>array('label'=>$langs->trans("Type"), 'checked'=>0, 'enabled'=>(!empty($conf->product->enabled) && !empty($conf->service->enabled))), + 'p.barcode'=>array('label'=>$langs->trans("Gencod"), 'checked'=>1, 'enabled'=>(!empty($conf->barcode->enabled))), + 'p.duration'=>array('label'=>$langs->trans("Duration"), 'checked'=>($contextpage != 'productlist'), 'enabled'=>(!empty($conf->service->enabled) && (string) $type == '1')), + 'p.weight'=>array('label'=>$langs->trans("Weight"), 'checked'=>0, 'enabled'=>(!empty($conf->product->enabled))), + 'p.length'=>array('label'=>$langs->trans("Length"), 'checked'=>0, 'enabled'=>(!empty($conf->product->enabled) && !empty($conf->global->PRODUCT_DISABLE_SIZE))), + 'p.surface'=>array('label'=>$langs->trans("Surface"), 'checked'=>0, 'enabled'=>(!empty($conf->product->enabled) && !empty($conf->global->PRODUCT_DISABLE_SURFACE))), + 'p.volume'=>array('label'=>$langs->trans("Volume"), 'checked'=>0, 'enabled'=>(!empty($conf->product->enabled) && !empty($conf->global->PRODUCT_DISABLE_VOLUME))), 'p.sellprice'=>array('label'=>$langs->trans("SellingPrice"), 'checked'=>1, 'enabled'=>empty($conf->global->PRODUIT_MULTIPRICES)), - 'p.minbuyprice'=>array('label'=>$langs->trans("BuyingPriceMinShort"), 'checked'=>1, 'enabled'=>(! empty($user->rights->fournisseur->lire))), - 'p.numbuyprice'=>array('label'=>$langs->trans("BuyingPriceNumShort"), 'checked'=>0, 'enabled'=>(! empty($user->rights->fournisseur->lire))), - 'p.tva_tx'=>array('label'=>$langs->trans("VATRate"), 'checked'=>0, 'enabled'=>(! empty($user->rights->fournisseur->lire))), - 'p.pmp'=>array('label'=>$langs->trans("PMPValueShort"), 'checked'=>0, 'enabled'=>(! empty($user->rights->fournisseur->lire))), - 'p.seuil_stock_alerte'=>array('label'=>$langs->trans("StockLimit"), 'checked'=>0, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), - 'p.desiredstock'=>array('label'=>$langs->trans("DesiredStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), - 'p.stock'=>array('label'=>$langs->trans("PhysicalStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), - 'stock_virtual'=>array('label'=>$langs->trans("VirtualStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service' && $virtualdiffersfromphysical)), - 'p.tobatch'=>array('label'=>$langs->trans("ManageLotSerial"), 'checked'=>0, 'enabled'=>(! empty($conf->productbatch->enabled))), + 'p.minbuyprice'=>array('label'=>$langs->trans("BuyingPriceMinShort"), 'checked'=>1, 'enabled'=>(!empty($user->rights->fournisseur->lire))), + 'p.numbuyprice'=>array('label'=>$langs->trans("BuyingPriceNumShort"), 'checked'=>0, 'enabled'=>(!empty($user->rights->fournisseur->lire))), + 'p.tva_tx'=>array('label'=>$langs->trans("VATRate"), 'checked'=>0, 'enabled'=>(!empty($user->rights->fournisseur->lire))), + 'p.pmp'=>array('label'=>$langs->trans("PMPValueShort"), 'checked'=>0, 'enabled'=>(!empty($user->rights->fournisseur->lire))), + 'p.seuil_stock_alerte'=>array('label'=>$langs->trans("StockLimit"), 'checked'=>0, 'enabled'=>(!empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), + 'p.desiredstock'=>array('label'=>$langs->trans("DesiredStock"), 'checked'=>1, 'enabled'=>(!empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), + 'p.stock'=>array('label'=>$langs->trans("PhysicalStock"), 'checked'=>1, 'enabled'=>(!empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), + 'stock_virtual'=>array('label'=>$langs->trans("VirtualStock"), 'checked'=>1, 'enabled'=>(!empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service' && $virtualdiffersfromphysical)), + 'p.tobatch'=>array('label'=>$langs->trans("ManageLotSerial"), 'checked'=>0, 'enabled'=>(!empty($conf->productbatch->enabled))), 'p.accountancy_code_sell'=>array('label'=>$langs->trans("ProductAccountancySellCode"), 'checked'=>0, 'position'=>400), 'p.accountancy_code_sell_intra'=>array('label'=>$langs->trans("ProductAccountancySellIntraCode"), 'checked'=>0, 'enabled'=>$isInEEC, 'position'=>401), 'p.accountancy_code_sell_export'=>array('label'=>$langs->trans("ProductAccountancySellExportCode"), 'checked'=>0, 'position'=>402), @@ -198,10 +198,10 @@ $arrayfields=array( // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -213,11 +213,11 @@ $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 +$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)) @@ -228,30 +228,30 @@ if (empty($reshook)) // Purge search criteria 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 { - $sall=""; - $search_ref=""; - $search_label=""; - $search_barcode=""; + $sall = ""; + $search_ref = ""; + $search_label = ""; + $search_barcode = ""; $searchCategoryProductOperator = 0; $searchCategoryProductList = array(); - $search_tosell=""; - $search_tobuy=""; - $search_vatrate=""; - $search_tobatch=''; + $search_tosell = ""; + $search_tobuy = ""; + $search_vatrate = ""; + $search_tobatch = ''; //$search_type=''; // There is 2 types of list: a list of product and a list of services. No list with both. So when we clear search criteria, we must keep the filter on type. $show_childproducts = ''; - $search_accountancy_code_sell=''; - $search_accountancy_code_sell_intra=''; - $search_accountancy_code_sell_export=''; - $search_accountancy_code_buy=''; - $search_array_options=array(); + $search_accountancy_code_sell = ''; + $search_accountancy_code_sell_intra = ''; + $search_accountancy_code_sell_export = ''; + $search_accountancy_code_buy = ''; + $search_array_options = array(); } // Mass actions - $objectclass='Product'; - if ((string) $search_type == '1') { $objectlabel='Services'; } - if ((string) $search_type == '0') { $objectlabel='Products'; } + $objectclass = 'Product'; + if ((string) $search_type == '1') { $objectlabel = 'Services'; } + if ((string) $search_type == '0') { $objectlabel = 'Products'; } $permissiontoread = $user->rights->produit->lire; $permissiontodelete = $user->rights->produit->supprimer; @@ -264,9 +264,9 @@ if (empty($reshook)) * View */ -$htmlother=new FormOther($db); +$htmlother = new FormOther($db); -$title=$langs->trans("ProductsAndServices"); +$title = $langs->trans("ProductsAndServices"); if ($search_type != '' && $search_type != '-1') { @@ -285,111 +285,111 @@ else } $sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.fk_product_type, p.barcode, p.price, p.tva_tx, p.price_ttc, p.price_base_type, p.entity,'; -$sql.= ' p.fk_product_type, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,'; -$sql.= ' p.tobatch, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy,'; -$sql.= ' p.datec as date_creation, p.tms as date_update, p.pmp, p.stock,'; -$sql.= ' p.weight, p.weight_units, p.length, p.length_units, p.surface, p.surface_units, p.volume, p.volume_units, p.width, p.width_units, p.height, p.height_units,'; -$sql.= ' MIN(pfp.unitprice) as minsellprice'; -if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && ! $show_childproducts )) { +$sql .= ' p.fk_product_type, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,'; +$sql .= ' p.tobatch, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy,'; +$sql .= ' p.datec as date_creation, p.tms as date_update, p.pmp, p.stock,'; +$sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.surface, p.surface_units, p.volume, p.volume_units, p.width, p.width_units, p.height, p.height_units,'; +$sql .= ' MIN(pfp.unitprice) as minsellprice'; +if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) { $sql .= ', pac.rowid prod_comb_id'; } // 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 : ''); +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 : ''); } // 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 '.MAIN_DB_PREFIX.'product as p'; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_extrafields as ef on (p.rowid = ef.fk_object)"; -if (!empty($searchCategoryProductList) || !empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; // We'll need this table joined to the select in order to filter by categ -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_extrafields as ef on (p.rowid = ef.fk_object)"; +if (!empty($searchCategoryProductList) || !empty($catid)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; // We'll need this table joined to the select in order to filter by categ +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; // multilang -if (! empty($conf->global->MAIN_MULTILANGS)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang = '".$langs->getDefaultLang() ."'"; +if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang = '".$langs->getDefaultLang()."'"; -if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && ! $show_childproducts )) { +if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_combination pac ON pac.fk_product_child = p.rowid"; } -$sql.= ' WHERE p.entity IN ('.getEntity('product').')'; +$sql .= ' WHERE p.entity IN ('.getEntity('product').')'; if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); // if the type is not 1, we show all products (type = 0,2,3) if (dol_strlen($search_type) && $search_type != '-1') { - if ($search_type == 1) $sql.= " AND p.fk_product_type = 1"; - else $sql.= " AND p.fk_product_type <> 1"; + if ($search_type == 1) $sql .= " AND p.fk_product_type = 1"; + else $sql .= " AND p.fk_product_type <> 1"; } -if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && ! $show_childproducts )) { +if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) { $sql .= " AND pac.rowid IS NULL"; } if ($search_ref) $sql .= natural_search('p.ref', $search_ref); if ($search_label) $sql .= natural_search('p.label', $search_label); if ($search_barcode) $sql .= natural_search('p.barcode', $search_barcode); -if (isset($search_tosell) && dol_strlen($search_tosell) > 0 && $search_tosell!=-1) $sql.= " AND p.tosell = ".$db->escape($search_tosell); -if (isset($search_tobuy) && dol_strlen($search_tobuy) > 0 && $search_tobuy!=-1) $sql.= " AND p.tobuy = ".$db->escape($search_tobuy); +if (isset($search_tosell) && dol_strlen($search_tosell) > 0 && $search_tosell != -1) $sql .= " AND p.tosell = ".$db->escape($search_tosell); +if (isset($search_tobuy) && dol_strlen($search_tobuy) > 0 && $search_tobuy != -1) $sql .= " AND p.tobuy = ".$db->escape($search_tobuy); if ($search_vatrate) $sql .= natural_search('p.tva_tx', $search_vatrate); -if (dol_strlen($canvas) > 0) $sql.= " AND p.canvas = '".$db->escape($canvas)."'"; -if ($catid > 0) $sql.= " AND cp.fk_categorie = ".$catid; -if ($catid == -2) $sql.= " AND cp.fk_categorie IS NULL"; +if (dol_strlen($canvas) > 0) $sql .= " AND p.canvas = '".$db->escape($canvas)."'"; +if ($catid > 0) $sql .= " AND cp.fk_categorie = ".$catid; +if ($catid == -2) $sql .= " AND cp.fk_categorie IS NULL"; $searchCategoryProductSqlList = array(); if ($searchCategoryProductOperator == 1) { foreach ($searchCategoryProductList as $searchCategoryProduct) { if (intval($searchCategoryProduct) == -2) { $searchCategoryProductSqlList[] = "cp.fk_categorie IS NULL"; } elseif (intval($searchCategoryProduct) > 0) { - $searchCategoryProductSqlList[] = "cp.fk_categorie = " . $db->escape($searchCategoryProduct); + $searchCategoryProductSqlList[] = "cp.fk_categorie = ".$db->escape($searchCategoryProduct); } } if (!empty($searchCategoryProductSqlList)) { - $sql .= " AND (" . implode(' OR ', $searchCategoryProductSqlList) . ")"; + $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")"; } } else { foreach ($searchCategoryProductList as $searchCategoryProduct) { if (intval($searchCategoryProduct) == -2) { $searchCategoryProductSqlList[] = "cp.fk_categorie IS NULL"; } elseif (intval($searchCategoryProduct) > 0) { - $searchCategoryProductSqlList[] = "p.rowid IN (SELECT fk_product FROM " . MAIN_DB_PREFIX . "categorie_product WHERE fk_categorie = " . $searchCategoryProduct . ")"; + $searchCategoryProductSqlList[] = "p.rowid IN (SELECT fk_product FROM ".MAIN_DB_PREFIX."categorie_product WHERE fk_categorie = ".$searchCategoryProduct.")"; } } if (!empty($searchCategoryProductSqlList)) { - $sql .= " AND (" . implode(' AND ', $searchCategoryProductSqlList) . ")"; + $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")"; } } -if ($fourn_id > 0) $sql.= " AND pfp.fk_soc = ".$fourn_id; -if ($search_tobatch != '' && $search_tobatch >= 0) $sql.= " AND p.tobatch = ".$db->escape($search_tobatch); -if ($search_accountancy_code_sell) $sql.= natural_search('p.accountancy_code_sell', $search_accountancy_code_sell); -if ($search_accountancy_code_sell_intra) $sql.= natural_search('p.accountancy_code_sell_intra', $search_accountancy_code_sell_intra); -if ($search_accountancy_code_sell_export) $sql.= natural_search('p.accountancy_code_sell_export', $search_accountancy_code_sell_export); -if ($search_accountancy_code_buy) $sql.= natural_search('p.accountancy_code_buy', $search_accountancy_code_buy); +if ($fourn_id > 0) $sql .= " AND pfp.fk_soc = ".$fourn_id; +if ($search_tobatch != '' && $search_tobatch >= 0) $sql .= " AND p.tobatch = ".$db->escape($search_tobatch); +if ($search_accountancy_code_sell) $sql .= natural_search('p.accountancy_code_sell', $search_accountancy_code_sell); +if ($search_accountancy_code_sell_intra) $sql .= natural_search('p.accountancy_code_sell_intra', $search_accountancy_code_sell_intra); +if ($search_accountancy_code_sell_export) $sql .= natural_search('p.accountancy_code_sell_export', $search_accountancy_code_sell_export); +if ($search_accountancy_code_buy) $sql .= natural_search('p.accountancy_code_buy', $search_accountancy_code_buy); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.tva_tx, p.price_ttc, p.price_base_type,"; -$sql.= " p.fk_product_type, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,"; -$sql.= ' p.datec, p.tms, p.entity, p.tobatch, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.pmp, p.stock,'; -$sql.= ' p.weight, p.weight_units, p.length, p.length_units, p.surface, p.surface_units, p.volume, p.volume_units, p.width, p.width_units, p.height, p.height_units'; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.tva_tx, p.price_ttc, p.price_base_type,"; +$sql .= " p.fk_product_type, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,"; +$sql .= ' p.datec, p.tms, p.entity, p.tobatch, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.pmp, p.stock,'; +$sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.surface, p.surface_units, p.volume, p.volume_units, p.width, p.width_units, p.height, p.height_units'; -if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && ! $show_childproducts )) { +if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) { $sql .= ', pac.rowid'; } // 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 : ''); +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 : ''); } // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldSelect', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; //if (GETPOST("toolowstock")) $sql.= " HAVING SUM(s.reel) < p.seuil_stock_alerte"; // Not used yet -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -403,7 +403,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit + 1, $offset); +$sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); @@ -411,9 +411,9 @@ if ($resql) { $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); - if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) + if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -421,81 +421,81 @@ if ($resql) exit; } - $helpurl=''; + $helpurl = ''; if ($search_type != '') { if ($search_type == 0) { - $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; } elseif ($search_type == 1) { - $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; } } llxHeader('', $title, $helpurl, ''); // Displays product removal confirmation - if (GETPOST('delprod')) { + if (GETPOST('delprod')) { setEventMessages($langs->trans("ProductDeleted", GETPOST('delprod')), null, 'mesgs'); } - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($sall) $param.="&sall=".urlencode($sall); - if ($searchCategoryProductOperator == 1) $param .= "&search_category_product_operator=" . urlencode($searchCategoryProductOperator); + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($sall) $param .= "&sall=".urlencode($sall); + if ($searchCategoryProductOperator == 1) $param .= "&search_category_product_operator=".urlencode($searchCategoryProductOperator); foreach ($searchCategoryProductList as $searchCategoryProduct) { - $param .= "&search_category_product_list[]=" . urlencode($searchCategoryProduct); + $param .= "&search_category_product_list[]=".urlencode($searchCategoryProduct); } - if ($search_ref) $param="&search_ref=".urlencode($search_ref); - if ($search_ref_supplier) $param="&search_ref_supplier=".urlencode($search_ref_supplier); - if ($search_barcode) $param.=($search_barcode?"&search_barcode=".urlencode($search_barcode):""); - if ($search_label) $param.="&search_label=".urlencode($search_label); - if ($search_tosell != '') $param.="&search_tosell=".urlencode($search_tosell); - if ($search_tobuy != '') $param.="&search_tobuy=".urlencode($search_tobuy); + if ($search_ref) $param = "&search_ref=".urlencode($search_ref); + if ($search_ref_supplier) $param = "&search_ref_supplier=".urlencode($search_ref_supplier); + if ($search_barcode) $param .= ($search_barcode ? "&search_barcode=".urlencode($search_barcode) : ""); + if ($search_label) $param .= "&search_label=".urlencode($search_label); + if ($search_tosell != '') $param .= "&search_tosell=".urlencode($search_tosell); + if ($search_tobuy != '') $param .= "&search_tobuy=".urlencode($search_tobuy); if ($search_vatrate) $sql .= natural_search('p.tva_tx', $search_vatrate); - if ($fourn_id > 0) $param.=($fourn_id?"&fourn_id=".$fourn_id:""); + if ($fourn_id > 0) $param .= ($fourn_id ? "&fourn_id=".$fourn_id : ""); //if ($seach_categ) $param.=($search_categ?"&search_categ=".urlencode($search_categ):""); - if ($show_childproducts) $param.=($show_childproducts?"&search_show_childproducts=".urlencode($show_childproducts):""); - if ($type != '') $param.='&type='.urlencode($type); - if ($search_type != '') $param.='&search_type='.urlencode($search_type); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); - if ($search_tobatch) $param="&search_ref_supplier=".urlencode($search_ref_supplier); - if ($search_accountancy_code_sell) $param="&search_accountancy_code_sell=".urlencode($search_accountancy_code_sell); - if ($search_accountancy_code_sell_intra) $param="&search_accountancy_code_sell_intra=".urlencode($search_accountancy_code_sell_intra); - if ($search_accountancy_code_sell_export) $param="&search_accountancy_code_sell_export=".urlencode($search_accountancy_code_sell_export); - if ($search_accountancy_code_buy) $param="&search_accountancy_code_buy=".urlencode($search_accountancy_code_buy); + if ($show_childproducts) $param .= ($show_childproducts ? "&search_show_childproducts=".urlencode($show_childproducts) : ""); + if ($type != '') $param .= '&type='.urlencode($type); + if ($search_type != '') $param .= '&search_type='.urlencode($search_type); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + if ($search_tobatch) $param = "&search_ref_supplier=".urlencode($search_ref_supplier); + if ($search_accountancy_code_sell) $param = "&search_accountancy_code_sell=".urlencode($search_accountancy_code_sell); + if ($search_accountancy_code_sell_intra) $param = "&search_accountancy_code_sell_intra=".urlencode($search_accountancy_code_sell_intra); + if ($search_accountancy_code_sell_export) $param = "&search_accountancy_code_sell_export=".urlencode($search_accountancy_code_sell_export); + if ($search_accountancy_code_buy) $param = "&search_accountancy_code_buy=".urlencode($search_accountancy_code_buy); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available - $arrayofmassactions = array( + $arrayofmassactions = array( 'generate_doc'=>$langs->trans("ReGeneratePDF"), //'builddoc'=>$langs->trans("PDFMerge"), //'presend'=>$langs->trans("SendByMail"), ); - if ($user->rights->produit->supprimer) $arrayofmassactions['predelete']="".$langs->trans("Delete"); - if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + if ($user->rights->produit->supprimer) $arrayofmassactions['predelete'] = "".$langs->trans("Delete"); + if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); - $newcardbutton=''; - $rightskey='produit'; - if($type == Product::TYPE_SERVICE) $rightskey='service'; - if($user->rights->{$rightskey}->creer) + $newcardbutton = ''; + $rightskey = 'produit'; + if ($type == Product::TYPE_SERVICE) $rightskey = 'service'; + if ($user->rights->{$rightskey}->creer) { - $oldtype=$type; + $oldtype = $type; if ($type === "") { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewProduct'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type=0'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewProduct'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type=0'); $type = Product::TYPE_SERVICE; } - $label='NewProduct'; - if($type == Product::TYPE_SERVICE) $label='NewService'; - $newcardbutton.= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type='.$type); + $label = 'NewProduct'; + if ($type == Product::TYPE_SERVICE) $label = 'NewService'; + $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type='.$type); - $type=$oldtype; + $type = $oldtype; } print '
'; @@ -511,13 +511,13 @@ if ($resql) print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'products', 0, $newcardbutton, '', $limit); - $topicmail="Information"; - $modelmail="product"; - $objecttmp=new Product($db); - $trackid='prod'.$object->id; + $topicmail = "Information"; + $modelmail = "product"; + $objecttmp = new Product($db); + $trackid = 'prod'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - if (! empty($catid)) + if (!empty($catid)) { print "
"; $c = new Categorie($db); @@ -528,35 +528,35 @@ if ($resql) if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } // Filter on categories - $moreforfilter=''; - if (! empty($conf->categorie->enabled)) + $moreforfilter = ''; + if (!empty($conf->categorie->enabled)) { - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('Categories'). ': '; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('Categories').': '; $categoriesProductArr = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', '', 64, 0, 1); - $categoriesProductArr[-2] = '- ' . $langs->trans('NotCategorized') . ' -'; - $moreforfilter.=Form::multiselectarray('search_category_product_list', $categoriesProductArr, $searchCategoryProductList, 0, 0, 'minwidth300'); - $moreforfilter.=' ' . $langs->trans('UseOrOperatorForCategories'); - $moreforfilter.='
'; + $categoriesProductArr[-2] = '- '.$langs->trans('NotCategorized').' -'; + $moreforfilter .= Form::multiselectarray('search_category_product_list', $categoriesProductArr, $searchCategoryProductList, 0, 0, 'minwidth300'); + $moreforfilter .= ' '.$langs->trans('UseOrOperatorForCategories'); + $moreforfilter .= '
'; } //Show/hide child products. Hidden by default if (!empty($conf->variants->enabled) && !empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) { - $moreforfilter.='
'; - $moreforfilter.= ''; - $moreforfilter.= ' '; - $moreforfilter.='
'; + $moreforfilter .= '
'; + $moreforfilter .= ''; + $moreforfilter .= ' '; + $moreforfilter .= '
'; } - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $moreforfilter.=$hookmanager->resPrint; - else $moreforfilter=$hookmanager->resPrint; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; + else $moreforfilter = $hookmanager->resPrint; if ($moreforfilter) { @@ -565,258 +565,258 @@ if ($resql) print '
'; } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); print '
'; - print ''."\n"; + print '
'."\n"; // Lines with input filters print ''; - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { print ''; } - if (! empty($arrayfields['pfp.ref_fourn']['checked'])) + if (!empty($arrayfields['pfp.ref_fourn']['checked'])) { print ''; } - if (! empty($arrayfields['p.label']['checked'])) + if (!empty($arrayfields['p.label']['checked'])) { print ''; } // Type - if (! empty($arrayfields['p.fk_product_type']['checked'])) + if (!empty($arrayfields['p.fk_product_type']['checked'])) { print ''; } // Barcode - if (! empty($arrayfields['p.barcode']['checked'])) + if (!empty($arrayfields['p.barcode']['checked'])) { print ''; } // Duration - if (! empty($arrayfields['p.duration']['checked'])) + if (!empty($arrayfields['p.duration']['checked'])) { print ''; } // Weight - if (! empty($arrayfields['p.weight']['checked'])) + if (!empty($arrayfields['p.weight']['checked'])) { print ''; } // Length - if (! empty($arrayfields['p.length']['checked'])) + if (!empty($arrayfields['p.length']['checked'])) { print ''; } // Surface - if (! empty($arrayfields['p.surface']['checked'])) + if (!empty($arrayfields['p.surface']['checked'])) { print ''; } // Volume - if (! empty($arrayfields['p.volume']['checked'])) + if (!empty($arrayfields['p.volume']['checked'])) { print ''; } // Sell price - if (! empty($arrayfields['p.sellprice']['checked'])) + if (!empty($arrayfields['p.sellprice']['checked'])) { print ''; } // Minimum buying Price - if (! empty($arrayfields['p.minbuyprice']['checked'])) + if (!empty($arrayfields['p.minbuyprice']['checked'])) { print ''; } // Number buying Price - if (! empty($arrayfields['p.numbuyprice']['checked'])) + if (!empty($arrayfields['p.numbuyprice']['checked'])) { print ''; } // Sell price - if (! empty($arrayfields['p.tva_tx']['checked'])) + if (!empty($arrayfields['p.tva_tx']['checked'])) { print ''; } // WAP - if (! empty($arrayfields['p.pmp']['checked'])) + if (!empty($arrayfields['p.pmp']['checked'])) { print ''; } // Limit for alert - if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) + if (!empty($arrayfields['p.seuil_stock_alerte']['checked'])) { print ''; } // Desired stock - if (! empty($arrayfields['p.desiredstock']['checked'])) + if (!empty($arrayfields['p.desiredstock']['checked'])) { print ''; } // Stock - if (! empty($arrayfields['p.stock']['checked'])) print ''; + if (!empty($arrayfields['p.stock']['checked'])) print ''; // Stock - if (! empty($arrayfields['stock_virtual']['checked'])) print ''; + if (!empty($arrayfields['stock_virtual']['checked'])) print ''; // To batch - if (! empty($arrayfields['p.tobatch']['checked'])) print ''; + if (!empty($arrayfields['p.tobatch']['checked'])) print ''; // Accountancy code sell - if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print ''; - if (! empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) print ''; - if (! empty($arrayfields['p.accountancy_code_sell_export']['checked'])) print ''; + if (!empty($arrayfields['p.accountancy_code_sell']['checked'])) print ''; + if (!empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) print ''; + if (!empty($arrayfields['p.accountancy_code_sell_export']['checked'])) print ''; // Accountancy code buy - if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) print ''; + if (!empty($arrayfields['p.accountancy_code_buy']['checked'])) print ''; // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['p.datec']['checked'])) + if (!empty($arrayfields['p.datec']['checked'])) { print ''; } // Date modification - if (! empty($arrayfields['p.tms']['checked'])) + if (!empty($arrayfields['p.tms']['checked'])) { print ''; } - if (! empty($arrayfields['p.tosell']['checked'])) + if (!empty($arrayfields['p.tosell']['checked'])) { print ''; } - if (! empty($arrayfields['p.tobuy']['checked'])) + if (!empty($arrayfields['p.tobuy']['checked'])) { print ''; } print ''; print ''; print ''; - if (! empty($arrayfields['p.ref']['checked'])) { + if (!empty($arrayfields['p.ref']['checked'])) { print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, "", $sortfield, $sortorder); } - if (! empty($arrayfields['pfp.ref_fourn']['checked'])) { + if (!empty($arrayfields['pfp.ref_fourn']['checked'])) { print_liste_field_titre($arrayfields['pfp.ref_fourn']['label'], $_SERVER["PHP_SELF"], "pfp.ref_fourn", "", $param, "", $sortfield, $sortorder); } - if (! empty($arrayfields['p.label']['checked'])) { + if (!empty($arrayfields['p.label']['checked'])) { print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"], "p.label", "", $param, "", $sortfield, $sortorder); } - if (! empty($arrayfields['p.fk_product_type']['checked'])) { + if (!empty($arrayfields['p.fk_product_type']['checked'])) { print_liste_field_titre($arrayfields['p.fk_product_type']['label'], $_SERVER["PHP_SELF"], "p.fk_product_type", "", $param, "", $sortfield, $sortorder); } - if (! empty($arrayfields['p.barcode']['checked'])) { + if (!empty($arrayfields['p.barcode']['checked'])) { print_liste_field_titre($arrayfields['p.barcode']['label'], $_SERVER["PHP_SELF"], "p.barcode", "", $param, "", $sortfield, $sortorder); } - if (! empty($arrayfields['p.duration']['checked'])) { + if (!empty($arrayfields['p.duration']['checked'])) { print_liste_field_titre($arrayfields['p.duration']['label'], $_SERVER["PHP_SELF"], "p.duration", "", $param, '', $sortfield, $sortorder, 'center '); } - if (! empty($arrayfields['p.weight']['checked'])) print_liste_field_titre($arrayfields['p.weight']['label'], $_SERVER["PHP_SELF"], "p.weight", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['p.length']['checked'])) print_liste_field_titre($arrayfields['p.length']['label'], $_SERVER["PHP_SELF"], "p.length", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['p.surface']['checked'])) print_liste_field_titre($arrayfields['p.surface']['label'], $_SERVER["PHP_SELF"], "p.surface", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['p.volume']['checked'])) print_liste_field_titre($arrayfields['p.volume']['label'], $_SERVER["PHP_SELF"], "p.volume", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['p.sellprice']['checked'])) { + if (!empty($arrayfields['p.weight']['checked'])) print_liste_field_titre($arrayfields['p.weight']['label'], $_SERVER["PHP_SELF"], "p.weight", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['p.length']['checked'])) print_liste_field_titre($arrayfields['p.length']['label'], $_SERVER["PHP_SELF"], "p.length", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['p.surface']['checked'])) print_liste_field_titre($arrayfields['p.surface']['label'], $_SERVER["PHP_SELF"], "p.surface", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['p.volume']['checked'])) print_liste_field_titre($arrayfields['p.volume']['label'], $_SERVER["PHP_SELF"], "p.volume", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['p.sellprice']['checked'])) { print_liste_field_titre($arrayfields['p.sellprice']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); } - if (! empty($arrayfields['p.minbuyprice']['checked'])) { + if (!empty($arrayfields['p.minbuyprice']['checked'])) { print_liste_field_titre($arrayfields['p.minbuyprice']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); } - if (! empty($arrayfields['p.numbuyprice']['checked'])) { + if (!empty($arrayfields['p.numbuyprice']['checked'])) { print_liste_field_titre($arrayfields['p.numbuyprice']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); } - if (! empty($arrayfields['p.tva_tx']['checked'])) { + if (!empty($arrayfields['p.tva_tx']['checked'])) { print_liste_field_titre($arrayfields['p.tva_tx']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); } - if (! empty($arrayfields['p.pmp']['checked'])) { + if (!empty($arrayfields['p.pmp']['checked'])) { print_liste_field_titre($arrayfields['p.pmp']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); } - if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) { + if (!empty($arrayfields['p.seuil_stock_alerte']['checked'])) { print_liste_field_titre($arrayfields['p.seuil_stock_alerte']['label'], $_SERVER["PHP_SELF"], "p.seuil_stock_alerte", "", $param, '', $sortfield, $sortorder, 'right '); } - if (! empty($arrayfields['p.desiredstock']['checked'])) { + if (!empty($arrayfields['p.desiredstock']['checked'])) { print_liste_field_titre($arrayfields['p.desiredstock']['label'], $_SERVER["PHP_SELF"], "p.desiredstock", "", $param, '', $sortfield, $sortorder, 'right '); } - if (! empty($arrayfields['p.stock']['checked'])) { + if (!empty($arrayfields['p.stock']['checked'])) { print_liste_field_titre($arrayfields['p.stock']['label'], $_SERVER["PHP_SELF"], "p.stock", "", $param, '', $sortfield, $sortorder, 'right '); } - if (! empty($arrayfields['stock_virtual']['checked'])) { + if (!empty($arrayfields['stock_virtual']['checked'])) { print_liste_field_titre($arrayfields['stock_virtual']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); } - if (! empty($arrayfields['p.tobatch']['checked'])) { + if (!empty($arrayfields['p.tobatch']['checked'])) { print_liste_field_titre($arrayfields['p.tobatch']['label'], $_SERVER["PHP_SELF"], "p.tobatch", "", $param, '', $sortfield, $sortorder, 'center '); } - if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) { + if (!empty($arrayfields['p.accountancy_code_sell']['checked'])) { print_liste_field_titre($arrayfields['p.accountancy_code_sell']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_sell", "", $param, '', $sortfield, $sortorder); } - if (! empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) { + if (!empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) { print_liste_field_titre($arrayfields['p.accountancy_code_sell_intra']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_sell_intra", "", $param, '', $sortfield, $sortorder); } - if (! empty($arrayfields['p.accountancy_code_sell_export']['checked'])) { + if (!empty($arrayfields['p.accountancy_code_sell_export']['checked'])) { print_liste_field_titre($arrayfields['p.accountancy_code_sell_export']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_sell_export", "", $param, '', $sortfield, $sortorder); } - if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) { + if (!empty($arrayfields['p.accountancy_code_buy']['checked'])) { print_liste_field_titre($arrayfields['p.accountancy_code_buy']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_buy", "", $param, '', $sortfield, $sortorder); } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['p.datec']['checked'])) { + if (!empty($arrayfields['p.datec']['checked'])) { print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } - if (! empty($arrayfields['p.tms']['checked'])) { + if (!empty($arrayfields['p.tms']['checked'])) { print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } - if (! empty($arrayfields['p.tosell']['checked'])) { + if (!empty($arrayfields['p.tosell']['checked'])) { print_liste_field_titre($arrayfields['p.tosell']['label'], $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'right '); } - if (! empty($arrayfields['p.tobuy']['checked'])) { + if (!empty($arrayfields['p.tobuy']['checked'])) { print_liste_field_titre($arrayfields['p.tobuy']['label'], $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'right '); } print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); @@ -827,25 +827,25 @@ if ($resql) $product_fourn = new ProductFournisseur($db); $i = 0; - $totalarray=array(); + $totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active + if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active { $sql = "SELECT label"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sql.= " WHERE fk_product=".$obj->rowid; - $sql.= " AND lang='". $db->escape($langs->getDefaultLang()) ."'"; - $sql.= " LIMIT 1"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sql .= " WHERE fk_product=".$obj->rowid; + $sql .= " AND lang='".$db->escape($langs->getDefaultLang())."'"; + $sql .= " LIMIT 1"; $result = $db->query($sql); if ($result) { $objtp = $db->fetch_object($result); - if (! empty($objtp->label)) $obj->label = $objtp->label; + if (!empty($objtp->label)) $obj->label = $objtp->label; } } @@ -876,11 +876,11 @@ if ($resql) $product_static->surface = $obj->surface; $product_static->surface_units = $obj->surface_units; - if ((! empty($conf->stock->enabled) && $user->rights->stock->lire && $search_type != 1) || ! empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) // To optimize call of load_stock + if ((!empty($conf->stock->enabled) && $user->rights->stock->lire && $search_type != 1) || !empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) // To optimize call of load_stock { - if ($obj->fk_product_type != 1 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Not a service + if ($obj->fk_product_type != 1 || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Not a service { - $product_static->load_stock('nobatch'); // Load stock_reel + stock_warehouse. This also call load_virtual_stock() + $product_static->load_stock('nobatch'); // Load stock_reel + stock_warehouse. This also call load_virtual_stock() } } @@ -888,107 +888,107 @@ if ($resql) print ''; // Ref - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { print '\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Ref supplier - if (! empty($arrayfields['pfp.ref_fourn']['checked'])) + if (!empty($arrayfields['pfp.ref_fourn']['checked'])) { print '\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Label - if (! empty($arrayfields['p.label']['checked'])) + if (!empty($arrayfields['p.label']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Type - if (! empty($arrayfields['p.fk_product_type']['checked'])) + if (!empty($arrayfields['p.fk_product_type']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Barcode - if (! empty($arrayfields['p.barcode']['checked'])) + if (!empty($arrayfields['p.barcode']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Duration - if (! empty($arrayfields['p.duration']['checked'])) + if (!empty($arrayfields['p.duration']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Weight - if (! empty($arrayfields['p.weight']['checked'])) + if (!empty($arrayfields['p.weight']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Length - if (! empty($arrayfields['p.length']['checked'])) + if (!empty($arrayfields['p.length']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Surface - if (! empty($arrayfields['p.surface']['checked'])) + if (!empty($arrayfields['p.surface']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Volume - if (! empty($arrayfields['p.volume']['checked'])) + if (!empty($arrayfields['p.volume']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Sell price - if (! empty($arrayfields['p.sellprice']['checked'])) + if (!empty($arrayfields['p.sellprice']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Better buy price - if (! empty($arrayfields['p.minbuyprice']['checked'])) + if (!empty($arrayfields['p.minbuyprice']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Number of buy prices - if (! empty($arrayfields['p.numbuyprice']['checked'])) + if (!empty($arrayfields['p.numbuyprice']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // WAP - if (! empty($arrayfields['p.pmp']['checked'])) + if (!empty($arrayfields['p.pmp']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Desired stock - if (! empty($arrayfields['p.desiredstock']['checked'])) + if (!empty($arrayfields['p.desiredstock']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Stock real - if (! empty($arrayfields['p.stock']['checked'])) + if (!empty($arrayfields['p.stock']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Stock virtual - if (! empty($arrayfields['stock_virtual']['checked'])) + if (!empty($arrayfields['stock_virtual']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Lot/Serial - if (! empty($arrayfields['p.tobatch']['checked'])) + if (!empty($arrayfields['p.tobatch']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Accountancy code sell - if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) + if (!empty($arrayfields['p.accountancy_code_sell']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) + if (!empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['p.accountancy_code_sell_export']['checked'])) + if (!empty($arrayfields['p.accountancy_code_sell_export']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Accountancy code buy - if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) + if (!empty($arrayfields['p.accountancy_code_buy']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['p.datec']['checked'])) + if (!empty($arrayfields['p.datec']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date modification - if (! empty($arrayfields['p.tms']['checked'])) + if (!empty($arrayfields['p.tms']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Status (to sell) - if (! empty($arrayfields['p.tosell']['checked'])) + if (!empty($arrayfields['p.tosell']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Status (to buy) - if (! empty($arrayfields['p.tobuy']['checked'])) + if (!empty($arrayfields['p.tobuy']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Action print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "\n"; $i++; diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index a87f1a28621..23efeb0cf6d 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -28,25 +28,25 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; // Load translation files required by the page -$langs->loadLangs(array("stocks","other")); +$langs->loadLangs(array("stocks", "other")); -$action = GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... -$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) -$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? -$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation -$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button -$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'stocklist'; // To manage different context of search -$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'stocklist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$search_all=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$search_ref=GETPOST("sref", "alpha")?GETPOST("sref", "alpha"):GETPOST("search_ref", "alpha"); -$search_label=GETPOST("snom", "alpha")?GETPOST("snom", "alpha"):GETPOST("search_label", "alpha"); -$search_status=GETPOST("search_status", "int"); +$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$search_ref = GETPOST("sref", "alpha") ?GETPOST("sref", "alpha") : GETPOST("search_ref", "alpha"); +$search_label = GETPOST("snom", "alpha") ?GETPOST("snom", "alpha") : GETPOST("search_label", "alpha"); +$search_status = GETPOST("search_status", "int"); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -54,11 +54,11 @@ if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST( $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield="e.ref"; -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "e.ref"; +if (!$sortorder) $sortorder = "ASC"; // Security check -$result=restrictedArea($user, 'stock'); +$result = restrictedArea($user, 'stock'); $year = strftime("%Y", time()); @@ -66,13 +66,13 @@ $year = strftime("%Y", time()); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Entrepot($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->inventory->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->inventory->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('stocklist')); // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" @@ -86,23 +86,23 @@ $fieldstosearchall = array( ); // Definition of fields for list -$arrayfields=array( +$arrayfields = array( 'stockqty'=>array('type'=>'float', 'label'=>'PhysicalStock', 'enabled'=>1, 'visible'=>-2, 'position'=>70), 'estimatedvalue'=>array('type'=>'float', 'label'=>'EstimatedStockValue', 'enabled'=>1, 'visible'=>-2, 'position'=>71), 'sellvalue'=>array('type'=>'float', 'label'=>'EstimatedStockValueSell', 'enabled'=>1, 'visible'=>-2, 'position'=>72), ); -foreach($object->fields as $key => $val) +foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); } // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -113,11 +113,11 @@ $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 +$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)) @@ -126,24 +126,24 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - 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_ref=""; - $sall=""; - $search_label=""; - $search_status=""; - $toselect=''; - $search_array_options=array(); + $search_ref = ""; + $sall = ""; + $search_label = ""; + $search_status = ""; + $toselect = ''; + $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { - $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='Entrepot'; - $objectlabel='Warehouse'; + $objectclass = 'Entrepot'; + $objectlabel = 'Warehouse'; $permissiontoread = $user->rights->stock->lire; $permissiontodelete = $user->rights->stock->supprimer; $uploaddir = $conf->stock->dir_output; @@ -155,48 +155,48 @@ if (empty($reshook)) * View */ -$form=new Form($db); -$warehouse=new Entrepot($db); +$form = new Form($db); +$warehouse = new Entrepot($db); -$now=dol_now(); +$now = dol_now(); -$help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; +$help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; $title = $langs->trans("ListOfWarehouses"); // Build and execute select // -------------------------------------------------------------------- $sql = "SELECT e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays, e.fk_parent,"; -$sql.= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty"; +$sql .= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty"; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { +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 : ''); + $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, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/,\s*$/', '', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as e"; -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 (e.rowid = ef.fk_object)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; -$sql.= " WHERE e.entity IN (".getEntity('stock').")"; -if ($search_ref) $sql.= natural_search("e.ref", $search_ref); // ref -if ($search_label) $sql.= natural_search("e.lieu", $search_label); // label -if ($search_status != '' && $search_status >= 0) $sql.= " AND e.statut = ".$search_status; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql = preg_replace('/,\s*$/', '', $sql); +$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as e"; +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 (e.rowid = ef.fk_object)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; +$sql .= " WHERE e.entity IN (".getEntity('stock').")"; +if ($search_ref) $sql .= natural_search("e.ref", $search_ref); // ref +if ($search_label) $sql .= natural_search("e.lieu", $search_label); // label +if ($search_status != '' && $search_status >= 0) $sql .= " AND e.statut = ".$search_status; if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql.= " GROUP BY e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays, e.fk_parent"; -$totalnboflines=0; -$result=$db->query($sql); +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= " GROUP BY e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays, e.fk_parent"; +$totalnboflines = 0; +$result = $db->query($sql); if ($result) { $totalnboflines = $db->num_rows($result); @@ -211,7 +211,7 @@ if ($result) $line++; } } -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -232,10 +232,10 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) } else { - $sql.= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); - $resql=$db->query($sql); - if (! $resql) + $resql = $db->query($sql); + if (!$resql) { dol_print_error($db); exit; @@ -245,7 +245,7 @@ else } // Direct jump if only one record found -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->rowid; @@ -259,27 +259,27 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && llxHeader('', $title, $help_url); -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -$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_ref) $param.="&search_ref=".urlencode($search_ref); -if ($search_label) $param.="&search_label=".urlencode($search_label); -if ($search_status) $param.="&search_status=".urlencode($search_status); -if ($search_all) $param.="&search_all=".urlencode($search_all); -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +$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_ref) $param .= "&search_ref=".urlencode($search_ref); +if ($search_label) $param .= "&search_label=".urlencode($search_label); +if ($search_status) $param .= "&search_status=".urlencode($search_status); +if ($search_all) $param .= "&search_all=".urlencode($search_all); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); //if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); print ''; if ($optioncss != '') print ''; @@ -296,17 +296,17 @@ $newcardbutton = dolGetButtonTitle($langs->trans('MenuNewWarehouse'), '', 'fa fa print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit); // Add code for pre mass action (confirmation or email presend form) -$topicmail="Information"; -$modelmail="warehouse"; -$objecttmp=new Entrepot($db); -$trackid='ware'.$object->id; +$topicmail = "Information"; +$modelmail = "warehouse"; +$objecttmp = new Entrepot($db); +$trackid = 'ware'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } $moreforfilter = ''; @@ -314,24 +314,24 @@ $moreforfilter = ''; $moreforfilter.= $langs->trans('MyFilter') . ': '; $moreforfilter.= '';*/ -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '
'; print $moreforfilter; print '
'; } -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); -print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print '
'; print ''; print ''; print ''; print ''; print ''; print ''; - $array=array('-1'=>' ', '0'=>$langs->trans('Product'), '1'=>$langs->trans('Service')); + $array = array('-1'=>' ', '0'=>$langs->trans('Product'), '1'=>$langs->trans('Service')); print $form->selectarray('search_type', $array, $search_type); print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ' '; print ''; print ' '; print ''; print ''; print ''; print ' '; print ''; print ' '; print ''; print ' '; print '    '.$form->selectyesno($search_tobatch, '', '', '', 1).''.$form->selectyesno($search_tobatch, '', '', '', 1).''; print ''; print ''; - print $form->selectarray('search_tosell', array('0'=>$langs->trans('ProductStatusNotOnSellShort'),'1'=>$langs->trans('ProductStatusOnSellShort')), $search_tosell, 1); + print $form->selectarray('search_tosell', array('0'=>$langs->trans('ProductStatusNotOnSellShort'), '1'=>$langs->trans('ProductStatusOnSellShort')), $search_tosell, 1); print ''; - print $form->selectarray('search_tobuy', array('0'=>$langs->trans('ProductStatusNotOnBuyShort'),'1'=>$langs->trans('ProductStatusOnBuyShort')), $search_tobuy, 1); + print $form->selectarray('search_tobuy', array('0'=>$langs->trans('ProductStatusNotOnBuyShort'), '1'=>$langs->trans('ProductStatusOnBuyShort')), $search_tobuy, 1); print ''; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; print $product_static->getNomUrl(1); print "'; print $product_static->getNomUrl(1); print "'.dol_trunc($obj->label, 80).''.$obj->fk_product_type.''.$obj->barcode.''; if (preg_match('/([^a-z]+)[a-z]$/i', $obj->duration)) { - $duration_value = substr($obj->duration, 0, dol_strlen($obj->duration)-1); - $duration_unit = substr($obj->duration, -1); + $duration_value = substr($obj->duration, 0, dol_strlen($obj->duration) - 1); + $duration_unit = substr($obj->duration, -1); if ((float) $duration_value > 1) { - $dur=array("i"=>$langs->trans("Minutes"),"h"=>$langs->trans("Hours"),"d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years")); + $dur = array("i"=>$langs->trans("Minutes"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); } elseif ((float) $duration_value > 0) { - $dur=array("i"=>$langs->trans("Minute"),"h"=>$langs->trans("Hour"),"d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year")); + $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); } print $duration_value; - print ((! empty($duration_unit) && isset($dur[$duration_unit]) && $duration_value != '') ? ' '.$langs->trans($dur[$duration_unit]) : ''); + print ((!empty($duration_unit) && isset($dur[$duration_unit]) && $duration_value != '') ? ' '.$langs->trans($dur[$duration_unit]) : ''); } - elseif (! preg_match('/^[a-z]$/i', $obj->duration)) // If duration is a simple char (like 's' of 'm'), we do not show value + elseif (!preg_match('/^[a-z]$/i', $obj->duration)) // If duration is a simple char (like 's' of 'm'), we do not show value { print $obj->duration; } print ''; print $obj->weight; print ''; print $obj->length; print ''; print $obj->surface; print ''; print $obj->volume; print ''; if ($obj->tosell) @@ -997,11 +997,11 @@ if ($resql) else print price($obj->price).' '.$langs->trans("HT"); } print ''; if ($obj->tobuy && $obj->minsellprice != '') @@ -1011,28 +1011,28 @@ if ($resql) { if ($product_fourn->product_fourn_price_id > 0) { - if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) + if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) { - $htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1); - print $form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) - $product_fourn->fourn_remise).' '.$langs->trans("HT"), $htmltext); + $htmltext = $product_fourn->display_price_product_fournisseur(1, 1, 0, 1); + print $form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent / 100) - $product_fourn->fourn_remise).' '.$langs->trans("HT"), $htmltext); } else print price($product_fourn->fourn_unitprice).' '.$langs->trans("HT"); } } } print ''; if ($obj->tobuy) { if (count($productFournList = $product_fourn->list_product_fournisseur_price($obj->rowid)) > 0) { - $htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1, $productFournList); + $htmltext = $product_fourn->display_price_product_fournisseur(1, 1, 0, 1, $productFournList); print $form->textwithpicto(count($productFournList), $htmltext); } } @@ -1040,16 +1040,16 @@ if ($resql) } // Sell Tax Rate - if (! empty($arrayfields['p.tva_tx']['checked'])) + if (!empty($arrayfields['p.tva_tx']['checked'])) { print ''; print vatrate($obj->tva_tx, true); print ''; print price($product_static->pmp, 1, $langs); @@ -1057,7 +1057,7 @@ if ($resql) } // Limit alert - if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) + if (!empty($arrayfields['p.seuil_stock_alerte']['checked'])) { print ''; if ($obj->fk_product_type != 1) @@ -1065,10 +1065,10 @@ if ($resql) print $obj->seuil_stock_alerte; } print ''; if ($obj->fk_product_type != 1) @@ -1076,10 +1076,10 @@ if ($resql) print $obj->desiredstock; } print ''; if ($obj->fk_product_type != 1) @@ -1088,10 +1088,10 @@ if ($resql) print $product_static->stock_reel; } print ''; if ($obj->fk_product_type != 1) @@ -1100,95 +1100,95 @@ if ($resql) print $product_static->stock_theorique; } print ''; print yn($obj->tobatch); print ''.$obj->accountancy_code_sell.''.$obj->accountancy_code_sell_intra.''.$obj->accountancy_code_sell_export.''.$obj->accountancy_code_buy.''; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; - if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { + if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { print ajax_object_onoff($product_static, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); } else { print $product_static->LibStatut($obj->tosell, 5, 0); } print ''; - if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { + if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { print ajax_object_onoff($product_static, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); } else { print $product_static->LibStatut($obj->tobuy, 5, 1); } print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; } print '
'."\n"; +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '
'."\n"; // Fields title search // -------------------------------------------------------------------- @@ -352,8 +352,8 @@ print ''; // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Status @@ -363,7 +363,7 @@ print ''; // Action column print ''; print ''."\n"; @@ -379,8 +379,8 @@ print_liste_field_titre("EstimatedStockValueSell", $_SERVER["PHP_SELF"], "", '', // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "e.statut", '', $param, '', $sortfield, $sortorder, 'right '); // Action column @@ -389,17 +389,17 @@ print ''."\n"; // Loop on record // -------------------------------------------------------------------- -$i=0; -$totalarray=array(); +$i = 0; +$totalarray = array(); if ($num) { - $warehouse=new Entrepot($db); + $warehouse = new Entrepot($db); - $totalarray=array(); + $totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) break; // Should not happen $warehouse->id = $obj->rowid; $warehouse->ref = $obj->ref; @@ -410,55 +410,55 @@ if ($num) // Show here line of result print ''; - print ''; - if (! $i) $totalarray['nbfield']++; + print ''; + if (!$i) $totalarray['nbfield']++; // Location print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Stock qty print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // PMP value print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Selling value print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Status print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Action column print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print ''."\n"; @@ -466,7 +466,7 @@ if ($num) $i++; } - if ($totalnboflines-$offset <= $limit) + if ($totalnboflines - $offset <= $limit) { print ''; print ''; @@ -476,7 +476,7 @@ if ($num) if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($totalsell, 'MT'), 1, $langs, 0, 0, -1, $conf->currency); else { - $htmltext=$langs->trans("OptionMULTIPRICESIsOn"); + $htmltext = $langs->trans("OptionMULTIPRICESIsOn"); print $form->textwithtooltip($langs->trans("Variable"), $htmltext); } print ''; @@ -488,8 +488,8 @@ if ($num) $db->free($resql); -$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '
' . $warehouse->getNomUrl(1) . ''.$warehouse->getNomUrl(1).''.$obj->lieu.''.price2num($obj->stockqty, 5).''; if (price2num($obj->estimatedvalue, 'MT')) print price(price2num($obj->estimatedvalue, 'MT'), 1); else print ''; print ''; if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($obj->sellvalue, 'MT'), 1); else { - $htmltext=$langs->trans("OptionMULTIPRICESIsOn"); + $htmltext = $langs->trans("OptionMULTIPRICESIsOn"); print $form->textwithtooltip($langs->trans("Variable"), $htmltext); } print ''.$warehouse->LibStatut($obj->statut, 5).''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; } print '
'.$langs->trans("Total").'
'."\n"; @@ -499,19 +499,19 @@ print ''."\n"; if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->mymodule->read; - $delallowed=$user->rights->mymodule->create; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->mymodule->read; + $delallowed = $user->rights->mymodule->create; print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index cef869d6a21..9d10e08be9a 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -37,25 +37,25 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -if (! empty($conf->projet->enabled)) { +if (!empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } // Load translation files required by the page $langs->loadLangs(array('products', 'stocks', 'orders')); -if (! empty($conf->productbatch->enabled)) $langs->load("productbatch"); +if (!empty($conf->productbatch->enabled)) $langs->load("productbatch"); // Security check -$result=restrictedArea($user, 'stock'); +$result = restrictedArea($user, 'stock'); -$id=GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$msid=GETPOST('msid', 'int'); -$product_id=GETPOST("product_id", 'int'); -$action=GETPOST('action', 'aZ09'); -$cancel=GETPOST('cancel', 'alpha'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'movementlist'; +$msid = GETPOST('msid', 'int'); +$product_id = GETPOST("product_id", 'int'); +$action = GETPOST('action', 'aZ09'); +$cancel = GETPOST('cancel', 'alpha'); +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'movementlist'; $idproduct = GETPOST('idproduct', 'int'); $year = GETPOST("year", 'int'); @@ -69,18 +69,18 @@ $search_inventorycode = trim(GETPOST("search_inventorycode", 'alpha')); $search_user = trim(GETPOST("search_user", 'alpha')); $search_batch = trim(GETPOST("search_batch", 'alpha')); $search_qty = trim(GETPOST("search_qty", 'alpha')); -$search_type_mouvement=GETPOST('search_type_mouvement', 'int'); +$search_type_mouvement = GETPOST('search_type_mouvement', 'int'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $page = GETPOST("page", 'int'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; -if (! $sortfield) $sortfield="m.datem"; -if (! $sortorder) $sortorder="DESC"; +if (!$sortfield) $sortfield = "m.datem"; +if (!$sortorder) $sortorder = "DESC"; -$pdluoid=GETPOST('pdluoid', 'int'); +$pdluoid = GETPOST('pdluoid', 'int'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new MouvementStock($db); @@ -91,17 +91,17 @@ $formfile = new FormFile($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); -$arrayfields=array( +$arrayfields = array( 'm.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'm.datem'=>array('label'=>$langs->trans("Date"), 'checked'=>1), 'p.ref'=>array('label'=>$langs->trans("ProductRef"), 'checked'=>1, 'css'=>'maxwidth100'), 'p.label'=>array('label'=>$langs->trans("ProductLabel"), 'checked'=>1), - 'm.batch'=>array('label'=>$langs->trans("BatchNumberShort"), 'checked'=>1, 'enabled'=>(! empty($conf->productbatch->enabled))), - 'pl.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>0, 'enabled'=>(! empty($conf->productbatch->enabled))), - 'pl.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(! empty($conf->productbatch->enabled))), - 'e.ref'=>array('label'=>$langs->trans("Warehouse"), 'checked'=>1, 'enabled'=>(! $id > 0)), // If we are on specific warehouse, we hide it + 'm.batch'=>array('label'=>$langs->trans("BatchNumberShort"), 'checked'=>1, 'enabled'=>(!empty($conf->productbatch->enabled))), + 'pl.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>0, 'enabled'=>(!empty($conf->productbatch->enabled))), + 'pl.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(!empty($conf->productbatch->enabled))), + 'e.ref'=>array('label'=>$langs->trans("Warehouse"), 'checked'=>1, 'enabled'=>(!$id > 0)), // If we are on specific warehouse, we hide it 'm.fk_user_author'=>array('label'=>$langs->trans("Author"), 'checked'=>0), 'm.inventorycode'=>array('label'=>$langs->trans("InventoryCodeShort"), 'checked'=>1), 'm.label'=>array('label'=>$langs->trans("MovementLabel"), 'checked'=>1), @@ -123,8 +123,8 @@ $usercanread = (($user->rights->stock->mouvement->lire)); $usercancreate = (($user->rights->stock->mouvement->creer)); $usercandelete = (($user->rights->stock->mouvement->supprimer)); -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 @@ -135,45 +135,45 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Do we click on purge search criteria ? if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers { - $year=''; - $month=''; - $search_ref=''; - $search_movement=""; - $search_type_mouvement=""; - $search_inventorycode=""; - $search_product_ref=""; - $search_product=""; - $search_warehouse=""; - $search_user=""; - $search_batch=""; - $search_qty=''; - $sall=""; - $toselect=''; - $search_array_options=array(); + $year = ''; + $month = ''; + $search_ref = ''; + $search_movement = ""; + $search_type_mouvement = ""; + $search_inventorycode = ""; + $search_product_ref = ""; + $search_product = ""; + $search_warehouse = ""; + $search_user = ""; + $search_batch = ""; + $search_qty = ''; + $sall = ""; + $toselect = ''; + $search_array_options = array(); } // Correct stock if ($action == "correct_stock") { $product = new Product($db); - if (! empty($product_id)) $result=$product->fetch($product_id); + if (!empty($product_id)) $result = $product->fetch($product_id); - $error=0; + $error = 0; if (empty($product_id)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); - $action='correction'; + $action = 'correction'; } - if (! is_numeric($_POST["nbpiece"])) + if (!is_numeric($_POST["nbpiece"])) { $error++; setEventMessages($langs->trans("ErrorFieldMustBeANumeric", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); - $action='correction'; + $action = 'correction'; } - if (! $error) + if (!$error) { $origin_element = ''; $origin_id = null; @@ -186,14 +186,14 @@ if ($action == "correct_stock") if ($product->hasbatch()) { - $batch=GETPOST('batch_number', 'alpha'); + $batch = GETPOST('batch_number', 'alpha'); //$eatby=GETPOST('eatby'); //$sellby=GETPOST('sellby'); - $eatby=dol_mktime(0, 0, 0, GETPOST('eatbymonth', 'int'), GETPOST('eatbyday', 'int'), GETPOST('eatbyyear', 'int')); - $sellby=dol_mktime(0, 0, 0, GETPOST('sellbymonth', 'int'), GETPOST('sellbyday', 'int'), GETPOST('sellbyyear', 'int')); + $eatby = dol_mktime(0, 0, 0, GETPOST('eatbymonth', 'int'), GETPOST('eatbyday', 'int'), GETPOST('eatbyyear', 'int')); + $sellby = dol_mktime(0, 0, 0, GETPOST('sellbymonth', 'int'), GETPOST('sellbyday', 'int'), GETPOST('sellbyyear', 'int')); - $result=$product->correct_stock_batch( + $result = $product->correct_stock_batch( $user, $id, GETPOST("nbpiece", 'int'), @@ -206,11 +206,11 @@ if ($action == "correct_stock") GETPOST('inventorycode', 'alpha'), $origin_element, $origin_id - ); // We do not change value of stock for a correction + ); // We do not change value of stock for a correction } else { - $result=$product->correct_stock( + $result = $product->correct_stock( $user, $id, GETPOST("nbpiece", 'int'), @@ -220,7 +220,7 @@ if ($action == "correct_stock") GETPOST('inventorycode', 'alpha'), $origin_element, $origin_id - ); // We do not change value of stock for a correction + ); // We do not change value of stock for a correction } if ($result > 0) @@ -232,72 +232,72 @@ if ($action == "correct_stock") { $error++; setEventMessages($product->error, $product->errors, 'errors'); - $action='correction'; + $action = 'correction'; } } - if (! $error) $action=''; + if (!$error) $action = ''; } // Transfer stock from a warehouse to another warehouse -if ($action == "transfert_stock" && ! $cancel) +if ($action == "transfert_stock" && !$cancel) { $product = new Product($db); - if (! empty($product_id)) $result=$product->fetch($product_id); + if (!empty($product_id)) $result = $product->fetch($product_id); - if (! (GETPOST("id_entrepot_destination", 'int') > 0)) + if (!(GETPOST("id_entrepot_destination", 'int') > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $error++; - $action='transfert'; + $action = 'transfert'; } if (empty($product_id)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); - $action='transfert'; + $action = 'transfert'; } - if (! GETPOST("nbpiece", 'int')) + if (!GETPOST("nbpiece", 'int')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); $error++; - $action='transfert'; + $action = 'transfert'; } if ($id == GETPOST("id_entrepot_destination", 'int')) { setEventMessages($langs->trans("ErrorSrcAndTargetWarehouseMustDiffers"), null, 'errors'); $error++; - $action='transfert'; + $action = 'transfert'; } - if (! empty($conf->productbatch->enabled)) + if (!empty($conf->productbatch->enabled)) { $product = new Product($db); - $result=$product->fetch($product_id); + $result = $product->fetch($product_id); - if ($product->hasbatch() && ! GETPOST("batch_number", 'alpha')) + if ($product->hasbatch() && !GETPOST("batch_number", 'alpha')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); $error++; - $action='transfert'; + $action = 'transfert'; } } - if (! $error) + if (!$error) { if ($id) { $object = new Entrepot($db); - $result=$object->fetch($id); + $result = $object->fetch($id); $db->begin(); - $product->load_stock('novirtual'); // Load array product->stock_warehouse + $product->load_stock('novirtual'); // Load array product->stock_warehouse // Define value of products moved - $pricesrc=0; - if (isset($product->pmp)) $pricesrc=$product->pmp; - $pricedest=$pricesrc; + $pricesrc = 0; + if (isset($product->pmp)) $pricesrc = $product->pmp; + $pricedest = $pricesrc; if ($product->hasbatch()) { @@ -305,13 +305,13 @@ if ($action == "transfert_stock" && ! $cancel) if ($pdluoid > 0) { - $result=$pdluo->fetch($pdluoid); + $result = $pdluo->fetch($pdluoid); if ($result) { - $srcwarehouseid=$pdluo->warehouseid; - $batch=$pdluo->batch; - $eatby=$pdluo->eatby; - $sellby=$pdluo->sellby; + $srcwarehouseid = $pdluo->warehouseid; + $batch = $pdluo->batch; + $eatby = $pdluo->eatby; + $sellby = $pdluo->sellby; } else { @@ -321,16 +321,16 @@ if ($action == "transfert_stock" && ! $cancel) } else { - $srcwarehouseid=$id; - $batch=GETPOST('batch_number', 'alpha'); - $eatby=$d_eatby; - $sellby=$d_sellby; + $srcwarehouseid = $id; + $batch = GETPOST('batch_number', 'alpha'); + $eatby = $d_eatby; + $sellby = $d_sellby; } - if (! $error) + if (!$error) { // Remove stock - $result1=$product->correct_stock_batch( + $result1 = $product->correct_stock_batch( $user, $srcwarehouseid, GETPOST("nbpiece", 'int'), @@ -343,7 +343,7 @@ if ($action == "transfert_stock" && ! $cancel) GETPOST('inventorycode', 'alpha') ); // Add stock - $result2=$product->correct_stock_batch( + $result2 = $product->correct_stock_batch( $user, GETPOST("id_entrepot_destination", 'int'), GETPOST("nbpiece", 'int'), @@ -360,7 +360,7 @@ if ($action == "transfert_stock" && ! $cancel) else { // Remove stock - $result1=$product->correct_stock( + $result1 = $product->correct_stock( $user, $id, GETPOST("nbpiece", 'int'), @@ -371,7 +371,7 @@ if ($action == "transfert_stock" && ! $cancel) ); // Add stock - $result2=$product->correct_stock( + $result2 = $product->correct_stock( $user, GETPOST("id_entrepot_destination"), GETPOST("nbpiece", 'int'), @@ -381,7 +381,7 @@ if ($action == "transfert_stock" && ! $cancel) GETPOST('inventorycode', 'alpha') ); } - if (! $error && $result1 >= 0 && $result2 >= 0) + if (!$error && $result1 >= 0 && $result2 >= 0) { $db->commit(); @@ -400,7 +400,7 @@ if ($action == "transfert_stock" && ! $cancel) { setEventMessages($product->error, $product->errors, 'errors'); $db->rollback(); - $action='transfert'; + $action = 'transfert'; } } } @@ -433,62 +433,62 @@ if (empty($reshook) && $action != 'remove_file') * View */ -$productlot=new ProductLot($db); -$productstatic=new Product($db); -$warehousestatic=new Entrepot($db); -$movement=new MouvementStock($db); -$userstatic=new User($db); -$form=new Form($db); -$formother=new FormOther($db); -$formproduct=new FormProduct($db); -if (!empty($conf->projet->enabled)) $formproject=new FormProjets($db); +$productlot = new ProductLot($db); +$productstatic = new Product($db); +$warehousestatic = new Entrepot($db); +$movement = new MouvementStock($db); +$userstatic = new User($db); +$form = new Form($db); +$formother = new FormOther($db); +$formproduct = new FormProduct($db); +if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db); $sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,"; -$sql.= " e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu,"; -$sql.= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,"; -$sql.= " m.batch, m.price,"; -$sql.= " m.type_mouvement,"; -$sql.= " pl.rowid as lotid, pl.eatby, pl.sellby,"; -$sql.= " u.login, u.photo, u.lastname, u.firstname"; +$sql .= " e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu,"; +$sql .= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,"; +$sql .= " m.batch, m.price,"; +$sql .= " m.type_mouvement,"; +$sql .= " pl.rowid as lotid, pl.eatby, pl.sellby,"; +$sql .= " u.login, u.photo, u.lastname, u.firstname"; // 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 : ''); +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 : ''); } // 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 ".MAIN_DB_PREFIX."entrepot as e,"; -$sql.= " ".MAIN_DB_PREFIX."product as p,"; -$sql.= " ".MAIN_DB_PREFIX."stock_mouvement as m"; -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 (m.rowid = ef.fk_object)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product"; -$sql.= " WHERE m.fk_product = p.rowid"; +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; +$sql .= " ".MAIN_DB_PREFIX."product as p,"; +$sql .= " ".MAIN_DB_PREFIX."stock_mouvement as m"; +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 (m.rowid = ef.fk_object)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product"; +$sql .= " WHERE m.fk_product = p.rowid"; if ($msid > 0) $sql .= " AND m.rowid = ".$msid; -$sql.= " AND m.fk_entrepot = e.rowid"; -$sql.= " AND e.entity IN (".getEntity('stock').")"; -if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql.= " AND p.fk_product_type = 0"; -if ($id > 0) $sql.= " AND e.rowid ='".$id."'"; -$sql.= dolSqlDateFilter('m.datem', 0, $month, $year); -if ($idproduct > 0) $sql.= " AND p.rowid = '".$idproduct."'"; -if (! empty($search_ref)) $sql.= natural_search('m.rowid', $search_ref, 1); -if (! empty($search_movement)) $sql.= natural_search('m.label', $search_movement); -if (! empty($search_inventorycode)) $sql.= natural_search('m.inventorycode', $search_inventorycode); -if (! empty($search_product_ref)) $sql.= natural_search('p.ref', $search_product_ref); -if (! empty($search_product)) $sql.= natural_search('p.label', $search_product); -if ($search_warehouse != '' && $search_warehouse != '-1') $sql.= natural_search('e.rowid', $search_warehouse, 2); -if (! empty($search_user)) $sql.= natural_search('u.login', $search_user); -if (! empty($search_batch)) $sql.= natural_search('m.batch', $search_batch); -if ($search_qty != '') $sql.= natural_search('m.value', $search_qty, 1); -if ($search_type_mouvement != '' && $search_type_mouvement != '-1') $sql.= natural_search('m.type_mouvement', $search_type_mouvement, 2); +$sql .= " AND m.fk_entrepot = e.rowid"; +$sql .= " AND e.entity IN (".getEntity('stock').")"; +if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .= " AND p.fk_product_type = 0"; +if ($id > 0) $sql .= " AND e.rowid ='".$id."'"; +$sql .= dolSqlDateFilter('m.datem', 0, $month, $year); +if ($idproduct > 0) $sql .= " AND p.rowid = '".$idproduct."'"; +if (!empty($search_ref)) $sql .= natural_search('m.rowid', $search_ref, 1); +if (!empty($search_movement)) $sql .= natural_search('m.label', $search_movement); +if (!empty($search_inventorycode)) $sql .= natural_search('m.inventorycode', $search_inventorycode); +if (!empty($search_product_ref)) $sql .= natural_search('p.ref', $search_product_ref); +if (!empty($search_product)) $sql .= natural_search('p.label', $search_product); +if ($search_warehouse != '' && $search_warehouse != '-1') $sql .= natural_search('e.rowid', $search_warehouse, 2); +if (!empty($search_user)) $sql .= natural_search('u.login', $search_user); +if (!empty($search_batch)) $sql .= natural_search('m.batch', $search_batch); +if ($search_qty != '') $sql .= natural_search('m.value', $search_qty, 1); +if ($search_type_mouvement != '' && $search_type_mouvement != '-1') $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -502,9 +502,9 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -if(empty($search_inventorycode)) +if (empty($search_inventorycode)) { - $sql.= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); } else { @@ -515,7 +515,7 @@ else $resql = $db->query($sql); -if(!empty($search_inventorycode)) $limit = $db->num_rows($resql); +if (!empty($search_inventorycode)) $limit = $db->num_rows($resql); if ($resql) { @@ -537,16 +537,16 @@ if ($resql) $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); $i = 0; - $help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; + $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; if ($msid) $texte = $langs->trans('StockMovementForId', $msid); else { $texte = $langs->trans("ListOfStockMovements"); - if ($id) $texte.=' ('.$langs->trans("ForThisWarehouse").')'; + if ($id) $texte .= ' ('.$langs->trans("ForThisWarehouse").')'; } llxHeader("", $texte, $help_url); @@ -562,12 +562,12 @@ if ($resql) $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
'; - $morehtmlref.=$langs->trans("LocationSummary").' : '.$object->lieu; - $morehtmlref.='
'; + $morehtmlref = '
'; + $morehtmlref .= $langs->trans("LocationSummary").' : '.$object->lieu; + $morehtmlref .= '
'; $shownav = 1; - if ($user->socid && ! in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', 'ref', $morehtmlref); @@ -583,18 +583,18 @@ if ($resql) // Description print ''.$langs->trans("Description").''.dol_htmlentitiesbr($object->description).''; - $calcproductsunique=$object->nb_different_products(); - $calcproducts=$object->nb_products(); + $calcproductsunique = $object->nb_different_products(); + $calcproducts = $object->nb_products(); // Total nb of different products print ''.$langs->trans("NumberOfDifferentProducts").''; - print empty($calcproductsunique['nb'])?'0':$calcproductsunique['nb']; + print empty($calcproductsunique['nb']) ? '0' : $calcproductsunique['nb']; print ""; // Nb of products print ''.$langs->trans("NumberOfProducts").''; - $valtoshow=price2num($calcproducts['nb'], 'MS'); - print empty($valtoshow)?'0':$valtoshow; + $valtoshow = price2num($calcproducts['nb'], 'MS'); + print empty($valtoshow) ? '0' : $valtoshow; print ""; print ''; @@ -608,7 +608,7 @@ if ($resql) // Value print ''.$langs->trans("EstimatedStockValueShort").''; - print price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency); + print price((empty($calcproducts['value']) ? '0' : price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency); print ""; // Last movement @@ -619,7 +619,7 @@ if ($resql) if ($resqlbis) { $obj = $db->fetch_object($resqlbis); - $lastmovementdate=$db->jdate($obj->datem); + $lastmovementdate = $db->jdate($obj->datem); } else { @@ -691,32 +691,32 @@ if ($resql) print '

'; } - $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 ($search_movement) $param.='&search_movement='.urlencode($search_movement); - if ($search_inventorycode) $param.='&search_inventorycode='.urlencode($search_inventorycode); - if ($search_type_mouvement) $param.='&search_type_mouvement='.urlencode($search_type_mouvement); - if ($search_product_ref) $param.='&search_product_ref='.urlencode($search_product_ref); - if ($search_product) $param.='&search_product='.urlencode($search_product); - if ($search_batch) $param.='&search_batch='.urlencode($search_batch); - if ($search_warehouse > 0) $param.='&search_warehouse='.urlencode($search_warehouse); - if (!empty($sref)) $param.='&sref='.urlencode($sref); // FIXME $sref is not defined - if (!empty($snom)) $param.='&snom='.urlencode($snom); // FIXME $snom is not defined - if ($search_user) $param.='&search_user='.urlencode($search_user); - if ($idproduct > 0) $param.='&idproduct='.urlencode($idproduct); + $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 ($search_movement) $param .= '&search_movement='.urlencode($search_movement); + if ($search_inventorycode) $param .= '&search_inventorycode='.urlencode($search_inventorycode); + if ($search_type_mouvement) $param .= '&search_type_mouvement='.urlencode($search_type_mouvement); + if ($search_product_ref) $param .= '&search_product_ref='.urlencode($search_product_ref); + if ($search_product) $param .= '&search_product='.urlencode($search_product); + if ($search_batch) $param .= '&search_batch='.urlencode($search_batch); + if ($search_warehouse > 0) $param .= '&search_warehouse='.urlencode($search_warehouse); + if (!empty($sref)) $param .= '&sref='.urlencode($sref); // FIXME $sref is not defined + if (!empty($snom)) $param .= '&snom='.urlencode($snom); // FIXME $snom is not defined + if ($search_user) $param .= '&search_user='.urlencode($search_user); + if ($idproduct > 0) $param .= '&idproduct='.urlencode($idproduct); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available - $arrayofmassactions = array( + $arrayofmassactions = array( // 'presend'=>$langs->trans("SendByMail"), // 'builddoc'=>$langs->trans("PDFMerge"), ); //if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); - if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '
'; if ($optioncss != '') print ''; @@ -735,140 +735,140 @@ if ($resql) if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } - $moreforfilter=''; + $moreforfilter = ''; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - if (! empty($moreforfilter)) + if (!empty($moreforfilter)) { print '
'; print $moreforfilter; print '
'; } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields print '
'; - print ''."\n"; + print '
'."\n"; // Fields title search print ''; - if (! empty($arrayfields['m.rowid']['checked'])) + if (!empty($arrayfields['m.rowid']['checked'])) { // Ref print ''; } - if (! empty($arrayfields['m.datem']['checked'])) + if (!empty($arrayfields['m.datem']['checked'])) { print ''; } - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { // Product Ref print ''; } - if (! empty($arrayfields['p.label']['checked'])) + if (!empty($arrayfields['p.label']['checked'])) { // Product label print ''; } // Batch - if (! empty($arrayfields['m.batch']['checked'])) + if (!empty($arrayfields['m.batch']['checked'])) { print ''; } - if (! empty($arrayfields['pl.eatby']['checked'])) + if (!empty($arrayfields['pl.eatby']['checked'])) { print ''; } - if (! empty($arrayfields['pl.sellby']['checked'])) + if (!empty($arrayfields['pl.sellby']['checked'])) { print ''; } // Warehouse - if (! empty($arrayfields['e.ref']['checked'])) + if (!empty($arrayfields['e.ref']['checked'])) { print ''; } - if (! empty($arrayfields['m.fk_user_author']['checked'])) + if (!empty($arrayfields['m.fk_user_author']['checked'])) { // Author print ''; } - if (! empty($arrayfields['m.inventorycode']['checked'])) + if (!empty($arrayfields['m.inventorycode']['checked'])) { // Inventory code print ''; } - if (! empty($arrayfields['m.label']['checked'])) + if (!empty($arrayfields['m.label']['checked'])) { // Label of movement print ''; } - if (! empty($arrayfields['m.type_mouvement']['checked'])) + if (!empty($arrayfields['m.type_mouvement']['checked'])) { // Type of movement print ''; } - if (! empty($arrayfields['origin']['checked'])) + if (!empty($arrayfields['origin']['checked'])) { // Origin of movement print ''; } - if (! empty($arrayfields['m.value']['checked'])) + if (!empty($arrayfields['m.value']['checked'])) { // Qty print ''; } - if (! empty($arrayfields['m.price']['checked'])) + if (!empty($arrayfields['m.price']['checked'])) { // Price print ''; } // Date modification - if (! empty($arrayfields['m.tms']['checked'])) + if (!empty($arrayfields['m.tms']['checked'])) { print ''; } // Actions print ''; print "\n"; print ''; - if (! empty($arrayfields['m.rowid']['checked'])) + if (!empty($arrayfields['m.rowid']['checked'])) print_liste_field_titre($arrayfields['m.rowid']['label'], $_SERVER["PHP_SELF"], 'm.rowid', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['m.datem']['checked'])) + if (!empty($arrayfields['m.datem']['checked'])) print_liste_field_titre($arrayfields['m.datem']['label'], $_SERVER["PHP_SELF"], 'm.datem', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['p.label']['checked'])) + if (!empty($arrayfields['p.label']['checked'])) print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"], 'p.label', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['m.batch']['checked'])) + if (!empty($arrayfields['m.batch']['checked'])) print_liste_field_titre($arrayfields['m.batch']['label'], $_SERVER["PHP_SELF"], 'm.batch', '', $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['pl.eatby']['checked'])) + if (!empty($arrayfields['pl.eatby']['checked'])) print_liste_field_titre($arrayfields['pl.eatby']['label'], $_SERVER["PHP_SELF"], 'pl.eatby', '', $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['pl.sellby']['checked'])) + if (!empty($arrayfields['pl.sellby']['checked'])) print_liste_field_titre($arrayfields['pl.sellby']['label'], $_SERVER["PHP_SELF"], 'pl.sellby', '', $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['e.ref']['checked'])) { + if (!empty($arrayfields['e.ref']['checked'])) { // We are on a specific warehouse card, no filter on other should be possible print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder); } - if (! empty($arrayfields['m.fk_user_author']['checked'])) + if (!empty($arrayfields['m.fk_user_author']['checked'])) print_liste_field_titre($arrayfields['m.fk_user_author']['label'], $_SERVER["PHP_SELF"], "m.fk_user_author", "", $param, "", $sortfield, $sortorder); - if (! empty($arrayfields['m.inventorycode']['checked'])) + if (!empty($arrayfields['m.inventorycode']['checked'])) print_liste_field_titre($arrayfields['m.inventorycode']['label'], $_SERVER["PHP_SELF"], "m.inventorycode", "", $param, "", $sortfield, $sortorder); - if (! empty($arrayfields['m.label']['checked'])) + if (!empty($arrayfields['m.label']['checked'])) print_liste_field_titre($arrayfields['m.label']['label'], $_SERVER["PHP_SELF"], "m.label", "", $param, "", $sortfield, $sortorder); - if (! empty($arrayfields['m.type_mouvement']['checked'])) + if (!empty($arrayfields['m.type_mouvement']['checked'])) print_liste_field_titre($arrayfields['m.type_mouvement']['label'], $_SERVER["PHP_SELF"], "m.type_mouvement", "", $param, '', $sortfield, $sortorder, 'center '); - if (! empty($arrayfields['origin']['checked'])) + if (!empty($arrayfields['origin']['checked'])) print_liste_field_titre($arrayfields['origin']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); - if (! empty($arrayfields['m.value']['checked'])) + if (!empty($arrayfields['m.value']['checked'])) print_liste_field_titre($arrayfields['m.value']['label'], $_SERVER["PHP_SELF"], "m.value", "", $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['m.price']['checked'])) + if (!empty($arrayfields['m.price']['checked'])) print_liste_field_titre($arrayfields['m.price']['label'], $_SERVER["PHP_SELF"], "m.price", "", $param, '', $sortfield, $sortorder, 'right '); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['m.datec']['checked'])) { + if (!empty($arrayfields['m.datec']['checked'])) { print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } - if (! empty($arrayfields['m.tms']['checked'])) { + if (!empty($arrayfields['m.tms']['checked'])) { print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; - $arrayofuniqueproduct=array(); + $arrayofuniqueproduct = array(); while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); - $userstatic->id=$objp->fk_user_author; - $userstatic->login=$objp->login; - $userstatic->lastname=$objp->lastname; - $userstatic->firstname=$objp->firstname; - $userstatic->photo=$objp->photo; + $userstatic->id = $objp->fk_user_author; + $userstatic->login = $objp->login; + $userstatic->lastname = $objp->lastname; + $userstatic->firstname = $objp->firstname; + $userstatic->photo = $objp->photo; - $productstatic->id=$objp->rowid; - $productstatic->ref=$objp->product_ref; - $productstatic->label=$objp->produit; - $productstatic->type=$objp->type; - $productstatic->entity=$objp->entity; - $productstatic->status_batch=$objp->tobatch; + $productstatic->id = $objp->rowid; + $productstatic->ref = $objp->product_ref; + $productstatic->label = $objp->produit; + $productstatic->type = $objp->type; + $productstatic->entity = $objp->entity; + $productstatic->status_batch = $objp->tobatch; $productlot->id = $objp->lotid; - $productlot->batch= $objp->batch; - $productlot->eatby= $objp->eatby; - $productlot->sellby= $objp->sellby; + $productlot->batch = $objp->batch; + $productlot->eatby = $objp->eatby; + $productlot->sellby = $objp->sellby; - $warehousestatic->id=$objp->entrepot_id; - $warehousestatic->libelle=$objp->warehouse_ref; // deprecated - $warehousestatic->label=$objp->warehouse_ref; - $warehousestatic->lieu=$objp->lieu; + $warehousestatic->id = $objp->entrepot_id; + $warehousestatic->libelle = $objp->warehouse_ref; // deprecated + $warehousestatic->label = $objp->warehouse_ref; + $warehousestatic->lieu = $objp->lieu; - $arrayofuniqueproduct[$objp->rowid]=$objp->produit; + $arrayofuniqueproduct[$objp->rowid] = $objp->produit; if (!empty($objp->fk_origin)) { $origin = $movement->get_origin($objp->fk_origin, $objp->origintype); } else { @@ -991,24 +991,24 @@ if ($resql) print ''; // Id movement - if (! empty($arrayfields['m.rowid']['checked'])) + if (!empty($arrayfields['m.rowid']['checked'])) { // This is primary not movement id print ''; } - if (! empty($arrayfields['m.datem']['checked'])) + if (!empty($arrayfields['m.datem']['checked'])) { // Date print ''; } - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { // Product ref print '\n"; } - if (! empty($arrayfields['p.label']['checked'])) + if (!empty($arrayfields['p.label']['checked'])) { // Product label print '\n"; } - if (! empty($arrayfields['m.batch']['checked'])) + if (!empty($arrayfields['m.batch']['checked'])) { print ''; } - if (! empty($arrayfields['pl.eatby']['checked'])) + if (!empty($arrayfields['pl.eatby']['checked'])) { - print ''; + print ''; } - if (! empty($arrayfields['pl.sellby']['checked'])) + if (!empty($arrayfields['pl.sellby']['checked'])) { - print ''; + print ''; } // Warehouse - if (! empty($arrayfields['e.ref']['checked'])) + if (!empty($arrayfields['e.ref']['checked'])) { print '\n"; } // Author - if (! empty($arrayfields['m.fk_user_author']['checked'])) + if (!empty($arrayfields['m.fk_user_author']['checked'])) { print '\n"; } - if (! empty($arrayfields['m.inventorycode']['checked'])) + if (!empty($arrayfields['m.inventorycode']['checked'])) { // Inventory code print ''; } - if (! empty($arrayfields['m.type_mouvement']['checked'])) + if (!empty($arrayfields['m.type_mouvement']['checked'])) { // Type of movement - switch($objp->type_mouvement) { + switch ($objp->type_mouvement) { case "0": print ''; break; @@ -1084,12 +1084,12 @@ if ($resql) break; } } - if (! empty($arrayfields['origin']['checked'])) + if (!empty($arrayfields['origin']['checked'])) { // Origin of movement print ''; } - if (! empty($arrayfields['m.value']['checked'])) + if (!empty($arrayfields['m.value']['checked'])) { // Qty print ''; } - if (! empty($arrayfields['m.price']['checked'])) + if (!empty($arrayfields['m.price']['checked'])) { // Price print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "\n"; $i++; @@ -1129,15 +1129,15 @@ if ($resql) { print "
"; - $productidselected=0; + $productidselected = 0; foreach ($arrayofuniqueproduct as $key => $val) { - $productidselected=$key; - $productlabelselected=$val; + $productidselected = $key; + $productlabelselected = $val; } - $datebefore=dol_get_first_day($year?$year:strftime("%Y", time()), $month?$month:1, true); - $dateafter=dol_get_last_day($year?$year:strftime("%Y", time()), $month?$month:12, true); - $balancebefore=$movement->calculateBalanceForProductBefore($productidselected, $datebefore); - $balanceafter=$movement->calculateBalanceForProductBefore($productidselected, $dateafter); + $datebefore = dol_get_first_day($year ? $year : strftime("%Y", time()), $month ? $month : 1, true); + $dateafter = dol_get_last_day($year ? $year : strftime("%Y", time()), $month ? $month : 12, true); + $balancebefore = $movement->calculateBalanceForProductBefore($productidselected, $datebefore); + $balanceafter = $movement->calculateBalanceForProductBefore($productidselected, $dateafter); //print ''; print ''; @@ -460,7 +460,7 @@ if ($id > 0 || ! empty($ref)) // Other attributes $cols = 2; - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
'; print ''; print ''; print ''; if (empty($conf->productbatch->enabled)) print ' '; //else print '
'; - $syear = $year?$year:-1; + $syear = $year ? $year : -1; print ''; //print $formother->selectyear($syear,'year',1, 20, 5); print '
'; - print ''; + print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; //print ''; print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200'); print ''; print ''; print ''; print ''; print ''; print ''; print ''; //print ''; print ''; print ajax_combobox('search_type_mouvement'); // TODO: add new function $formentrepot->selectTypeOfMovement(...) like // print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200'); print ''; print '  '; print ''; print ''; print ''; @@ -881,108 +881,108 @@ if ($resql) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['m.datec']['checked'])) + if (!empty($arrayfields['m.datec']['checked'])) { print ''; print ''; print ''; - $searchpicto=$form->showFilterAndCheckAddButtons(0); + $searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
'.$objp->mid.''.dol_print_date($db->jdate($objp->datem), 'dayhour').''; print $productstatic->getNomUrl(1, 'stock', 16); print "'; @@ -1019,36 +1019,36 @@ if ($resql) print $productstatic->label; print "'; if ($productlot->id > 0) print $productlot->getNomUrl(1); - else print $productlot->batch; // the id may not be defined if movement was entered when lot was not saved or if lot was removed after movement. + else print $productlot->batch; // the id may not be defined if movement was entered when lot was not saved or if lot was removed after movement. print ''. dol_print_date($objp->eatby, 'day') .''.dol_print_date($objp->eatby, 'day').''. dol_print_date($objp->sellby, 'day') .''.dol_print_date($objp->sellby, 'day').''; print $warehousestatic->getNomUrl(1); print "'; print $userstatic->getNomUrl(-1); print "'.$objp->label.''.$langs->trans('StockIncreaseAfterCorrectTransfer').''.$origin.''; @@ -1097,7 +1097,7 @@ if ($resql) print $objp->qty; print ''; @@ -1108,12 +1108,12 @@ if ($resql) print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; } print '
'; print $langs->trans("NbOfProductBeforePeriod", $productlabelselected, dol_print_date($datebefore, 'day', 'gmt')); @@ -1166,9 +1166,9 @@ else * Documents generes */ //Area for doc and last events of warehouse are stored on the main card of warehouse -$modulepart='movement'; +$modulepart = 'movement'; -if ($action != 'create' && $action != 'edit' && $action != 'delete' && $id>0) +if ($action != 'create' && $action != 'edit' && $action != 'delete' && $id > 0) { print '
'; print '
'; @@ -1177,33 +1177,33 @@ if ($action != 'create' && $action != 'edit' && $action != 'delete' && $id>0) // Documents $objectref = dol_sanitizeFileName($object->ref); // Add inventorycode & type_mouvement to filename of the pdf - if(!empty($search_inventorycode)) $objectref.="_".$id."_".$search_inventorycode; - if($search_type_mouvement) $objectref.="_".$search_type_mouvement; - $relativepath = $comref . '/' . $objectref . '.pdf'; - $filedir = $conf->stock->dir_output . '/movement/' . $objectref; + if (!empty($search_inventorycode)) $objectref .= "_".$id."_".$search_inventorycode; + if ($search_type_mouvement) $objectref .= "_".$search_type_mouvement; + $relativepath = $comref.'/'.$objectref.'.pdf'; + $filedir = $conf->stock->dir_output.'/movement/'.$objectref; - $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id."&search_inventorycode=".$search_inventorycode."&search_type_mouvement=$search_type_mouvement"; - $genallowed=$usercanread; - $delallowed=$usercancreate; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id."&search_inventorycode=".$search_inventorycode."&search_type_mouvement=$search_type_mouvement"; + $genallowed = $usercanread; + $delallowed = $usercancreate; - $genallowed=$user->rights->stock->lire; - $delallowed=$user->rights->stock->creer; + $genallowed = $user->rights->stock->lire; + $delallowed = $user->rights->stock->creer; print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $object->default_lang, '', $object); - $somethingshown=$formfile->numoffiles; + $somethingshown = $formfile->numoffiles; print '
'; $MAXEVENT = 10; $morehtmlright = ''; - $morehtmlright.= $langs->trans("SeeAll"); - $morehtmlright.= ''; + $morehtmlright .= $langs->trans("SeeAll"); + $morehtmlright .= ''; // List of actions on element - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'mouvement', 0, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for product + $somethingshown = $formactions->showactions($object, 'mouvement', 0, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for product print '
'; } diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 4c306dc1702..d832a0406ee 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -42,19 +42,19 @@ $myparam = GETPOST('myparam', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$search_entity=GETPOST('search_entity', 'int'); -$search_product=GETPOST('search_product', 'alpha'); -$search_batch=GETPOST('search_batch', 'alpha'); -$search_fk_user_creat=GETPOST('search_fk_user_creat', 'int'); -$search_fk_user_modif=GETPOST('search_fk_user_modif', 'int'); -$search_import_key=GETPOST('search_import_key', 'int'); +$search_entity = GETPOST('search_entity', 'int'); +$search_product = GETPOST('search_product', 'alpha'); +$search_batch = GETPOST('search_batch', 'alpha'); +$search_fk_user_creat = GETPOST('search_fk_user_creat', 'int'); +$search_fk_user_modif = GETPOST('search_fk_user_modif', 'int'); +$search_import_key = GETPOST('search_import_key', 'int'); -$search_myfield=GETPOST('search_myfield'); +$search_myfield = GETPOST('search_myfield'); $optioncss = GETPOST('optioncss', 'alpha'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); @@ -62,11 +62,11 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield="t.batch"; // Set here default search field -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "t.batch"; // Set here default search field +if (!$sortorder) $sortorder = "ASC"; // Protection if external user -$socid=0; +$socid = 0; if ($user->socid > 0) { $socid = $user->socid; @@ -81,7 +81,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -90,7 +90,7 @@ $fieldstosearchall = array( ); // Definition of fields for list -$arrayfields=array( +$arrayfields = array( //'t.entity'=>array('label'=>$langs->trans("Fieldentity"), 'checked'=>1), 't.batch'=>array('label'=>$langs->trans("Batch"), 'checked'=>1), 't.fk_product'=>array('label'=>$langs->trans("Product"), 'checked'=>1), @@ -107,19 +107,19 @@ $arrayfields=array( // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); // Load object if id or ref is provided as parameter -if (($id > 0 || ! empty($ref)) && $action != 'add') +if (($id > 0 || !empty($ref)) && $action != 'add') { - $result=$object->fetch($id, $ref); + $result = $object->fetch($id, $ref); if ($result < 0) dol_print_error($db); } @@ -129,35 +129,35 @@ if (($id > 0 || ! empty($ref)) && $action != 'add') * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'confirm_presend') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $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 +$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'); include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria -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_entity=''; - $search_product=''; - $search_batch=''; - $search_fk_user_creat=''; - $search_fk_user_modif=''; - $search_import_key=''; - $search_date_creation=''; - $search_date_update=''; - $toselect=array(); - $search_array_options=array(); + $search_entity = ''; + $search_product = ''; + $search_batch = ''; + $search_fk_user_creat = ''; + $search_fk_user_modif = ''; + $search_import_key = ''; + $search_date_creation = ''; + $search_date_update = ''; + $toselect = array(); + $search_array_options = array(); } if (empty($reshook)) { - $objectclass='ProductLot'; - $objectlabel='LotSerial'; + $objectclass = 'ProductLot'; + $objectlabel = 'LotSerial'; $permissiontoread = $user->rights->stock->read; $permissiontodelete = $user->rights->stock->delete; $uploaddir = $conf->stock->dir_output; @@ -171,13 +171,13 @@ if (empty($reshook)) * VIEW */ -$now=dol_now(); +$now = dol_now(); -$form=new Form($db); -$productstatic=new Product($db); +$form = new Form($db); +$productstatic = new Product($db); //$help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes"; -$help_url=''; +$help_url = ''; $title = $langs->trans('LotSerialList'); llxHeader('', $title, $help_url); @@ -259,37 +259,37 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); dol_syslog($script_file, LOG_DEBUG); -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - $arrayofselected=is_array($toselect)?$toselect:array(); + $arrayofselected = is_array($toselect) ? $toselect : array(); - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_entity != '') $param.= '&search_entity='.urlencode($search_entity); - if ($search_product != '') $param.= '&search_product='.urlencode($search_product); - if ($search_batch != '') $param.= '&search_batch='.urlencode($search_batch); - if ($search_fk_user_creat != '') $param.= '&search_fk_user_creat='.urlencode($search_fk_user_creat); - if ($search_fk_user_modif != '') $param.= '&search_fk_user_modif='.urlencode($search_fk_user_modif); - if ($search_import_key != '') $param.= '&search_import_key='.urlencode($search_import_key); - if ($optioncss != '') $param.='&optioncss='.$optioncss; + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + if ($search_entity != '') $param .= '&search_entity='.urlencode($search_entity); + if ($search_product != '') $param .= '&search_product='.urlencode($search_product); + if ($search_batch != '') $param .= '&search_batch='.urlencode($search_batch); + if ($search_fk_user_creat != '') $param .= '&search_fk_user_creat='.urlencode($search_fk_user_creat); + if ($search_fk_user_modif != '') $param .= '&search_fk_user_modif='.urlencode($search_fk_user_modif); + if ($search_import_key != '') $param .= '&search_import_key='.urlencode($search_import_key); + if ($optioncss != '') $param .= '&optioncss='.$optioncss; // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - $arrayofmassactions = array( + $arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); //if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); - if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print ''; if ($optioncss != '') print ''; @@ -302,16 +302,16 @@ if ($resql) print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'products', 0, '', '', $limit); - $topicmail="Information"; - $modelmail="productlot"; - $objecttmp=new Productlot($db); - $trackid='lot'.$object->id; + $topicmail = "Information"; + $modelmail = "productlot"; + $objecttmp = new Productlot($db); + $trackid = 'lot'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } /*$moreforfilter = ''; @@ -319,48 +319,48 @@ if ($resql) $moreforfilter.= $langs->trans('MyFilter') . ': '; $moreforfilter.= '';*/ - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - if (! empty($moreforfilter)) + if (!empty($moreforfilter)) { print '
'; print $moreforfilter; print '
'; } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields print '
'; - print ''."\n"; + print '
'."\n"; // Fields title search print ''; - if (! empty($arrayfields['t.entity']['checked'])) print ''; - if (! empty($arrayfields['t.batch']['checked'])) print ''; - if (! empty($arrayfields['t.fk_product']['checked'])) print ''; - if (! empty($arrayfields['t.sellby']['checked'])) print ''; - if (! empty($arrayfields['t.eatby']['checked'])) print ''; - if (! empty($arrayfields['t.fk_user_creat']['checked'])) print ''; - if (! empty($arrayfields['t.fk_user_modif']['checked'])) print ''; - if (! empty($arrayfields['t.import_key']['checked'])) print ''; + if (!empty($arrayfields['t.entity']['checked'])) print ''; + if (!empty($arrayfields['t.batch']['checked'])) print ''; + if (!empty($arrayfields['t.fk_product']['checked'])) print ''; + if (!empty($arrayfields['t.sellby']['checked'])) print ''; + if (!empty($arrayfields['t.eatby']['checked'])) print ''; + if (!empty($arrayfields['t.fk_user_creat']['checked'])) print ''; + if (!empty($arrayfields['t.fk_user_modif']['checked'])) print ''; + if (!empty($arrayfields['t.import_key']['checked'])) print ''; // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['t.datec']['checked'])) + if (!empty($arrayfields['t.datec']['checked'])) { // Date creation print ''; } - if (! empty($arrayfields['t.tms']['checked'])) + if (!empty($arrayfields['t.tms']['checked'])) { // Date modification print ''; print ''."\n"; // Fields title print ''; - if (! empty($arrayfields['t.entity']['checked'])) print_liste_field_titre($arrayfields['t.entity']['label'], $_SERVER['PHP_SELF'], 't.entity', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['t.batch']['checked'])) print_liste_field_titre($arrayfields['t.batch']['label'], $_SERVER['PHP_SELF'], 't.batch', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['t.fk_product']['checked'])) print_liste_field_titre($arrayfields['t.fk_product']['label'], $_SERVER['PHP_SELF'], 't.fk_product', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['t.sellby']['checked'])) print_liste_field_titre($arrayfields['t.sellby']['label'], $_SERVER['PHP_SELF'], 't.sellby', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['t.eatby']['checked'])) print_liste_field_titre($arrayfields['t.eatby']['label'], $_SERVER['PHP_SELF'], 't.eatby', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['t.fk_user_creat']['checked'])) print_liste_field_titre($arrayfields['t.fk_user_creat']['label'], $_SERVER['PHP_SELF'], 't.fk_user_creat', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['t.fk_user_modif']['checked'])) print_liste_field_titre($arrayfields['t.fk_user_modif']['label'], $_SERVER['PHP_SELF'], 't.fk_user_modif', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['t.import_key']['checked'])) print_liste_field_titre($arrayfields['t.import_key']['label'], $_SERVER['PHP_SELF'], 't.import_key', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.entity']['checked'])) print_liste_field_titre($arrayfields['t.entity']['label'], $_SERVER['PHP_SELF'], 't.entity', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.batch']['checked'])) print_liste_field_titre($arrayfields['t.batch']['label'], $_SERVER['PHP_SELF'], 't.batch', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.fk_product']['checked'])) print_liste_field_titre($arrayfields['t.fk_product']['label'], $_SERVER['PHP_SELF'], 't.fk_product', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.sellby']['checked'])) print_liste_field_titre($arrayfields['t.sellby']['label'], $_SERVER['PHP_SELF'], 't.sellby', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.eatby']['checked'])) print_liste_field_titre($arrayfields['t.eatby']['label'], $_SERVER['PHP_SELF'], 't.eatby', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.fk_user_creat']['checked'])) print_liste_field_titre($arrayfields['t.fk_user_creat']['label'], $_SERVER['PHP_SELF'], 't.fk_user_creat', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.fk_user_modif']['checked'])) print_liste_field_titre($arrayfields['t.fk_user_modif']['label'], $_SERVER['PHP_SELF'], 't.fk_user_modif', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.import_key']['checked'])) print_liste_field_titre($arrayfields['t.import_key']['label'], $_SERVER['PHP_SELF'], 't.import_key', '', $param, '', $sortfield, $sortorder); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['t.datec']['checked'])) { + if (!empty($arrayfields['t.datec']['checked'])) { print_liste_field_titre($arrayfields['t.datec']['label'], $_SERVER["PHP_SELF"], "t.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } - if (! empty($arrayfields['t.tms']['checked'])) { + if (!empty($arrayfields['t.tms']['checked'])) { print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER["PHP_SELF"], "t.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); } //if (! empty($arrayfields['t.status']['checked'])) { @@ -410,8 +410,8 @@ if ($resql) $productlot = new Productlot($db); - $i=0; - $totalarray=array(); + $i = 0; + $totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); @@ -422,72 +422,72 @@ if ($resql) // You can use here results print ''; - if (! empty($arrayfields['t.entity']['checked'])) + if (!empty($arrayfields['t.entity']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['t.batch']['checked'])) + if (!empty($arrayfields['t.batch']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['t.fk_product']['checked'])) + if (!empty($arrayfields['t.fk_product']['checked'])) { - $productstatic->id=$obj->fk_product; - $productstatic->type=$obj->product_type; - $productstatic->ref=$obj->product_ref; - $productstatic->label=$obj->product_label; + $productstatic->id = $obj->fk_product; + $productstatic->type = $obj->product_type; + $productstatic->ref = $obj->product_ref; + $productstatic->label = $obj->product_label; $productstatic->status_batch = $obj->tobatch; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['t.sellby']['checked'])) + if (!empty($arrayfields['t.sellby']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['t.eatby']['checked'])) + if (!empty($arrayfields['t.eatby']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['t.fk_user_creat']['checked'])) + if (!empty($arrayfields['t.fk_user_creat']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['t.fk_user_modif']['checked'])) + if (!empty($arrayfields['t.fk_user_modif']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['t.import_key']['checked'])) + if (!empty($arrayfields['t.import_key']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['t.datec']['checked'])) + if (!empty($arrayfields['t.datec']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date modification - if (! empty($arrayfields['t.tms']['checked'])) + if (!empty($arrayfields['t.tms']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Status /* @@ -501,12 +501,12 @@ if ($resql) print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print ''; } @@ -518,8 +518,8 @@ if ($resql) $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 + $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 '
'; print ''; @@ -375,31 +375,31 @@ if ($resql) }*/ // Action column print ''; - $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); + $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); print $searchpicto; print '
'.$obj->entity.''.$productlot->getNomUrl(1).''.$productstatic->getNomUrl(1).''.dol_print_date($db->jdate($obj->sellby), 'day').''.dol_print_date($db->jdate($obj->eatby), 'day').''.$obj->fk_user_creat.''.$obj->fk_user_modif.''.$obj->import_key.''; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; } print '
'."\n"; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 61a96af9f58..d5c37b81fa6 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -37,17 +37,17 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; // Load translation files required by the page $langs->loadLangs(array('projects', 'companies', 'commercial')); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'projectlist'; +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'projectlist'; $title = $langs->trans("Projects"); // Security check -$socid = (is_numeric($_GET["socid"]) ? $_GET["socid"] : 0 ); +$socid = (is_numeric($_GET["socid"]) ? $_GET["socid"] : 0); //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. if ($socid > 0) { @@ -57,40 +57,40 @@ if ($socid > 0) } if (!$user->rights->projet->lire) accessforbidden(); -$diroutputmassaction=$conf->projet->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->projet->dir_output.'/temp/massgeneration/'.$user->id; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", "alpha"); $sortorder = GETPOST("sortorder"); $page = GETPOST("page"); $page = is_numeric($page) ? $page : 0; $page = $page == -1 ? 0 : $page; -if (! $sortfield) $sortfield="p.ref"; -if (! $sortorder) $sortorder="ASC"; -$offset = $limit * $page ; +if (!$sortfield) $sortfield = "p.ref"; +if (!$sortorder) $sortorder = "ASC"; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -$search_all=GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'); -$search_categ=GETPOST("search_categ", 'alpha'); -$search_ref=GETPOST("search_ref", 'alpha'); -$search_label=GETPOST("search_label", 'alpha'); -$search_societe=GETPOST("search_societe", 'alpha'); -$search_status=GETPOST("search_status", 'int'); -$search_opp_status=GETPOST("search_opp_status", 'alpha'); -$search_opp_percent=GETPOST("search_opp_percent", 'alpha'); -$search_opp_amount=GETPOST("search_opp_amount", 'alpha'); -$search_budget_amount=GETPOST("search_budget_amount", 'alpha'); -$search_public=GETPOST("search_public", 'int'); -$search_project_user=GETPOST('search_project_user', 'int'); -$search_sale=GETPOST('search_sale', 'int'); -$search_usage_opportunity=GETPOST('search_usage_opportunity', 'int'); -$search_usage_task=GETPOST('search_usage_task', 'int'); -$search_usage_bill_time=GETPOST('search_usage_bill_time', 'int'); +$search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'); +$search_categ = GETPOST("search_categ", 'alpha'); +$search_ref = GETPOST("search_ref", 'alpha'); +$search_label = GETPOST("search_label", 'alpha'); +$search_societe = GETPOST("search_societe", 'alpha'); +$search_status = GETPOST("search_status", 'int'); +$search_opp_status = GETPOST("search_opp_status", 'alpha'); +$search_opp_percent = GETPOST("search_opp_percent", 'alpha'); +$search_opp_amount = GETPOST("search_opp_amount", 'alpha'); +$search_budget_amount = GETPOST("search_budget_amount", 'alpha'); +$search_public = GETPOST("search_public", 'int'); +$search_project_user = GETPOST('search_project_user', 'int'); +$search_sale = GETPOST('search_sale', 'int'); +$search_usage_opportunity = GETPOST('search_usage_opportunity', 'int'); +$search_usage_task = GETPOST('search_usage_task', 'int'); +$search_usage_bill_time = GETPOST('search_usage_bill_time', 'int'); $optioncss = GETPOST('optioncss', 'alpha'); -$mine = $_REQUEST['mode']=='mine' ? 1 : 0; -if ($mine) { $search_project_user = $user->id; $mine=0; } +$mine = $_REQUEST['mode'] == 'mine' ? 1 : 0; +if ($mine) { $search_project_user = $user->id; $mine = 0; } $search_sday = GETPOST('search_sday', 'int'); $search_smonth = GETPOST('search_smonth', 'int'); @@ -99,7 +99,7 @@ $search_eday = GETPOST('search_eday', 'int'); $search_emonth = GETPOST('search_emonth', 'int'); $search_eyear = GETPOST('search_eyear', 'int'); -if ($search_status == '') $search_status=-1; // -1 or 1 +if ($search_status == '') $search_status = -1; // -1 or 1 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Project($db); @@ -109,7 +109,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -118,23 +118,23 @@ $fieldstosearchall = array( 's.nom'=>"ThirdPartyName", "p.note_public"=>"NotePublic" ); -if (empty($user->socid)) $fieldstosearchall["p.note_private"]="NotePrivate"; +if (empty($user->socid)) $fieldstosearchall["p.note_private"] = "NotePrivate"; -$arrayfields=array( +$arrayfields = array( 'p.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'p.title'=>array('label'=>$langs->trans("Label"), 'checked'=>1), - 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'enabled'=>(empty($conf->societe->enabled)?0:1)), + 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'enabled'=>(empty($conf->societe->enabled) ? 0 : 1)), 'commercial'=>array('label'=>$langs->trans("SaleRepresentativesOfThirdParty"), 'checked'=>0), 'p.dateo'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1, 'position'=>100), 'p.datee'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1, 'position'=>101), 'p.public'=>array('label'=>$langs->trans("Visibility"), 'checked'=>1, 'position'=>102), - 'p.opp_amount'=>array('label'=>$langs->trans("OpportunityAmountShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>103), - 'p.fk_opp_status'=>array('label'=>$langs->trans("OpportunityStatusShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>104), - 'p.opp_percent'=>array('label'=>$langs->trans("OpportunityProbabilityShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>105), + 'p.opp_amount'=>array('label'=>$langs->trans("OpportunityAmountShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES ? 1 : 0), 'position'=>103), + 'p.fk_opp_status'=>array('label'=>$langs->trans("OpportunityStatusShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES ? 1 : 0), 'position'=>104), + 'p.opp_percent'=>array('label'=>$langs->trans("OpportunityProbabilityShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES ? 1 : 0), 'position'=>105), 'p.budget_amount'=>array('label'=>$langs->trans("Budget"), 'checked'=>0, 'position'=>110), - 'p.usage_opportunity'=>array('label'=>$langs->trans("UsageOpportunity"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>115), - 'p.usage_task'=>array('label'=>$langs->trans("UsageTasks"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_HIDE_TASKS?0:1), 'position'=>116), - 'p.usage_bill_time'=>array('label'=>$langs->trans("UsageBillTimeShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_HIDE_TASKS?0:1), 'position'=>117), + 'p.usage_opportunity'=>array('label'=>$langs->trans("UsageOpportunity"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES ? 1 : 0), 'position'=>115), + 'p.usage_task'=>array('label'=>$langs->trans("UsageTasks"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_HIDE_TASKS ? 0 : 1), 'position'=>116), + 'p.usage_bill_time'=>array('label'=>$langs->trans("UsageBillTimeShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_HIDE_TASKS ? 0 : 1), 'position'=>117), 'p.datec'=>array('label'=>$langs->trans("DateCreationShort"), 'checked'=>0, 'position'=>500), 'p.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), 'p.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), @@ -142,10 +142,10 @@ $arrayfields=array( // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -157,11 +157,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; } -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) @@ -172,51 +172,51 @@ if (empty($reshook)) // Purge search criteria 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_all=''; - $search_categ=''; - $search_ref=""; - $search_label=""; - $search_societe=""; - $search_status=-1; - $search_opp_status=-1; - $search_opp_amount=''; - $search_opp_percent=''; - $search_budget_amount=''; - $search_public=""; - $search_sale=""; - $search_project_user=''; - $search_sday=""; - $search_smonth=""; - $search_syear=""; - $search_eday=""; - $search_emonth=""; - $search_eyear=""; - $search_usage_opportunity=''; - $search_usage_task=''; - $search_usage_bill_time=''; - $toselect=''; - $search_array_options=array(); + $search_all = ''; + $search_categ = ''; + $search_ref = ""; + $search_label = ""; + $search_societe = ""; + $search_status = -1; + $search_opp_status = -1; + $search_opp_amount = ''; + $search_opp_percent = ''; + $search_budget_amount = ''; + $search_public = ""; + $search_sale = ""; + $search_project_user = ''; + $search_sday = ""; + $search_smonth = ""; + $search_syear = ""; + $search_eday = ""; + $search_emonth = ""; + $search_eyear = ""; + $search_usage_opportunity = ''; + $search_usage_task = ''; + $search_usage_bill_time = ''; + $toselect = ''; + $search_array_options = array(); } // Mass actions - $objectclass='Project'; - $objectlabel='Project'; + $objectclass = 'Project'; + $objectlabel = 'Project'; $permissiontoread = $user->rights->projet->lire; $permissiontodelete = $user->rights->projet->supprimer; $uploaddir = $conf->projet->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; // Close records - if (! $error && $massaction == 'close' && $user->rights->projet->creer) + if (!$error && $massaction == 'close' && $user->rights->projet->creer) { $db->begin(); - $objecttmp=new $objectclass($db); + $objecttmp = new $objectclass($db); $nbok = 0; - foreach($toselect as $toselectid) + foreach ($toselect as $toselectid) { - $result=$objecttmp->fetch($toselectid); + $result = $objecttmp->fetch($toselectid); if ($result > 0) { $userWrite = $object->restrictedProjectArea($user, 'write'); @@ -227,7 +227,7 @@ if (empty($reshook)) $error++; break; } else $nbok++; - } elseif($userWrite <= 0) { + } elseif ($userWrite <= 0) { setEventMessages($langs->trans("DontHavePermissionForCloseProject", $objecttmp->ref), null, 'warnings'); } else { setEventMessages($langs->trans("DontHaveTheValidateStatus", $objecttmp->ref), null, 'warnings'); @@ -241,7 +241,7 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { if ($nbok > 1) setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs'); else setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs'); @@ -264,64 +264,64 @@ $form = new Form($db); $formother = new FormOther($db); $formproject = new FormProjets($db); -$title=$langs->trans("Projects"); +$title = $langs->trans("Projects"); // Get list of project id allowed to user (in a string list separated by coma) -$projectsListId=''; -if (! $user->rights->projet->all->lire) $projectsListId = $object->getProjectsAuthorizedForUser($user, 0, 1, $socid); +$projectsListId = ''; +if (!$user->rights->projet->all->lire) $projectsListId = $object->getProjectsAuthorizedForUser($user, 0, 1, $socid); // Get id of types of contacts for projects (This list never contains a lot of elements) -$listofprojectcontacttype=array(); +$listofprojectcontacttype = array(); $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc"; -$sql.= " WHERE ctc.element = '" . $object->element . "'"; -$sql.= " AND ctc.source = 'internal'"; +$sql .= " WHERE ctc.element = '".$object->element."'"; +$sql .= " AND ctc.source = 'internal'"; $resql = $db->query($sql); if ($resql) { - while($obj = $db->fetch_object($resql)) + while ($obj = $db->fetch_object($resql)) { - $listofprojectcontacttype[$obj->rowid]=$obj->code; + $listofprojectcontacttype[$obj->rowid] = $obj->code; } } else dol_print_error($db); -if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0'; // To avoid sql syntax error if not found +if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found -$distinct='DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is only once. +$distinct = 'DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is only once. $sql = "SELECT ".$distinct." p.rowid as id, p.ref, p.title, p.fk_statut, p.fk_opp_status, p.public, p.fk_user_creat"; -$sql.= ", p.datec as date_creation, p.dateo as date_start, p.datee as date_end, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount, p.usage_opportunity, p.usage_task, p.usage_bill_time"; -$sql.= ", s.rowid as socid, s.nom as name, s.email"; -$sql.= ", cls.code as opp_status_code"; +$sql .= ", p.datec as date_creation, p.dateo as date_start, p.datee as date_end, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount, p.usage_opportunity, p.usage_task, p.usage_bill_time"; +$sql .= ", s.rowid as socid, s.nom as name, s.email"; +$sql .= ", cls.code as opp_status_code"; // We'll need these fields in order to filter by categ if ($search_categ) $sql .= ", cs.fk_categorie, cs.fk_project"; // 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 : ''); +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 : ''); } // 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 ".MAIN_DB_PREFIX."projet as p"; -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 (p.rowid = ef.fk_object)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls on p.fk_opp_status = cls.rowid"; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; +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 (p.rowid = ef.fk_object)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls on p.fk_opp_status = cls.rowid"; // We'll need this table joined to the select in order to filter by categ -if (! empty($search_categ)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_project as cs ON p.rowid = cs.fk_project"; // We'll need this table joined to the select in order to filter by categ +if (!empty($search_categ)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_project as cs ON p.rowid = cs.fk_project"; // We'll need this table joined to the select in order to filter by categ // We'll need this table joined to the select in order to filter by sale // No check is done on company permission because readability is managed by public status of project and assignement. //if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; if ($search_sale > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; if ($search_project_user > 0) { - $sql.=", ".MAIN_DB_PREFIX."element_contact as ecp"; + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ecp"; } -$sql.= " WHERE p.entity IN (".getEntity('project').')'; -if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users +$sql .= " WHERE p.entity IN (".getEntity('project').')'; +if (!$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users // No need to check if company is external user, as filtering of projects must be done by getProjectsAuthorizedForUser -if ($socid > 0) $sql.= " AND (p.fk_soc = ".$socid.")"; // This filter if when we use a hard coded filter on company on url (not related to filter for external users) -if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ); -if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL"; +if ($socid > 0) $sql .= " AND (p.fk_soc = ".$socid.")"; // This filter if when we use a hard coded filter on company on url (not related to filter for external users) +if ($search_categ > 0) $sql .= " AND cs.fk_categorie = ".$db->escape($search_categ); +if ($search_categ == -2) $sql .= " AND cs.fk_categorie IS NULL"; if ($search_ref) $sql .= natural_search('p.ref', $search_ref); if ($search_label) $sql .= natural_search('p.title', $search_label); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); @@ -343,13 +343,13 @@ if ($search_opp_status) if ($search_opp_status == 'notopenedopp') $sql .= " AND (p.fk_opp_status IS NULL OR p.fk_opp_status = -1 OR p.fk_opp_status IN (SELECT rowid FROM ".MAIN_DB_PREFIX."c_lead_status WHERE code IN ('WON')))"; if ($search_opp_status == 'none') $sql .= " AND (p.fk_opp_status IS NULL OR p.fk_opp_status = -1)"; } -if ($search_public!='') $sql .= " AND p.public = ".$db->escape($search_public); +if ($search_public != '') $sql .= " AND p.public = ".$db->escape($search_public); // For external user, no check is done on company permission because readability is managed by public status of project and assignement. //if ($socid > 0) $sql.= " AND s.rowid = ".$socid; -if ($search_sale > 0) $sql.= " AND sc.fk_user = " .$search_sale; +if ($search_sale > 0) $sql .= " AND sc.fk_user = ".$search_sale; // No check is done on company permission because readability is managed by public status of project and assignement. //if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; -if ($search_project_user > 0) $sql.= " AND ecp.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_project_user; +if ($search_project_user > 0) $sql .= " AND ecp.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_project_user; if ($search_opp_amount != '') $sql .= natural_search('p.opp_amount', $search_opp_amount, 1); if ($search_budget_amount != '') $sql .= natural_search('p.budget_amount', $search_budget_amount, 1); if ($search_usage_opportunity != '' && $search_usage_opportunity >= 0) $sql .= natural_search('p.usage_opportunity', $search_usage_opportunity, 2); @@ -358,10 +358,10 @@ if ($search_usage_bill_time != '' && $search_usage_bill_time >= 0) $sql .= n // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -375,12 +375,12 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit + 1, $offset); +$sql .= $db->plimit($limit + 1, $offset); dol_syslog("list allowed project", LOG_DEBUG); $resql = $db->query($sql); -if (! $resql) +if (!$resql) { dol_print_error($db); exit; @@ -388,61 +388,61 @@ if (! $resql) $num = $db->num_rows($resql); -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); header("Location: ".DOL_URL_ROOT.'/projet/card.php?id='.$obj->id); exit; } -$help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; +$help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; llxHeader("", $title, $help_url); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; -if ($search_all != '') $param.='&search_all='.$search_all; -if ($search_sday) $param.='&search_sday='.$search_sday; -if ($search_smonth) $param.='&search_smonth='.$search_smonth; -if ($search_syear) $param.='&search_syear=' .$search_syear; -if ($search_eday) $param.='&search_eday='.$search_eday; -if ($search_emonth) $param.='&search_emonth='.$search_emonth; -if ($search_eyear) $param.='&search_eyear=' .$search_eyear; -if ($socid) $param.='&socid='.$socid; -if ($search_ref != '') $param.='&search_ref='.$search_ref; -if ($search_label != '') $param.='&search_label='.$search_label; -if ($search_societe != '') $param.='&search_societe='.$search_societe; -if ($search_status >= 0) $param.='&search_status='.$search_status; -if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all','openedopp','notopenedopp','none'))) $param.='&search_opp_status='.urlencode($search_opp_status); -if ($search_opp_percent != '') $param.='&search_opp_percent='.urlencode($search_opp_percent); -if ($search_public != '') $param.='&search_public='.$search_public; -if ($search_project_user != '') $param.='&search_project_user='.$search_project_user; -if ($search_sale > 0) $param.='&search_sale='.$search_sale; -if ($search_opp_amount != '') $param.='&search_opp_amount='.$search_opp_amount; -if ($search_budget_amount != '') $param.='&search_budget_amount='.$search_budget_amount; -if ($optioncss != '') $param.='&optioncss='.$optioncss; +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; +if ($search_all != '') $param .= '&search_all='.$search_all; +if ($search_sday) $param .= '&search_sday='.$search_sday; +if ($search_smonth) $param .= '&search_smonth='.$search_smonth; +if ($search_syear) $param .= '&search_syear='.$search_syear; +if ($search_eday) $param .= '&search_eday='.$search_eday; +if ($search_emonth) $param .= '&search_emonth='.$search_emonth; +if ($search_eyear) $param .= '&search_eyear='.$search_eyear; +if ($socid) $param .= '&socid='.$socid; +if ($search_ref != '') $param .= '&search_ref='.$search_ref; +if ($search_label != '') $param .= '&search_label='.$search_label; +if ($search_societe != '') $param .= '&search_societe='.$search_societe; +if ($search_status >= 0) $param .= '&search_status='.$search_status; +if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all', 'openedopp', 'notopenedopp', 'none'))) $param .= '&search_opp_status='.urlencode($search_opp_status); +if ($search_opp_percent != '') $param .= '&search_opp_percent='.urlencode($search_opp_percent); +if ($search_public != '') $param .= '&search_public='.$search_public; +if ($search_project_user != '') $param .= '&search_project_user='.$search_project_user; +if ($search_sale > 0) $param .= '&search_sale='.$search_sale; +if ($search_opp_amount != '') $param .= '&search_opp_amount='.$search_opp_amount; +if ($search_budget_amount != '') $param .= '&search_budget_amount='.$search_budget_amount; +if ($optioncss != '') $param .= '&optioncss='.$optioncss; // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( 'generate_doc'=>$langs->trans("ReGeneratePDF"), //'builddoc'=>$langs->trans("PDFMerge"), //'presend'=>$langs->trans("SendByMail"), ); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); -if ($user->rights->projet->creer) $arrayofmassactions['close']=$langs->trans("Close"); -if ($user->rights->societe->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); -if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); +if ($user->rights->projet->creer) $arrayofmassactions['close'] = $langs->trans("Close"); +if ($user->rights->societe->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); -$newcardbutton=''; +$newcardbutton = ''; if ($user->rights->projet->creer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewProject'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewProject'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?action=create'); } print ''; @@ -457,173 +457,173 @@ print ''; print ''; // Show description of content -$texthelp=''; -if ($search_project_user == $user->id) $texthelp.=$langs->trans("MyProjectsDesc"); +$texthelp = ''; +if ($search_project_user == $user->id) $texthelp .= $langs->trans("MyProjectsDesc"); else { - if ($user->rights->projet->all->lire && ! $socid) $texthelp.=$langs->trans("ProjectsDesc"); - else $texthelp.=$langs->trans("ProjectsPublicDesc"); + if ($user->rights->projet->all->lire && !$socid) $texthelp .= $langs->trans("ProjectsDesc"); + else $texthelp .= $langs->trans("ProjectsPublicDesc"); } print_barre_liste($form->textwithpicto($title, $texthelp), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'project', 0, $newcardbutton, '', $limit); -$topicmail="Information"; -$modelmail="project"; -$objecttmp=new Project($db); -$trackid='prj'.$object->id; +$topicmail = "Information"; +$modelmail = "project"; +$objecttmp = new Project($db); +$trackid = 'prj'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; } -$moreforfilter=''; +$moreforfilter = ''; // Filter on categories -if (! empty($conf->categorie->enabled)) +if (!empty($conf->categorie->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('ProjectCategories'). ': '; - $moreforfilter.=$formother->select_categories('project', $search_categ, 'search_categ', 1, 1, 'maxwidth300'); - $moreforfilter.='
'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('ProjectCategories').': '; + $moreforfilter .= $formother->select_categories('project', $search_categ, 'search_categ', 1, 1, 'maxwidth300'); + $moreforfilter .= '
'; } // If the user can view user other than himself -$moreforfilter.='
'; -$moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ': '; -$includeonly='hierarchyme'; -if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); -$moreforfilter.=$form->select_dolusers($search_project_user?$search_project_user:'', 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); -$moreforfilter.='
'; +$moreforfilter .= '
'; +$moreforfilter .= $langs->trans('ProjectsWithThisUserAsContact').': '; +$includeonly = 'hierarchyme'; +if (empty($user->rights->user->user->lire)) $includeonly = array($user->id); +$moreforfilter .= $form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); +$moreforfilter .= '
'; // If the user can view thirdparties other than his' if ($user->rights->societe->client->voir || $socid) { $langs->load("commercial"); - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); - $moreforfilter.='
'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; + $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); + $moreforfilter .= '
'; } -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '
'; print $moreforfilter; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; } -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); print '
'; -print ''."\n"; +print '
'."\n"; print ''; // Project ref -if (! empty($arrayfields['p.ref']['checked'])) +if (!empty($arrayfields['p.ref']['checked'])) { print ''; } // Project label -if (! empty($arrayfields['p.title']['checked'])) +if (!empty($arrayfields['p.title']['checked'])) { print ''; } // Third party -if (! empty($arrayfields['s.nom']['checked'])) +if (!empty($arrayfields['s.nom']['checked'])) { print ''; } // Sale representative -if (! empty($arrayfields['commercial']['checked'])) +if (!empty($arrayfields['commercial']['checked'])) { print ''; } // Start date -if (! empty($arrayfields['p.dateo']['checked'])) +if (!empty($arrayfields['p.dateo']['checked'])) { print ''; } // End date -if (! empty($arrayfields['p.datee']['checked'])) +if (!empty($arrayfields['p.datee']['checked'])) { print ''; } -if (! empty($arrayfields['p.public']['checked'])) +if (!empty($arrayfields['p.public']['checked'])) { print ''; } // Opp status -if (! empty($arrayfields['p.fk_opp_status']['checked'])) +if (!empty($arrayfields['p.fk_opp_status']['checked'])) { print ''; } -if (! empty($arrayfields['p.opp_amount']['checked'])) +if (!empty($arrayfields['p.opp_amount']['checked'])) { print ''; } -if (! empty($arrayfields['p.opp_percent']['checked'])) +if (!empty($arrayfields['p.opp_percent']['checked'])) { print ''; } -if (! empty($arrayfields['p.budget_amount']['checked'])) +if (!empty($arrayfields['p.budget_amount']['checked'])) { print ''; } -if (! empty($arrayfields['p.usage_opportunity']['checked'])) +if (!empty($arrayfields['p.usage_opportunity']['checked'])) { print ''; } -if (! empty($arrayfields['p.usage_task']['checked'])) +if (!empty($arrayfields['p.usage_task']['checked'])) { print ''; } -if (! empty($arrayfields['p.usage_bill_time']['checked'])) +if (!empty($arrayfields['p.usage_bill_time']['checked'])) { print ''; } -if (! empty($arrayfields['p.tms']['checked'])) +if (!empty($arrayfields['p.tms']['checked'])) { // Date modification print ''; } -if (! empty($arrayfields['p.fk_statut']['checked'])) +if (!empty($arrayfields['p.fk_statut']['checked'])) { print ''; } // Action column print ''; print ''."\n"; print ''; -if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['commercial']['checked'])) print_liste_field_titre($arrayfields['commercial']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['p.dateo']['checked'])) print_liste_field_titre($arrayfields['p.dateo']['label'], $_SERVER["PHP_SELF"], "p.dateo", "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['p.datee']['checked'])) print_liste_field_titre($arrayfields['p.datee']['label'], $_SERVER["PHP_SELF"], "p.datee", "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['p.public']['checked'])) print_liste_field_titre($arrayfields['p.public']['label'], $_SERVER["PHP_SELF"], "p.public", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['p.fk_opp_status']['checked'])) print_liste_field_titre($arrayfields['p.fk_opp_status']['label'], $_SERVER["PHP_SELF"], 'p.fk_opp_status', "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['p.opp_amount']['checked'])) print_liste_field_titre($arrayfields['p.opp_amount']['label'], $_SERVER["PHP_SELF"], 'p.opp_amount', "", $param, '', $sortfield, $sortorder, 'right '); -if (! empty($arrayfields['p.opp_percent']['checked'])) print_liste_field_titre($arrayfields['p.opp_percent']['label'], $_SERVER["PHP_SELF"], 'p.opp_percent', "", $param, '', $sortfield, $sortorder, 'right '); -if (! empty($arrayfields['p.budget_amount']['checked'])) print_liste_field_titre($arrayfields['p.budget_amount']['label'], $_SERVER["PHP_SELF"], 'p.budget_amount', "", $param, '', $sortfield, $sortorder, 'right '); -if (! empty($arrayfields['p.usage_opportunity']['checked'])) print_liste_field_titre($arrayfields['p.usage_opportunity']['label'], $_SERVER["PHP_SELF"], 'p.usage_opportunity', "", $param, '', $sortfield, $sortorder, 'right '); -if (! empty($arrayfields['p.usage_task']['checked'])) print_liste_field_titre($arrayfields['p.usage_task']['label'], $_SERVER["PHP_SELF"], 'p.usage_task', "", $param, '', $sortfield, $sortorder, 'right '); -if (! empty($arrayfields['p.usage_bill_time']['checked'])) print_liste_field_titre($arrayfields['p.usage_bill_time']['label'], $_SERVER["PHP_SELF"], 'p.usage_bill_time', "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['commercial']['checked'])) print_liste_field_titre($arrayfields['commercial']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['p.dateo']['checked'])) print_liste_field_titre($arrayfields['p.dateo']['label'], $_SERVER["PHP_SELF"], "p.dateo", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['p.datee']['checked'])) print_liste_field_titre($arrayfields['p.datee']['label'], $_SERVER["PHP_SELF"], "p.datee", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['p.public']['checked'])) print_liste_field_titre($arrayfields['p.public']['label'], $_SERVER["PHP_SELF"], "p.public", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['p.fk_opp_status']['checked'])) print_liste_field_titre($arrayfields['p.fk_opp_status']['label'], $_SERVER["PHP_SELF"], 'p.fk_opp_status', "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['p.opp_amount']['checked'])) print_liste_field_titre($arrayfields['p.opp_amount']['label'], $_SERVER["PHP_SELF"], 'p.opp_amount', "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['p.opp_percent']['checked'])) print_liste_field_titre($arrayfields['p.opp_percent']['label'], $_SERVER["PHP_SELF"], 'p.opp_percent', "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['p.budget_amount']['checked'])) print_liste_field_titre($arrayfields['p.budget_amount']['label'], $_SERVER["PHP_SELF"], 'p.budget_amount', "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['p.usage_opportunity']['checked'])) print_liste_field_titre($arrayfields['p.usage_opportunity']['label'], $_SERVER["PHP_SELF"], 'p.usage_opportunity', "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['p.usage_task']['checked'])) print_liste_field_titre($arrayfields['p.usage_task']['label'], $_SERVER["PHP_SELF"], 'p.usage_task', "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['p.usage_bill_time']['checked'])) print_liste_field_titre($arrayfields['p.usage_bill_time']['label'], $_SERVER["PHP_SELF"], 'p.usage_bill_time', "", $param, '', $sortfield, $sortorder, 'right '); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -if (! empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -if (! empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +if (!empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +if (!empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; -$i=0; -$totalarray=array(); +$i = 0; +$totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); @@ -708,34 +708,34 @@ while ($i < min($num, $limit)) $object->opp_status = $obj->fk_opp_status; $object->title = $obj->title; - $userAccess = $object->restrictedProjectArea($user); // why this ? + $userAccess = $object->restrictedProjectArea($user); // why this ? if ($userAccess >= 0) { - $socstatic->id=$obj->socid; - $socstatic->name=$obj->name; - $socstatic->email=$obj->email; + $socstatic->id = $obj->socid; + $socstatic->name = $obj->name; + $socstatic->email = $obj->email; print ''; // Project url - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Title - if (! empty($arrayfields['p.title']['checked'])) + if (!empty($arrayfields['p.title']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Company - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Sales Representatives - if (! empty($arrayfields['commercial']['checked'])) + if (!empty($arrayfields['commercial']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date start - if (! empty($arrayfields['p.dateo']['checked'])) + if (!empty($arrayfields['p.dateo']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date end - if (! empty($arrayfields['p.datee']['checked'])) + if (!empty($arrayfields['p.datee']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Visibility - if (! empty($arrayfields['p.public']['checked'])) + if (!empty($arrayfields['p.public']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Opp Status - if (! empty($arrayfields['p.fk_opp_status']['checked'])) + if (!empty($arrayfields['p.fk_opp_status']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Opp Amount - if (! empty($arrayfields['p.opp_amount']['checked'])) + if (!empty($arrayfields['p.opp_amount']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Usage task - if (! empty($arrayfields['p.usage_task']['checked'])) + if (!empty($arrayfields['p.usage_task']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Bill time - if (! empty($arrayfields['p.usage_bill_time']['checked'])) + if (!empty($arrayfields['p.usage_bill_time']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['p.datec']['checked'])) + if (!empty($arrayfields['p.datec']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date modification - if (! empty($arrayfields['p.tms']['checked'])) + if (!empty($arrayfields['p.tms']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Status - if (! empty($arrayfields['p.fk_statut']['checked'])) + if (!empty($arrayfields['p.fk_statut']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Action column print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "\n"; } @@ -944,8 +944,8 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; $db->free($resql); -$parameters=array('sql' => $sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('sql' => $sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print "
'; print ''; print ''; print ''; print ''; if ($socid > 0) { - $tmpthirdparty=new Societe($db); + $tmpthirdparty = new Societe($db); $tmpthirdparty->fetch($socid); - $search_societe=$tmpthirdparty->nom; + $search_societe = $tmpthirdparty->nom; } print ''; print ' '; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; - $formother->select_year($search_syear?$search_syear:-1, 'search_syear', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); + $formother->select_year($search_syear ? $search_syear : -1, 'search_syear', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; - $formother->select_year($search_eyear?$search_eyear:-1, 'search_eyear', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); + $formother->select_year($search_eyear ? $search_eyear : -1, 'search_eyear', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); print ''; - $array=array(''=>'',0 => $langs->trans("PrivateProject"),1 => $langs->trans("SharedProject")); + $array = array(''=>'', 0 => $langs->trans("PrivateProject"), 1 => $langs->trans("SharedProject")); print $form->selectarray('search_public', $array, $search_public); print ''; print $formproject->selectOpportunityStatus('search_opp_status', $search_opp_status, 1, 0, 1, 0, 'maxwidth100'); print ''; print ''; print ''; print ''; print ''; print ''; print ''; print $form->selectyesno('search_usage_opportunity', $search_usage_opportunity, 1, false, 1); print ''; print ''; print $form->selectyesno('search_usage_task', $search_usage_task, 1, false, 1); print ''; print $form->selectyesno('search_usage_bill_time', $search_usage_bill_time, 1, false, 1); @@ -633,68 +633,68 @@ if (! empty($arrayfields['p.usage_bill_time']['checked'])) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (! empty($arrayfields['p.datec']['checked'])) +if (!empty($arrayfields['p.datec']['checked'])) { // Date creation print ''; print ''; print ''; $arrayofstatus = array(); - foreach($object->statuts_short as $key => $val) $arrayofstatus[$key]=$langs->trans($val); - $arrayofstatus['99']=$langs->trans("NotClosed").' ('.$langs->trans('Draft').' + '.$langs->trans('Opened').')'; + foreach ($object->statuts_short as $key => $val) $arrayofstatus[$key] = $langs->trans($val); + $arrayofstatus['99'] = $langs->trans("NotClosed").' ('.$langs->trans('Draft').' + '.$langs->trans('Opened').')'; print $form->selectarray('search_status', $arrayofstatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100 selectarrowonleft'); print ajax_combobox('search_status'); print ''; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; print $object->getNomUrl(1); if ($object->hasDelay()) print img_warning($langs->trans('Late')); print ''; print dol_trunc($obj->title, 80); print ''; if ($obj->socid) @@ -747,18 +747,18 @@ while ($i < min($num, $limit)) print ' '; } print ''; if ($obj->socid) { - $socstatic->id=$obj->socid; - $socstatic->name=$obj->name; - $listsalesrepresentatives=$socstatic->getSalesRepresentatives($user); - $nbofsalesrepresentative=count($listsalesrepresentatives); + $socstatic->id = $obj->socid; + $socstatic->name = $obj->name; + $listsalesrepresentatives = $socstatic->getSalesRepresentatives($user); + $nbofsalesrepresentative = count($listsalesrepresentatives); if ($nbofsalesrepresentative > 3) // We print only number { print ''; @@ -767,17 +767,17 @@ while ($i < min($num, $limit)) } elseif ($nbofsalesrepresentative > 0) { - $userstatic=new User($db); - $j=0; - foreach($listsalesrepresentatives as $val) + $userstatic = new User($db); + $j = 0; + foreach ($listsalesrepresentatives as $val) { - $userstatic->id=$val['id']; - $userstatic->lastname=$val['lastname']; - $userstatic->firstname=$val['firstname']; - $userstatic->email=$val['email']; - $userstatic->statut=$val['statut']; - $userstatic->entity=$val['entity']; - $userstatic->photo=$val['photo']; + $userstatic->id = $val['id']; + $userstatic->lastname = $val['lastname']; + $userstatic->firstname = $val['firstname']; + $userstatic->email = $val['email']; + $userstatic->statut = $val['statut']; + $userstatic->entity = $val['entity']; + $userstatic->photo = $val['photo']; //print $userstatic->getNomUrl(1, '', 0, 0, 12); print $userstatic->getNomUrl(-2); $j++; @@ -791,43 +791,43 @@ while ($i < min($num, $limit)) print ' '; } print ''; print dol_print_date($db->jdate($obj->date_start), 'day'); print ''; print dol_print_date($db->jdate($obj->date_end), 'day'); print ''; if ($obj->public) print $langs->trans('SharedProject'); else print $langs->trans('PrivateProject'); print ''; if ($obj->opp_status_code) print $langs->trans("OppStatus".$obj->opp_status_code); print ''; //if ($obj->opp_status_code) @@ -870,10 +870,10 @@ while ($i < min($num, $limit)) print yn($obj->usage_opportunity); } print ''; if ($obj->usage_task) @@ -881,10 +881,10 @@ while ($i < min($num, $limit)) print yn($obj->usage_task); } print ''; if ($obj->usage_bill_time) @@ -892,46 +892,46 @@ while ($i < min($num, $limit)) print yn($obj->usage_bill_time); } print ''; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''.$object->getLibStatut(5).''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->id, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->id, $arrayofselected)) $selected = 1; + print ''; } print '
\n"; diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index f16a9070325..9d9b8e69516 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -36,31 +36,31 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; $langs->loadLangs(array('projects', 'users', 'companies')); $action = GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $taskref = GETPOST('taskref', 'alpha'); -$backtopage=GETPOST('backtopage', 'alpha'); -$cancel=GETPOST('cancel', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); $search_user_id = GETPOST('search_user_id', 'int'); -$search_taskref=GETPOST('search_taskref'); -$search_tasklabel=GETPOST('search_tasklabel'); -$search_dtstartday=GETPOST('search_dtstartday'); -$search_dtstartmonth=GETPOST('search_dtstartmonth'); -$search_dtstartyear=GETPOST('search_dtstartyear'); -$search_dtendday=GETPOST('search_dtendday'); -$search_dtendmonth=GETPOST('search_dtendmonth'); -$search_dtendyear=GETPOST('search_dtendyear'); -$search_planedworkload=GETPOST('search_planedworkload'); -$search_timespend=GETPOST('search_timespend'); -$search_progresscalc=GETPOST('search_progresscalc'); -$search_progressdeclare=GETPOST('search_progressdeclare'); +$search_taskref = GETPOST('search_taskref'); +$search_tasklabel = GETPOST('search_tasklabel'); +$search_dtstartday = GETPOST('search_dtstartday'); +$search_dtstartmonth = GETPOST('search_dtstartmonth'); +$search_dtstartyear = GETPOST('search_dtstartyear'); +$search_dtendday = GETPOST('search_dtendday'); +$search_dtendmonth = GETPOST('search_dtendmonth'); +$search_dtendyear = GETPOST('search_dtendyear'); +$search_planedworkload = GETPOST('search_planedworkload'); +$search_timespend = GETPOST('search_timespend'); +$search_progresscalc = GETPOST('search_progresscalc'); +$search_progressdeclare = GETPOST('search_progressdeclare'); //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects @@ -68,10 +68,10 @@ $object = new Project($db); $taskstatic = new Task($db); $extrafields = new ExtraFields($db); -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once -if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once +if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); @@ -79,23 +79,23 @@ if ($id > 0 || ! empty($ref)) $extrafields->fetch_name_optionals_label($taskstatic->table_element); // Security check -$socid=0; +$socid = 0; //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. $result = restrictedArea($user, 'projet', $id, 'projet&project'); -$diroutputmassaction=$conf->projet->dir_output . '/tasks/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->projet->dir_output.'/tasks/temp/massgeneration/'.$user->id; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('projecttaskscard','globalcard')); +$hookmanager->initHooks(array('projecttaskscard', 'globalcard')); -$progress=GETPOST('progress', 'int'); -$label=GETPOST('label', 'alpha'); -$description=GETPOST('description'); -$planned_workloadhour=(GETPOST('planned_workloadhour', 'int')?GETPOST('planned_workloadhour', 'int'):0); -$planned_workloadmin=(GETPOST('planned_workloadmin', 'int')?GETPOST('planned_workloadmin', 'int'):0); -$planned_workload=$planned_workloadhour*3600+$planned_workloadmin*60; +$progress = GETPOST('progress', 'int'); +$label = GETPOST('label', 'alpha'); +$description = GETPOST('description'); +$planned_workloadhour = (GETPOST('planned_workloadhour', 'int') ?GETPOST('planned_workloadhour', 'int') : 0); +$planned_workloadmin = (GETPOST('planned_workloadmin', 'int') ?GETPOST('planned_workloadmin', 'int') : 0); +$planned_workload = $planned_workloadhour * 3600 + $planned_workloadmin * 60; -$arrayfields=array( +$arrayfields = array( 't.ref'=>array('label'=>$langs->trans("RefTask"), 'checked'=>1, 'position'=>80), 't.label'=>array('label'=>$langs->trans("LabelTask"), 'checked'=>1, 'position'=>80), 't.dateo'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1, 'position'=>100), @@ -117,10 +117,10 @@ $arrayfields=array( // Extra fields project if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -131,8 +131,8 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -$parameters=array('id'=>$id); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$id); +$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)) @@ -143,40 +143,40 @@ if (empty($reshook)) // Purge search criteria 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_user_id=""; - $search_taskref=''; - $search_tasklabel=''; - $search_dtstartday=''; - $search_dtstartmonth=''; - $search_dtstartyear=''; - $search_dtendday=''; - $search_dtendmonth=''; - $search_dtendyear=''; - $search_planedworkload=''; - $search_timespend=''; - $search_progresscalc=''; - $search_progressdeclare=''; - $toselect=''; - $search_array_options=array(); + $search_user_id = ""; + $search_taskref = ''; + $search_tasklabel = ''; + $search_dtstartday = ''; + $search_dtstartmonth = ''; + $search_dtstartyear = ''; + $search_dtendday = ''; + $search_dtendmonth = ''; + $search_dtendyear = ''; + $search_planedworkload = ''; + $search_timespend = ''; + $search_progresscalc = ''; + $search_progressdeclare = ''; + $toselect = ''; + $search_array_options = array(); } // Mass actions - $objectclass='Task'; - $objectlabel='Tasks'; + $objectclass = 'Task'; + $objectlabel = 'Tasks'; $permissiontoread = $user->rights->projet->lire; $permissiontodelete = $user->rights->projet->supprimer; $uploaddir = $conf->projet->dir_output.'/tasks'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } -$morewherefilterarray=array(); +$morewherefilterarray = array(); if (!empty($search_taskref)) { - $morewherefilterarray[]= natural_search('t.ref', $search_taskref, 0, 1); + $morewherefilterarray[] = natural_search('t.ref', $search_taskref, 0, 1); } if (!empty($search_tasklabel)) { - $morewherefilterarray[]= natural_search('t.label', $search_tasklabel, 0, 1); + $morewherefilterarray[] = natural_search('t.label', $search_tasklabel, 0, 1); } $moresql = dolSqlDateFilter('t.dateo', $search_dtstartday, $search_dtstartmonth, $search_dtstartyear, 1); @@ -186,32 +186,32 @@ $moresql = dolSqlDateFilter('t.datee', $search_dtendday, $search_dtendmonth, $se if ($moresql) $morewherefilterarray[] = $moresql; if (!empty($search_planedworkload)) { - $morewherefilterarray[]= natural_search('t.planned_workload', $search_planedworkload, 1, 1); + $morewherefilterarray[] = natural_search('t.planned_workload', $search_planedworkload, 1, 1); } if (!empty($search_timespend)) { - $morewherefilterarray[]= natural_search('t.duration_effective', $search_timespend, 1, 1); + $morewherefilterarray[] = natural_search('t.duration_effective', $search_timespend, 1, 1); } if (!empty($search_progresscalc)) { - $filterprogresscalc='if '.natural_search('round(100 * $line->duration / $line->planned_workload,2)', $search_progresscalc, 1, 1). '{return 1;} else {return 0;}'; + $filterprogresscalc = 'if '.natural_search('round(100 * $line->duration / $line->planned_workload,2)', $search_progresscalc, 1, 1).'{return 1;} else {return 0;}'; } else { - $filterprogresscalc=''; + $filterprogresscalc = ''; } if (!empty($search_progressdeclare)) { - $morewherefilterarray[]= natural_search('t.progress', $search_progressdeclare, 1, 1); + $morewherefilterarray[] = natural_search('t.progress', $search_progressdeclare, 1, 1); } -$morewherefilter=''; -if (count($morewherefilterarray)>0) { - $morewherefilter= ' AND '. implode(' AND ', $morewherefilterarray); +$morewherefilter = ''; +if (count($morewherefilterarray) > 0) { + $morewherefilter = ' AND '.implode(' AND ', $morewherefilterarray); } if ($action == 'createtask' && $user->rights->projet->creer) { - $error=0; + $error = 0; // If we use user timezone, we must change also view/list to use user timezone everywhere //$date_start = dol_mktime($_POST['dateohour'],$_POST['dateomin'],0,$_POST['dateomonth'],$_POST['dateoday'],$_POST['dateoyear'],'user'); @@ -219,34 +219,34 @@ if ($action == 'createtask' && $user->rights->projet->creer) $date_start = dol_mktime($_POST['dateohour'], $_POST['dateomin'], 0, $_POST['dateomonth'], $_POST['dateoday'], $_POST['dateoyear']); $date_end = dol_mktime($_POST['dateehour'], $_POST['dateemin'], 0, $_POST['dateemonth'], $_POST['dateeday'], $_POST['dateeyear']); - if (! $cancel) + if (!$cancel) { if (empty($taskref)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors'); - $action='create'; + $action = 'create'; $error++; } if (empty($label)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); - $action='create'; + $action = 'create'; $error++; } elseif (empty($_POST['task_parent'])) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("ChildOfProjectTask")), null, 'errors'); - $action='create'; + $action = 'create'; $error++; } - if (! $error) + if (!$error) { - $tmparray=explode('_', $_POST['task_parent']); - $projectid=$tmparray[0]; + $tmparray = explode('_', $_POST['task_parent']); + $projectid = $tmparray[0]; if (empty($projectid)) $projectid = $id; // If projectid is '' - $task_parent=$tmparray[1]; - if (empty($task_parent)) $task_parent = 0; // If task_parent is '' + $task_parent = $tmparray[1]; + if (empty($task_parent)) $task_parent = 0; // If task_parent is '' $task = new Task($db); @@ -287,16 +287,16 @@ if ($action == 'createtask' && $user->rights->projet->creer) } } - if (! $error) + if (!$error) { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } elseif (empty($projectid)) { - header("Location: ".DOL_URL_ROOT.'/projet/tasks/list.php'.(empty($mode)?'':'?mode='.$mode)); + header("Location: ".DOL_URL_ROOT.'/projet/tasks/list.php'.(empty($mode) ? '' : '?mode='.$mode)); exit; } $id = $projectid; @@ -304,7 +304,7 @@ if ($action == 'createtask' && $user->rights->projet->creer) } else { - if (! empty($backtopage)) + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; @@ -312,7 +312,7 @@ if ($action == 'createtask' && $user->rights->projet->creer) elseif (empty($id)) { // We go back on task list - header("Location: ".DOL_URL_ROOT.'/projet/tasks/list.php'.(empty($mode)?'':'?mode='.$mode)); + header("Location: ".DOL_URL_ROOT.'/projet/tasks/list.php'.(empty($mode) ? '' : '?mode='.$mode)); exit; } } @@ -324,62 +324,62 @@ if ($action == 'createtask' && $user->rights->projet->creer) */ $now = dol_now(); -$form=new Form($db); -$formother=new FormOther($db); -$socstatic=new Societe($db); +$form = new Form($db); +$formother = new FormOther($db); +$socstatic = new Societe($db); $projectstatic = new Project($db); $taskstatic = new Task($db); -$userstatic=new User($db); +$userstatic = new User($db); -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -$title=$langs->trans("Project").' - '.$langs->trans("Tasks").' - '.$object->ref.' '.$object->name; -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->ref.' '.$object->name.' - '.$langs->trans("Tasks"); -$help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; +$title = $langs->trans("Project").' - '.$langs->trans("Tasks").' - '.$object->ref.' '.$object->name; +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->ref.' '.$object->name.' - '.$langs->trans("Tasks"); +$help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; llxHeader("", $title, $help_url); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $object->fetch($id, $ref); $object->fetch_thirdparty(); - $res=$object->fetch_optionals(); + $res = $object->fetch_optionals(); // To verify role of users //$userAccess = $object->restrictedProjectArea($user,'read'); - $userWrite = $object->restrictedProjectArea($user, 'write'); + $userWrite = $object->restrictedProjectArea($user, 'write'); //$userDelete = $object->restrictedProjectArea($user,'delete'); //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete; - $tab=GETPOST('tab')?GETPOST('tab'):'tasks'; + $tab = GETPOST('tab') ?GETPOST('tab') : 'tasks'; - $head=project_prepare_head($object); - dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($object->public?'projectpub':'project')); + $head = project_prepare_head($object); + dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project')); - $param=''; - if ($search_user_id > 0) $param.='&search_user_id='.dol_escape_htmltag($search_user_id); + $param = ''; + if ($search_user_id > 0) $param .= '&search_user_id='.dol_escape_htmltag($search_user_id); // Project card $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref='
'; + $morehtmlref = '
'; // Title - $morehtmlref.=$object->title; + $morehtmlref .= $object->title; // Thirdparty if ($object->thirdparty->id > 0) { - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project'); + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project'); } - $morehtmlref.='
'; + $morehtmlref .= '
'; // Define a complementary filter for search of next/prev ref. - if (! $user->rights->projet->all->lire) + if (!$user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); - $object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',', array_keys($objectsListId)):'0').")"; + $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; } dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -395,23 +395,23 @@ if ($id > 0 || ! empty($ref)) print $langs->trans("Usage"); print '
'; - if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { - print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; + print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); print '
'; } if (empty($conf->global->PROJECT_HIDE_TASKS)) { - print 'usage_task ? ' checked="checked"' : '')).'"> '; + print 'usage_task ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectFollowTasks"); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '
'; } - if (! empty($conf->global->PROJECT_BILL_TIME_SPENT)) + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) { - print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; + print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print $form->textwithpicto($langs->trans("BillTime"), $htmltext); print '
'; @@ -446,10 +446,10 @@ if ($id > 0 || ! empty($ref)) // Date start - end print '
'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; $start = dol_print_date($object->date_start, 'dayhour'); - print ($start?$start:'?'); + print ($start ? $start : '?'); $end = dol_print_date($object->date_end, 'dayhour'); print ' - '; - print ($end?$end:'?'); + print ($end ? $end : '?'); if ($object->hasDelay()) print img_warning("Late"); print '
'; @@ -477,7 +477,7 @@ if ($id > 0 || ! empty($ref)) print ''; // Bill time - if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_BILL_TIME_SPENT)) + if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print ''.$langs->trans("BillTime").''; print yn($object->usage_bill_time); @@ -506,7 +506,7 @@ if ($id > 0 || ! empty($ref)) if ($action == 'create' && $user->rights->projet->creer && (empty($object->thirdparty->id) || $userWrite > 0)) { - if ($id > 0 || ! empty($ref)) print '
'; + if ($id > 0 || !empty($ref)) print '
'; print load_fiche_titre($langs->trans("NewTask"), '', 'project'); @@ -523,34 +523,34 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third print ''; print ''; print ''; - if (! empty($object->id)) print ''; + if (!empty($object->id)) print ''; dol_fiche_head(''); print ''; - $defaultref=''; - $obj = empty($conf->global->PROJECT_TASK_ADDON)?'mod_task_simple':$conf->global->PROJECT_TASK_ADDON; - if (! empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) + $defaultref = ''; + $obj = empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON; + if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) { - require_once DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php'; + require_once DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php'; $modTask = new $obj; $defaultref = $modTask->getNextValue($object->thirdparty, null); } - if (is_numeric($defaultref) && $defaultref <= 0) $defaultref=''; + if (is_numeric($defaultref) && $defaultref <= 0) $defaultref = ''; // Ref print ''; print ''; print ''; // Date end print ''; // Planned workload print ''; // Progress @@ -601,13 +601,13 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third print ''; // Other options - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $taskstatic, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $taskstatic, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields[$taskstatic->table_element]['label'])) + if (empty($reshook) && !empty($extrafields[$taskstatic->table_element]['label'])) { - print $taskstatic->showOptionals($extrafields, 'edit'); // Do not use $object here that is object of project but use $taskstatic + print $taskstatic->showOptionals($extrafields, 'edit'); // Do not use $object here that is object of project but use $taskstatic } print '
'.$langs->trans("Ref").''; if (empty($duplicate_code_error)) { - print (GETPOSTISSET("ref")?GETPOST("ref", 'alpha'):$defaultref); + print (GETPOSTISSET("ref") ?GETPOST("ref", 'alpha') : $defaultref); } else { print $defaultref; } - print ''; + print ''; print '
'.$langs->trans("Label").''; @@ -559,11 +559,11 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third // List of projects print '
'.$langs->trans("ChildOfProjectTask").''; - print $formother->selectProjectTasks(GETPOST('task_parent'), $projectid?$projectid:$object->id, 'task_parent', 0, 0, 1, 1, 0, '0,1', 'maxwidth500'); + print $formother->selectProjectTasks(GETPOST('task_parent'), $projectid ? $projectid : $object->id, 'task_parent', 0, 0, 1, 1, 0, '0,1', 'maxwidth500'); print '
'.$langs->trans("AffectedTo").''; - $contactsofproject=(! empty($object->id)?$object->getListContactId('internal'):''); + $contactsofproject = (!empty($object->id) ? $object->getListContactId('internal') : ''); if (is_array($contactsofproject) && count($contactsofproject)) { print $form->select_dolusers($user->id, 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, '', 'maxwidth300'); @@ -576,17 +576,17 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third // Date start print '
'.$langs->trans("DateStart").''; - print $form->selectDate(($date_start?$date_start:''), 'dateo', 1, 1, 0, '', 1, 1); + print $form->selectDate(($date_start ? $date_start : ''), 'dateo', 1, 1, 0, '', 1, 1); print '
'.$langs->trans("DateEnd").''; - print $form->selectDate(($date_end?$date_end:-1), 'datee', -1, 1, 0, '', 1, 1); + print $form->selectDate(($date_end ? $date_end : -1), 'datee', -1, 1, 0, '', 1, 1); print '
'.$langs->trans("PlannedWorkload").''; - print $form->select_duration('planned_workload', $planned_workload?$planned_workload : 0, 0, 'text'); + print $form->select_duration('planned_workload', $planned_workload ? $planned_workload : 0, 0, 'text'); print '
'; @@ -623,25 +623,25 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third print ''; } } -elseif ($id > 0 || ! empty($ref)) +elseif ($id > 0 || !empty($ref)) { /* * Projet card in view mode */ // Definition of fields for list - $arrayfields=array(); - $arrayfields['t.task_ref']=array('label'=>$langs->trans("RefTask"), 'checked'=>1); - $arrayfields['t.task_label']=array('label'=>$langs->trans("LabelTask"), 'checked'=>1); - $arrayfields['t.task_date_start']=array('label'=>$langs->trans("DateStart"), 'checked'=>1); - $arrayfields['t.task_date_end']=array('label'=>$langs->trans("DateEnd"), 'checked'=>1); + $arrayfields = array(); + $arrayfields['t.task_ref'] = array('label'=>$langs->trans("RefTask"), 'checked'=>1); + $arrayfields['t.task_label'] = array('label'=>$langs->trans("LabelTask"), 'checked'=>1); + $arrayfields['t.task_date_start'] = array('label'=>$langs->trans("DateStart"), 'checked'=>1); + $arrayfields['t.task_date_end'] = array('label'=>$langs->trans("DateEnd"), 'checked'=>1); // Extra fields if (is_array($extrafields->attributes[$taskstatic->table_element]['label']) && count($extrafields->attributes[$taskstatic->table_element]['label']) > 0) { - foreach($extrafields->attributes[$taskstatic->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$taskstatic->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$taskstatic->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$taskstatic->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$taskstatic->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$taskstatic->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$taskstatic->table_element]['list'][$key])!=3 && $extrafields->attributes[$taskstatic->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$taskstatic->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$taskstatic->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$taskstatic->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$taskstatic->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$taskstatic->table_element]['list'][$key]) != 3 && $extrafields->attributes[$taskstatic->table_element]['perms'][$key])); } } $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -652,9 +652,9 @@ elseif ($id > 0 || ! empty($ref)) $linktocreatetaskParam = array(); $linktocreatetaskUserRight = false; if ($user->rights->projet->all->creer || $user->rights->projet->creer) { - if ($object->public || $userWrite > 0){ + if ($object->public || $userWrite > 0) { $linktocreatetaskUserRight = true; - }else{ + } else { $linktocreatetaskParam['attr']['title'] = $langs->trans("NotOwnerOfProject"); } } @@ -672,7 +672,7 @@ elseif ($id > 0 || ! empty($ref)) print ''; print ''; - $title=$langs->trans("ListOfTasks"); + $title = $langs->trans("ListOfTasks"); $linktotasks = dolGetButtonTitle($langs->trans('GoToGanttView'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/projet/ganttview.php?id='.$object->id.'&withproject=1', '', 1, array('morecss'=>'reposition')); //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'generic', 0, '', '', 0, 1); @@ -681,28 +681,28 @@ elseif ($id > 0 || ! empty($ref)) // Get list of tasks in tasksarray and taskarrayfiltered // We need all tasks (even not limited to a user because a task to user can have a parent that is not affected to him). $filteronthirdpartyid = $socid; - $tasksarray=$taskstatic->getTasksArray(0, 0, $object->id, $filteronthirdpartyid, 0, '', -1, $morewherefilter, 0, 0, array(), 1); + $tasksarray = $taskstatic->getTasksArray(0, 0, $object->id, $filteronthirdpartyid, 0, '', -1, $morewherefilter, 0, 0, array(), 1); // We load also tasks limited to a particular user - $tmpuser=new User($db); + $tmpuser = new User($db); if ($search_user_id > 0) $tmpuser->fetch($search_user_id); - $tasksrole=($tmpuser->id > 0 ? $taskstatic->getUserRolesForProjectsOrTasks(0, $tmpuser, $object->id, 0) : ''); + $tasksrole = ($tmpuser->id > 0 ? $taskstatic->getUserRolesForProjectsOrTasks(0, $tmpuser, $object->id, 0) : ''); //var_dump($tasksarray); //var_dump($tasksrole); - if (! empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) { include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } // Filter on categories - $moreforfilter=''; + $moreforfilter = ''; if (count($tasksarray) > 0) { - $moreforfilter.='
'; - $moreforfilter.=$langs->trans("TasksAssignedTo").': '; - $moreforfilter.=$form->select_dolusers($tmpuser->id > 0 ? $tmpuser->id : '', 'search_user_id', 1); - $moreforfilter.='
'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans("TasksAssignedTo").': '; + $moreforfilter .= $form->select_dolusers($tmpuser->id > 0 ? $tmpuser->id : '', 'search_user_id', 1); + $moreforfilter .= '
'; } if ($moreforfilter) { @@ -711,11 +711,11 @@ elseif ($id > 0 || ! empty($ref)) print '
'; } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields print '
'; - print ''; + print '
'; // Fields title search print ''; @@ -731,13 +731,13 @@ elseif ($id > 0 || ! empty($ref)) print ''; print ''; print ''; } - if (! empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) print ''; + if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) print ''; // Action column print ''; print "\n"; @@ -793,20 +793,20 @@ elseif ($id > 0 || ! empty($ref)) print_liste_field_titre("TimeToBill", $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'right '); print_liste_field_titre("TimeBilled", $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'right '); } - if (! empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) print_liste_field_titre("TaskRessourceLinks", $_SERVER["PHP_SELF"], '', '', '', $sortfield, $sortorder); + if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) print_liste_field_titre("TaskRessourceLinks", $_SERVER["PHP_SELF"], '', '', '', $sortfield, $sortorder); print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', 'width="80"', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; if (count($tasksarray) > 0) { // Show all lines in taskarray (recursive function to go down on tree) - $j=0; $level=0; - $nboftaskshown=projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $object->id, 1, $object->id, $filterprogresscalc, ($object->usage_bill_time?1:0)); + $j = 0; $level = 0; + $nboftaskshown = projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $object->id, 1, $object->id, $filterprogresscalc, ($object->usage_bill_time ? 1 : 0)); } else { - $colspan=10; - if ($object->usage_bill_time) $colspan+=2; + $colspan = 10; + if ($object->usage_bill_time) $colspan += 2; print ''; } @@ -818,7 +818,7 @@ elseif ($id > 0 || ! empty($ref)) // Test if database is clean. If not we clean it. //print 'mode='.$_REQUEST["mode"].' $nboftaskshown='.$nboftaskshown.' count($tasksarray)='.count($tasksarray).' count($tasksrole)='.count($tasksrole).'
'; - if (! empty($user->rights->projet->all->lire)) // We make test to clean only if user has permission to see all (test may report false positive otherwise) + if (!empty($user->rights->projet->all->lire)) // We make test to clean only if user has permission to see all (test may report false positive otherwise) { if ($search_user_id == $user->id) { @@ -830,7 +830,7 @@ elseif ($id > 0 || ! empty($ref)) } else { - if ($nboftaskshown < count($tasksarray) && ! GETPOST('search_user_id', 'int')) + if ($nboftaskshown < count($tasksarray) && !GETPOST('search_user_id', 'int')) { include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; cleanCorruptedTree($db, 'projet_task', 'fk_task_parent'); diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 5215c82a062..a529c7d1a9d 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -34,32 +34,32 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page $langs->loadLangs(array('projects', 'users', 'companies')); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$id=GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); -$search_all=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$search_categ=GETPOST("search_categ", 'alpha'); -$search_project=GETPOST('search_project'); -if (! isset($_GET['search_projectstatus']) && ! isset($_POST['search_projectstatus'])) +$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$search_categ = GETPOST("search_categ", 'alpha'); +$search_project = GETPOST('search_project'); +if (!isset($_GET['search_projectstatus']) && !isset($_POST['search_projectstatus'])) { - if ($search_all != '') $search_projectstatus=-1; - else $search_projectstatus=1; + if ($search_all != '') $search_projectstatus = -1; + else $search_projectstatus = 1; } -else $search_projectstatus=GETPOST('search_projectstatus'); -$search_project_ref=GETPOST('search_project_ref'); -$search_project_title=GETPOST('search_project_title'); -$search_task_ref=GETPOST('search_task_ref'); -$search_task_label=GETPOST('search_task_label'); -$search_task_description=GETPOST('search_task_description'); -$search_project_user=GETPOST('search_project_user'); -$search_task_user=GETPOST('search_task_user'); +else $search_projectstatus = GETPOST('search_projectstatus'); +$search_project_ref = GETPOST('search_project_ref'); +$search_project_title = GETPOST('search_project_title'); +$search_task_ref = GETPOST('search_task_ref'); +$search_task_label = GETPOST('search_task_label'); +$search_task_description = GETPOST('search_task_description'); +$search_project_user = GETPOST('search_project_user'); +$search_task_user = GETPOST('search_task_user'); -$mine = $_REQUEST['mode']=='mine' ? 1 : 0; +$mine = $_REQUEST['mode'] == 'mine' ? 1 : 0; if ($mine) { $search_task_user = $user->id; $mine = 0; } $search_sday = GETPOST('search_sday', 'int'); @@ -70,7 +70,7 @@ $search_emonth = GETPOST('search_emonth', 'int'); $search_eyear = GETPOST('search_eyear', 'int'); // Initialize context for list -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'tasklist'; +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'tasklist'; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Task($db); @@ -79,16 +79,16 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Security check -$socid=0; +$socid = 0; //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. if (!$user->rights->projet->lire) accessforbidden(); -$diroutputmassaction=$conf->projet->dir_output . '/tasks/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->projet->dir_output.'/tasks/temp/massgeneration/'.$user->id; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -96,8 +96,8 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='p.ref'; -if (! $sortorder) $sortorder='DESC'; +if (!$sortfield) $sortfield = 'p.ref'; +if (!$sortorder) $sortorder = 'DESC'; // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -106,9 +106,9 @@ $fieldstosearchall = array( 't.description'=>"Description", 't.note_public'=>"NotePublic", ); -if (empty($user->socid)) $fieldstosearchall['t.note_private']="NotePrivate"; +if (empty($user->socid)) $fieldstosearchall['t.note_private'] = "NotePrivate"; -$arrayfields=array( +$arrayfields = array( 't.ref'=>array('label'=>$langs->trans("RefTask"), 'checked'=>1, 'position'=>80), 't.label'=>array('label'=>$langs->trans("LabelTask"), 'checked'=>1, 'position'=>80), 't.dateo'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1, 'position'=>100), @@ -131,10 +131,10 @@ $arrayfields=array( // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -145,11 +145,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; } -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) @@ -160,37 +160,37 @@ if (empty($reshook)) // Purge search criteria 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_all=""; - $search_categ=""; - $search_project=""; - $search_projectstatus=-1; - $search_project_ref=""; - $search_project_title=""; - $search_task_ref=""; - $search_task_label=""; - $search_task_description=""; - $search_task_user=-1; - $search_project_user=-1; - $search_sday=''; - $search_smonth=''; - $search_syear=''; - $search_eday=''; - $search_emonth=''; - $search_eyear=''; - $toselect=''; - $search_array_options=array(); + $search_all = ""; + $search_categ = ""; + $search_project = ""; + $search_projectstatus = -1; + $search_project_ref = ""; + $search_project_title = ""; + $search_task_ref = ""; + $search_task_label = ""; + $search_task_description = ""; + $search_task_user = -1; + $search_project_user = -1; + $search_sday = ''; + $search_smonth = ''; + $search_syear = ''; + $search_eday = ''; + $search_emonth = ''; + $search_eyear = ''; + $toselect = ''; + $search_array_options = array(); } // Mass actions - $objectclass='Task'; - $objectlabel='Tasks'; + $objectclass = 'Task'; + $objectlabel = 'Tasks'; $permissiontoread = $user->rights->projet->lire; $permissiontodelete = $user->rights->projet->supprimer; $uploaddir = $conf->projet->dir_output.'/tasks'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } -if (empty($search_projectstatus) && $search_projectstatus == '') $search_projectstatus=1; +if (empty($search_projectstatus) && $search_projectstatus == '') $search_projectstatus = 1; @@ -200,21 +200,21 @@ if (empty($search_projectstatus) && $search_projectstatus == '') $search_project */ $now = dol_now(); -$form=new Form($db); -$formother=new FormOther($db); -$socstatic=new Societe($db); +$form = new Form($db); +$formother = new FormOther($db); +$socstatic = new Societe($db); $projectstatic = new Project($db); -$puser=new User($db); -$tuser=new User($db); +$puser = new User($db); +$tuser = new User($db); if ($search_project_user > 0) $puser->fetch($search_project_user); if ($search_task_user > 0) $tuser->fetch($search_task_user); -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -$title=$langs->trans("Activities"); +$title = $langs->trans("Activities"); //if ($search_task_user == $user->id) $title=$langs->trans("MyActivities"); if ($id) @@ -224,115 +224,115 @@ if ($id) } // Get list of project id allowed to user (in a string list separated by coma) -if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); +if (!$user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); //var_dump($projectsListId); // Get id of types of contacts for projects (This list never contains a lot of elements) -$listofprojectcontacttype=array(); +$listofprojectcontacttype = array(); $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc"; -$sql.= " WHERE ctc.element = '" . $projectstatic->element . "'"; -$sql.= " AND ctc.source = 'internal'"; +$sql .= " WHERE ctc.element = '".$projectstatic->element."'"; +$sql .= " AND ctc.source = 'internal'"; $resql = $db->query($sql); if ($resql) { - while($obj = $db->fetch_object($resql)) + while ($obj = $db->fetch_object($resql)) { - $listofprojectcontacttype[$obj->rowid]=$obj->code; + $listofprojectcontacttype[$obj->rowid] = $obj->code; } } else dol_print_error($db); -if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0'; // To avoid sql syntax error if not found +if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found // Get id of types of contacts for tasks (This list never contains a lot of elements) -$listoftaskcontacttype=array(); +$listoftaskcontacttype = array(); $sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc"; -$sql.= " WHERE ctc.element = '" . $object->element . "'"; -$sql.= " AND ctc.source = 'internal'"; +$sql .= " WHERE ctc.element = '".$object->element."'"; +$sql .= " AND ctc.source = 'internal'"; $resql = $db->query($sql); if ($resql) { - while($obj = $db->fetch_object($resql)) + while ($obj = $db->fetch_object($resql)) { - $listoftaskcontacttype[$obj->rowid]=$obj->code; + $listoftaskcontacttype[$obj->rowid] = $obj->code; } } else dol_print_error($db); -if (count($listoftaskcontacttype) == 0) $listoftaskcontacttype[0]='0'; // To avoid sql syntax error if not found +if (count($listoftaskcontacttype) == 0) $listoftaskcontacttype[0] = '0'; // To avoid sql syntax error if not found -$distinct='DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is assigned only once. +$distinct = 'DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is assigned only once. $sql = "SELECT ".$distinct." p.rowid as projectid, p.ref as projectref, p.title as projecttitle, p.fk_statut as projectstatus, p.datee as projectdatee, p.fk_opp_status, p.public, p.fk_user_creat as projectusercreate, p.usage_bill_time,"; -$sql.= " s.nom as name, s.rowid as socid,"; -$sql.= " t.datec as date_creation, t.dateo as date_start, t.datee as date_end, t.tms as date_update,"; -$sql.= " t.rowid as id, t.ref, t.label, t.planned_workload, t.duration_effective, t.progress, t.fk_statut"; +$sql .= " s.nom as name, s.rowid as socid,"; +$sql .= " t.datec as date_creation, t.dateo as date_start, t.datee as date_end, t.tms as date_update,"; +$sql .= " t.rowid as id, t.ref, t.label, t.planned_workload, t.duration_effective, t.progress, t.fk_statut"; // We'll need these fields in order to filter by categ if ($search_categ) $sql .= ", cs.fk_categorie, cs.fk_project"; // Add sum fields -if (! empty($arrayfields['t.tobill']['checked']) || ! empty($arrayfields['t.billed']['checked'])) +if (!empty($arrayfields['t.tobill']['checked']) || !empty($arrayfields['t.billed']['checked'])) { - $sql.=" , SUM(tt.task_duration * ".$db->ifsql("invoice_id IS NULL", "1", "0").") as tobill, SUM(tt.task_duration * ".$db->ifsql("invoice_id IS NULL", "0", "1").") as billed"; + $sql .= " , SUM(tt.task_duration * ".$db->ifsql("invoice_id IS NULL", "1", "0").") as tobill, SUM(tt.task_duration * ".$db->ifsql("invoice_id IS NULL", "0", "1").") as billed"; } // 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 : ''); +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 : ''); } // 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 ".MAIN_DB_PREFIX."projet as p"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; // We'll need this table joined to the select in order to filter by categ -if (! empty($search_categ)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_project as cs ON p.rowid = cs.fk_project"; // We'll need this table joined to the select in order to filter by categ -$sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; -if (! empty($arrayfields['t.tobill']['checked']) || ! empty($arrayfields['t.billed']['checked'])) +if (!empty($search_categ)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_project as cs ON p.rowid = cs.fk_project"; // We'll need this table joined to the select in order to filter by categ +$sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; +if (!empty($arrayfields['t.tobill']['checked']) || !empty($arrayfields['t.billed']['checked'])) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tt ON tt.fk_task = t.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tt ON tt.fk_task = t.rowid"; } -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 (t.rowid = ef.fk_object)"; -if ($search_project_user > 0) $sql.=", ".MAIN_DB_PREFIX."element_contact as ecp"; -if ($search_task_user > 0) $sql.=", ".MAIN_DB_PREFIX."element_contact as ect"; -$sql.= " WHERE t.fk_projet = p.rowid"; -$sql.= " AND p.entity IN (".getEntity('project').')'; -if (! $user->rights->projet->all->lire) $sql.=" AND p.rowid IN (".($projectsListId?$projectsListId:'0').")"; // public and assigned to projects, or restricted to company for external users -if (is_object($projectstatic) && $projectstatic->id > 0) $sql.=" AND p.rowid = ".$projectstatic->id; +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 (t.rowid = ef.fk_object)"; +if ($search_project_user > 0) $sql .= ", ".MAIN_DB_PREFIX."element_contact as ecp"; +if ($search_task_user > 0) $sql .= ", ".MAIN_DB_PREFIX."element_contact as ect"; +$sql .= " WHERE t.fk_projet = p.rowid"; +$sql .= " AND p.entity IN (".getEntity('project').')'; +if (!$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".($projectsListId ? $projectsListId : '0').")"; // public and assigned to projects, or restricted to company for external users +if (is_object($projectstatic) && $projectstatic->id > 0) $sql .= " AND p.rowid = ".$projectstatic->id; // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser -if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; -if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ); -if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL"; +if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; +if ($search_categ > 0) $sql .= " AND cs.fk_categorie = ".$db->escape($search_categ); +if ($search_categ == -2) $sql .= " AND cs.fk_categorie IS NULL"; if ($search_project_ref) $sql .= natural_search('p.ref', $search_project_ref); if ($search_project_title) $sql .= natural_search('p.title', $search_project_title); if ($search_task_ref) $sql .= natural_search('t.ref', $search_task_ref); if ($search_task_label) $sql .= natural_search('t.label', $search_task_label); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); -$sql.= dolSqlDateFilter('t.dateo', $search_sday, $search_smonth, $search_syear); -$sql.= dolSqlDateFilter('t.datee', $search_eday, $search_emonth, $search_eyear); +$sql .= dolSqlDateFilter('t.dateo', $search_sday, $search_smonth, $search_syear); +$sql .= dolSqlDateFilter('t.datee', $search_eday, $search_emonth, $search_eyear); if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); if ($search_projectstatus >= 0) { if ($search_projectstatus == 99) $sql .= " AND p.fk_statut <> 2"; else $sql .= " AND p.fk_statut = ".$db->escape($search_projectstatus); } -if ($search_public!='') $sql .= " AND p.public = ".$db->escape($search_public); -if ($search_project_user > 0) $sql.= " AND ecp.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_project_user; -if ($search_task_user > 0) $sql.= " AND ect.fk_c_type_contact IN (".join(',', array_keys($listoftaskcontacttype)).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".$search_task_user; +if ($search_public != '') $sql .= " AND p.public = ".$db->escape($search_public); +if ($search_project_user > 0) $sql .= " AND ecp.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_project_user; +if ($search_task_user > 0) $sql .= " AND ect.fk_c_type_contact IN (".join(',', array_keys($listoftaskcontacttype)).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".$search_task_user; // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -if (! empty($arrayfields['t.tobill']['checked']) || ! empty($arrayfields['t.billed']['checked'])) +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +if (!empty($arrayfields['t.tobill']['checked']) || !empty($arrayfields['t.billed']['checked'])) { - $sql.=" GROUP BY p.rowid, p.ref, p.title, p.fk_statut, p.datee, p.fk_opp_status, p.public, p.fk_user_creat,"; - $sql.=" s.nom, s.rowid,"; - $sql.=" t.datec, t.dateo, t.datee, t.tms,"; - $sql.=" t.rowid, t.ref, t.label, t.planned_workload, t.duration_effective, t.progress, t.fk_statut"; + $sql .= " GROUP BY p.rowid, p.ref, p.title, p.fk_statut, p.datee, p.fk_opp_status, p.public, p.fk_user_creat,"; + $sql .= " s.nom, s.rowid,"; + $sql .= " t.datec, t.dateo, t.datee, t.tms,"; + $sql .= " t.rowid, t.ref, t.label, t.planned_workload, t.duration_effective, t.progress, t.fk_statut"; if ($search_categ) $sql .= ", cs.fk_categorie, cs.fk_project"; // 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 : ''); + 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 : ''); } } -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -346,12 +346,12 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit + 1, $offset); +$sql .= $db->plimit($limit + 1, $offset); dol_syslog("list allowed project", LOG_DEBUG); $resql = $db->query($sql); -if (! $resql) +if (!$resql) { dol_print_error($db); exit; @@ -359,9 +359,9 @@ if (! $resql) $num = $db->num_rows($resql); -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->id; @@ -369,48 +369,48 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && exit; } -$help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; +$help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; llxHeader("", $title, $help_url); -$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_sday) $param.='&search_sday='.urlencode($search_sday); -if ($search_smonth) $param.='&search_smonth='.urlencode($search_smonth); -if ($search_syear) $param.='&search_syear=' .urlencode($search_syear); -if ($search_eday) $param.='&search_eday='.urlencode($search_eday); -if ($search_emonth) $param.='&search_emonth='.urlencode($search_emonth); -if ($search_eyear) $param.='&search_eyear=' .urlencode($search_eyear); -if ($socid) $param.='&socid='.urlencode($socid); -if ($search_all != '') $param.='&search_all='.urlencode($search_all); -if ($search_project_ref != '') $param.='&search_project_ref='.urlencode($search_project_ref); -if ($search_project_title != '') $param.='&search_project_title='.urlencode($search_project_title); -if ($search_ref != '') $param.='&search_ref='.urlencode($search_ref); -if ($search_label != '') $param.='&search_label='.urlencode($search_label); -if ($search_societe != '') $param.='&search_societe='.urlencode($search_societe); -if ($search_projectstatus != '') $param.='&search_projectstatus='.urlencode($search_projectstatus); -if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all','none'))) $param.='&search_opp_status='.urlencode($search_opp_status); -if ($search_public != '') $param.='&search_public='.urlencode($search_public); -if ($search_project_user != '') $param.='&search_project_user='.urlencode($search_project_user); -if ($search_task_user > 0) $param.='&search_task_user='.urlencode($search_task_user); -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +$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_sday) $param .= '&search_sday='.urlencode($search_sday); +if ($search_smonth) $param .= '&search_smonth='.urlencode($search_smonth); +if ($search_syear) $param .= '&search_syear='.urlencode($search_syear); +if ($search_eday) $param .= '&search_eday='.urlencode($search_eday); +if ($search_emonth) $param .= '&search_emonth='.urlencode($search_emonth); +if ($search_eyear) $param .= '&search_eyear='.urlencode($search_eyear); +if ($socid) $param .= '&socid='.urlencode($socid); +if ($search_all != '') $param .= '&search_all='.urlencode($search_all); +if ($search_project_ref != '') $param .= '&search_project_ref='.urlencode($search_project_ref); +if ($search_project_title != '') $param .= '&search_project_title='.urlencode($search_project_title); +if ($search_ref != '') $param .= '&search_ref='.urlencode($search_ref); +if ($search_label != '') $param .= '&search_label='.urlencode($search_label); +if ($search_societe != '') $param .= '&search_societe='.urlencode($search_societe); +if ($search_projectstatus != '') $param .= '&search_projectstatus='.urlencode($search_projectstatus); +if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all', 'none'))) $param .= '&search_opp_status='.urlencode($search_opp_status); +if ($search_public != '') $param .= '&search_public='.urlencode($search_public); +if ($search_project_user != '') $param .= '&search_project_user='.urlencode($search_project_user); +if ($search_task_user > 0) $param .= '&search_task_user='.urlencode($search_task_user); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( // 'presend'=>$langs->trans("SendByMail"), // 'builddoc'=>$langs->trans("PDFMerge"), ); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); -if ($user->rights->societe->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); -if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($user->rights->societe->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); -$newcardbutton=''; +$newcardbutton = ''; if ($user->rights->projet->creer) { - $newcardbutton.= dolGetButtonTitle($langs->trans('NewTask'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/tasks.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewTask'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/tasks.php?action=create'); } print ''; @@ -425,149 +425,149 @@ print ''; print ''; // Show description of content -$texthelp=''; -if ($search_task_user == $user->id) $texthelp.=$langs->trans("MyTasksDesc"); +$texthelp = ''; +if ($search_task_user == $user->id) $texthelp .= $langs->trans("MyTasksDesc"); else { - if ($user->rights->projet->all->lire && ! $socid) $texthelp.=$langs->trans("TasksOnProjectsDesc"); - else $texthelp.=$langs->trans("TasksOnProjectsPublicDesc"); + if ($user->rights->projet->all->lire && !$socid) $texthelp .= $langs->trans("TasksOnProjectsDesc"); + else $texthelp .= $langs->trans("TasksOnProjectsPublicDesc"); } print_barre_liste($form->textwithpicto($title, $texthelp), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'project', 0, $newcardbutton, '', $limit); -$topicmail="Information"; -$modelmail="task"; -$objecttmp=new Task($db); -$trackid='tas'.$object->id; +$topicmail = "Information"; +$modelmail = "task"; +$objecttmp = new Task($db); +$trackid = 'tas'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; } $morehtmlfilter = ''; // Filter on categories -if (! empty($conf->categorie->enabled)) +if (!empty($conf->categorie->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('ProjectCategories'). ': '; - $moreforfilter.=$formother->select_categories('project', $search_categ, 'search_categ', 1, 'maxwidth300'); - $moreforfilter.='
'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('ProjectCategories').': '; + $moreforfilter .= $formother->select_categories('project', $search_categ, 'search_categ', 1, 'maxwidth300'); + $moreforfilter .= '
'; } // If the user can view users -$moreforfilter.='
'; -$moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ' '; -$includeonly=''; -if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); -$moreforfilter.=$form->select_dolusers($search_project_user?$search_project_user:'', 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); -$moreforfilter.='
'; +$moreforfilter .= '
'; +$moreforfilter .= $langs->trans('ProjectsWithThisUserAsContact').' '; +$includeonly = ''; +if (empty($user->rights->user->user->lire)) $includeonly = array($user->id); +$moreforfilter .= $form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); +$moreforfilter .= '
'; // If the user can view users -$moreforfilter.='
'; -$moreforfilter.=$langs->trans('TasksWithThisUserAsContact'). ': '; -$includeonly=''; -if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); -$moreforfilter.=$form->select_dolusers($search_task_user, 'search_task_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); -$moreforfilter.='
'; +$moreforfilter .= '
'; +$moreforfilter .= $langs->trans('TasksWithThisUserAsContact').': '; +$includeonly = ''; +if (empty($user->rights->user->user->lire)) $includeonly = array($user->id); +$moreforfilter .= $form->select_dolusers($search_task_user, 'search_task_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); +$moreforfilter .= '
'; -if (! empty($moreforfilter)) +if (!empty($moreforfilter)) { print '
'; print $moreforfilter; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; } -if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); +if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); print '
'; -print '
'; print ''; print ''; - $formother->select_year($search_dtstartyear?$search_dtstartyear:-1, 'search_dtstartyear', 1, 20, 5); + $formother->select_year($search_dtstartyear ? $search_dtstartyear : -1, 'search_dtstartyear', 1, 20, 5); print ''; print ''; print ''; - $formother->select_year($search_dtendyear?$search_dtendyear:-1, 'search_dtendyear', 1, 20, 5); + $formother->select_year($search_dtendyear ? $search_dtendyear : -1, 'search_dtendyear', 1, 20, 5); print ''; @@ -768,11 +768,11 @@ elseif ($id > 0 || ! empty($ref)) print ''; - $searchpicto=$form->showFilterButtons(); + $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'.$langs->trans("NoTasks").'
'."\n"; +print '
'."\n"; print ''; -if (! empty($arrayfields['t.ref']['checked'])) +if (!empty($arrayfields['t.ref']['checked'])) { print ''; } -if (! empty($arrayfields['t.label']['checked'])) +if (!empty($arrayfields['t.label']['checked'])) { print ''; } // Start date -if (! empty($arrayfields['t.dateo']['checked'])) +if (!empty($arrayfields['t.dateo']['checked'])) { print ''; } // End date -if (! empty($arrayfields['t.datee']['checked'])) +if (!empty($arrayfields['t.datee']['checked'])) { print ''; } -if (! empty($arrayfields['p.ref']['checked'])) +if (!empty($arrayfields['p.ref']['checked'])) { print ''; } -if (! empty($arrayfields['p.title']['checked'])) +if (!empty($arrayfields['p.title']['checked'])) { print ''; } -if (! empty($arrayfields['s.nom']['checked'])) +if (!empty($arrayfields['s.nom']['checked'])) { print ''; } -if (! empty($arrayfields['p.fk_statut']['checked'])) +if (!empty($arrayfields['p.fk_statut']['checked'])) { print ''; } -if (! empty($arrayfields['t.planned_workload']['checked'])) print ''; -if (! empty($arrayfields['t.duration_effective']['checked'])) print ''; -if (! empty($arrayfields['t.progress_calculated']['checked'])) print ''; -if (! empty($arrayfields['t.progress']['checked'])) print ''; -if (! empty($arrayfields['t.progress_summary']['checked'])) print ''; -if (! empty($arrayfields['t.tobill']['checked'])) print ''; -if (! empty($arrayfields['t.billed']['checked'])) print ''; +if (!empty($arrayfields['t.planned_workload']['checked'])) print ''; +if (!empty($arrayfields['t.duration_effective']['checked'])) print ''; +if (!empty($arrayfields['t.progress_calculated']['checked'])) print ''; +if (!empty($arrayfields['t.progress']['checked'])) print ''; +if (!empty($arrayfields['t.progress_summary']['checked'])) print ''; +if (!empty($arrayfields['t.tobill']['checked'])) print ''; +if (!empty($arrayfields['t.billed']['checked'])) print ''; // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (! empty($arrayfields['t.datec']['checked'])) +if (!empty($arrayfields['t.datec']['checked'])) { // Date creation print ''; } -if (! empty($arrayfields['t.tms']['checked'])) +if (!empty($arrayfields['t.tms']['checked'])) { // Date modification print ''; print "\n"; print ''; -if (! empty($arrayfields['t.ref']['checked'])) print_liste_field_titre($arrayfields['t.ref']['label'], $_SERVER["PHP_SELF"], "t.ref", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['t.label']['checked'])) print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER["PHP_SELF"], "t.label", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['t.dateo']['checked'])) print_liste_field_titre($arrayfields['t.dateo']['label'], $_SERVER["PHP_SELF"], "t.dateo", "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['t.datee']['checked'])) print_liste_field_titre($arrayfields['t.datee']['label'], $_SERVER["PHP_SELF"], "t.datee", "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder); -if (! empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['t.planned_workload']['checked'])) print_liste_field_titre($arrayfields['t.planned_workload']['label'], $_SERVER["PHP_SELF"], "t.planned_workload", "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['t.duration_effective']['checked'])) print_liste_field_titre($arrayfields['t.duration_effective']['label'], $_SERVER["PHP_SELF"], "t.duration_effective", "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['t.progress_calculated']['checked'])) print_liste_field_titre($arrayfields['t.progress_calculated']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', '', '', 'center '); -if (! empty($arrayfields['t.progress']['checked'])) print_liste_field_titre($arrayfields['t.progress']['label'], $_SERVER["PHP_SELF"], "t.progress", "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['t.progress_summary']['checked'])) print_liste_field_titre($arrayfields['t.progress_summary']['label'], $_SERVER["PHP_SELF"], "t.progress", "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['t.tobill']['checked'])) print_liste_field_titre($arrayfields['t.tobill']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center '); -if (! empty($arrayfields['t.billed']['checked'])) print_liste_field_titre($arrayfields['t.billed']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.ref']['checked'])) print_liste_field_titre($arrayfields['t.ref']['label'], $_SERVER["PHP_SELF"], "t.ref", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['t.label']['checked'])) print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER["PHP_SELF"], "t.label", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['t.dateo']['checked'])) print_liste_field_titre($arrayfields['t.dateo']['label'], $_SERVER["PHP_SELF"], "t.dateo", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.datee']['checked'])) print_liste_field_titre($arrayfields['t.datee']['label'], $_SERVER["PHP_SELF"], "t.datee", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.planned_workload']['checked'])) print_liste_field_titre($arrayfields['t.planned_workload']['label'], $_SERVER["PHP_SELF"], "t.planned_workload", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.duration_effective']['checked'])) print_liste_field_titre($arrayfields['t.duration_effective']['label'], $_SERVER["PHP_SELF"], "t.duration_effective", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.progress_calculated']['checked'])) print_liste_field_titre($arrayfields['t.progress_calculated']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', '', '', 'center '); +if (!empty($arrayfields['t.progress']['checked'])) print_liste_field_titre($arrayfields['t.progress']['label'], $_SERVER["PHP_SELF"], "t.progress", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.progress_summary']['checked'])) print_liste_field_titre($arrayfields['t.progress_summary']['label'], $_SERVER["PHP_SELF"], "t.progress", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.tobill']['checked'])) print_liste_field_titre($arrayfields['t.tobill']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.billed']['checked'])) print_liste_field_titre($arrayfields['t.billed']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center '); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (! empty($arrayfields['t.datec']['checked'])) print_liste_field_titre($arrayfields['t.datec']['label'], $_SERVER["PHP_SELF"], "t.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER["PHP_SELF"], "t.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +if (!empty($arrayfields['t.datec']['checked'])) print_liste_field_titre($arrayfields['t.datec']['label'], $_SERVER["PHP_SELF"], "t.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +if (!empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER["PHP_SELF"], "t.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; -$plannedworkloadoutputformat='allhourmin'; -$timespentoutputformat='allhourmin'; -if (! empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat=$conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; -if (! empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat=$conf->global->PROJECT_TIME_SPENT_FORMAT; +$plannedworkloadoutputformat = 'allhourmin'; +$timespentoutputformat = 'allhourmin'; +if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; +if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT; -$i=0; -$totalarray=array(); +$i = 0; +$totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); @@ -624,10 +624,10 @@ while ($i < min($num, $limit)) $object->label = $obj->label; $object->fk_statut = $obj->fk_statut; $object->progress = $obj->progress; - $object->datee = $db->jdate($obj->date_end); // deprecated + $object->datee = $db->jdate($obj->date_end); // deprecated $object->date_end = $db->jdate($obj->date_end); - $object->planned_workload= $obj->planned_workload; - $object->duration_effective= $obj->duration_effective; + $object->planned_workload = $obj->planned_workload; + $object->duration_effective = $obj->duration_effective; $projectstatic->id = $obj->projectid; @@ -637,69 +637,69 @@ while ($i < min($num, $limit)) $projectstatic->statut = $obj->projectstatus; $projectstatic->datee = $db->jdate($obj->projectdatee); - $userAccess = $projectstatic->restrictedProjectArea($user); // why this ? + $userAccess = $projectstatic->restrictedProjectArea($user); // why this ? if ($userAccess >= 0) { print ''; // Ref - if (! empty($arrayfields['t.ref']['checked'])) + if (!empty($arrayfields['t.ref']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Label - if (! empty($arrayfields['t.label']['checked'])) + if (!empty($arrayfields['t.label']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date start - if (! empty($arrayfields['t.dateo']['checked'])) + if (!empty($arrayfields['t.dateo']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date end - if (! empty($arrayfields['t.datee']['checked'])) + if (!empty($arrayfields['t.datee']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Project ref - if (! empty($arrayfields['p.ref']['checked'])) + if (!empty($arrayfields['p.ref']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Project title - if (! empty($arrayfields['p.title']['checked'])) + if (!empty($arrayfields['p.title']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Third party - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Project status - if (! empty($arrayfields['p.fk_statut']['checked'])) + if (!empty($arrayfields['p.fk_statut']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Planned workload - if (! empty($arrayfields['t.planned_workload']['checked'])) + if (!empty($arrayfields['t.planned_workload']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totalprogress_calculatedfield']=$totalarray['nbfield']; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['totalprogress_calculatedfield'] = $totalarray['nbfield']; } // Declared progress - if (! empty($arrayfields['t.progress']['checked'])) + if (!empty($arrayfields['t.progress']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "\n"; @@ -885,7 +885,7 @@ if (isset($totalarray['totaldurationeffectivefield']) || isset($totalarray['tota || isset($totalarray['totaltobill']) || isset($totalarray['totalbilled'])) { print ''; - $i=0; + $i = 0; while ($i < $totalarray['nbfield']) { $i++; @@ -907,8 +907,8 @@ if (isset($totalarray['totaldurationeffectivefield']) || isset($totalarray['tota $db->free($resql); -$parameters=array('sql' => $sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('sql' => $sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print "
'; print ''; print ''; print ''; print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; - $formother->select_year($search_syear?$search_syear:-1, 'search_syear', 1, 20, 5); + $formother->select_year($search_syear ? $search_syear : -1, 'search_syear', 1, 20, 5); print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; - $formother->select_year($search_eyear?$search_eyear:-1, 'search_eyear', 1, 20, 5); + $formother->select_year($search_eyear ? $search_eyear : -1, 'search_eyear', 1, 20, 5); print ''; print ''; print ''; print ''; print ''; print ''; print ''; $arrayofstatus = array(); - foreach($projectstatic->statuts_short as $key => $val) $arrayofstatus[$key]=$langs->trans($val); - $arrayofstatus['99']=$langs->trans("NotClosed").' ('.$langs->trans('Draft').'+'.$langs->trans('Opened').')'; + foreach ($projectstatic->statuts_short as $key => $val) $arrayofstatus[$key] = $langs->trans($val); + $arrayofstatus['99'] = $langs->trans("NotClosed").' ('.$langs->trans('Draft').'+'.$langs->trans('Opened').')'; print $form->selectarray('search_projectstatus', $arrayofstatus, $search_projectstatus, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100'); print ''; print ''; @@ -575,46 +575,46 @@ if (! empty($arrayfields['t.tms']['checked'])) } // Action column print ''; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; print $object->getNomUrl(1, 'withproject'); if ($object->hasDelay()) print img_warning("Late"); print ''; print $object->label; print ''; print dol_print_date($db->jdate($obj->date_start), 'day'); print ''; print dol_print_date($db->jdate($obj->date_end), 'day'); print ''; print $projectstatic->getNomUrl(1, 'task'); if ($projectstatic->hasDelay()) print img_warning("Late"); print ''; print dol_trunc($obj->projecttitle, 80); print ''; if ($obj->socid) { - $socstatic->id=$obj->socid; - $socstatic->name=$obj->name; + $socstatic->id = $obj->socid; + $socstatic->name = $obj->name; print $socstatic->getNomUrl(1); } else @@ -707,23 +707,23 @@ while ($i < min($num, $limit)) print ' '; } print ''; print $projectstatic->getLibStatut(1); print ''; - $fullhour=convertSecondToTime($obj->planned_workload, $plannedworkloadoutputformat); - $workingdelay=convertSecondToTime($obj->planned_workload, 'all', 86400, 7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks + $fullhour = convertSecondToTime($obj->planned_workload, $plannedworkloadoutputformat); + $workingdelay = convertSecondToTime($obj->planned_workload, 'all', 86400, 7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks if ($obj->planned_workload != '') { print $fullhour; @@ -766,11 +766,11 @@ while ($i < min($num, $limit)) else print $form->textwithpicto('', $langs->trans('WorkloadNotDefined'), 1, 'help'); } print ''; if ($obj->progress != '') @@ -865,12 +865,12 @@ while ($i < min($num, $limit)) print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->id, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->id, $arrayofselected)) $selected = 1; + print ''; } print '
"; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 5a93b888192..afd4c89aab5 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -41,12 +41,12 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; $langs->loadLangs(array("companies", "commercial", "customers", "suppliers", "bills", "compta", "categories", "cashdesk")); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'thirdpartylist'; +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'thirdpartylist'; if ($contextpage == 'poslist') { @@ -55,71 +55,71 @@ if ($contextpage == 'poslist') // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'societe', $socid, ''); -$search_all=trim(GETPOST('search_all', 'alphanohtml')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$search_cti=preg_replace('/^0+/', '', preg_replace('/[^0-9]/', '', GETPOST('search_cti', 'alphanohtml'))); // Phone number without any special chars +$search_all = trim(GETPOST('search_all', 'alphanohtml') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$search_cti = preg_replace('/^0+/', '', preg_replace('/[^0-9]/', '', GETPOST('search_cti', 'alphanohtml'))); // Phone number without any special chars -$search_id=trim(GETPOST("search_id", "int")); -$search_nom=trim(GETPOST("search_nom", 'none')); -$search_alias=trim(GETPOST("search_alias", 'none')); -$search_nom_only=trim(GETPOST("search_nom_only", 'none')); -$search_barcode=trim(GETPOST("search_barcode", 'alpha')); -$search_customer_code=trim(GETPOST('search_customer_code', 'alpha')); -$search_supplier_code=trim(GETPOST('search_supplier_code', 'alpha')); -$search_account_customer_code=trim(GETPOST('search_account_customer_code', 'alpha')); -$search_account_supplier_code=trim(GETPOST('search_account_supplier_code', 'alpha')); -$search_town=trim(GETPOST("search_town", 'alpha')); -$search_zip=trim(GETPOST("search_zip", 'alpha')); -$search_state=trim(GETPOST("search_state", 'alpha')); -$search_region=trim(GETPOST("search_region", 'alpha')); -$search_email=trim(GETPOST('search_email', 'alpha')); -$search_phone=trim(GETPOST('search_phone', 'alpha')); -$search_fax=trim(GETPOST('search_fax', 'alpha')); -$search_url=trim(GETPOST('search_url', 'alpha')); -$search_idprof1=trim(GETPOST('search_idprof1', 'alpha')); -$search_idprof2=trim(GETPOST('search_idprof2', 'alpha')); -$search_idprof3=trim(GETPOST('search_idprof3', 'alpha')); -$search_idprof4=trim(GETPOST('search_idprof4', 'alpha')); -$search_idprof5=trim(GETPOST('search_idprof5', 'alpha')); -$search_idprof6=trim(GETPOST('search_idprof6', 'alpha')); -$search_vat=trim(GETPOST('search_vat', 'alpha')); -$search_sale=trim(GETPOST("search_sale", 'int')); -$search_categ_cus=trim(GETPOST("search_categ_cus", 'int')); -$search_categ_sup=trim(GETPOST("search_categ_sup", 'int')); -$search_country=GETPOST("search_country", 'intcomma'); -$search_type_thirdparty=GETPOST("search_type_thirdparty", 'int'); -$search_staff=GETPOST("search_staff", 'int'); -$search_status=GETPOST("search_status", 'int'); -$search_type=GETPOST('search_type', 'alpha'); -$search_level = GETPOST("search_level", "array"); -$search_stcomm=GETPOST('search_stcomm', 'int'); +$search_id = trim(GETPOST("search_id", "int")); +$search_nom = trim(GETPOST("search_nom", 'none')); +$search_alias = trim(GETPOST("search_alias", 'none')); +$search_nom_only = trim(GETPOST("search_nom_only", 'none')); +$search_barcode = trim(GETPOST("search_barcode", 'alpha')); +$search_customer_code = trim(GETPOST('search_customer_code', 'alpha')); +$search_supplier_code = trim(GETPOST('search_supplier_code', 'alpha')); +$search_account_customer_code = trim(GETPOST('search_account_customer_code', 'alpha')); +$search_account_supplier_code = trim(GETPOST('search_account_supplier_code', 'alpha')); +$search_town = trim(GETPOST("search_town", 'alpha')); +$search_zip = trim(GETPOST("search_zip", 'alpha')); +$search_state = trim(GETPOST("search_state", 'alpha')); +$search_region = trim(GETPOST("search_region", 'alpha')); +$search_email = trim(GETPOST('search_email', 'alpha')); +$search_phone = trim(GETPOST('search_phone', 'alpha')); +$search_fax = trim(GETPOST('search_fax', 'alpha')); +$search_url = trim(GETPOST('search_url', 'alpha')); +$search_idprof1 = trim(GETPOST('search_idprof1', 'alpha')); +$search_idprof2 = trim(GETPOST('search_idprof2', 'alpha')); +$search_idprof3 = trim(GETPOST('search_idprof3', 'alpha')); +$search_idprof4 = trim(GETPOST('search_idprof4', 'alpha')); +$search_idprof5 = trim(GETPOST('search_idprof5', 'alpha')); +$search_idprof6 = trim(GETPOST('search_idprof6', 'alpha')); +$search_vat = trim(GETPOST('search_vat', 'alpha')); +$search_sale = trim(GETPOST("search_sale", 'int')); +$search_categ_cus = trim(GETPOST("search_categ_cus", 'int')); +$search_categ_sup = trim(GETPOST("search_categ_sup", 'int')); +$search_country = GETPOST("search_country", 'intcomma'); +$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); +$search_staff = GETPOST("search_staff", 'int'); +$search_status = GETPOST("search_status", 'int'); +$search_type = GETPOST('search_type', 'alpha'); +$search_level = GETPOST("search_level", "array"); +$search_stcomm = GETPOST('search_stcomm', 'int'); $search_import_key = GETPOST("search_import_key", "alpha"); -$search_btn=GETPOST('button_search', 'alpha'); -$search_remove_btn=GETPOST('button_removefilter', 'alpha'); +$search_btn = GETPOST('button_search', 'alpha'); +$search_remove_btn = GETPOST('button_removefilter', 'alpha'); $search_parent_name = GETPOST('search_parent_name', 'alpha'); -$type=GETPOST('type', 'alpha'); -$optioncss=GETPOST('optioncss', 'alpha'); -$mode=GETPOST("mode", 'alpha'); +$type = GETPOST('type', 'alpha'); +$optioncss = GETPOST('optioncss', 'alpha'); +$mode = GETPOST("mode", 'alpha'); -$diroutputmassaction=$conf->societe->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->societe->dir_output.'/temp/massgeneration/'.$user->id; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; -$sortfield=GETPOST("sortfield", 'alpha'); -$sortorder=GETPOST("sortorder", 'alpha'); -$page=GETPOST("page", 'int'); -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="s.nom"; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); +$page = GETPOST("page", 'int'); +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "s.nom"; if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if ($type == 'c') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage='customerlist'; if ($search_type=='') $search_type='1,3'; } -if ($type == 'p') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage='prospectlist'; if ($search_type=='') $search_type='2,3'; } -if ($type == 'f') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage='supplierlist'; if ($search_type=='') $search_type='4'; } +if ($type == 'c') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage = 'customerlist'; if ($search_type == '') $search_type = '1,3'; } +if ($type == 'p') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage = 'prospectlist'; if ($search_type == '') $search_type = '2,3'; } +if ($type == 'f') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage = 'supplierlist'; if ($search_type == '') $search_type = '4'; } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Societe($db); @@ -129,7 +129,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -148,40 +148,40 @@ $fieldstosearchall = array( 's.phone'=>"Phone", 's.fax'=>"Fax", ); -if (($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof4']='ProfId4'; -if (($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof5']='ProfId5'; -if (($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof6']='ProfId6'; -if (!empty($conf->barcode->enabled)) $fieldstosearchall['s.barcode']='Gencod'; +if (($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof4'] = 'ProfId4'; +if (($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof5'] = 'ProfId5'; +if (($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof6'] = 'ProfId6'; +if (!empty($conf->barcode->enabled)) $fieldstosearchall['s.barcode'] = 'Gencod'; // Personalized search criterias. Example: $conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS = 's.nom=ThirdPartyName;s.name_alias=AliasNameShort;s.code_client=CustomerCode' -if (! empty($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS)) $fieldstosearchall=dolExplodeIntoArray($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS); +if (!empty($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS)) $fieldstosearchall = dolExplodeIntoArray($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS); // Define list of fields to show into list -$checkedcustomercode=(in_array($contextpage, array('thirdpartylist', 'customerlist', 'prospectlist', 'poslist')) ? 1 : 0); -$checkedsuppliercode=(in_array($contextpage, array('supplierlist')) ? 1 : 0); -$checkedcustomeraccountcode=(in_array($contextpage, array('customerlist')) ? 1 : 0); -$checkedsupplieraccountcode=(in_array($contextpage, array('supplierlist')) ? 1 : 0); -$checkedtypetiers=1; -$checkedprofid1=0; -$checkedprofid2=0; -$checkedprofid3=0; -$checkedprofid4=0; -$checkedprofid5=0; -$checkedprofid6=0; +$checkedcustomercode = (in_array($contextpage, array('thirdpartylist', 'customerlist', 'prospectlist', 'poslist')) ? 1 : 0); +$checkedsuppliercode = (in_array($contextpage, array('supplierlist')) ? 1 : 0); +$checkedcustomeraccountcode = (in_array($contextpage, array('customerlist')) ? 1 : 0); +$checkedsupplieraccountcode = (in_array($contextpage, array('supplierlist')) ? 1 : 0); +$checkedtypetiers = 1; +$checkedprofid1 = 0; +$checkedprofid2 = 0; +$checkedprofid3 = 0; +$checkedprofid4 = 0; +$checkedprofid5 = 0; +$checkedprofid6 = 0; //$checkedprofid4=((($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') ? 1 : 0); //$checkedprofid5=((($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') ? 1 : 0); //$checkedprofid6=((($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') ? 1 : 0); -$checkprospectlevel=(in_array($contextpage, array('prospectlist')) ? 1 : 0); -$checkstcomm=(in_array($contextpage, array('prospectlist')) ? 1 : 0); -$arrayfields=array( - 's.rowid'=>array('label'=>"TechnicalID", 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0)), +$checkprospectlevel = (in_array($contextpage, array('prospectlist')) ? 1 : 0); +$checkstcomm = (in_array($contextpage, array('prospectlist')) ? 1 : 0); +$arrayfields = array( + 's.rowid'=>array('label'=>"TechnicalID", 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID ? 1 : 0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID ? 1 : 0)), 's.nom'=>array('label'=>"ThirdPartyName", 'checked'=>1), 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>1), - 's.barcode'=>array('label'=>"Gencod", 'checked'=>1, 'enabled'=>(! empty($conf->barcode->enabled))), + 's.barcode'=>array('label'=>"Gencod", 'checked'=>1, 'enabled'=>(!empty($conf->barcode->enabled))), 's.code_client'=>array('label'=>"CustomerCodeShort", 'checked'=>$checkedcustomercode), - 's.code_fournisseur'=>array('label'=>"SupplierCodeShort", 'checked'=>$checkedsuppliercode, 'enabled'=>(! empty($conf->fournisseur->enabled))), + 's.code_fournisseur'=>array('label'=>"SupplierCodeShort", 'checked'=>$checkedsuppliercode, 'enabled'=>(!empty($conf->fournisseur->enabled))), 's.code_compta'=>array('label'=>"CustomerAccountancyCodeShort", 'checked'=>$checkedcustomeraccountcode), - 's.code_compta_fournisseur'=>array('label'=>"SupplierAccountancyCodeShort", 'checked'=>$checkedsupplieraccountcode, 'enabled'=>(! empty($conf->fournisseur->enabled))), + 's.code_compta_fournisseur'=>array('label'=>"SupplierAccountancyCodeShort", 'checked'=>$checkedsupplieraccountcode, 'enabled'=>(!empty($conf->fournisseur->enabled))), 's.town'=>array('label'=>"Town", 'checked'=>1), 's.zip'=>array('label'=>"Zip", 'checked'=>1), 'state.nom'=>array('label'=>"State", 'checked'=>0), @@ -212,10 +212,10 @@ $arrayfields=array( // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -226,19 +226,19 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ -if ($action=="change") // Change customer for TakePOS +if ($action == "change") // Change customer for TakePOS { $idcustomer = GETPOST('idcustomer', 'int'); - $place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant + $place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant // @TODO Check if draft invoice already exists, if not create it or return a warning to ask to enter at least one line to have it created automatically - $sql="UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".$idcustomer." where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; + $sql = "UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".$idcustomer." where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; $resql = $db->query($sql); ?> '; -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); -foreach($search as $key => $val) { +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +foreach ($search as $key => $val) { if (is_array($search[$key]) && count($search[$key])) { - foreach($search[$key] as $skey) { - $param.='&search_'.$key.'[]='.urlencode($skey); + foreach ($search[$key] as $skey) { + $param .= '&search_'.$key.'[]='.urlencode($skey); } } else { - $param.= '&search_'.$key.'='.urlencode($search[$key]); + $param .= '&search_'.$key.'='.urlencode($search[$key]); } } -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); -if ($user->rights->mymodule->delete) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($user->rights->mymodule->delete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); print ''; if ($optioncss != '') print ''; @@ -365,12 +365,12 @@ print ''; print ''; print ''; -$newcardbutton=''; +$newcardbutton = ''; //if ($user->rights->mymodule->creer) //{ - $newcardbutton=''.$langs->trans('New').''; - $newcardbutton.= ''; - $newcardbutton.= ''; + $newcardbutton = ''.$langs->trans('New').''; + $newcardbutton .= ''; + $newcardbutton .= ''; //} //else //{ @@ -382,15 +382,15 @@ $newcardbutton=''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit); // Add code for pre mass action (confirmation or email presend form) -$topicmail="SendHookRef"; -$modelmail="hook"; -$objecttmp=new Hook($db); -$trackid='xxxx'.$object->id; +$topicmail = "SendHookRef"; +$modelmail = "hook"; +$objecttmp = new Hook($db); +$trackid = 'xxxx'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } $moreforfilter = ''; @@ -398,56 +398,56 @@ $moreforfilter = ''; $moreforfilter.= $langs->trans('MyFilter') . ': '; $moreforfilter.= '
';*/ -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; -if (! empty($moreforfilter)) { +if (!empty($moreforfilter)) { print '
'; print $moreforfilter; print '
'; } -$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); -print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print ''."\n"; +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '
'."\n"; // Fields title search // -------------------------------------------------------------------- print ''; -foreach($object->fields as $key => $val) { - $cssforfield=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) { - $cssforfield.=($cssforfield?' ':'').'center'; +foreach ($object->fields as $key => $val) { + $cssforfield = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; } if (in_array($val['type'], array('timestamp'))) { - $cssforfield.=($cssforfield?' ':'').'nowrap'; + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; } if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) { - $cssforfield.=($cssforfield?' ':'').'right'; + $cssforfield .= ($cssforfield ? ' ' : '').'right'; } if ($key == 'status') { - $cssforfield.=($cssforfield?' ':'').'center'; + $cssforfield .= ($cssforfield ? ' ' : '').'center'; } - if (! empty($arrayfields['t.'.$key]['checked'])) { - print ''; + if (!empty($arrayfields['t.'.$key]['checked'])) { + print ''; } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; print ''."\n"; @@ -456,16 +456,16 @@ print ''."\n"; // Fields title label // -------------------------------------------------------------------- print ''; -foreach($object->fields as $key => $val) { - $cssforfield=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield.=($cssforfield?' ':'').'right'; +foreach ($object->fields as $key => $val) { + $cssforfield = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; + if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield .= ($cssforfield ? ' ' : '').'right'; if ($key == 'status') { - $cssforfield.=($cssforfield?' ':'').'center'; + $cssforfield .= ($cssforfield ? ' ' : '').'center'; } - if (! empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n"; + if (!empty($arrayfields['t.'.$key]['checked'])) { + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } } // Extra fields @@ -477,7 +477,7 @@ $parameters = array( 'sortfield' => $sortfield, 'sortorder' => $sortorder, ); -$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; @@ -485,7 +485,7 @@ print ''."\n"; // Detect if we need a fetch on each output line -$needToFetchEachLine=0; +$needToFetchEachLine = 0; if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { if (preg_match('/\$object/', $val)) { @@ -498,36 +498,36 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co // Loop on record // -------------------------------------------------------------------- -$i=0; -$totalarray=array(); +$i = 0; +$totalarray = array(); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); if (empty($obj)) { - break; // Should not happen + break; // Should not happen } // Store properties in $object $object->id = $obj->rowid; - foreach($object->fields as $key => $val) { + foreach ($object->fields as $key => $val) { if (isset($obj->$key)) $object->$key = $obj->$key; } // Show here line of result print ''; - foreach($object->fields as $key => $val) { - $cssforfield=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) { - $cssforfield.=($cssforfield?' ':'').'center'; + foreach ($object->fields as $key => $val) { + $cssforfield = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif ($key == 'status') { - $cssforfield.=($cssforfield?' ':'').'center'; + $cssforfield .= ($cssforfield ? ' ' : '').'center'; } - if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; + if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield.=($cssforfield?' ':'').'right'; + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (! empty($arrayfields['t.'.$key]['checked'])) { + if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; if ($key == 'status') print $object->getLibStatut(5); - elseif (in_array($val['type'], array('date','datetime','timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); + elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); else print $object->showOutputField($val, $key, $obj->$key, ''); print ''; - if (! $i) $totalarray['nbfield']++; - if (! empty($val['isameasure'])) + if (!$i) $totalarray['nbfield']++; + if (!empty($val['isameasure'])) { - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; $totalarray['val']['t.'.$key] += $obj->$key; } } @@ -550,19 +550,19 @@ while ($i < min($num, $limit)) { // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print ''; @@ -575,9 +575,9 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found if ($num == 0) { - $colspan=1; - foreach($arrayfields as $key => $val) { - if (! empty($val['checked'])) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { $colspan++; } } @@ -591,7 +591,7 @@ $parameters = array( 'arrayfields' => $arrayfields, 'sql' => $sql, ); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; } print '
'."\n"; @@ -600,21 +600,21 @@ print '
'."\n"; print ''."\n"; if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - $hidegeneratedfilelistifempty=1; + $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { - $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 0; } require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->mymodule->read; - $delallowed=$user->rights->mymodule->create; + $filedir = $diroutputmassaction; + $genallowed = $user->rights->mymodule->read; + $delallowed = $user->rights->mymodule->create; print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); }