From df664e790bdfdf788507fdf11a2f7fb66fc51442 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Mon, 11 Nov 2019 23:15:34 +0000 Subject: [PATCH] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/compta/accounting-files.php | 306 ++-- htdocs/compta/bank/annuel.php | 248 ++-- htdocs/compta/bank/releve.php | 296 ++-- htdocs/compta/charges/index.php | 248 ++-- htdocs/compta/deplacement/card.php | 94 +- htdocs/compta/facture/card-rec.php | 418 +++--- htdocs/compta/facture/card.php | 1650 +++++++++++----------- htdocs/compta/localtax/index.php | 172 +-- htdocs/compta/localtax/list.php | 24 +- htdocs/compta/localtax/quadri_detail.php | 264 ++-- htdocs/compta/paiement/cheque/card.php | 186 +-- htdocs/compta/prelevement/factures.php | 48 +- htdocs/compta/recap-compta.php | 88 +- htdocs/compta/resultat/clientfourn.php | 562 ++++---- htdocs/compta/tva/clients.php | 246 ++-- htdocs/compta/tva/index.php | 174 +-- htdocs/compta/tva/list.php | 142 +- htdocs/compta/tva/quadri_detail.php | 276 ++-- htdocs/contrat/index.php | 360 ++--- htdocs/don/index.php | 66 +- htdocs/fourn/commande/index.php | 144 +- htdocs/fourn/contact.php | 24 +- htdocs/fourn/recap-fourn.php | 42 +- htdocs/loan/createschedule.php | 94 +- htdocs/loan/schedule.php | 104 +- htdocs/printing/admin/printing.php | 62 +- htdocs/product/card.php | 552 ++++---- htdocs/product/index.php | 242 ++-- htdocs/product/price.php | 884 ++++++------ htdocs/product/stats/card.php | 210 +-- htdocs/product/traduction.php | 72 +- htdocs/reception/card.php | 668 ++++----- htdocs/takepos/invoice.php | 316 ++--- htdocs/takepos/send.php | 32 +- htdocs/user/bank.php | 102 +- htdocs/website/index.php | 984 ++++++------- 36 files changed, 5200 insertions(+), 5200 deletions(-) diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index eec09bb94cc..1d238a7b852 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -34,24 +34,24 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; $langs->loadLangs(array("accountancy", "bills", "companies", "salaries", "compta")); -$date_start =GETPOST('date_start', 'alpha'); -$date_startDay= GETPOST('date_startday', 'int'); -$date_startMonth= GETPOST('date_startmonth', 'int'); -$date_startYear= GETPOST('date_startyear', 'int'); -$date_start=($date_startDay)?dol_mktime(0, 0, 0, $date_startMonth, $date_startDay, $date_startYear):strtotime($date_start); -$date_stop =GETPOST('date_stop', 'alpha'); -$date_stopDay= GETPOST('date_stopday', 'int'); -$date_stopMonth= GETPOST('date_stopmonth', 'int'); -$date_stopYear= GETPOST('date_stopyear', 'int'); +$date_start = GETPOST('date_start', 'alpha'); +$date_startDay = GETPOST('date_startday', 'int'); +$date_startMonth = GETPOST('date_startmonth', 'int'); +$date_startYear = GETPOST('date_startyear', 'int'); +$date_start = ($date_startDay) ?dol_mktime(0, 0, 0, $date_startMonth, $date_startDay, $date_startYear) : strtotime($date_start); +$date_stop = GETPOST('date_stop', 'alpha'); +$date_stopDay = GETPOST('date_stopday', 'int'); +$date_stopMonth = GETPOST('date_stopmonth', 'int'); +$date_stopYear = GETPOST('date_stopyear', 'int'); //FIXME doldate -$date_stop=($date_stopDay)?dol_mktime(23, 59, 59, $date_stopMonth, $date_stopDay, $date_stopYear):strtotime($date_stop); -$action =GETPOST('action', 'alpha'); +$date_stop = ($date_stopDay) ?dol_mktime(23, 59, 59, $date_stopMonth, $date_stopDay, $date_stopYear) : strtotime($date_stop); +$action = GETPOST('action', 'alpha'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('comptafileslist','globallist')); +$hookmanager->initHooks(array('comptafileslist', 'globallist')); // 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'); @@ -59,11 +59,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="date,item"; // Set here default search field -if (! $sortorder) $sortorder="DESC"; +if (!$sortfield) $sortfield = "date,item"; // Set here default search field +if (!$sortorder) $sortorder = "DESC"; -$arrayfields=array( +$arrayfields = array( 'type'=>array('label'=>"Type", 'checked'=>1), 'date'=>array('label'=>"Date", 'checked'=>1), //... @@ -77,7 +77,7 @@ if ($user->socid > 0) { accessforbidden(); } -$entity = GETPOST('entity', 'int')?GETPOST('entity', 'int'):$conf->entity; +$entity = GETPOST('entity', 'int') ?GETPOST('entity', 'int') : $conf->entity; /* @@ -89,9 +89,9 @@ $entity = GETPOST('entity', 'int')?GETPOST('entity', 'int'):$conf->entity; //$reshook = $hookmanager->executeHooks('doActions', $parameters, $object); // Note that $object may have been modified by some hooks //if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -$filesarray=array(); -$result=false; -if (($action=="searchfiles" || $action=="dl" )) { +$filesarray = array(); +$result = false; +if (($action == "searchfiles" || $action == "dl")) { if (empty($date_start)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateStart")), null, 'errors'); @@ -103,159 +103,159 @@ if (($action=="searchfiles" || $action=="dl" )) { $error++; } - if (! $error) + if (!$error) { - $wheretail=" '".$db->idate($date_start)."' AND '".$db->idate($date_stop)."'"; + $wheretail = " '".$db->idate($date_start)."' AND '".$db->idate($date_stop)."'"; - $sql="SELECT t.rowid as id, t.ref, t.paye as paid, total as total_ht, total_ttc, tva as total_vat, fk_soc, t.datef as date, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; - $sql.=" FROM ".MAIN_DB_PREFIX."facture as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; - $sql.=" WHERE datef between ".$wheretail; - $sql.=" AND t.entity IN (".($entity==1?'0,1':$entity).')'; - $sql.=" AND t.fk_statut <> ".Facture::STATUS_DRAFT; - $sql.=" UNION ALL"; - $sql.=" SELECT t.rowid as id, t.ref, paye as paid, total_ht, total_ttc, total_tva as total_vat, fk_soc, datef as date, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; - $sql.=" FROM ".MAIN_DB_PREFIX."facture_fourn as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; - $sql.=" WHERE datef between ".$wheretail; - $sql.=" AND t.entity IN (".($entity==1?'0,1':$entity).')'; - $sql.=" AND t.fk_statut <> ".FactureFournisseur::STATUS_DRAFT; - $sql.=" UNION ALL"; - $sql.=" SELECT t.rowid as id, t.ref, paid, total_ht, total_ttc, total_tva as total_vat, fk_user_author as fk_soc, date_fin as date, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; - $sql.=" FROM ".MAIN_DB_PREFIX."expensereport as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user_author LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; - $sql.=" WHERE date_fin between ".$wheretail; - $sql.=" AND t.entity IN (".($entity==1?'0,1':$entity).')'; - $sql.=" AND t.fk_statut <> ".ExpenseReport::STATUS_DRAFT; - $sql.=" UNION ALL"; - $sql.=" SELECT t.rowid as id, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, 0 as fk_soc, datedon as date, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; - $sql.=" FROM ".MAIN_DB_PREFIX."don as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_country"; - $sql.=" WHERE datedon between ".$wheretail; - $sql.=" AND t.entity IN (".($entity==1?'0,1':$entity).')'; - $sql.=" AND t.fk_statut <> ".Don::STATUS_DRAFT; - $sql.=" UNION ALL"; - $sql.=" SELECT t.rowid as id, t.label as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, t.fk_user as fk_soc, datep as date, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; - $sql.=" FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; - $sql.=" WHERE datep between ".$wheretail; - $sql.=" AND t.entity IN (".($entity==1?'0,1':$entity).')'; + $sql = "SELECT t.rowid as id, t.ref, t.paye as paid, total as total_ht, total_ttc, tva as total_vat, fk_soc, t.datef as date, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; + $sql .= " WHERE datef between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + $sql .= " AND t.fk_statut <> ".Facture::STATUS_DRAFT; + $sql .= " UNION ALL"; + $sql .= " SELECT t.rowid as id, t.ref, paye as paid, total_ht, total_ttc, total_tva as total_vat, fk_soc, datef as date, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; + $sql .= " WHERE datef between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + $sql .= " AND t.fk_statut <> ".FactureFournisseur::STATUS_DRAFT; + $sql .= " UNION ALL"; + $sql .= " SELECT t.rowid as id, t.ref, paid, total_ht, total_ttc, total_tva as total_vat, fk_user_author as fk_soc, date_fin as date, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user_author LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; + $sql .= " WHERE date_fin between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + $sql .= " AND t.fk_statut <> ".ExpenseReport::STATUS_DRAFT; + $sql .= " UNION ALL"; + $sql .= " SELECT t.rowid as id, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, 0 as fk_soc, datedon as date, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; + $sql .= " FROM ".MAIN_DB_PREFIX."don as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_country"; + $sql .= " WHERE datedon between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; + $sql .= " AND t.fk_statut <> ".Don::STATUS_DRAFT; + $sql .= " UNION ALL"; + $sql .= " SELECT t.rowid as id, t.label as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, t.fk_user as fk_soc, datep as date, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; + $sql .= " WHERE datep between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; //$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT; - $sql.=" UNION ALL"; - $sql.=" SELECT t.rowid as id, t.libelle as ref, paye as paid, amount as total_ht, amount as total_ttc, 0 as total_tva, 0 as fk_soc, date_creation as date, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum"; - $sql.=" FROM ".MAIN_DB_PREFIX."chargesociales as t"; - $sql.=" WHERE date_creation between ".$wheretail; - $sql.=" AND t.entity IN (".($entity==1?'0,1':$entity).')'; + $sql .= " UNION ALL"; + $sql .= " SELECT t.rowid as id, t.libelle as ref, paye as paid, amount as total_ht, amount as total_ttc, 0 as total_tva, 0 as fk_soc, date_creation as date, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum"; + $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as t"; + $sql .= " WHERE date_creation between ".$wheretail; + $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; //$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT; - $sql.= $db->order($sortfield, $sortorder); + $sql .= $db->order($sortfield, $sortorder); //print $sql; $resd = $db->query($sql); - $files=array(); - $link=''; + $files = array(); + $link = ''; if ($resd) { $numd = $db->num_rows($resd); - $tmpinvoice=new Facture($db); - $tmpinvoicesupplier=new FactureFournisseur($db); - $tmpdonation=new Don($db); + $tmpinvoice = new Facture($db); + $tmpinvoicesupplier = new FactureFournisseur($db); + $tmpdonation = new Don($db); - $upload_dir =''; - $i=0; + $upload_dir = ''; + $i = 0; while ($i < $numd) { $objd = $db->fetch_object($resd); - switch($objd->item) + switch ($objd->item) { case "Invoice": $subdir = ''; - $subdir.=($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); $upload_dir = $conf->facture->dir_output.'/'.$subdir; - $link="document.php?modulepart=facture&file=".str_replace('/', '%2F', $subdir).'%2F'; + $link = "document.php?modulepart=facture&file=".str_replace('/', '%2F', $subdir).'%2F'; break; case "SupplierInvoice": $tmpinvoicesupplier->fetch($objd->id); - $subdir = get_exdir($tmpinvoicesupplier->id, 2, 0, 1, $tmpinvoicesupplier, 'invoice_supplier'); // TODO Use first file - $subdir.=($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); + $subdir = get_exdir($tmpinvoicesupplier->id, 2, 0, 1, $tmpinvoicesupplier, 'invoice_supplier'); // TODO Use first file + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); $upload_dir = $conf->fournisseur->facture->dir_output.'/'.$subdir; - $link="document.php?modulepart=facture_fournisseur&file=".str_replace('/', '%2F', $subdir).'%2F'; + $link = "document.php?modulepart=facture_fournisseur&file=".str_replace('/', '%2F', $subdir).'%2F'; break; case "ExpenseReport": $subdir = ''; - $subdir.=($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->ref); $upload_dir = $conf->expensereport->dir_output.'/'.$subdir; - $link="document.php?modulepart=expensereport&file=".str_replace('/', '%2F', $subdir).'%2F'; + $link = "document.php?modulepart=expensereport&file=".str_replace('/', '%2F', $subdir).'%2F'; break; case "SalaryPayment": $subdir = ''; - $subdir.=($subdir ? '/' : '').dol_sanitizeFileName($objd->id); + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); $upload_dir = $conf->salaries->dir_output.'/'.$subdir; - $link="document.php?modulepart=salaries&file=".str_replace('/', '%2F', $subdir).'%2F'; + $link = "document.php?modulepart=salaries&file=".str_replace('/', '%2F', $subdir).'%2F'; break; case "Donation": $tmpdonation->fetch($objp->id); - $subdir=get_exdir(0, 0, 0, 0, $tmpdonation, 'donation'); - $subdir.=($subdir ? '/' : '').dol_sanitizeFileName($objd->id); - $upload_dir = $conf->don->dir_output . '/' . $subdir; - $link="document.php?modulepart=don&file=".str_replace('/', '%2F', $subdir).'%2F'; + $subdir = get_exdir(0, 0, 0, 0, $tmpdonation, 'donation'); + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); + $upload_dir = $conf->don->dir_output.'/'.$subdir; + $link = "document.php?modulepart=don&file=".str_replace('/', '%2F', $subdir).'%2F'; break; case "SocialContributions": $subdir = ''; - $subdir.=($subdir ? '/' : '').dol_sanitizeFileName($objd->id); - $upload_dir = $conf->tax->dir_output . '/' . $subdir; - $link="document.php?modulepart=tax&file=".str_replace('/', '%2F', $subdir).'%2F'; + $subdir .= ($subdir ? '/' : '').dol_sanitizeFileName($objd->id); + $upload_dir = $conf->tax->dir_output.'/'.$subdir; + $link = "document.php?modulepart=tax&file=".str_replace('/', '%2F', $subdir).'%2F'; break; default: - $subdir=''; - $upload_dir=''; - $link=''; + $subdir = ''; + $upload_dir = ''; + $link = ''; break; } if (!empty($upload_dir)) { - $result=true; - $files=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview\.png)$', '', SORT_ASC, 1); + $result = true; + $files = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview\.png)$', '', SORT_ASC, 1); //var_dump($upload_dir); if (count($files) < 1) { - $nofile['id']=$objd->id; - $nofile['date']=$db->idate($objd->date); - $nofile['paid']=$objd->paid; - $nofile['amount_ht']=$objd->total_ht; - $nofile['amount_ttc']=$objd->total_ttc; - $nofile['amount_vat']=$objd->total_vat; - $nofile['ref']=($objd->ref ? $objd->ref : $objd->id); - $nofile['fk']=$objd->fk_soc; - $nofile['item']=$objd->item; - $nofile['thirdparty_name']=$objd->thirdparty_name; - $nofile['thirdparty_code']=$objd->thirdparty_code; - $nofile['country_code']=$objd->country_code; - $nofile['vatnum']=$objd->vatnum; + $nofile['id'] = $objd->id; + $nofile['date'] = $db->idate($objd->date); + $nofile['paid'] = $objd->paid; + $nofile['amount_ht'] = $objd->total_ht; + $nofile['amount_ttc'] = $objd->total_ttc; + $nofile['amount_vat'] = $objd->total_vat; + $nofile['ref'] = ($objd->ref ? $objd->ref : $objd->id); + $nofile['fk'] = $objd->fk_soc; + $nofile['item'] = $objd->item; + $nofile['thirdparty_name'] = $objd->thirdparty_name; + $nofile['thirdparty_code'] = $objd->thirdparty_code; + $nofile['country_code'] = $objd->country_code; + $nofile['vatnum'] = $objd->vatnum; - $filesarray[]=$nofile; + $filesarray[] = $nofile; } else { foreach ($files as $key => $file) { - $file['id']=$objd->id; - $file['date']=$db->idate($objd->date); - $file['paid']=$objd->paid; - $file['amount_ht']=$objd->total_ht; - $file['amount_ttc']=$objd->total_ttc; - $file['amount_vat']=$objd->total_vat; - $file['ref']=($objd->ref ? $objd->ref : $objd->id); - $file['fk']=$objd->fk_soc; - $file['item']=$objd->item; + $file['id'] = $objd->id; + $file['date'] = $db->idate($objd->date); + $file['paid'] = $objd->paid; + $file['amount_ht'] = $objd->total_ht; + $file['amount_ttc'] = $objd->total_ttc; + $file['amount_vat'] = $objd->total_vat; + $file['ref'] = ($objd->ref ? $objd->ref : $objd->id); + $file['fk'] = $objd->fk_soc; + $file['item'] = $objd->item; - $file['thirdparty_name']=$objd->thirdparty_name; - $file['thirdparty_code']=$objd->thirdparty_code; - $file['country_code']=$objd->country_code; - $file['vatnum']=$objd->vatnum; + $file['thirdparty_name'] = $objd->thirdparty_name; + $file['thirdparty_code'] = $objd->thirdparty_code; + $file['country_code'] = $objd->country_code; + $file['vatnum'] = $objd->vatnum; - $file['link']=$link.$file['name']; + $file['link'] = $link.$file['name']; $file['relpathnamelang'] = $langs->trans($file['item']).'/'.$file['name']; - $filesarray[]=$file; + $filesarray[] = $file; } } } @@ -284,9 +284,9 @@ if (empty($dirfortmpfile)) } -if ($result && $action == "dl" && ! $error) +if ($result && $action == "dl" && !$error) { - if (! extension_loaded('zip')) + if (!extension_loaded('zip')) { setEventMessages('PHPZIPExtentionNotLoaded', null, 'errors'); exit; @@ -295,41 +295,41 @@ if ($result && $action == "dl" && ! $error) dol_mkdir($dirfortmpfile); $log = $langs->transnoentitiesnoconv("Type"); - $log .= ',' . $langs->transnoentitiesnoconv("Date"); - $log .= ',' . $langs->transnoentitiesnoconv("Ref"); - $log .= ',' . $langs->transnoentitiesnoconv("TotalHT"); - $log .= ',' . $langs->transnoentitiesnoconv("TotalTTC"); - $log .= ',' . $langs->transnoentitiesnoconv("TotalVAT"); - $log .= ',' . $langs->transnoentitiesnoconv("Paid"); + $log .= ','.$langs->transnoentitiesnoconv("Date"); + $log .= ','.$langs->transnoentitiesnoconv("Ref"); + $log .= ','.$langs->transnoentitiesnoconv("TotalHT"); + $log .= ','.$langs->transnoentitiesnoconv("TotalTTC"); + $log .= ','.$langs->transnoentitiesnoconv("TotalVAT"); + $log .= ','.$langs->transnoentitiesnoconv("Paid"); $log .= ',filename,item_id'; - $log .= ',' . $langs->transnoentitiesnoconv("ThirdParty"); - $log .= ',' . $langs->transnoentitiesnoconv("Code"); - $log .= ',' . $langs->transnoentitiesnoconv("Country"); - $log .= ',' . $langs->transnoentitiesnoconv("VATIntra")."\n"; + $log .= ','.$langs->transnoentitiesnoconv("ThirdParty"); + $log .= ','.$langs->transnoentitiesnoconv("Code"); + $log .= ','.$langs->transnoentitiesnoconv("Country"); + $log .= ','.$langs->transnoentitiesnoconv("VATIntra")."\n"; $zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc')."-".dol_print_date($date_stop, 'dayrfc').'_export.zip'; dol_delete_file($zipname); $zip = new ZipArchive; - $res = $zip->open($zipname, ZipArchive::OVERWRITE|ZipArchive::CREATE); + $res = $zip->open($zipname, ZipArchive::OVERWRITE | ZipArchive::CREATE); if ($res) { foreach ($filesarray as $key => $file) { if (file_exists($file["fullname"])) $zip->addFile($file["fullname"], $file["relpathnamelang"]); $log .= $file['item']; - $log .= ',' . dol_print_date($file['date'], 'dayrfc'); - $log .= ',' . $file['ref']; - $log .= ',' . $file['amount_ht']; - $log .= ',' . $file['amount_ttc']; - $log .= ',' . $file['amount_vat']; - $log .= ',' . $file['paid']; - $log .= ',' . $file["name"]; - $log .= ',' . $file['fk']; - $log .= ',' . $file['thirdparty_name']; - $log .= ',' . $file['thirdparty_code']; - $log .= ',' . $file['country_code']; - $log .= ',"' . $file['vatnum'].'"'."\n"; + $log .= ','.dol_print_date($file['date'], 'dayrfc'); + $log .= ','.$file['ref']; + $log .= ','.$file['amount_ht']; + $log .= ','.$file['amount_ttc']; + $log .= ','.$file['amount_vat']; + $log .= ','.$file['paid']; + $log .= ','.$file["name"]; + $log .= ','.$file['fk']; + $log .= ','.$file['thirdparty_name']; + $log .= ','.$file['thirdparty_code']; + $log .= ','.$file['country_code']; + $log .= ',"'.$file['vatnum'].'"'."\n"; } $zip->addFromString('transactions.csv', $log); $zip->close(); @@ -337,7 +337,7 @@ if ($result && $action == "dl" && ! $error) ///Then download the zipped file. header('Content-Type: application/zip'); header('Content-disposition: attachment; filename='.basename($zipname)); - header('Content-Length: ' . filesize($zipname)); + header('Content-Length: '.filesize($zipname)); readfile($zipname); dol_delete_file($zipname); @@ -356,13 +356,13 @@ if ($result && $action == "dl" && ! $error) */ $form = new Form($db); -$userstatic=new User($db); +$userstatic = new User($db); -$title=$langs->trans("ComptaFiles").' - '.$langs->trans("List"); +$title = $langs->trans("ComptaFiles").' - '.$langs->trans("List"); llxHeader('', $title, $help_url); -$h=0; +$h = 0; $head[$h][0] = $_SERVER["PHP_SELF"].$varlink; $head[$h][1] = $langs->trans("AccountantFiles"); $head[$h][2] = 'AccountancyFiles'; @@ -376,7 +376,7 @@ print $langs->trans("ReportPeriod").': '.$form->selectDate($date_start, 'date_st print ' - '.$form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0)."\n"; // Export is for current company only ! -if (! empty($conf->multicompany->enabled) && is_object($mc)) +if (!empty($conf->multicompany->enabled) && is_object($mc)) { print '('.$langs->trans("Entity").' : '; $mc->dao->getEntities(); @@ -393,13 +393,13 @@ dol_fiche_end(); if (!empty($date_start) && !empty($date_stop)) { - $param='action=searchfiles'; - $param.='&date_startday='.GETPOST('date_startday', 'int'); - $param.='&date_startmonth='.GETPOST('date_startmonth', 'int'); - $param.='&date_startyear='.GETPOST('date_startyear', 'int'); - $param.='&date_stopday='.GETPOST('date_stopday', 'int'); - $param.='&date_stopmonth='.GETPOST('date_stopmonth', 'int'); - $param.='&date_stopyear='.GETPOST('date_stopyear', 'int'); + $param = 'action=searchfiles'; + $param .= '&date_startday='.GETPOST('date_startday', 'int'); + $param .= '&date_startmonth='.GETPOST('date_startmonth', 'int'); + $param .= '&date_startyear='.GETPOST('date_startyear', 'int'); + $param .= '&date_stopday='.GETPOST('date_stopday', 'int'); + $param .= '&date_stopmonth='.GETPOST('date_stopmonth', 'int'); + $param .= '&date_stopyear='.GETPOST('date_stopyear', 'int'); print '
'."\n"; print ''; @@ -422,7 +422,7 @@ if (!empty($date_start) && !empty($date_stop)) print '
'; - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "type", "", $param, '', $sortfield, $sortorder, 'nowrap '); @@ -457,7 +457,7 @@ if (!empty($date_start) && !empty($date_stop)) $totalCredit = 0; // Display array - foreach($TData as $data) + foreach ($TData as $data) { $html_class = ''; //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture']; diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index d10374e4c8d..1f6e5e6620c 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -32,28 +32,28 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; // Load translation files required by the page $langs->loadLangs(array('banks', 'categories')); -$WIDTH=DolGraph::getDefaultGraphSizeForStats('width', 380); // Large for one graph in a smarpthone. -$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height', 160); +$WIDTH = DolGraph::getDefaultGraphSizeForStats('width', 380); // Large for one graph in a smarpthone. +$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height', 160); -$id=GETPOST('account')?GETPOST('account', 'alpha'):GETPOST('id'); -$ref=GETPOST('ref'); +$id = GETPOST('account') ?GETPOST('account', 'alpha') : GETPOST('id'); +$ref = GETPOST('ref'); // Security check -$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :'')); -$fieldtype = (! empty($ref) ? 'ref' :'rowid'); -if ($user->socid) $socid=$user->socid; -$result=restrictedArea($user, 'banque', $fieldvalue, 'bank_account&bank_account', '', '', $fieldtype); +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'banque', $fieldvalue, 'bank_account&bank_account', '', '', $fieldtype); -$year_start=GETPOST('year_start'); +$year_start = GETPOST('year_start'); $year_current = strftime("%Y", time()); -if (! $year_start) +if (!$year_start) { $year_start = $year_current - 2; $year_end = $year_current; } else { - $year_end=$year_start+2; + $year_end = $year_start + 2; } @@ -70,15 +70,15 @@ $form = new Form($db); // Get account informations $object = new Account($db); -if ($id > 0 && ! preg_match('/,/', $id)) // if for a particular account and not a list +if ($id > 0 && !preg_match('/,/', $id)) // if for a particular account and not a list { - $result=$object->fetch($id); - $id=$object->id; + $result = $object->fetch($id); + $id = $object->id; } -if (! empty($ref)) +if (!empty($ref)) { - $result=$object->fetch(0, $ref); - $id=$object->id; + $result = $object->fetch(0, $ref); + $id = $object->id; } @@ -86,17 +86,17 @@ if (! empty($ref)) // plutot que sur llx_paiement + llx_paiementfourn $sql = "SELECT SUM(b.amount)"; -$sql.= ", date_format(b.dateo,'%Y-%m') as dm"; -$sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; -$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; -$sql.= " WHERE b.fk_account = ba.rowid"; -$sql.= " AND ba.entity IN (".getEntity('bank_account').")"; -$sql.= " AND b.amount >= 0"; -if (! empty($id)) +$sql .= ", date_format(b.dateo,'%Y-%m') as dm"; +$sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; +$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; +$sql .= " WHERE b.fk_account = ba.rowid"; +$sql .= " AND ba.entity IN (".getEntity('bank_account').")"; +$sql .= " AND b.amount >= 0"; +if (!empty($id)) $sql .= " AND b.fk_account IN (".$db->escape($id).")"; -$sql.= " GROUP BY dm"; +$sql .= " GROUP BY dm"; -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -114,17 +114,17 @@ else } $sql = "SELECT SUM(b.amount)"; -$sql.= ", date_format(b.dateo,'%Y-%m') as dm"; -$sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; -$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; -$sql.= " WHERE b.fk_account = ba.rowid"; -$sql.= " AND ba.entity IN (".getEntity('bank_account').")"; -$sql.= " AND b.amount <= 0"; -if (! empty($id)) +$sql .= ", date_format(b.dateo,'%Y-%m') as dm"; +$sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; +$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; +$sql .= " WHERE b.fk_account = ba.rowid"; +$sql .= " AND ba.entity IN (".getEntity('bank_account').")"; +$sql .= " AND b.amount <= 0"; +if (!empty($id)) $sql .= " AND b.fk_account IN (".$db->escape($id).")"; -$sql.= " GROUP BY dm"; +$sql .= " GROUP BY dm"; -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -143,31 +143,31 @@ else // Onglets -$head=bank_prepare_head($object); +$head = bank_prepare_head($object); dol_fiche_head($head, 'annual', $langs->trans("FinancialAccount"), 0, 'account'); -$title=$langs->trans("FinancialAccount")." : ".$object->label; -$link=($year_start?"".img_previous('', 'class="valignbottom"')." ".$langs->trans("Year")." ".img_next('', 'class="valignbottom"')."":""); +$title = $langs->trans("FinancialAccount")." : ".$object->label; +$link = ($year_start ? "".img_previous('', 'class="valignbottom"')." ".$langs->trans("Year")." ".img_next('', 'class="valignbottom"')."" : ""); $linkback = ''.$langs->trans("BackToList").''; if (!empty($id)) { - if (! preg_match('/,/', $id)) + if (!preg_match('/,/', $id)) { dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); } else { - $bankaccount=new Account($db); - $listid=explode(',', $id); - foreach($listid as $key => $aId) + $bankaccount = new Account($db); + $listid = explode(',', $id); + foreach ($listid as $key => $aId) { $bankaccount->fetch($aId); - $bankaccount->label=$bankaccount->ref; + $bankaccount->label = $bankaccount->ref; print $bankaccount->getNomUrl(1); - if ($key < (count($listid)-1)) print ', '; + if ($key < (count($listid) - 1)) print ', '; } } } @@ -182,11 +182,11 @@ dol_fiche_end(); // Affiche tableau print load_fiche_titre('', $link, ''); -print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print '
'; print ''; -for ($annee = $year_start ; $annee <= $year_end ; $annee++) +for ($annee = $year_start; $annee <= $year_end; $annee++) { print ''; } @@ -194,33 +194,33 @@ print ''; print ''; print ''; -for ($annee = $year_start ; $annee <= $year_end ; $annee++) +for ($annee = $year_start; $annee <= $year_end; $annee++) { print ''; } print ''; -for ($mois = 1 ; $mois < 13 ; $mois++) +for ($mois = 1; $mois < 13; $mois++) { print ''; print ""; - for ($annee = $year_start ; $annee <= $year_end ; $annee++) + for ($annee = $year_start; $annee <= $year_end; $annee++) { $case = sprintf("%04s-%02s", $annee, $mois); print '"; print '"; } @@ -229,7 +229,7 @@ for ($mois = 1 ; $mois < 13 ; $mois++) // Total debit-credit print '"; -for ($annee = $year_start ; $annee <= $year_end ; $annee++) +for ($annee = $year_start; $annee <= $year_end; $annee++) { print ''; } @@ -242,21 +242,21 @@ print '
'; // Current balance -$balance=0; +$balance = 0; $sql = "SELECT SUM(b.amount) as total"; -$sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; -$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; -$sql.= " WHERE b.fk_account = ba.rowid"; -$sql.= " AND ba.entity IN (".getEntity('bank_account').")"; -if (! empty($id)) - $sql.= " AND b.fk_account IN (".$db->escape($id).")"; +$sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; +$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; +$sql .= " WHERE b.fk_account = ba.rowid"; +$sql .= " AND ba.entity IN (".getEntity('bank_account').")"; +if (!empty($id)) + $sql .= " AND b.fk_account IN (".$db->escape($id).")"; -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) $balance=$obj->total; + if ($obj) $balance = $obj->total; } else { dol_print_error($db); @@ -274,7 +274,7 @@ print "
'.$langs->trans("Month").''.$annee.'
 '.$langs->trans("Debit").''.$langs->trans("Credit").'
".dol_print_date(dol_mktime(1, 1, 1, $mois, 1, 2000), "%B")." '; - if ($decaiss[$case]>0) + if ($decaiss[$case] > 0) { print price($decaiss[$case]); - $totsorties[$annee]+=$decaiss[$case]; + $totsorties[$annee] += $decaiss[$case]; } print " '; - if ($encaiss[$case]>0) + if ($encaiss[$case] > 0) { print price($encaiss[$case]); - $totentrees[$annee]+=$encaiss[$case]; + $totentrees[$annee] += $encaiss[$case]; } print "
'.$langs->trans("Total")."'.price($totsorties[$annee]).''.price($totentrees[$annee]).'
"; $year = $year_end; -$result=dol_mkdir($conf->bank->dir_temp); +$result = dol_mkdir($conf->bank->dir_temp); if ($result < 0) { $langs->load("errors"); @@ -285,11 +285,11 @@ else { // Calcul de $min et $max $sql = "SELECT MIN(b.datev) as min, MAX(b.datev) as max"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - if ($id && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$id.")"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + if ($id && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$id.")"; $resql = $db->query($sql); if ($resql) @@ -303,7 +303,7 @@ else { dol_print_error($db); } - $log="graph.php: min=".$min." max=".$max; + $log = "graph.php: min=".$min." max=".$max; dol_syslog($log); // CRED PART @@ -312,18 +312,18 @@ else $tblyear[1] = array(); $tblyear[2] = array(); - for ($annee=0;$annee<3;$annee++) + for ($annee = 0; $annee < 3; $annee++) { $sql = "SELECT date_format(b.datev,'%m')"; - $sql.= ", SUM(b.amount)"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql.= " AND b.datev >= '".($year-$annee)."-01-01 00:00:00'"; - $sql.= " AND b.datev <= '".($year-$annee)."-12-31 23:59:59'"; - $sql.= " AND b.amount > 0"; - if ($id && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$id.")"; + $sql .= ", SUM(b.amount)"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql .= " AND b.datev >= '".($year - $annee)."-01-01 00:00:00'"; + $sql .= " AND b.datev <= '".($year - $annee)."-12-31 23:59:59'"; + $sql .= " AND b.amount > 0"; + if ($id && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$id.")"; $sql .= " GROUP BY date_format(b.datev,'%m');"; $resql = $db->query($sql); @@ -350,38 +350,38 @@ else $data_year_1 = array(); $data_year_2 = array(); - for ($i = 0 ; $i < 12 ; $i++) + for ($i = 0; $i < 12; $i++) { - $data_year_0[$i] = isset($tblyear[0][substr("0".($i+1), -2)]) ? $tblyear[0][substr("0".($i+1), -2)] : 0; - $data_year_1[$i] = isset($tblyear[1][substr("0".($i+1), -2)]) ? $tblyear[1][substr("0".($i+1), -2)] : 0; - $data_year_2[$i] = isset($tblyear[2][substr("0".($i+1), -2)]) ? $tblyear[2][substr("0".($i+1), -2)] : 0; - $labels[$i] = $langs->transnoentitiesnoconv("MonthVeryShort".sprintf("%02d", $i+1)); + $data_year_0[$i] = isset($tblyear[0][substr("0".($i + 1), -2)]) ? $tblyear[0][substr("0".($i + 1), -2)] : 0; + $data_year_1[$i] = isset($tblyear[1][substr("0".($i + 1), -2)]) ? $tblyear[1][substr("0".($i + 1), -2)] : 0; + $data_year_2[$i] = isset($tblyear[2][substr("0".($i + 1), -2)]) ? $tblyear[2][substr("0".($i + 1), -2)] : 0; + $labels[$i] = $langs->transnoentitiesnoconv("MonthVeryShort".sprintf("%02d", $i + 1)); $datamin[$i] = 0; } // Fabrication tableau 4b - $file= $conf->bank->dir_temp."/credmovement".$id."-".$year.".png"; - $fileurl=DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/credmovement".$id."-".$year.".png"; - $title=$langs->transnoentities("Credit").' - '.$langs->transnoentities("Year").': '.($year-2).' - '.($year-1)." - ".$year; - $graph_datas=array(); - for($i=0;$i<12;$i++) + $file = $conf->bank->dir_temp."/credmovement".$id."-".$year.".png"; + $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/credmovement".$id."-".$year.".png"; + $title = $langs->transnoentities("Credit").' - '.$langs->transnoentities("Year").': '.($year - 2).' - '.($year - 1)." - ".$year; + $graph_datas = array(); + for ($i = 0; $i < 12; $i++) { - $graph_datas[$i]=array($labels[$i], $data_year_0[$i], $data_year_1[$i], $data_year_2[$i]); + $graph_datas[$i] = array($labels[$i], $data_year_0[$i], $data_year_1[$i], $data_year_2[$i]); } $px1 = new DolGraph(); $px1->SetData($graph_datas); - $px1->SetLegend(array(($year),($year-1),($year-2))); + $px1->SetLegend(array(($year), ($year - 1), ($year - 2))); $px1->SetLegendWidthMin(180); - $px1->SetMaxValue($px1->GetCeilMaxValue()<0?0:$px1->GetCeilMaxValue()); - $px1->SetMinValue($px1->GetFloorMinValue()>0?0:$px1->GetFloorMinValue()); + $px1->SetMaxValue($px1->GetCeilMaxValue() < 0 ? 0 : $px1->GetCeilMaxValue()); + $px1->SetMinValue($px1->GetFloorMinValue() > 0 ? 0 : $px1->GetFloorMinValue()); $px1->SetTitle($title); $px1->SetWidth($WIDTH); $px1->SetHeight($HEIGHT); - $px1->SetType(array('line','line','line')); + $px1->SetType(array('line', 'line', 'line')); $px1->SetShading(3); $px1->setBgColor('onglet'); - $px1->setBgColorGrid(array(255,255,255)); + $px1->setBgColorGrid(array(255, 255, 255)); $px1->SetHorizTickIncrement(1); $px1->draw($file, $fileurl); @@ -399,18 +399,18 @@ else $tblyear[1] = array(); $tblyear[2] = array(); - for ($annee=0;$annee<3;$annee++) + for ($annee = 0; $annee < 3; $annee++) { $sql = "SELECT date_format(b.datev,'%m')"; - $sql.= ", SUM(b.amount)"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql.= " AND b.datev >= '".($year-$annee)."-01-01 00:00:00'"; - $sql.= " AND b.datev <= '".($year-$annee)."-12-31 23:59:59'"; - $sql.= " AND b.amount < 0"; - if ($id && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$id.")"; + $sql .= ", SUM(b.amount)"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql .= " AND b.datev >= '".($year - $annee)."-01-01 00:00:00'"; + $sql .= " AND b.datev <= '".($year - $annee)."-12-31 23:59:59'"; + $sql .= " AND b.amount < 0"; + if ($id && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$id.")"; $sql .= " GROUP BY date_format(b.datev,'%m');"; $resql = $db->query($sql); @@ -437,37 +437,37 @@ else $data_year_1 = array(); $data_year_2 = array(); - for ($i = 0 ; $i < 12 ; $i++) + for ($i = 0; $i < 12; $i++) { - $data_year_0[$i] = isset($tblyear[0][substr("0".($i+1), -2)]) ? $tblyear[0][substr("0".($i+1), -2)] : 0; - $data_year_1[$i] = isset($tblyear[1][substr("0".($i+1), -2)]) ? $tblyear[1][substr("0".($i+1), -2)] : 0; - $data_year_2[$i] = isset($tblyear[2][substr("0".($i+1), -2)]) ? $tblyear[2][substr("0".($i+1), -2)] : 0; - $labels[$i] = $langs->transnoentitiesnoconv("MonthVeryShort".sprintf("%02d", $i+1)); + $data_year_0[$i] = isset($tblyear[0][substr("0".($i + 1), -2)]) ? $tblyear[0][substr("0".($i + 1), -2)] : 0; + $data_year_1[$i] = isset($tblyear[1][substr("0".($i + 1), -2)]) ? $tblyear[1][substr("0".($i + 1), -2)] : 0; + $data_year_2[$i] = isset($tblyear[2][substr("0".($i + 1), -2)]) ? $tblyear[2][substr("0".($i + 1), -2)] : 0; + $labels[$i] = $langs->transnoentitiesnoconv("MonthVeryShort".sprintf("%02d", $i + 1)); $datamin[$i] = 0; } - $file= $conf->bank->dir_temp."/debmovement".$id."-".$year.".png"; - $fileurl= DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/debmovement".$id."-".$year.".png"; - $title=$langs->transnoentities("Debit").' - '.$langs->transnoentities("Year").': '.($year-2).' - '.($year-1)." - ".$year; - $graph_datas=array(); - for($i=0;$i<12;$i++) + $file = $conf->bank->dir_temp."/debmovement".$id."-".$year.".png"; + $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/debmovement".$id."-".$year.".png"; + $title = $langs->transnoentities("Debit").' - '.$langs->transnoentities("Year").': '.($year - 2).' - '.($year - 1)." - ".$year; + $graph_datas = array(); + for ($i = 0; $i < 12; $i++) { - $graph_datas[$i]=array($labels[$i], $data_year_0[$i], $data_year_1[$i], $data_year_2[$i]); + $graph_datas[$i] = array($labels[$i], $data_year_0[$i], $data_year_1[$i], $data_year_2[$i]); } $px2 = new DolGraph(); $px2->SetData($graph_datas); - $px2->SetLegend(array(($year),($year-1),($year-2))); + $px2->SetLegend(array(($year), ($year - 1), ($year - 2))); $px2->SetLegendWidthMin(180); - $px2->SetMaxValue($px2->GetCeilMaxValue()<0?0:$px2->GetCeilMaxValue()); - $px2->SetMinValue($px2->GetFloorMinValue()>0?0:$px2->GetFloorMinValue()); + $px2->SetMaxValue($px2->GetCeilMaxValue() < 0 ? 0 : $px2->GetCeilMaxValue()); + $px2->SetMinValue($px2->GetFloorMinValue() > 0 ? 0 : $px2->GetFloorMinValue()); $px2->SetTitle($title); $px2->SetWidth($WIDTH); $px2->SetHeight($HEIGHT); - $px2->SetType(array('line','line','line')); + $px2->SetType(array('line', 'line', 'line')); $px2->SetShading(3); $px2->setBgColor('onglet'); - $px2->setBgColorGrid(array(255,255,255)); + $px2->setBgColorGrid(array(255, 255, 255)); $px2->SetHorizTickIncrement(1); $px2->draw($file, $fileurl); @@ -479,9 +479,9 @@ else unset($tblyear[1]); unset($tblyear[2]); - print '
'; // do not use class="center" here, it will have no effect for the js graph inside. + print '
'; // do not use class="center" here, it will have no effect for the js graph inside. print $show1; - print '
'; // do not use class="center" here, it will have no effect for the js graph inside. + print '
'; // do not use class="center" here, it will have no effect for the js graph inside. print $show2; print '
'; print '
'; diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index d267f55f640..8920d5eff9b 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -43,38 +43,38 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("banks","categories","companies","bills","trips")); +$langs->loadLangs(array("banks", "categories", "companies", "bills", "trips")); -$action=GETPOST('action', 'alpha'); -$id=GETPOST('account', 'int'); -$ref=GETPOST('ref', 'alpha'); -$dvid=GETPOST('dvid', 'alpha'); -$numref=GETPOST('num', 'alpha'); -$ve=GETPOST("ve", 'alpha'); -$brref=GETPOST('brref', 'alpha'); -$oldbankreceipt=GETPOST('oldbankreceipt', 'alpha'); -$newbankreceipt=GETPOST('newbankreceipt', 'alpha'); +$action = GETPOST('action', 'alpha'); +$id = GETPOST('account', 'int'); +$ref = GETPOST('ref', 'alpha'); +$dvid = GETPOST('dvid', 'alpha'); +$numref = GETPOST('num', 'alpha'); +$ve = GETPOST("ve", 'alpha'); +$brref = GETPOST('brref', 'alpha'); +$oldbankreceipt = GETPOST('oldbankreceipt', 'alpha'); +$newbankreceipt = GETPOST('newbankreceipt', 'alpha'); // Security check -$fieldid = (! empty($ref)?$ref:$id); -$fieldname = isset($ref)?'ref':'rowid'; -if ($user->socid) $socid=$user->socid; -$result=restrictedArea($user, 'banque', $fieldid, 'bank_account', '', '', $fieldname); +$fieldid = (!empty($ref) ? $ref : $id); +$fieldname = isset($ref) ? 'ref' : 'rowid'; +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'banque', $fieldid, 'bank_account', '', '', $fieldname); -if ($user->rights->banque->consolidate && $action == 'dvnext' && ! empty($dvid)) +if ($user->rights->banque->consolidate && $action == 'dvnext' && !empty($dvid)) { $al = new AccountLine($db); $al->datev_next($dvid); } -if ($user->rights->banque->consolidate && $action == 'dvprev' && ! empty($dvid)) +if ($user->rights->banque->consolidate && $action == 'dvprev' && !empty($dvid)) { $al = new AccountLine($db); $al->datev_previous($dvid); } -$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'); @@ -84,31 +84,31 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="s.nom"; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "s.nom"; $object = new Account($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { - $result=$object->fetch($id, $ref); - $account = $object->id; // Force the search field on id of account + $result = $object->fetch($id, $ref); + $account = $object->id; // Force the search field on id of account } // Initialize technical object to manage context to save list fields -$contextpage='banktransactionlist'.(empty($object->ref)?'':'-'.$object->id); +$contextpage = 'banktransactionlist'.(empty($object->ref) ? '' : '-'.$object->id); // Define number of receipt to show (current, previous or next one ?) -$found=false; +$found = false; if ($_GET["rel"] == 'prev') { // Recherche valeur pour num = numero releve precedent $sql = "SELECT DISTINCT(b.num_releve) as num"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= " WHERE b.num_releve < '".$db->escape($numref)."'"; - $sql.= " AND b.fk_account = ".$object->id; - $sql.= " ORDER BY b.num_releve DESC"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= " WHERE b.num_releve < '".$db->escape($numref)."'"; + $sql .= " AND b.fk_account = ".$object->id; + $sql .= " ORDER BY b.num_releve DESC"; dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG); $resql = $db->query($sql); @@ -119,7 +119,7 @@ if ($_GET["rel"] == 'prev') { $obj = $db->fetch_object($resql); $numref = $obj->num; - $found=true; + $found = true; } } } @@ -127,10 +127,10 @@ elseif ($_GET["rel"] == 'next') { // Recherche valeur pour num = numero releve precedent $sql = "SELECT DISTINCT(b.num_releve) as num"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= " WHERE b.num_releve > '".$db->escape($numref)."'"; - $sql.= " AND b.fk_account = ".$object->id; - $sql.= " ORDER BY b.num_releve ASC"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= " WHERE b.num_releve > '".$db->escape($numref)."'"; + $sql .= " AND b.fk_account = ".$object->id; + $sql .= " ORDER BY b.num_releve ASC"; dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG); $resql = $db->query($sql); @@ -141,29 +141,29 @@ elseif ($_GET["rel"] == 'next') { $obj = $db->fetch_object($resql); $numref = $obj->num; - $found=true; + $found = true; } } } else { // On veut le releve num - $found=true; + $found = true; } $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv,"; -$sql.= " b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,"; -$sql.= " b.fk_bordereau,"; -$sql.= " bc.ref,"; -$sql.= " ba.rowid as bankid, ba.ref as bankref, ba.label as banklabel"; -$sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; -$sql.= ", ".MAIN_DB_PREFIX."bank as b"; -$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bordereau_cheque as bc ON bc.rowid=b.fk_bordereau'; -$sql.= " WHERE b.num_releve='".$db->escape($numref)."'"; -if (empty($numref)) $sql.= " OR b.num_releve is null"; -$sql.= " AND b.fk_account = ".$object->id; -$sql.= " AND b.fk_account = ba.rowid"; -$sql.= $db->order("b.datev, b.datec", "ASC"); // We add date of creation to have correct order when everything is done the same day +$sql .= " b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,"; +$sql .= " b.fk_bordereau,"; +$sql .= " bc.ref,"; +$sql .= " ba.rowid as bankid, ba.ref as bankref, ba.label as banklabel"; +$sql .= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; +$sql .= ", ".MAIN_DB_PREFIX."bank as b"; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bordereau_cheque as bc ON bc.rowid=b.fk_bordereau'; +$sql .= " WHERE b.num_releve='".$db->escape($numref)."'"; +if (empty($numref)) $sql .= " OR b.num_releve is null"; +$sql .= " AND b.fk_account = ".$object->id; +$sql .= " AND b.fk_account = ba.rowid"; +$sql .= $db->order("b.datev, b.datec", "ASC"); // We add date of creation to have correct order when everything is done the same day $sqlrequestforbankline = $sql; @@ -173,14 +173,14 @@ $sqlrequestforbankline = $sql; * Actions */ -if ($action == 'confirm_editbankreceipt' && ! empty($oldbankreceipt) && ! empty($newbankreceipt)) +if ($action == 'confirm_editbankreceipt' && !empty($oldbankreceipt) && !empty($newbankreceipt)) { // TODO Add a test to check newbankreceipt does not exists yet $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX.'bank SET num_releve = "'.$db->escape($newbankreceipt).'" WHERE num_releve = "'.$db->escape($oldbankreceipt).'"'; $result = $db->query($sqlupdate); if ($result < 0) dol_print_error($db); - $action='view'; + $action = 'view'; } @@ -193,33 +193,33 @@ $helpurl = ""; llxHeader('', $title, $helpurl); $form = new Form($db); -$societestatic=new Societe($db); -$chargestatic=new ChargeSociales($db); -$memberstatic=new Adherent($db); -$paymentstatic=new Paiement($db); -$paymentsupplierstatic=new PaiementFourn($db); -$paymentvatstatic=new TVA($db); -$bankstatic=new Account($db); -$banklinestatic=new AccountLine($db); +$societestatic = new Societe($db); +$chargestatic = new ChargeSociales($db); +$memberstatic = new Adherent($db); +$paymentstatic = new Paiement($db); +$paymentsupplierstatic = new PaiementFourn($db); +$paymentvatstatic = new TVA($db); +$bankstatic = new Account($db); +$banklinestatic = new AccountLine($db); $remisestatic = new RemiseCheque($db); // Must be before button action -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; -if ($id > 0) $param.='&id='.urlencode($id); +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; +if ($id > 0) $param .= '&id='.urlencode($id); if (empty($numref)) { - $sortfield='numr'; - $sortorder='DESC'; + $sortfield = 'numr'; + $sortorder = 'DESC'; // List of all standing receipts $sql = "SELECT DISTINCT(b.num_releve) as numr"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= " WHERE b.fk_account = ".$object->id; - $sql.=$db->order($sortfield, $sortorder); + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= " WHERE b.fk_account = ".$object->id; + $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -229,7 +229,7 @@ if (empty($numref)) $nbtotalofrecords = $db->num_rows($result); } - $sql.= $db->plimit($conf->liste_limit+1, $offset); + $sql .= $db->plimit($conf->liste_limit + 1, $offset); $result = $db->query($sql); if ($result) @@ -238,7 +238,7 @@ if (empty($numref)) $i = 0; // Onglets - $head=bank_prepare_head($object); + $head = bank_prepare_head($object); dol_fiche_head($head, 'statement', $langs->trans("FinancialAccount"), 0, 'account'); $linkback = ''.$langs->trans("BackToList").''; @@ -279,14 +279,14 @@ if (empty($numref)) print ''; print ''; - $balancestart=array(); - $content=array(); + $balancestart = array(); + $content = array(); while ($i < min($numrows, $conf->liste_limit)) { $objp = $db->fetch_object($result); - if (! isset($objp->numr)) + if (!isset($objp->numr)) { // } @@ -309,13 +309,13 @@ if (empty($numref)) // Calculate start amount $sql = "SELECT sum(b.amount) as amount"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= " WHERE b.num_releve < '".$db->escape($objp->numr)."'"; - $sql.= " AND b.fk_account = ".$object->id; - $resql=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= " WHERE b.num_releve < '".$db->escape($objp->numr)."'"; + $sql .= " AND b.fk_account = ".$object->id; + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); $balancestart[$objp->numr] = $obj->amount; $db->free($resql); } @@ -323,17 +323,17 @@ if (empty($numref)) // Calculate end amount $sql = "SELECT sum(b.amount) as amount"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= " WHERE b.num_releve = '".$db->escape($objp->numr)."'"; - $sql.= " AND b.fk_account = ".$object->id; - $resql=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= " WHERE b.num_releve = '".$db->escape($objp->numr)."'"; + $sql .= " AND b.fk_account = ".$object->id; + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); $content[$objp->numr] = $obj->amount; $db->free($resql); } - print ''.price(($balancestart[$objp->numr]+$content[$objp->numr]), '', $langs, 1, -1, -1, $conf->currency).''; + print ''.price(($balancestart[$objp->numr] + $content[$objp->numr]), '', $langs, 1, -1, -1, $conf->currency).''; print ''; if ($user->rights->banque->consolidate && $action != 'editbankreceipt') { @@ -362,20 +362,20 @@ else */ // Onglets - $head=account_statement_prepare_head($object, $numref); + $head = account_statement_prepare_head($object, $numref); dol_fiche_head($head, 'statement', $langs->trans("FinancialAccount"), 0, 'account'); - $mesprevnext=''; - $mesprevnext.=''; - $title=$langs->trans("AccountStatement").' '.$numref.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts'); + $title = $langs->trans("AccountStatement").' '.$numref.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts'); print load_fiche_titre($title, $mesprevnext, 'title_bank.png'); //print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, 0, $nbtotalofrecords, 'title_bank.png', 0, '', '', 0, 1); @@ -398,14 +398,14 @@ else // Calcul du solde de depart du releve $sql = "SELECT sum(b.amount) as amount"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= " WHERE b.num_releve < '".$db->escape($numref)."'"; - $sql.= " AND b.fk_account = ".$object->id; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= " WHERE b.num_releve < '".$db->escape($numref)."'"; + $sql .= " AND b.fk_account = ".$object->id; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); $total = $obj->amount; $db->free($resql); } @@ -437,142 +437,142 @@ else // Date de valeur print ''; - print dol_print_date($db->jdate($objp->dv), "day") .' '; + print dol_print_date($db->jdate($objp->dv), "day").' '; print ''; - print img_edit_remove() . " "; + print img_edit_remove()." "; print ''; - print img_edit_add() .""; + print img_edit_add().""; print "\n"; print ''; // Type and num if ($objp->fk_type == 'SOLD') { - $type_label=' '; + $type_label = ' '; } else { - $type_label=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$objp->fk_type; + $type_label = ($langs->trans("PaymentTypeShort".$objp->fk_type) != "PaymentTypeShort".$objp->fk_type) ? $langs->trans("PaymentTypeShort".$objp->fk_type) : $objp->fk_type; } - $link=''; - if ($objp->fk_bordereau>0) { + $link = ''; + if ($objp->fk_bordereau > 0) { $remisestatic->id = $objp->fk_bordereau; $remisestatic->ref = $objp->ref; $link = ' '.$remisestatic->getNomUrl(1); } - print ''.$type_label.' '.($objp->num_chq?$objp->num_chq:'').$link.''; + print ''.$type_label.' '.($objp->num_chq ? $objp->num_chq : '').$link.''; // Description print ''; - $reg=array(); - preg_match('/\((.+)\)/i', $objp->label, $reg); // Si texte entoure de parenthese 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 parenthese on tente recherche de traduction + if ($reg[1] && $langs->trans($reg[1]) != $reg[1]) print $langs->trans($reg[1]); else print $objp->label; print ''; /* * Ajout les liens (societe, company...) */ - $newline=1; + $newline = 1; $links = $object->get_url($objp->rowid); - foreach($links as $key=>$val) + foreach ($links as $key=>$val) { - if (! $newline) print ' - '; + if (!$newline) print ' - '; else print '
'; - if ($links[$key]['type']=='payment') + if ($links[$key]['type'] == 'payment') { - $paymentstatic->id=$links[$key]['url_id']; - $paymentstatic->ref=$langs->trans("Payment"); + $paymentstatic->id = $links[$key]['url_id']; + $paymentstatic->ref = $langs->trans("Payment"); print ' '.$paymentstatic->getNomUrl(1); - $newline=0; + $newline = 0; } - elseif ($links[$key]['type']=='payment_supplier') + elseif ($links[$key]['type'] == 'payment_supplier') { - $paymentsupplierstatic->id=$links[$key]['url_id']; - $paymentsupplierstatic->ref=$langs->trans("Payment"); + $paymentsupplierstatic->id = $links[$key]['url_id']; + $paymentsupplierstatic->ref = $langs->trans("Payment"); print ' '.$paymentsupplierstatic->getNomUrl(1); - $newline=0; + $newline = 0; } - 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 ''; - $newline=0; + $newline = 0; } - elseif ($links[$key]['type']=='payment_vat') + elseif ($links[$key]['type'] == 'payment_vat') { - $paymentvatstatic->id=$links[$key]['url_id']; - $paymentvatstatic->ref=$langs->trans("Payment"); + $paymentvatstatic->id = $links[$key]['url_id']; + $paymentvatstatic->ref = $langs->trans("Payment"); print ' '.$paymentvatstatic->getNomUrl(1); } - elseif ($links[$key]['type']=='payment_salary') + elseif ($links[$key]['type'] == 'payment_salary') { print ''; print ' '.img_object($langs->trans('ShowPayment'), 'payment').' '; print $langs->trans("Payment"); print ''; - $newline=0; + $newline = 0; } - 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_label; + $bankstatic->id = $banklinestatic->fk_account; + $bankstatic->label = $banklinestatic->bank_account_label; print ' ('.$langs->trans("from").' '; 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("from").' '; print $bankstatic->getNomUrl(1, ''); print ' '.$langs->trans("toward").' '; $banklinestatic->fetch($links[$key]['url_id']); - $bankstatic->id=$banklinestatic->fk_account; - $bankstatic->label=$banklinestatic->bank_account_label; + $bankstatic->id = $banklinestatic->fk_account; + $bankstatic->label = $banklinestatic->bank_account_label; print $bankstatic->getNomUrl(1, 'transactions'); print ')'; } } - elseif ($links[$key]['type']=='company') { + elseif ($links[$key]['type'] == 'company') { $societestatic->id = $links[$key]['url_id']; $societestatic->name = $links[$key]['label']; print $societestatic->getNomUrl(1, 'company', 24); - $newline=0; + $newline = 0; } - elseif ($links[$key]['type']=='member') { + elseif ($links[$key]['type'] == 'member') { print ''; print img_object($langs->trans('ShowMember'), 'user').' '; print $links[$key]['label']; print ''; - $newline=0; + $newline = 0; } - elseif ($links[$key]['type']=='user') { + elseif ($links[$key]['type'] == 'user') { print ''; print img_object($langs->trans('ShowUser'), 'user').' '; print $links[$key]['label']; print ''; - $newline=0; + $newline = 0; } - elseif ($links[$key]['type']=='sc') { + elseif ($links[$key]['type'] == 'sc') { print ''; print img_object($langs->trans('ShowBill'), 'bill').' '; print $langs->trans("SocialContribution"); print ''; - $newline=0; + $newline = 0; } else { print ''; print $links[$key]['label']; print ''; - $newline=0; + $newline = 0; } } @@ -580,18 +580,18 @@ else if ($ve) { $sql = "SELECT label"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_categ as ct"; - $sql.= ", ".MAIN_DB_PREFIX."bank_class as cl"; - $sql.= " WHERE ct.rowid = cl.fk_categ"; - $sql.= " AND ct.entity = ".$conf->entity; - $sql.= " AND cl.lineid = ".$objp->rowid; + $sql .= " FROM ".MAIN_DB_PREFIX."bank_categ as ct"; + $sql .= ", ".MAIN_DB_PREFIX."bank_class as cl"; + $sql .= " WHERE ct.rowid = cl.fk_categ"; + $sql .= " AND ct.entity = ".$conf->entity; + $sql .= " AND cl.lineid = ".$objp->rowid; $resc = $db->query($sql); if ($resc) { $numc = $db->num_rows($resc); $ii = 0; - if ($numc && ! $newline) print '
'; + if ($numc && !$newline) print '
'; while ($ii < $numc) { $objc = $db->fetch_object($resc); diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index bd333110e51..fd270cba3f1 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -45,17 +45,17 @@ $hookmanager->initHooks(array('specialexpensesindex')); $langs->loadLangs(array('compta', 'bills')); // Security check -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'tax|salaries', '', '', 'charges|'); -$mode=GETPOST("mode", 'alpha'); -$year=GETPOST("year", 'int'); -$filtre=GETPOST("filtre", 'alpha'); -if (! $year && $mode != 'sconly') { $year=date("Y", time()); } +$mode = GETPOST("mode", 'alpha'); +$year = GETPOST("year", 'int'); +$filtre = GETPOST("filtre", 'alpha'); +if (!$year && $mode != 'sconly') { $year = date("Y", time()); } $search_account = GETPOST('search_account', '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'); @@ -63,8 +63,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="cs.date_ech"; -if (! $sortorder) $sortorder="DESC"; +if (!$sortfield) $sortfield = "cs.date_ech"; +if (!$sortorder) $sortorder = "DESC"; /* @@ -72,22 +72,22 @@ if (! $sortorder) $sortorder="DESC"; */ $tva_static = new Tva($db); -$socialcontrib=new ChargeSociales($db); -$payment_sc_static=new PaymentSocialContribution($db); +$socialcontrib = new ChargeSociales($db); +$payment_sc_static = new PaymentSocialContribution($db); $sal_static = new PaymentSalary($db); $accountstatic = new Account($db); llxHeader('', $langs->trans("SpecialExpensesArea")); -$title=$langs->trans("SpecialExpensesArea"); -if ($mode == 'sconly') $title=$langs->trans("SocialContributionsPayments"); +$title = $langs->trans("SpecialExpensesArea"); +if ($mode == 'sconly') $title = $langs->trans("SocialContributionsPayments"); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; -if ($mode == 'sconly') $param='&mode=sconly'; -if ($sortfield) $param.='&sortfield='.$sortfield; -if ($sortorder) $param.='&sortorder='.$sortorder; +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; +if ($mode == 'sconly') $param = '&mode=sconly'; +if ($sortfield) $param .= '&sortfield='.$sortfield; +if ($sortorder) $param .= '&sortorder='.$sortorder; print ''; @@ -101,7 +101,7 @@ print ''; if ($mode != 'sconly') { - $center=($year?''.img_previous($langs->trans("Previous"), 'class="valignbottom"')." ".$langs->trans("Year").' '.$year.' '.img_next($langs->trans("Next"), 'class="valignbottom"')."":""); + $center = ($year ? ''.img_previous($langs->trans("Previous"), 'class="valignbottom"')." ".$langs->trans("Year").' '.$year.' '.img_next($langs->trans("Next"), 'class="valignbottom"')."" : ""); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy', 0, '', '', $limit, 1); } else @@ -109,7 +109,7 @@ else print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy', 0, '', '', $limit); } -if ($year) $param.='&year='.$year; +if ($year) $param .= '&year='.$year; if ($mode != 'sconly') { @@ -117,12 +117,12 @@ if ($mode != 'sconly') print "
"; } -if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) +if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { // Social contributions only if ($mode != 'sconly') { - print load_fiche_titre($langs->trans("SocialContributionsPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); + print load_fiche_titre($langs->trans("SocialContributionsPayments").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); } print ''; @@ -134,23 +134,23 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "pc.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "pc.datep", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder); - if (! empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); + if (!empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pc.amount", "", $param, 'class="right"', $sortfield, $sortorder); print "\n"; $sql = "SELECT c.id, c.libelle as label,"; - $sql.= " cs.rowid, cs.libelle, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total,"; - $sql.= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment, pc.fk_bank,"; - $sql.= " pct.code as payment_code,"; - $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; - $sql.= " ".MAIN_DB_PREFIX."chargesociales as cs"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pc.fk_bank = b.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; - $sql.= " WHERE cs.fk_type = c.id"; - $sql.= " AND cs.entity IN (".getEntity("tax").")"; + $sql .= " cs.rowid, cs.libelle, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total,"; + $sql .= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment, pc.fk_bank,"; + $sql .= " pct.code as payment_code,"; + $sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; + $sql .= " ".MAIN_DB_PREFIX."chargesociales as cs"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pc.fk_bank = b.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; + $sql .= " WHERE cs.fk_type = c.id"; + $sql .= " AND cs.entity IN (".getEntity("tax").")"; if ($year > 0) { $sql .= " AND ("; @@ -160,12 +160,12 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $sql .= " OR (cs.periode IS NULL AND cs.date_ech between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')"; $sql .= ")"; } - if (preg_match('/^cs\./', $sortfield) || preg_match('/^c\./', $sortfield) || preg_match('/^pc\./', $sortfield) || preg_match('/^pct\./', $sortfield)) $sql.= $db->order($sortfield, $sortorder); + if (preg_match('/^cs\./', $sortfield) || preg_match('/^c\./', $sortfield) || preg_match('/^pc\./', $sortfield) || preg_match('/^pct\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder); //$sql.= $db->plimit($limit+1,$offset); //print $sql; dol_syslog("compta/charges/index.php: select payment", LOG_DEBUG); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -179,14 +179,14 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $obj = $db->fetch_object($resql); print ''; // Date - $date=$obj->periode; - if (empty($date)) $date=$obj->date_ech; + $date = $obj->periode; + if (empty($date)) $date = $obj->date_ech; print ''; // Label print ''; // Type @@ -194,8 +194,8 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) // Expected to pay print ''; // Ref payment - $payment_sc_static->id=$obj->pid; - $payment_sc_static->ref=$obj->pid; + $payment_sc_static->id = $obj->pid; + $payment_sc_static->ref = $obj->pid; print '\n"; // Date payment print ''; @@ -204,18 +204,18 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; print $obj->num_payment.''; // Account - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { print ''; - print ''; // A total here has no sense + print ''; // A total here has no sense print ''; print ''; print ''; - if (! empty($conf->banque->enabled)) print ''; + if (!empty($conf->banque->enabled)) print ''; print '"; print ""; } @@ -249,38 +249,38 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) } // VAT -if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) +if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { - if (! $mode || $mode != 'sconly') + if (!$mode || $mode != 'sconly') { print "
"; $tva = new Tva($db); - print load_fiche_titre($langs->trans("VATPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); + print load_fiche_titre($langs->trans("VATPayments").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); $sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm, pv.fk_bank,"; - $sql.= " pct.code as payment_code,"; - $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; - $sql.= " FROM ".MAIN_DB_PREFIX."tva as pv"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pv.fk_bank = b.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pv.fk_typepayment = pct.id"; - $sql.= " WHERE pv.entity IN (".getEntity("tax").")"; + $sql .= " pct.code as payment_code,"; + $sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; + $sql .= " FROM ".MAIN_DB_PREFIX."tva as pv"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pv.fk_bank = b.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pv.fk_typepayment = pct.id"; + $sql .= " WHERE pv.entity IN (".getEntity("tax").")"; if ($year > 0) { // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire - $sql.= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; + $sql .= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; } - if (preg_match('/^pv\./', $sortfield)) $sql.= $db->order($sortfield, $sortorder); + if (preg_match('/^pv\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; - $total = 0 ; + $total = 0; print '
'.dol_print_date($date, 'day').''; - $socialcontrib->id=$obj->rowid; - $socialcontrib->ref=$obj->label; - $socialcontrib->label=$obj->label; + $socialcontrib->id = $obj->rowid; + $socialcontrib->ref = $obj->label; + $socialcontrib->label = $obj->label; print $socialcontrib->getNomUrl(1, '20'); print ''.price($obj->total).''.$payment_sc_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->datep), 'day').''; if ($obj->fk_bank > 0) { //$accountstatic->fetch($obj->fk_bank); - $accountstatic->id=$obj->bid; - $accountstatic->ref=$obj->bref; - $accountstatic->number=$obj->bnumber; - $accountstatic->accountancy_number=$obj->account_number; - $accountstatic->accountancy_journal=$obj->accountancy_journal; - $accountstatic->label=$obj->blabel; + $accountstatic->id = $obj->bid; + $accountstatic->ref = $obj->bref; + $accountstatic->number = $obj->bnumber; + $accountstatic->accountancy_number = $obj->account_number; + $accountstatic->accountancy_journal = $obj->accountancy_journal; + $accountstatic->label = $obj->blabel; print $accountstatic->getNomUrl(1); } else print ' '; @@ -233,11 +233,11 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $i++; } print '
'.$langs->trans("Total").'   '.price($totalpaye)."
'; print ''; print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'width="140px"', $sortfield, $sortorder); @@ -289,10 +289,10 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "pv.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder); - if (! empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); + if (!empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pv.amount", "", $param, 'class="right"', $sortfield, $sortorder); print "\n"; - $var=1; + $var = 1; while ($i < $num) { $obj = $db->fetch_object($result); @@ -308,8 +308,8 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print '"; // Ref payment - $tva_static->id=$obj->rowid; - $tva_static->ref=$obj->rowid; + $tva_static->id = $obj->rowid; + $tva_static->ref = $obj->rowid; print '\n"; // Date @@ -321,18 +321,18 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print $obj->num_payment.''; // Account - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { print '"; print ''; // Who print ""; print ''; // Date @@ -397,8 +397,8 @@ elseif ($id) } // Other attributes - $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; print '
'.price($obj->amount)."'.$tva_static->getNomUrl(1)."'; if ($obj->fk_bank > 0) { //$accountstatic->fetch($obj->fk_bank); - $accountstatic->id=$obj->bid; - $accountstatic->ref=$obj->bref; - $accountstatic->number=$obj->bnumber; - $accountstatic->accountancy_number=$obj->account_number; - $accountstatic->accountancy_journal=$obj->accountancy_journal; - $accountstatic->label=$obj->blabel; + $accountstatic->id = $obj->bid; + $accountstatic->ref = $obj->bref; + $accountstatic->number = $obj->bnumber; + $accountstatic->accountancy_number = $obj->account_number; + $accountstatic->accountancy_journal = $obj->accountancy_journal; + $accountstatic->label = $obj->blabel; print $accountstatic->getNomUrl(1); } else print ' '; @@ -365,55 +365,55 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) } // Localtax -if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") +if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") { - $j=1; - $numlt=3; + $j = 1; + $numlt = 3; } -elseif($mysoc->localtax1_assuj=="1") +elseif ($mysoc->localtax1_assuj == "1") { - $j=1; - $numlt=2; + $j = 1; + $numlt = 2; } -elseif($mysoc->localtax2_assuj=="1") +elseif ($mysoc->localtax2_assuj == "1") { - $j=2; - $numlt=3; + $j = 2; + $numlt = 3; } else { - $j=0; - $numlt=0; + $j = 0; + $numlt = 0; } -while($j<$numlt) +while ($j < $numlt) { - if (! $mode || $mode != 'sconly') + if (!$mode || $mode != 'sconly') { print "
"; $tva = new Tva($db); - print load_fiche_titre($langs->transcountry(($j==1?"LT1Payments":"LT2Payments"), $mysoc->country_code).($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); + print load_fiche_titre($langs->transcountry(($j == 1 ? "LT1Payments" : "LT2Payments"), $mysoc->country_code).($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); $sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm, pv.datep as dp"; - $sql.= " FROM ".MAIN_DB_PREFIX."localtax as pv"; - $sql.= " WHERE pv.entity = ".$conf->entity." AND localtaxtype = ".$j ; + $sql .= " FROM ".MAIN_DB_PREFIX."localtax as pv"; + $sql .= " WHERE pv.entity = ".$conf->entity." AND localtaxtype = ".$j; if ($year > 0) { // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire - $sql.= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; + $sql .= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; } - if (preg_match('/^pv/', $sortfield)) $sql.= $db->order($sortfield, $sortorder); + if (preg_match('/^pv/', $sortfield)) $sql .= $db->order($sortfield, $sortorder); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; - $total = 0 ; + $total = 0; print ''; print ''; print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'width="120"', $sortfield, $sortorder); @@ -435,8 +435,8 @@ while($j<$numlt) print "\n"; // Ref payment - $tva_static->id=$obj->rowid; - $tva_static->ref=$obj->rowid; + $tva_static->id = $obj->rowid; + $tva_static->ref = $obj->rowid; print '\n"; print '\n"; @@ -462,39 +462,39 @@ while($j<$numlt) // Payment Salary -if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) +if (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) { - if (! $mode || $mode != 'sconly') + if (!$mode || $mode != 'sconly') { $sal = new PaymentSalary($db); print "
"; - print load_fiche_titre($langs->trans("SalariesPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); + print load_fiche_titre($langs->trans("SalariesPayments").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); $sql = "SELECT s.rowid, s.amount, s.label, s.datep as datep, s.datev as datev, s.datesp, s.dateep, s.salary, s.fk_bank, u.salary as current_salary,"; - $sql.= " pct.code as payment_code,"; - $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; - $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON s.fk_typepayment = pct.id"; - $sql.= " , ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE s.entity IN (".getEntity('user').")"; - $sql.= " AND u.rowid = s.fk_user"; + $sql .= " pct.code as payment_code,"; + $sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON s.fk_typepayment = pct.id"; + $sql .= " , ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE s.entity IN (".getEntity('user').")"; + $sql .= " AND u.rowid = s.fk_user"; if ($year > 0) { - $sql.= " AND (s.datesp between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; - $sql.= " OR s.dateep between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."')"; + $sql .= " AND (s.datesp between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; + $sql .= " OR s.dateep between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."')"; } - if (preg_match('/^s\./', $sortfield)) $sql.= $db->order($sortfield, $sortorder); + if (preg_match('/^s\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; - $total = 0 ; + $total = 0; print '
".$obj->label."'.$tva_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->dp), 'day')."
'; print ''; print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "s.dateep", "", $param, 'width="140px"', $sortfield, $sortorder); @@ -502,7 +502,7 @@ if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "s.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "s.datep", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder); - if (! empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); + if (!empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "s.amount", "", $param, 'class="right"', $sortfield, $sortorder); print "\n"; @@ -520,8 +520,8 @@ if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) print "\n"; // Ref payment - $sal_static->id=$obj->rowid; - $sal_static->ref=$obj->rowid; + $sal_static->id = $obj->rowid; + $sal_static->ref = $obj->rowid; print '\n"; // Date @@ -533,18 +533,18 @@ if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) print $obj->num_payment.''; // Account - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { print '"; print ''; // Km - print ''; + print ''; // Company print ""; @@ -300,8 +300,8 @@ if ($action == 'create') } // Other attributes - $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; print '
".$obj->label."'.$sal_static->getNomUrl(1)."'; if ($obj->fk_bank > 0) { //$accountstatic->fetch($obj->fk_bank); - $accountstatic->id=$obj->bid; - $accountstatic->ref=$obj->bref; - $accountstatic->number=$obj->bnumber; - $accountstatic->accountancy_number=$obj->account_number; - $accountstatic->accountancy_journal=$obj->accountancy_journal; - $accountstatic->label=$obj->blabel; + $accountstatic->id = $obj->bid; + $accountstatic->ref = $obj->bref; + $accountstatic->number = $obj->bnumber; + $accountstatic->accountancy_number = $obj->account_number; + $accountstatic->accountancy_journal = $obj->accountancy_journal; + $accountstatic->label = $obj->blabel; print $accountstatic->getNomUrl(1); } else print ' '; diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php index 488a5a86cf7..5f469a2cef6 100644 --- a/htdocs/compta/deplacement/card.php +++ b/htdocs/compta/deplacement/card.php @@ -29,7 +29,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/trip.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -if (! empty($conf->projet->enabled)) +if (!empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } @@ -40,7 +40,7 @@ $langs->load("trips"); // Security check $id = GETPOST('id', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'deplacement', $id, ''); $action = GETPOST('action', 'alpha'); @@ -49,16 +49,16 @@ $confirm = GETPOST('confirm', 'alpha'); $object = new Deplacement($db); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('tripsandexpensescard','globalcard')); +$hookmanager->initHooks(array('tripsandexpensescard', 'globalcard')); -$permissionnote=$user->rights->deplacement->creer; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->rights->deplacement->creer; // Used by the include of actions_setnotes.inc.php /* * Actions */ -include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once if ($action == 'validate' && $user->rights->deplacement->creer) { @@ -68,7 +68,7 @@ if ($action == 'validate' && $user->rights->deplacement->creer) $result = $object->setStatut(1); if ($result > 0) { - header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; } else @@ -86,7 +86,7 @@ elseif ($action == 'classifyrefunded' && $user->rights->deplacement->creer) $result = $object->setStatut(2); if ($result > 0) { - header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; } else @@ -98,7 +98,7 @@ elseif ($action == 'classifyrefunded' && $user->rights->deplacement->creer) elseif ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->deplacement->supprimer) { - $result=$object->delete($id); + $result = $object->delete($id); if ($result >= 0) { header("Location: index.php"); @@ -112,20 +112,20 @@ elseif ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->depla elseif ($action == 'add' && $user->rights->deplacement->creer) { - if (! GETPOST('cancel', 'alpha')) + if (!GETPOST('cancel', 'alpha')) { - $error=0; + $error = 0; $object->date = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - $object->km = price2num(GETPOST('km', 'alpha'), 'MU'); // Not 'int', it may be a formated amount + $object->km = price2num(GETPOST('km', 'alpha'), 'MU'); // Not 'int', it may be a formated amount $object->type = GETPOST('type', 'alpha'); - $object->socid = GETPOST('socid', 'int'); - $object->fk_user = GETPOST('fk_user', 'int'); - $object->note_private = GETPOST('note_private', 'alpha'); + $object->socid = GETPOST('socid', 'int'); + $object->fk_user = GETPOST('fk_user', 'int'); + $object->note_private = GETPOST('note_private', 'alpha'); $object->note_public = GETPOST('note_public', 'alpha'); $object->statut = 0; - if (! $object->date) + if (!$object->date) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); $error++; @@ -135,30 +135,30 @@ elseif ($action == 'add' && $user->rights->deplacement->creer) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); $error++; } - if (! ($object->fk_user > 0)) + if (!($object->fk_user > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Person")), null, 'errors'); $error++; } - if (! $error) + if (!$error) { $id = $object->create($user); if ($id > 0) { - header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); - $action='create'; + $action = 'create'; } } else { - $action='create'; + $action = 'create'; } } else @@ -171,23 +171,23 @@ elseif ($action == 'add' && $user->rights->deplacement->creer) // Update record elseif ($action == 'update' && $user->rights->deplacement->creer) { - if (! GETPOST('cancel', 'alpha')) + if (!GETPOST('cancel', 'alpha')) { $result = $object->fetch($id); $object->date = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - $object->km = price2num(GETPOST('km', 'alpha'), 'MU'); // Not 'int', it may be a formated amount + $object->km = price2num(GETPOST('km', 'alpha'), 'MU'); // Not 'int', it may be a formated amount $object->type = GETPOST('type', 'alpha'); - $object->socid = GETPOST('socid', 'int'); - $object->fk_user = GETPOST('fk_user', 'int'); - $object->note_private = GETPOST('note_private', 'alpha'); - $object->note_public = GETPOST('note_public', 'alpha'); + $object->socid = GETPOST('socid', 'int'); + $object->fk_user = GETPOST('fk_user', 'int'); + $object->note_private = GETPOST('note_private', 'alpha'); + $object->note_public = GETPOST('note_public', 'alpha'); $result = $object->update($user); if ($result > 0) { - header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; } else @@ -197,7 +197,7 @@ elseif ($action == 'update' && $user->rights->deplacement->creer) } else { - header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; } } @@ -206,22 +206,22 @@ elseif ($action == 'update' && $user->rights->deplacement->creer) elseif ($action == 'classin' && $user->rights->deplacement->creer) { $object->fetch($id); - $result=$object->setProject(GETPOST('projectid', 'int')); + $result = $object->setProject(GETPOST('projectid', 'int')); if ($result < 0) dol_print_error($db, $object->error); } // Set fields elseif ($action == 'setdated' && $user->rights->deplacement->creer) { - $dated=dol_mktime(GETPOST('datedhour', 'int'), GETPOST('datedmin', 'int'), GETPOST('datedsec', 'int'), GETPOST('datedmonth', 'int'), GETPOST('datedday', 'int'), GETPOST('datedyear', 'int')); + $dated = dol_mktime(GETPOST('datedhour', 'int'), GETPOST('datedmin', 'int'), GETPOST('datedsec', 'int'), GETPOST('datedmonth', 'int'), GETPOST('datedday', 'int'), GETPOST('datedyear', 'int')); $object->fetch($id); - $result=$object->setValueFrom('dated', $dated, '', '', 'date', '', $user, 'DEPLACEMENT_MODIFY'); + $result = $object->setValueFrom('dated', $dated, '', '', 'date', '', $user, 'DEPLACEMENT_MODIFY'); if ($result < 0) dol_print_error($db, $object->error); } elseif ($action == 'setkm' && $user->rights->deplacement->creer) { $object->fetch($id); - $result=$object->setValueFrom('km', GETPOST('km', 'int'), '', null, 'text', '', $user, 'DEPLACEMENT_MODIFY'); + $result = $object->setValueFrom('km', GETPOST('km', 'int'), '', null, 'text', '', $user, 'DEPLACEMENT_MODIFY'); if ($result < 0) dol_print_error($db, $object->error); } @@ -246,7 +246,7 @@ if ($action == 'create') $datec = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - print '' . "\n"; + print ''."\n"; print ''; print ''; @@ -264,11 +264,11 @@ if ($action == 'create') print "
'.$langs->trans("Date").''; - print $form->selectDate($datec?$datec:-1, '', '', '', '', 'add', 1, 1); + print $form->selectDate($datec ? $datec : -1, '', '', '', '', 'add', 1, 1); print '
'.$langs->trans("FeesKilometersOrAmout").'
'.$langs->trans("FeesKilometersOrAmout").'
'; @@ -334,7 +334,7 @@ elseif ($id) $soc->fetch($object->socid); } - print '' . "\n"; + print ''."\n"; print ''; print ''; print ''; @@ -350,13 +350,13 @@ elseif ($id) // Type print "
'.$langs->trans("Type").''; - $form->select_type_fees(GETPOST('type', 'int')?GETPOST('type', 'int'):$object->type, 'type', 0); + $form->select_type_fees(GETPOST('type', 'int') ?GETPOST('type', 'int') : $object->type, 'type', 0); print '
'.$langs->trans("Person").''; - print $form->select_dolusers(GETPOST('fk_user', 'int')?GETPOST('fk_user', 'int'):$object->fk_user, 'fk_user', 0, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); + print $form->select_dolusers(GETPOST('fk_user', 'int') ?GETPOST('fk_user', 'int') : $object->fk_user, 'fk_user', 0, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); print '
'; @@ -428,7 +428,7 @@ elseif ($id) print ''; - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; // Ref print ''; @@ -472,7 +472,7 @@ elseif ($id) print ''; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load('projects'); print ''; @@ -505,8 +505,8 @@ elseif ($id) print ''; // Other attributes - $parameters=array('socid'=>$object->id); - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + $parameters = array('socid'=>$object->id); + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print "
'.$langs->trans("Ref").''; @@ -446,7 +446,7 @@ elseif ($id) // Who print '
'.$langs->trans("Person").''; - $userfee=new User($db); + $userfee = new User($db); $userfee->fetch($object->fk_user); print $userfee->getNomUrl(1); print '
'.$langs->trans("Status").''.$object->getLibStatut(4).'

"; diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index e13693e7411..e5139b061aa 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -34,14 +34,14 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -if (! empty($conf->projet->enabled)) { - include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; +if (!empty($conf->projet->enabled)) { + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; //include_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.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/lib/invoice.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.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/lib/invoice.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load translation files required by the page $langs->loadLangs(array('bills', 'compta', 'admin', 'other', 'products')); @@ -52,29 +52,29 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'invoicetemplatelist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'invoicetemplatelist'; // To manage different context of search // Security check -$id=(GETPOST('facid', 'int')?GETPOST('facid', 'int'):GETPOST('id', 'int')); -$lineid=GETPOST('lineid', 'int'); -$ref=GETPOST('ref', 'alpha'); -if ($user->socid) $socid=$user->socid; +$id = (GETPOST('facid', 'int') ?GETPOST('facid', 'int') : GETPOST('id', 'int')); +$lineid = GETPOST('lineid', 'int'); +$ref = GETPOST('ref', 'alpha'); +if ($user->socid) $socid = $user->socid; $objecttype = 'facture_rec'; if ($action == "create" || $action == "add") $objecttype = ''; $result = restrictedArea($user, 'facture', $id, $objecttype); $projectid = GETPOST('projectid', 'int'); -$year_date_when=GETPOST('year_date_when'); -$month_date_when=GETPOST('month_date_when'); +$year_date_when = GETPOST('year_date_when'); +$month_date_when = GETPOST('month_date_when'); -$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; -if (! $sortorder) $sortorder='DESC'; -if (! $sortfield) $sortfield='f.titre'; +if (!$sortorder) $sortorder = 'DESC'; +if (!$sortfield) $sortfield = 'f.titre'; $pageprev = $page - 1; $pagenext = $page + 1; @@ -89,26 +89,26 @@ if (($id > 0 || $ref) && $action != 'create' && $action != 'add') } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('invoicereccard','globalcard')); +$hookmanager->initHooks(array('invoicereccard', 'globalcard')); $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_'); $permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php +$permissiondellink = $user->rights->facture->creer; // Used by the include of actions_dellink.inc.php $permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php $usercanread = $user->rights->facture->lire; $usercancreate = $user->rights->facture->creer; $usercanissuepayment = $user->rights->facture->paiement; $usercandelete = $user->rights->facture->supprimer; -$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->validate))); +$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->validate))); $usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->facture->invoice_advance->send); $usercanreopen = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->facture->invoice_advance->reopen); -$usercanunvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($usercancreate)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate))); +$usercanunvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($usercancreate)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->unvalidate))); $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)); $usercancreatemargin = $user->rights->margins->creer; @@ -122,8 +122,8 @@ $now = dol_now(); * 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 @@ -131,17 +131,17 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if (GETPOST('cancel', 'alpha')) $action=''; + if (GETPOST('cancel', 'alpha')) $action = ''; // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Set note - 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 // Mass actions /*$objectclass='MyObject'; @@ -154,20 +154,20 @@ if (empty($reshook)) // Create predefined invoice if ($action == 'add') { - if (! GETPOST('titre', 'nohtml')) + if (!GETPOST('titre', 'nohtml')) { setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("Title")), null, 'errors'); $action = "create"; $error++; } - $frequency=GETPOST('frequency', 'int'); - $reyear=GETPOST('reyear', 'int'); - $remonth=GETPOST('remonth', 'int'); - $reday=GETPOST('reday', 'int'); - $rehour=GETPOST('rehour', 'int'); - $remin=GETPOST('remin', 'int'); - $nb_gen_max=GETPOST('nb_gen_max', 'int'); + $frequency = GETPOST('frequency', 'int'); + $reyear = GETPOST('reyear', 'int'); + $remonth = GETPOST('remonth', 'int'); + $reday = GETPOST('reday', 'int'); + $rehour = GETPOST('rehour', 'int'); + $remin = GETPOST('remin', 'int'); + $nb_gen_max = GETPOST('nb_gen_max', 'int'); //if (empty($nb_gen_max)) $nb_gen_max =0; if (GETPOST('frequency', 'int')) @@ -186,12 +186,12 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { - $object->titre = GETPOST('titre', 'nohtml'); // deprecated + $object->titre = GETPOST('titre', 'nohtml'); // deprecated $object->title = GETPOST('titre', 'nohtml'); $object->note_private = GETPOST('note_private', 'none'); - $object->note_public = GETPOST('note_public', 'none'); + $object->note_public = GETPOST('note_public', 'none'); $object->modelpdf = GETPOST('modelpdf', 'alpha'); $object->usenewprice = GETPOST('usenewprice', 'alpha'); @@ -213,7 +213,7 @@ if (empty($reshook)) $srcObject->fetchObjectLinked(); - if (! empty($srcObject->linkedObjectsIds['contrat'])) + if (!empty($srcObject->linkedObjectsIds['contrat'])) { $contractidid = reset($srcObject->linkedObjectsIds['contrat']); @@ -231,7 +231,7 @@ if (empty($reshook)) $result = $object->create($user, $oldinvoice->id); if ($result > 0) { - $result=$oldinvoice->delete($user, 1); + $result = $oldinvoice->delete($user, 1); if ($result < 0) { $error++; @@ -246,11 +246,11 @@ if (empty($reshook)) $action = "create"; } - if (! $error) + if (!$error) { $db->commit(); - header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $object->id); + header("Location: ".$_SERVER['PHP_SELF'].'?facid='.$object->id); exit; } else @@ -269,7 +269,7 @@ if (empty($reshook)) { $object->delete($user); - header("Location: " . DOL_URL_ROOT.'/compta/facture/invoicetemplate_list.php'); + header("Location: ".DOL_URL_ROOT.'/compta/facture/invoicetemplate_list.php'); exit; } @@ -278,12 +278,12 @@ if (empty($reshook)) // Set condition if ($action == 'setconditions' && $user->rights->facture->creer) { - $result=$object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); + $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); } // Set mode elseif ($action == 'setmode' && $user->rights->facture->creer) { - $result=$object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); + $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); } // Set project elseif ($action == 'classin' && $user->rights->facture->creer) @@ -294,10 +294,10 @@ if (empty($reshook)) elseif ($action == 'setref' && $user->rights->facture->creer) { //var_dump(GETPOST('ref', 'alpha'));exit; - $result=$object->setValueFrom('titre', GETPOST('ref', 'alpha'), '', null, 'text', '', $user, 'BILLREC_MODIFY'); + $result = $object->setValueFrom('titre', GETPOST('ref', 'alpha'), '', null, 'text', '', $user, 'BILLREC_MODIFY'); if ($result > 0) { - $object->titre = GETPOST('ref', 'alpha'); // deprecated + $object->titre = GETPOST('ref', 'alpha'); // deprecated $object->title = GETPOST('ref', 'alpha'); $object->ref = $object->title; } @@ -306,7 +306,7 @@ if (empty($reshook)) // Set bank account elseif ($action == 'setbankaccount' && $user->rights->facture->creer) { - $result=$object->setBankAccount(GETPOST('fk_account', 'int')); + $result = $object->setBankAccount(GETPOST('fk_account', 'int')); } // Set frequency and unit frequency elseif ($action == 'setfrequency' && $user->rights->facture->creer) @@ -353,7 +353,7 @@ if (empty($reshook)) $error++; } - if (! $error) + if (!$error) { $db->commit(); } @@ -377,7 +377,7 @@ if (empty($reshook)) $error++; } - if (! $error) + if (!$error) { $db->commit(); } @@ -405,19 +405,19 @@ if (empty($reshook)) $db->begin(); - $line=new FactureLigneRec($db); + $line = new FactureLigneRec($db); // For triggers $line->id = $lineid; if ($line->delete($user) > 0) { - $result=$object->update_price(1); + $result = $object->update_price(1); if ($result > 0) { $db->commit(); - $object->fetch($object->id); // Reload lines + $object->fetch($object->id); // Reload lines } else { @@ -439,7 +439,7 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; - if (! $error) + if (!$error) { $result = $object->insertExtraFields('BILLREC_MODIFY'); if ($result < 0) @@ -457,24 +457,24 @@ 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', 'alpha'); if ($prod_entry_mode == 'free') { - $idprod=0; + $idprod = 0; $tva_tx = (GETPOST('tva_tx', 'alpha') ? GETPOST('tva_tx', 'alpha') : 0); } else { - $idprod=GETPOST('idprod', 'int'); + $idprod = GETPOST('idprod', 'int'); $tva_tx = ''; } - $qty = GETPOST('qty' . $predef); - $remise_percent = GETPOST('remise_percent' . $predef); + $qty = GETPOST('qty'.$predef); + $remise_percent = GETPOST('remise_percent'.$predef); // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -484,38 +484,38 @@ if (empty($reshook)) { // Get extra fields foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key . $predef]); + unset($_POST["options_".$key.$predef]); } } if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) { setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors'); - $error ++; + $error++; } 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 >= 0) || $price_ht == '')) // Unit price can be 0 but not '' + if ($prod_entry_mode == 'free' && empty($idprod) && (!($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); - $error ++; + $error++; } if ($qty == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 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 ($qty < 0) { $langs->load("errors"); setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors'); - $error ++; + $error++; } - if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) + if (!$error && ($qty >= 0) && (!empty($product_desc) || !empty($idprod))) { $ret = $object->fetch($id); if ($ret < 0) { @@ -525,8 +525,8 @@ if (empty($reshook)) $ret = $object->fetch_thirdparty(); // 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')); + $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'); // Define special_code for special lines @@ -538,7 +538,7 @@ if (empty($reshook)) // Ecrase $tva_tx par celui du produit // Ecrase $base_price_type par celui du produit // Replaces $fk_unit with the product's - if (! empty($idprod)) + if (!empty($idprod)) { $prod = new Product($db); $prod->fetch($idprod); @@ -548,7 +548,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; // Search the correct price into loaded array product_price_by_qty using id of array retrieved into POST['pqp']. $pqp = (GETPOST('pbq', 'int') ? GETPOST('pbq', 'int') : 0); @@ -566,7 +566,7 @@ if (empty($reshook)) $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); // if price ht was forced (ie: from gui when 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'); @@ -588,7 +588,7 @@ 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 = ''; @@ -596,13 +596,13 @@ if (empty($reshook)) $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 { @@ -612,27 +612,27 @@ if (empty($reshook)) $desc = dol_concatdesc($desc, $product_desc); // 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)) $tmptxt .= ' - '; - if (! empty($prod->country_code)) $tmptxt .= $outputlangs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $outputlangs, 0); + 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); } else { - 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->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); } $tmptxt .= ')'; $desc = dol_concatdesc($desc, $tmptxt); @@ -647,19 +647,19 @@ if (empty($reshook)) $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); $tva_tx = str_replace('*', '', $tva_tx); - if (empty($tva_tx)) $tva_npr=0; + if (empty($tva_tx)) $tva_npr = 0; $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); $desc = $product_desc; $type = GETPOST('type'); - $fk_unit= GETPOST('units', 'alpha'); + $fk_unit = GETPOST('units', 'alpha'); } $date_start_fill = GETPOST('date_start_fill', 'int'); $date_end_fill = GETPOST('date_end_fill', 'int'); // 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 must 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 must keep this value // Local Taxes $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr); @@ -669,7 +669,7 @@ if (empty($reshook)) if ($tva_npr) $info_bits |= 0x01; - if ($usercanproductignorepricemin && (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) { + if ($usercanproductignorepricemin && (!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'); } @@ -698,7 +698,7 @@ if (empty($reshook)) $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); }*/ - $object->fetch($object->id); // Reload lines + $object->fetch($object->id); // Reload lines unset($_POST['prod_entry_mode']); @@ -749,9 +749,9 @@ if (empty($reshook)) } } - elseif ($action == 'updateline' && $usercancreate && ! GETPOST('cancel', 'alpha')) + elseif ($action == 'updateline' && $usercancreate && !GETPOST('cancel', 'alpha')) { - if (! $object->fetch($id) > 0) dol_print_error($db); + if (!$object->fetch($id) > 0) dol_print_error($db); $object->fetch_thirdparty(); // Clean parameters @@ -776,7 +776,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 $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -785,8 +785,8 @@ if (empty($reshook)) $objectline = new FactureLigneRec($db); if ($objectline->fetch(GETPOST('lineid', 'int'))) { - $objectline->array_options=$array_options; - $result=$objectline->insertExtraFields(); + $objectline->array_options = $array_options; + $result = $objectline->insertExtraFields(); if ($result < 0) { setEventMessages($langs->trans('Error').$result, null, 'errors'); @@ -801,13 +801,13 @@ if (empty($reshook)) // 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', 'int'); - if (! GETPOST('qty', 'alpha')) $special_code=3; + $special_code = GETPOST('special_code', 'int'); + if (!GETPOST('qty', 'alpha')) $special_code = 3; /*$line = new FactureLigne($db); $line->fetch(GETPOST('lineid')); @@ -823,7 +823,7 @@ if (empty($reshook)) // Check minimum price $productid = GETPOST('productid', 'int'); - if (! empty($productid)) + if (!empty($productid)) { $product = new Product($db); $product->fetch($productid); @@ -831,16 +831,16 @@ if (empty($reshook)) $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') : ''); // Check price is not lower than minimum (check is done only for standard or replacement invoices) - if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $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)) && (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $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', 'int'); @@ -849,20 +849,20 @@ if (empty($reshook)) // Check parameters if (GETPOST('type', 'int') < 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); - $error ++; + $error++; } } if ($qty < 0) { $langs->load("errors"); setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors'); - $error ++; + $error++; } $date_start_fill = GETPOST('date_start_fill', 'int'); $date_end_fill = GETPOST('date_end_fill', 'int'); // Update line - if (! $error) + if (!$error) { $result = $object->updateline( GETPOST('lineid'), @@ -910,7 +910,7 @@ if (empty($reshook)) $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); }*/ - $object->fetch($object->id); // Reload lines + $object->fetch($object->id); // Reload lines unset($_POST['qty']); unset($_POST['type']); @@ -965,13 +965,13 @@ llxHeader('', $langs->trans("RepeatableInvoices"), 'ch-facture.html#s-fac-factur $form = new Form($db); $formother = new FormOther($db); -if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } $companystatic = new Societe($db); $invoicerectmp = new FactureRec($db); $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 /* @@ -981,7 +981,7 @@ if ($action == 'create') { print load_fiche_titre($langs->trans("CreateRepeatableInvoice"), '', 'invoicing'); - $object = new Facture($db); // Source invoice + $object = new Facture($db); // Source invoice $product_static = new Product($db); if ($object->fetch($id, $ref) > 0) @@ -995,8 +995,8 @@ if ($action == 'create') dol_fiche_head(null, '', '', 0); - $rowspan=4; - if (! empty($conf->projet->enabled)) $rowspan++; + $rowspan = 4; + if (!empty($conf->projet->enabled)) $rowspan++; if ($object->fk_account > 0) $rowspan++; print ''; @@ -1012,8 +1012,8 @@ if ($action == 'create') print ''; print ''; - $note_public=GETPOST('note_public', 'none')?GETPOST('note_public', 'none'):$object->note_public; - $note_private=GETPOST('note_private', 'none')?GETPOST('note_private', 'none'):$object->note_private; + $note_public = GETPOST('note_public', 'none') ?GETPOST('note_public', 'none') : $object->note_public; + $note_private = GETPOST('note_private', 'none') ?GETPOST('note_private', 'none') : $object->note_private; // Help of substitution key $substitutionarray = getCommonSubstitutionArray($langs, 2, null, $object); @@ -1025,18 +1025,18 @@ if ($action == 'create') $substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date, '%B').')'; $substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%B').')'; $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'y'), '%Y').')'; - $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date, '%Y').')'; + $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date, '%Y').')'; $substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'y'), '%Y').')'; // Only on template invoices $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date($object->date_when, 'dayhour').')'; $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans("DateNextInvoiceAfterGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date_when, $object->frequency, $object->unit_frequency), 'dayhour').')'; $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
'; - foreach($substitutionarray as $key => $val) + foreach ($substitutionarray as $key => $val) { - $htmltext.=$key.' = '.$langs->trans($val).'
'; + $htmltext .= $key.' = '.$langs->trans($val).'
'; } - $htmltext.='
'; + $htmltext .= ''; // Public note print ''; @@ -1075,13 +1075,13 @@ if ($action == 'create') print ""; // Project - if (! empty($conf->projet->enabled) && is_object($object->thirdparty) && $object->thirdparty->id > 0) + if (!empty($conf->projet->enabled) && is_object($object->thirdparty) && $object->thirdparty->id > 0) { - $projectid = GETPOST('projectid')?GETPOST('projectid'):$object->fk_project; + $projectid = GETPOST('projectid') ?GETPOST('projectid') : $object->fk_project; $langs->load('projects'); - print ''; } @@ -1095,7 +1095,7 @@ if ($action == 'create') // Model pdf print ""; @@ -1115,7 +1115,7 @@ if ($action == 'create') // Frequency + unit print '"; // Date next run @@ -1131,15 +1131,15 @@ if ($action == 'create') // Auto validate the invoice print ""; // Auto generate document - if (! empty($conf->global->INVOICE_REC_CAN_DISABLE_DOCUMENT_FILE_GENERATION)) + if (!empty($conf->global->INVOICE_REC_CAN_DISABLE_DOCUMENT_FILE_GENERATION)) { print ""; } @@ -1167,12 +1167,12 @@ if ($action == 'create') print '
'; print '
'.$langs->trans("Customer").''.$object->thirdparty->getNomUrl(1, 'customer').'
' . $langs->trans('Project') . ''; + print '
'.$langs->trans('Project').''; $numprojet = $formproject->select_projects($object->thirdparty->id, $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, ''); - print '   thirdparty->id.(!empty($id)?'&id='.$id:'')).'">' . $langs->trans("AddProject") . ''; + print '   thirdparty->id.(!empty($id) ? '&id='.$id : '')).'">'.$langs->trans("AddProject").''; print '
".$langs->trans('Model').""; - include_once DOL_DOCUMENT_ROOT . '/core/modules/facture/modules_facture.php'; + include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; $list = ModelePDFFactures::liste_modeles($db); print $form->selectarray('modelpdf', $list, $conf->global->FACTURE_ADDON_PDF); print "
'.$form->textwithpicto($langs->trans("Frequency"), $langs->transnoentitiesnoconv('toolTipFrequency')).""; - print " ".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), (GETPOST('unit_frequency')?GETPOST('unit_frequency'):'m')); + print " ".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), (GETPOST('unit_frequency') ?GETPOST('unit_frequency') : 'm')); print "
".$langs->trans("StatusOfGeneratedInvoices").""; - $select = array('0'=>$langs->trans('BillStatusDraft'),'1'=>$langs->trans('BillStatusValidated')); + $select = array('0'=>$langs->trans('BillStatusDraft'), '1'=>$langs->trans('BillStatusValidated')); print $form->selectarray('auto_validate', $select, GETPOST('auto_validate')); print "
".$langs->trans("StatusOfGeneratedDocuments").""; - $select = array('0'=>$langs->trans('DoNotGenerateDoc'),'1'=>$langs->trans('AutoGenerateDoc')); + $select = array('0'=>$langs->trans('DoNotGenerateDoc'), '1'=>$langs->trans('AutoGenerateDoc')); print $form->selectarray('generate_pdf', $select, GETPOST('generate_pdf')); print "
'; // Show object lines - if (! empty($object->lines)) + if (!empty($object->lines)) { - $disableedit=1; - $disablemove=1; - $disableremove=1; - $object->printObjectLines('', $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice + $disableedit = 1; + $disablemove = 1; + $disableremove = 1; + $object->printObjectLines('', $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice } print "
\n"; @@ -1193,7 +1193,7 @@ if ($action == 'create') print '
'; print '     '; - print ''; + print ''; print '
'; print "\n"; } @@ -1213,12 +1213,12 @@ else // Confirmation de la suppression d'une ligne produit if ($action == 'ask_deleteline') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 'no', 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 'no', 1); } // Confirm delete of repeatable invoice if ($action == 'ask_deleteinvoice') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteRepeatableInvoice'), $langs->trans('ConfirmDeleteRepeatableInvoice'), 'confirm_deleteinvoice', '', 'no', 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteRepeatableInvoice'), $langs->trans('ConfirmDeleteRepeatableInvoice'), 'confirm_deleteinvoice', '', 'no', 1); } print $formconfirm; @@ -1226,58 +1226,58 @@ else $author = new User($db); $author->fetch($object->user_author); - $head=invoice_rec_prepare_head($object); + $head = invoice_rec_prepare_head($object); - dol_fiche_head($head, 'card', $langs->trans("RepeatableInvoice"), -1, 'bill'); // Add a div + dol_fiche_head($head, 'card', $langs->trans("RepeatableInvoice"), -1, 'bill'); // Add a div // Recurring invoice content - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref=''; - if ($action != 'editref') $morehtmlref.=$form->editfieldkey($object->ref, 'ref', $object->ref, $object, $user->rights->facture->creer, '', '', 0, 2); - else $morehtmlref.= $form->editfieldval('', 'ref', $object->ref, $object, $user->rights->facture->creer, 'string'); + $morehtmlref = ''; + if ($action != 'editref') $morehtmlref .= $form->editfieldkey($object->ref, 'ref', $object->ref, $object, $user->rights->facture->creer, '', '', 0, 2); + else $morehtmlref .= $form->editfieldval('', 'ref', $object->ref, $object, $user->rights->facture->creer, 'string'); - $morehtmlref.='
'; + $morehtmlref .= '
'; // Ref customer //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', 0, 1); //$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); + $morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; + $morehtmlref .= '
'.$langs->trans('Project').' '; if ($user->rights->facture->creer) { 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, 'titre', 'none', $morehtmlref, '', 0, '', $morehtmlright); @@ -1299,13 +1299,13 @@ else // Amount Local Taxes if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(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" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) // Localtax2 { - 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).''; } print ''.$langs->trans("AmountTTC").''.price($object->total_ttc, '', $langs, 1, -1, -1, $conf->currency).''; @@ -1318,18 +1318,18 @@ else print $langs->trans('PaymentConditionsShort'); print ''; if ($action != 'editconditions' && $user->rights->facture->creer) - print 'id . '">' . img_edit($langs->trans('SetConditions'), 1) . ''; + print 'id.'">'.img_edit($langs->trans('SetConditions'), 1).''; print ''; print ''; if ($object->type != Facture::TYPE_CREDIT_NOTE) { if ($action == 'editconditions') { - $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->cond_reglement_id, 'cond_reglement_id'); + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->cond_reglement_id, 'cond_reglement_id'); } else { - $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->cond_reglement_id, 'none'); + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->cond_reglement_id, 'none'); } } else { print ' '; @@ -1342,7 +1342,7 @@ else print $langs->trans('PaymentMode'); print ''; if ($action != 'editmode' && $user->rights->facture->creer) - print 'id . '">' . img_edit($langs->trans('SetMode'), 1) . ''; + print 'id.'">'.img_edit($langs->trans('SetMode'), 1).''; print ''; print ''; if ($action == 'editmode') @@ -1356,7 +1356,7 @@ else print ''; // Multicurrency - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { // Multicurrency code print ''; @@ -1364,13 +1364,13 @@ else print ''; - if ($usercancreate && $action != 'editmulticurrencycode' && ! empty($object->brouillon)) { - print ''; + if ($usercancreate && $action != 'editmulticurrencycode' && !empty($object->brouillon)) { + print ''; } print '
'; print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'
'; print ''; - $htmlname = (($usercancreate && $action == 'editmulticurrencycode')?'multicurrency_code':'none'); - $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, $htmlname); + $htmlname = (($usercancreate && $action == 'editmulticurrencycode') ? 'multicurrency_code' : 'none'); + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, $htmlname); print ''; // Multicurrency rate @@ -1381,19 +1381,19 @@ else print ''; - if ($usercancreate && $action != 'editmulticurrencyrate' && ! empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { - print ''; + if ($usercancreate && $action != 'editmulticurrencyrate' && !empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { + print ''; } print '
'; print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); 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, ($usercancreate?'multicurrency_tx':'none'), $object->multicurrency_code); + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, ($usercancreate ? 'multicurrency_tx' : 'none'), $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 '
'; @@ -1404,8 +1404,8 @@ else } // Help of substitution key - $dateexample=dol_now(); - if (! empty($object->frequency) && ! empty($object->date_when)) $dateexample=$object->date_when; + $dateexample = dol_now(); + if (!empty($object->frequency) && !empty($object->date_when)) $dateexample = $object->date_when; $substitutionarray = getCommonSubstitutionArray($langs, 2, null, $object); @@ -1416,18 +1416,18 @@ else $substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%B').')'; $substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'), '%B').')'; $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'y'), '%Y').')'; - $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%Y').')'; + $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%Y').')'; $substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'), '%Y').')'; // Only on template invoices - $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date(($object->date_when?$object->date_when:dol_now()), 'dayhour').')'; - $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans("DateNextInvoiceAfterGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree(($object->date_when?$object->date_when:dol_now()), $object->frequency, $object->unit_frequency), 'dayhour').')'; + $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date(($object->date_when ? $object->date_when : dol_now()), 'dayhour').')'; + $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans("DateNextInvoiceAfterGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree(($object->date_when ? $object->date_when : dol_now()), $object->frequency, $object->unit_frequency), 'dayhour').')'; $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
'; - foreach($substitutionarray as $key => $val) + foreach ($substitutionarray as $key => $val) { - $htmltext.=$key.' = '.$langs->trans($val).'
'; + $htmltext .= $key.' = '.$langs->trans($val).'
'; } - $htmltext.='
'; + $htmltext .= ''; // Note public print ''; @@ -1480,11 +1480,11 @@ else print ''; if ($action == 'editmodelpdf') { - include_once DOL_DOCUMENT_ROOT . '/core/modules/facture/modules_facture.php'; + include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; $list = array(); $models = ModelePDFFactures::liste_modeles($db); foreach ($models as $k => $model) { - $list[] = str_replace(':', '|', $k) . ':' . $model; + $list[] = str_replace(':', '|', $k).':'.$model; } $select = 'select;'.implode(',', $list); print $form->editfieldval($langs->trans("Model"), 'modelpdf', $object->modelpdf, $object, $user->rights->facture->creer, $select); @@ -1498,7 +1498,7 @@ else // 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 ''; @@ -1524,17 +1524,17 @@ else print $langs->trans('Frequency'); print ''; if ($action != 'editfrequency' && $user->rights->facture->creer) - print 'id . '">' . img_edit($langs->trans('Edit'), 1) . ''; + print 'id.'">'.img_edit($langs->trans('Edit'), 1).''; print ''; print ''; if ($action == 'editfrequency') { - print '
'; + print ''; print ''; print ''; print ''; print ''; print ''; print '
'; - print " ".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), ($object->unit_frequency?$object->unit_frequency:'m')); + print " ".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), ($object->unit_frequency ? $object->unit_frequency : 'm')); print '
'; @@ -1568,9 +1568,9 @@ else print $form->editfieldval($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'day', $object->date_when, null, '', '', 0, 'strikeIfMaxNbGenReached'); } //var_dump(dol_print_date($object->date_when+60, 'dayhour').' - '.dol_print_date($now, 'dayhour')); - if (! $object->isMaxNbGenReached()) + if (!$object->isMaxNbGenReached()) { - if (! $object->suspended && $action != 'editdate_when' && $object->frequency > 0 && $object->date_when && $object->date_when < $now) print img_warning($langs->trans("Late")); + if (!$object->suspended && $action != 'editdate_when' && $object->frequency > 0 && $object->date_when && $object->date_when < $now) print img_warning($langs->trans("Late")); } else { @@ -1592,7 +1592,7 @@ else print ''; if ($action == 'nb_gen_max' || $object->frequency > 0) { - print $form->editfieldval($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max?$object->nb_gen_max:'', $object, $user->rights->facture->creer); + print $form->editfieldval($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max ? $object->nb_gen_max : '', $object, $user->rights->facture->creer); } else { @@ -1615,7 +1615,7 @@ else } print ''; // Auto generate documents - if (! empty($conf->global->INVOICE_REC_CAN_DISABLE_DOCUMENT_FILE_GENERATION)) + if (!empty($conf->global->INVOICE_REC_CAN_DISABLE_DOCUMENT_FILE_GENERATION)) { print ''; print ''; @@ -1656,7 +1656,7 @@ else // Nb of generation already done print ''.$langs->trans("NbOfGenerationDone").''; print ''; - print $object->nb_gen_done?$object->nb_gen_done:'0'; + print $object->nb_gen_done ? $object->nb_gen_done : '0'; print ''; print ''; @@ -1681,25 +1681,25 @@ else // Lines - 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 '
'; print ''; // Show object lines - if (! empty($object->lines)) + if (!empty($object->lines)) { //$disableedit=1; //$disablemove=1; - $ret = $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice + $ret = $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice } // Form to add new line @@ -1708,7 +1708,7 @@ else if ($action != 'editline') { // Add free products/services - $object->formAddObjectLine(0, $mysoc, $object->thirdparty); // No date selector for template invoice + $object->formAddObjectLine(0, $mysoc, $object->thirdparty); // No date selector for template invoice $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -1732,7 +1732,7 @@ else { if ($user->rights->facture->creer) { - if (! empty($object->frequency) && $object->nb_gen_max > 0 && ($object->nb_gen_done >= $object->nb_gen_max)) + if (!empty($object->frequency) && $object->nb_gen_max > 0 && ($object->nb_gen_done >= $object->nb_gen_max)) { print ''; } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 10f54e538a2..48cd8e81054 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -37,38 +37,38 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture-rec.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/modules/facture/modules_facture.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formmargin.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/invoice.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; -if (! empty($conf->commande->enabled)) - require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.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.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +if (!empty($conf->commande->enabled)) + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.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'; } -if (! empty($conf->accounting->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +if (!empty($conf->accounting->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; } // Load translation files required by the page -$langs->loadLangs(array('bills','companies','compta','products','banks','main','withdrawals')); -if (! empty($conf->incoterm->enabled)) $langs->load('incoterm'); -if (! empty($conf->margin->enabled)) $langs->load('margins'); +$langs->loadLangs(array('bills', 'companies', 'compta', 'products', 'banks', 'main', 'withdrawals')); +if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); +if (!empty($conf->margin->enabled)) $langs->load('margins'); $projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : 0); @@ -86,37 +86,37 @@ $search_montant_ht = GETPOST('search_montant_ht', 'alpha'); $search_montant_ttc = GETPOST('search_montant_ttc', 'alpha'); $origin = GETPOST('origin', 'alpha'); $originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility -$fac_rec=GETPOST('fac_rec', 'int'); +$fac_rec = GETPOST('fac_rec', '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; -$usehm = (! empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE : 0); +$usehm = (!empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE : 0); $object = new Facture($db); $extrafields = new ExtraFields($db); // Load object -if ($id > 0 || ! empty($ref)) { +if ($id > 0 || !empty($ref)) { $ret = $object->fetch($id, $ref, '', '', $conf->global->INVOICE_USE_SITUATION); } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('invoicecard','globalcard')); +$hookmanager->initHooks(array('invoicecard', 'globalcard')); $usercanread = $user->rights->facture->lire; $usercancreate = $user->rights->facture->creer; $usercanissuepayment = $user->rights->facture->paiement; $usercandelete = $user->rights->facture->supprimer; -$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->validate))); +$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->validate))); $usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->facture->invoice_advance->send); $usercanreopen = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->facture->invoice_advance->reopen); -$usercanunvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($usercancreate)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate))); +$usercanunvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($usercancreate)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->unvalidate))); $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)); $usercancreatemargin = $user->rights->margins->creer; @@ -124,12 +124,12 @@ $usercanreadallmargin = $user->rights->margins->liretous; $usercancreatewithdrarequest = $user->rights->prelevement->bons->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_lineupdonw.inc.php $permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php // Security check -$fieldid = (! empty($ref) ? 'ref' : 'rowid'); +$fieldid = (!empty($ref) ? 'ref' : 'rowid'); if ($user->socid) $socid = $user->socid; $isdraft = (($object->statut == Facture::STATUS_DRAFT) ? 1 : 0); $result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid, $isdraft); @@ -146,30 +146,30 @@ 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_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' && $permissiontoadd) { - $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone. We use native clone to keep this->db valid. + $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone. We use native clone to keep this->db valid. $objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); $objectutil->socid = $socid; $result = $objectutil->createFromClone($user, $id); if ($result > 0) { - header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $result); + header("Location: ".$_SERVER['PHP_SELF'].'?facid='.$result); exit(); } else { $langs->load("errors"); @@ -185,7 +185,7 @@ if (empty($reshook)) if ($object->statut == Facture::STATUS_CLOSED || ($object->statut == Facture::STATUS_ABANDONED && ($object->close_code != 'replaced' || $object->getIdReplacingInvoice() == 0)) || ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 1)) { // ($object->statut == 1 && $object->paye == 1) should not happened but can be found when data are corrupted $result = $object->set_unpaid($user); if ($result > 0) { - header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); + header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); exit(); } else { setEventMessages($object->error, $object->errors, 'errors'); @@ -207,18 +207,18 @@ if (empty($reshook)) $qualified_for_stock_change = $object->hasProductsOrServices(1); } - $isErasable=$object->is_erasable(); + $isErasable = $object->is_erasable(); if (($usercandelete && $isErasable > 0) || ($usercancreate && $isErasable == 1)) { $result = $object->delete($user, 0, $idwarehouse); if ($result > 0) { - header('Location: ' . DOL_URL_ROOT . '/compta/facture/list.php?restore_lastsearch_values=1'); + header('Location: '.DOL_URL_ROOT.'/compta/facture/list.php?restore_lastsearch_values=1'); exit(); } else { setEventMessages($object->error, $object->errors, 'errors'); - $action=''; + $action = ''; } } } @@ -234,11 +234,11 @@ if (empty($reshook)) // Define output language $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; 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); $outputlangs->load('products'); @@ -248,7 +248,7 @@ if (empty($reshook)) $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } if ($result >= 0) { - header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); + header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); exit(); } } else { @@ -294,7 +294,7 @@ if (empty($reshook)) $object->fetch($id); $object->setValueFrom('fk_soc', $socid, '', null, 'int', '', $user, 'BILL_MODIFY'); - header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); + header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); exit(); } @@ -365,7 +365,7 @@ if (empty($reshook)) header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id.'&action=editinvoicedate'); exit; } - $object->date=$date; + $object->date = $date; $new_date_lim_reglement = $object->calculate_date_lim_reglement(); if ($new_date_lim_reglement > $old_date_lim_reglement) $object->date_lim_reglement = $new_date_lim_reglement; if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement = $object->date; @@ -377,7 +377,7 @@ if (empty($reshook)) { $object->fetch($id); $date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']); - $object->date_pointoftax=$date_pointoftax; + $object->date_pointoftax = $date_pointoftax; $result = $object->update($user); if ($result < 0) dol_print_error($db, $object->error); } @@ -430,7 +430,7 @@ if (empty($reshook)) // bank account elseif ($action == 'setbankaccount' && $usercancreate) { - $result=$object->setBankAccount(GETPOST('fk_account', 'int')); + $result = $object->setBankAccount(GETPOST('fk_account', 'int')); } elseif ($action == 'setremisepercent' && $usercancreate) @@ -444,7 +444,7 @@ if (empty($reshook)) // POST[remise_id] or POST[remise_id_for_payment] // We use the credit to reduce amount of invoice - if (! empty($_POST["remise_id"])) { + if (!empty($_POST["remise_id"])) { $ret = $object->fetch($id); if ($ret > 0) { $result = $object->insert_discount($_POST["remise_id"]); @@ -456,9 +456,9 @@ if (empty($reshook)) } } // We use the credit to reduce remain to pay - if (! empty($_POST["remise_id_for_payment"])) + if (!empty($_POST["remise_id_for_payment"])) { - require_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; $discount = new DiscountAbsolute($db); $discount->fetch($_POST["remise_id_for_payment"]); @@ -471,7 +471,7 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorDiscountLargerThanRemainToPaySplitItBefore"), null, 'errors'); } - if (! $error) + if (!$error) { $result = $discount->link_to_invoice(0, $id); if ($result < 0) { @@ -486,7 +486,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); } @@ -514,12 +514,12 @@ if (empty($reshook)) // Check parameters // Check for mandatory fields in thirdparty (defined into setup) - $array_to_check=array('IDPROF1','IDPROF2','IDPROF3','IDPROF4','IDPROF5','IDPROF6','EMAIL'); - foreach($array_to_check as $key) + $array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL'); + foreach ($array_to_check as $key) { - $keymin=strtolower($key); - $i=(int) preg_replace('/[^0-9]/', '', $key); - $vallabel=$object->thirdparty->$keymin; + $keymin = strtolower($key); + $i = (int) preg_replace('/[^0-9]/', '', $key); + $vallabel = $object->thirdparty->$keymin; if ($i > 0) { @@ -528,8 +528,8 @@ if (empty($reshook)) // Check for mandatory prof id (but only if country is other than ours) if ($mysoc->country_id > 0 && $object->thirdparty->country_id == $mysoc->country_id) { - $idprof_mandatory ='SOCIETE_'.$key.'_INVOICE_MANDATORY'; - if (! $vallabel && ! empty($conf->global->$idprof_mandatory)) + $idprof_mandatory = 'SOCIETE_'.$key.'_INVOICE_MANDATORY'; + if (!$vallabel && !empty($conf->global->$idprof_mandatory)) { $langs->load("errors"); $error++; @@ -544,7 +544,7 @@ if (empty($reshook)) if ($key == 'EMAIL') { // Check for mandatory - if (! empty($conf->global->SOCIETE_EMAIL_INVOICE_MANDATORY) && ! isValidEMail($object->thirdparty->email)) + if (!empty($conf->global->SOCIETE_EMAIL_INVOICE_MANDATORY) && !isValidEMail($object->thirdparty->email)) { $langs->load("errors"); $error++; @@ -555,15 +555,15 @@ if (empty($reshook)) } // Check for mandatory fields in invoice - $array_to_check=array('REF_CUSTOMER'=>'RefCustomer'); - foreach($array_to_check as $key => $val) + $array_to_check = array('REF_CUSTOMER'=>'RefCustomer'); + foreach ($array_to_check as $key => $val) { - $keymin=strtolower($key); - $vallabel=$object->$keymin; + $keymin = strtolower($key); + $vallabel = $object->$keymin; // Check for mandatory - $keymandatory ='INVOICE_'.$key.'_MANDATORY_FOR_VALIDATION'; - if (! $vallabel && ! empty($conf->global->$keymandatory)) + $keymandatory = 'INVOICE_'.$key.'_MANDATORY_FOR_VALIDATION'; + if (!$vallabel && !empty($conf->global->$keymandatory)) { $langs->load("errors"); $error++; @@ -572,7 +572,7 @@ if (empty($reshook)) } // Check for warehouse - if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL)) + if ($object->type != Facture::TYPE_DEPOSIT && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) { $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { @@ -583,7 +583,7 @@ if (empty($reshook)) if ($qualified_for_stock_change) { - if (! $idwarehouse || $idwarehouse == - 1) { + if (!$idwarehouse || $idwarehouse == - 1) { $error++; setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $action = ''; @@ -591,7 +591,7 @@ if (empty($reshook)) } } - if (! $error) + if (!$error) { $result = $object->validate($user, '', $idwarehouse); if ($result >= 0) @@ -603,12 +603,12 @@ 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); $outputlangs->load('products'); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -632,7 +632,7 @@ if (empty($reshook)) $object->fetch_thirdparty(); // Check parameters - if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL)) + if ($object->type != Facture::TYPE_DEPOSIT && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) { $qualified_for_stock_change = 0; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { @@ -643,7 +643,7 @@ if (empty($reshook)) if ($qualified_for_stock_change) { - if (! $idwarehouse || $idwarehouse == - 1) { + if (!$idwarehouse || $idwarehouse == - 1) { $error++; setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $action = ''; @@ -651,11 +651,11 @@ if (empty($reshook)) } } - if (! $error) { + if (!$error) { // On verifie si la facture a des paiements $sql = 'SELECT pf.amount'; - $sql .= ' FROM ' . MAIN_DB_PREFIX . 'paiement_facture as pf'; - $sql .= ' WHERE pf.fk_facture = ' . $object->id; + $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf'; + $sql .= ' WHERE pf.fk_facture = '.$object->id; $result = $db->query($sql); if ($result) { @@ -665,7 +665,7 @@ if (empty($reshook)) while ($i < $num) { $objp = $db->fetch_object($result); $totalpaye += $objp->amount; - $i ++; + $i++; } } else { dol_print_error($db, ''); @@ -679,10 +679,10 @@ if (empty($reshook)) // On verifie si aucun paiement n'a ete effectue if ($ventilExportCompta == 0) { - if (! empty($conf->global->INVOICE_CAN_ALWAYS_BE_EDITED) || ($resteapayer == $object->total_ttc && empty($object->paye))) + if (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_EDITED) || ($resteapayer == $object->total_ttc && empty($object->paye))) { - $result=$object->setDraft($user, $idwarehouse); - if ($result<0) setEventMessages($object->error, $object->errors, 'errors'); + $result = $object->setDraft($user, $idwarehouse); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) @@ -691,12 +691,12 @@ 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); $outputlangs->load('products'); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -711,7 +711,7 @@ if (empty($reshook)) { $object->fetch($id); $result = $object->set_paid($user); - if ($result<0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // Classif "paid partialy" elseif ($action == 'confirm_paid_partially' && $confirm == 'yes' && $usercanissuepayment) { @@ -720,7 +720,7 @@ if (empty($reshook)) $close_note = GETPOST("close_note", 'none'); if ($close_code) { $result = $object->set_paid($user, $close_code, $close_note); - if ($result<0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } else { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Reason")), null, 'errors'); } @@ -731,7 +731,7 @@ if (empty($reshook)) $close_note = GETPOST("close_note", 'none'); if ($close_code) { $result = $object->set_canceled($user, $close_code, $close_note); - if ($result<0) setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } else { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Reason")), null, 'errors'); } @@ -745,12 +745,12 @@ if (empty($reshook)) //$object->fetch_lines(); // Already done into fetch // Check if there is already a discount (protection to avoid duplicate creation when resubmit post) - $discountcheck=new DiscountAbsolute($db); - $result=$discountcheck->fetch(0, $object->id); + $discountcheck = new DiscountAbsolute($db); + $result = $discountcheck->fetch(0, $object->id); - $canconvert=0; - if ($object->type == Facture::TYPE_DEPOSIT && empty($discountcheck->id)) $canconvert=1; // we can convert deposit into discount if deposit is payed (completely, partially or not at all) and not already converted (see real condition into condition used to show button converttoreduc) - if (($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_STANDARD) && $object->paye == 0 && empty($discountcheck->id)) $canconvert=1; // we can convert credit note into discount if credit note is not payed back and not already converted and amount of payment is 0 (see real condition into condition used to show button converttoreduc) + $canconvert = 0; + if ($object->type == Facture::TYPE_DEPOSIT && empty($discountcheck->id)) $canconvert = 1; // we can convert deposit into discount if deposit is payed (completely, partially or not at all) and not already converted (see real condition into condition used to show button converttoreduc) + if (($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_STANDARD) && $object->paye == 0 && empty($discountcheck->id)) $canconvert = 1; // we can convert credit note into discount if credit note is not payed back and not already converted and amount of payment is 0 (see real condition into condition used to show button converttoreduc) if ($canconvert) { $db->begin(); @@ -796,13 +796,13 @@ if (empty($reshook)) // Total payments $sql = 'SELECT SUM(pf.amount) as total_paiements'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'paiement as p'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; - $sql.= ' WHERE pf.fk_facture = '.$object->id; - $sql.= ' AND pf.fk_paiement = p.rowid'; - $sql.= ' AND p.entity IN ('.getEntity('invoice').')'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'paiement as p'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; + $sql .= ' WHERE pf.fk_facture = '.$object->id; + $sql .= ' AND pf.fk_paiement = p.rowid'; + $sql .= ' AND p.entity IN ('.getEntity('invoice').')'; $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); $res = $db->fetch_object($resql); $total_paiements = $res->total_paiements; @@ -811,8 +811,8 @@ if (empty($reshook)) $total_creditnote_and_deposit = 0; $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; $sql .= " re.description, re.fk_facture_source"; - $sql .= " FROM " . MAIN_DB_PREFIX . "societe_remise_except as re"; - $sql .= " WHERE fk_facture = " . $object->id; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re"; + $sql .= " WHERE fk_facture = ".$object->id; $resql = $db->query($sql); if (!empty($resql)) { while ($obj = $db->fetch_object($resql)) { @@ -853,7 +853,7 @@ if (empty($reshook)) if (empty($error)) { - if($object->type != Facture::TYPE_DEPOSIT) { + if ($object->type != Facture::TYPE_DEPOSIT) { // Classe facture $result = $object->set_paid($user); if ($result >= 0) @@ -884,9 +884,9 @@ if (empty($reshook)) if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0) { $paiement = new Paiement($db); - $result=$paiement->fetch(GETPOST('paiement_id')); + $result = $paiement->fetch(GETPOST('paiement_id')); if ($result > 0) { - $result=$paiement->delete(); // If fetch ok and found + $result = $paiement->delete(); // If fetch ok and found header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); } if ($result < 0) { @@ -920,32 +920,32 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); } - if (! ($_POST['fac_replacement'] > 0)) { + if (!($_POST['fac_replacement'] > 0)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ReplaceInvoice")), null, 'errors'); } $date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']); - if (! $error) { + if (!$error) { // This is a replacement invoice $result = $object->fetch($_POST['fac_replacement']); $object->fetch_thirdparty(); - $object->date = $dateinvoice; - $object->date_pointoftax = $date_pointoftax; + $object->date = $dateinvoice; + $object->date_pointoftax = $date_pointoftax; $object->note_public = trim(GETPOST('note_public', 'none')); // We do not copy the private note $object->ref_client = $_POST['ref_client']; - $object->ref_int = $_POST['ref_int']; - $object->modelpdf = $_POST['model']; + $object->ref_int = $_POST['ref_int']; + $object->modelpdf = $_POST['model']; $object->fk_project = $_POST['projectid']; $object->cond_reglement_id = $_POST['cond_reglement_id']; $object->mode_reglement_id = $_POST['mode_reglement_id']; - $object->fk_account = GETPOST('fk_account', 'int'); + $object->fk_account = GETPOST('fk_account', 'int'); $object->remise_absolue = $_POST['remise_absolue']; $object->remise_percent = $_POST['remise_percent']; - $object->fk_incoterms = GETPOST('incoterm_id', 'int'); + $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); @@ -965,7 +965,7 @@ if (empty($reshook)) if ($_POST['type'] == Facture::TYPE_CREDIT_NOTE) { $sourceinvoice = GETPOST('fac_avoir'); - if (! ($sourceinvoice > 0) && empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) + if (!($sourceinvoice > 0) && empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CorrectInvoice")), null, 'errors'); @@ -980,27 +980,27 @@ if (empty($reshook)) $date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']); - if (! $error) + if (!$error) { if (!empty($originentity)) { $object->entity = $originentity; } - $object->socid = GETPOST('socid', 'int'); - $object->number = $_POST['ref']; - $object->date = $dateinvoice; - $object->date_pointoftax = $date_pointoftax; + $object->socid = GETPOST('socid', 'int'); + $object->number = $_POST['ref']; + $object->date = $dateinvoice; + $object->date_pointoftax = $date_pointoftax; $object->note_public = trim(GETPOST('note_public', 'none')); // We do not copy the private note $object->ref_client = $_POST['ref_client']; - $object->ref_int = $_POST['ref_int']; - $object->modelpdf = $_POST['model']; + $object->ref_int = $_POST['ref_int']; + $object->modelpdf = $_POST['model']; $object->fk_project = $_POST['projectid']; $object->cond_reglement_id = 0; $object->mode_reglement_id = $_POST['mode_reglement_id']; - $object->fk_account = GETPOST('fk_account', 'int'); + $object->fk_account = GETPOST('fk_account', 'int'); $object->remise_absolue = $_POST['remise_absolue']; $object->remise_percent = $_POST['remise_percent']; - $object->fk_incoterms = GETPOST('incoterm_id', 'int'); + $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); @@ -1010,24 +1010,24 @@ if (empty($reshook)) $object->type = Facture::TYPE_CREDIT_NOTE; $facture_source = new Facture($db); // fetch origin object - if ($facture_source->fetch($object->fk_facture_source)>0) + if ($facture_source->fetch($object->fk_facture_source) > 0) { if ($facture_source->type == Facture::TYPE_SITUATION) { - $object->situation_counter = $facture_source->situation_counter; + $object->situation_counter = $facture_source->situation_counter; $object->situation_cycle_ref = $facture_source->situation_cycle_ref; $facture_source->fetchPreviousNextSituationInvoice(); } } $id = $object->create($user); - if (GETPOST('invoiceAvoirWithLines', 'int')==1 && $id>0) + if (GETPOST('invoiceAvoirWithLines', 'int') == 1 && $id > 0) { if (!empty($facture_source->lines)) { $fk_parent_line = 0; - foreach($facture_source->lines as $line) + foreach ($facture_source->lines as $line) { // Extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($line, 'fetch_optionals')) { @@ -1043,21 +1043,21 @@ if (empty($reshook)) - if($facture_source->type == Facture::TYPE_SITUATION) + if ($facture_source->type == Facture::TYPE_SITUATION) { $source_fk_prev_id = $line->fk_prev_id; // temporary storing situation invoice fk_prev_id $line->fk_prev_id = $line->id; // Credit note line need to be linked to the situation invoice it is create from - if(!empty($facture_source->tab_previous_situation_invoice)) + if (!empty($facture_source->tab_previous_situation_invoice)) { // search the last invoice in cycle $lineIndex = count($facture_source->tab_previous_situation_invoice) - 1; $searchPreviousInvoice = true; - while( $searchPreviousInvoice ) + while ($searchPreviousInvoice) { - if($facture_source->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) + if ($facture_source->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) { - $searchPreviousInvoice=false; // find, exit; + $searchPreviousInvoice = false; // find, exit; break; } else @@ -1068,9 +1068,9 @@ if (empty($reshook)) $maxPrevSituationPercent = 0; - foreach($facture_source->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) + foreach ($facture_source->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) { - if($prevLine->id == $source_fk_prev_id) + if ($prevLine->id == $source_fk_prev_id) { $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent); @@ -1081,8 +1081,8 @@ if (empty($reshook)) $line->total_localtax1 = $line->total_localtax1 - $prevLine->total_localtax1; $line->total_localtax2 = $line->total_localtax2 - $prevLine->total_localtax2; - $line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice; - $line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht; + $line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice; + $line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht; $line->multicurrency_total_tva = $line->multicurrency_total_tva - $prevLine->multicurrency_total_tva; $line->multicurrency_total_ttc = $line->multicurrency_total_ttc - $prevLine->multicurrency_total_ttc; } @@ -1097,7 +1097,7 @@ if (empty($reshook)) $line->fk_parent_line = $fk_parent_line; $line->subprice = -$line->subprice; // invert price for object - $line->pa_ht = $line->pa_ht; // we choosed to have buy/cost price always positive, so no revert of sign here + $line->pa_ht = $line->pa_ht; // we choosed to have buy/cost price always positive, so no revert of sign here $line->total_ht = -$line->total_ht; $line->total_tva = -$line->total_tva; $line->total_ttc = -$line->total_ttc; @@ -1109,7 +1109,7 @@ if (empty($reshook)) $line->multicurrency_total_tva = -$line->multicurrency_total_tva; $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc; - $result = $line->insert(0, 1); // When creating credit note with same lines than source, we must ignore error if discount alreayd linked + $result = $line->insert(0, 1); // When creating credit note with same lines than source, we must ignore error if discount alreayd linked $object->lines[] = $line; // insert new line in current object @@ -1123,9 +1123,9 @@ if (empty($reshook)) } } - if(GETPOST('invoiceAvoirWithPaymentRestAmount', 'int')==1 && $id>0) + if (GETPOST('invoiceAvoirWithPaymentRestAmount', 'int') == 1 && $id > 0) { - if ($facture_source->fetch($object->fk_facture_source)>0) + if ($facture_source->fetch($object->fk_facture_source) > 0) { $totalpaye = $facture_source->getSommePaiement(); $totalcreditnotes = $facture_source->getSumCreditNotesUsed(); @@ -1137,12 +1137,12 @@ if (empty($reshook)) } // Add link between credit note and origin - if(! empty($object->fk_facture_source)) { + if (!empty($object->fk_facture_source)) { $facture_source->fetch($object->fk_facture_source); $facture_source->fetchObjectLinked(); - if(! empty($facture_source->linkedObjectsIds)) { - foreach($facture_source->linkedObjectsIds as $sourcetype => $TIds) { + if (!empty($facture_source->linkedObjectsIds)) { + foreach ($facture_source->linkedObjectsIds as $sourcetype => $TIds) { $object->add_object_linked($sourcetype, current($TIds)); } } @@ -1162,26 +1162,26 @@ if (empty($reshook)) $date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']); - if (! $error) + if (!$error) { - $object->socid = GETPOST('socid', 'int'); + $object->socid = GETPOST('socid', 'int'); $object->type = $_POST['type']; $object->number = $_POST['ref']; $object->date = $dateinvoice; $object->date_pointoftax = $date_pointoftax; - $object->note_public = trim(GETPOST('note_public', 'none')); + $object->note_public = trim(GETPOST('note_public', 'none')); $object->note_private = trim(GETPOST('note_private', 'none')); $object->ref_client = $_POST['ref_client']; - $object->ref_int = $_POST['ref_int']; + $object->ref_int = $_POST['ref_int']; $object->modelpdf = $_POST['model']; - $object->fk_project = $_POST['projectid']; - $object->cond_reglement_id = ($_POST['type'] == 3?1:$_POST['cond_reglement_id']); + $object->fk_project = $_POST['projectid']; + $object->cond_reglement_id = ($_POST['type'] == 3 ? 1 : $_POST['cond_reglement_id']); $object->mode_reglement_id = $_POST['mode_reglement_id']; - $object->fk_account = GETPOST('fk_account', 'int'); - $object->amount = $_POST['amount']; + $object->fk_account = GETPOST('fk_account', 'int'); + $object->amount = $_POST['amount']; $object->remise_absolue = $_POST['remise_absolue']; $object->remise_percent = $_POST['remise_percent']; - $object->fk_incoterms = GETPOST('incoterm_id', 'int'); + $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); @@ -1189,7 +1189,7 @@ if (empty($reshook)) // Source facture $object->fac_rec = GETPOST('fac_rec', 'int'); - $id = $object->create($user); // This include recopy of links from recurring invoice and recurring invoice lines + $id = $object->create($user); // This include recopy of links from recurring invoice and recurring invoice lines } } @@ -1211,27 +1211,27 @@ if (empty($reshook)) $date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']); - if (! $error) + if (!$error) { // Si facture standard - $object->socid = GETPOST('socid', 'int'); + $object->socid = GETPOST('socid', 'int'); $object->type = GETPOST('type'); - $object->number = $_POST['ref']; + $object->number = $_POST['ref']; $object->date = $dateinvoice; - $object->date_pointoftax = $date_pointoftax; + $object->date_pointoftax = $date_pointoftax; $object->note_public = trim(GETPOST('note_public', 'none')); - $object->note_private = trim(GETPOST('note_private', 'none')); + $object->note_private = trim(GETPOST('note_private', 'none')); $object->ref_client = $_POST['ref_client']; - $object->ref_int = $_POST['ref_int']; - $object->modelpdf = $_POST['model']; + $object->ref_int = $_POST['ref_int']; + $object->modelpdf = $_POST['model']; $object->fk_project = $_POST['projectid']; - $object->cond_reglement_id = ($_POST['type'] == 3?1:$_POST['cond_reglement_id']); + $object->cond_reglement_id = ($_POST['type'] == 3 ? 1 : $_POST['cond_reglement_id']); $object->mode_reglement_id = $_POST['mode_reglement_id']; - $object->fk_account = GETPOST('fk_account', 'int'); - $object->amount = $_POST['amount']; + $object->fk_account = GETPOST('fk_account', 'int'); + $object->amount = $_POST['amount']; $object->remise_absolue = $_POST['remise_absolue']; $object->remise_percent = $_POST['remise_percent']; - $object->fk_incoterms = GETPOST('incoterm_id', 'int'); + $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); @@ -1243,11 +1243,11 @@ if (empty($reshook)) $object->situation_cycle_ref = $object->newCycle(); - $object->retained_warranty = GETPOST('retained_warranty', 'int'); - $object->retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); + $object->retained_warranty = GETPOST('retained_warranty', 'int'); + $object->retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); $retained_warranty_date_limit = GETPOST('retained_warranty_date_limit'); - if(!empty($retained_warranty_date_limit) && $db->jdate($retained_warranty_date_limit)){ + if (!empty($retained_warranty_date_limit) && $db->jdate($retained_warranty_date_limit)) { $object->retained_warranty_date_limit = $db->jdate($retained_warranty_date_limit); } $object->retained_warranty_date_limit = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement); @@ -1256,7 +1256,7 @@ if (empty($reshook)) $object->fetch_thirdparty(); // 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; @@ -1291,32 +1291,32 @@ if (empty($reshook)) // link with order if it is a shipping invoice if ($object->origin == 'shipping') { - 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($object->origin_id); $exp->fetchObjectLinked(); if (is_array($exp->linkedObjectsIds['commande']) && count($exp->linkedObjectsIds['commande']) > 0) { - foreach ($exp->linkedObjectsIds['commande'] as $key => $value){ + foreach ($exp->linkedObjectsIds['commande'] as $key => $value) { $object->linked_objects['commande'] = $value; } } } - 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); // This include class to add_object_linked() and add add_contact() + $id = $object->create($user); // This include class to add_object_linked() and add add_contact() 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 or deposit lines"); + dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines or deposit lines"); $result = $srcobject->fetch($object->origin_id); // If deposit invoice @@ -1334,8 +1334,8 @@ if (empty($reshook)) $TTotalByTva = array(); foreach ($srcobject->lines as &$line) { - if(! empty($line->special_code)) continue; - $TTotalByTva[$line->tva_tx] += $line->total_ttc ; + if (!empty($line->special_code)) continue; + $TTotalByTva[$line->tva_tx] += $line->total_ttc; } foreach ($TTotalByTva as $tva => &$total) @@ -1358,20 +1358,20 @@ if (empty($reshook)) { $totalamount = 0; $lines = $srcobject->lines; - $numlines=count($lines); - for ($i=0; $i<$numlines; $i++) + $numlines = count($lines); + for ($i = 0; $i < $numlines; $i++) { - $qualified=1; - if (empty($lines[$i]->qty)) $qualified=0; // We discard qty=0, it is an option - if (! empty($lines[$i]->special_code)) $qualified=0; // We discard special_code (frais port, ecotaxe, option, ...) - if ($qualified){ + $qualified = 1; + if (empty($lines[$i]->qty)) $qualified = 0; // We discard qty=0, it is an option + if (!empty($lines[$i]->special_code)) $qualified = 0; // We discard special_code (frais port, ecotaxe, option, ...) + if ($qualified) { $totalamount += $lines[$i]->total_ht; // Fixme : is it not for the customer ? Shouldn't we take total_ttc ? $tva_tx = $lines[$i]->tva_tx; $amountdeposit[$tva_tx] += ($lines[$i]->total_ht * $valuedeposit) / 100; } } - if($totalamount == 0) { + if ($totalamount == 0) { $amountdeposit[0] = 0; } } else { @@ -1386,33 +1386,33 @@ if (empty($reshook)) { if (empty($amount)) continue; - $arraylist = array('amount' => 'FixAmount','variable' => 'VarAmount'); + $arraylist = array('amount' => 'FixAmount', 'variable' => 'VarAmount'); $descline = $langs->trans('Deposit'); //$descline.= ' - '.$langs->trans($arraylist[$typeamount]); - if ($typeamount=='amount') { - $descline.= ' ('. price($valuedeposit, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).')'; - } elseif ($typeamount=='variable') { - $descline.= ' ('. $valuedeposit.'%)'; + if ($typeamount == 'amount') { + $descline .= ' ('.price($valuedeposit, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).')'; + } elseif ($typeamount == 'variable') { + $descline .= ' ('.$valuedeposit.'%)'; } - $descline.= ' - '.$srcobject->ref; + $descline .= ' - '.$srcobject->ref; $result = $object->addline( $descline, - $amount, // subprice - 1, // quantity - $tva, // vat rate - 0, // localtax1_tx - 0, // localtax2_tx - (empty($conf->global->INVOICE_PRODUCTID_DEPOSIT)?0:$conf->global->INVOICE_PRODUCTID_DEPOSIT), // fk_product - 0, // remise_percent - 0, // date_start - 0, // date_end + $amount, // subprice + 1, // quantity + $tva, // vat rate + 0, // localtax1_tx + 0, // localtax2_tx + (empty($conf->global->INVOICE_PRODUCTID_DEPOSIT) ? 0 : $conf->global->INVOICE_PRODUCTID_DEPOSIT), // fk_product + 0, // remise_percent + 0, // date_start + 0, // date_end 0, - $lines[$i]->info_bits, // info_bits + $lines[$i]->info_bits, // info_bits 0, 'HT', 0, - 0, // product_type + 0, // product_type 1, $lines[$i]->special_code, $object->origin, @@ -1444,19 +1444,19 @@ 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++) { // Don't add lines with qty 0 when coming from a shipment including all order lines - if($srcobject->element == 'shipping' && $conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS && $lines[$i]->qty == 0) continue; + if ($srcobject->element == 'shipping' && $conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS && $lines[$i]->qty == 0) continue; // Don't add closed lines when coming from a contract (Set constant to '0,5' to exclude also inactive lines) - if (! isset($conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE)) $conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE = '5'; + if (!isset($conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE)) $conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE = '5'; if ($srcobject->element == 'contrat' && in_array($lines[$i]->statut, explode(',', $conf->global->CONTRACT_EXCLUDE_SERVICES_STATUS_FOR_INVOICE))) continue; - $label=(! empty($lines[$i]->label)?$lines[$i]->label:''); - $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle); - if ($object->situation_counter == 1) $lines[$i]->situation_percent = 0; + $label = (!empty($lines[$i]->label) ? $lines[$i]->label : ''); + $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc : $lines[$i]->libelle); + if ($object->situation_counter == 1) $lines[$i]->situation_percent = 0; if ($lines[$i]->subprice < 0 && empty($conf->global->INVOICE_KEEP_DISCOUNT_LINES_AS_IN_ORIGIN)) { @@ -1511,7 +1511,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.')'; // View third's localtaxes for NOW and do not use value from origin. // TODO Is this really what we want ? Yes if source if template invoice but what if proposal or order ? @@ -1590,13 +1590,13 @@ if (empty($reshook)) { // If some invoice's lines coming from page $id = $object->create($user); - for ($i = 1; $i <= $NBLINES; $i ++) { - if ($_POST['idprod' . $i]) { + for ($i = 1; $i <= $NBLINES; $i++) { + if ($_POST['idprod'.$i]) { $product = new Product($db); - $product->fetch($_POST['idprod' . $i]); - $startday = dol_mktime(12, 0, 0, $_POST['date_start' . $i . 'month'], $_POST['date_start' . $i . 'day'], $_POST['date_start' . $i . 'year']); - $endday = dol_mktime(12, 0, 0, $_POST['date_end' . $i . 'month'], $_POST['date_end' . $i . 'day'], $_POST['date_end' . $i . 'year']); - $result = $object->addline($product->description, $product->price, $_POST['qty' . $i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod' . $i], $_POST['remise_percent' . $i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type, -1, 0, '', 0, 0, null, 0, '', 0, 100, '', $product->fk_unit); + $product->fetch($_POST['idprod'.$i]); + $startday = dol_mktime(12, 0, 0, $_POST['date_start'.$i.'month'], $_POST['date_start'.$i.'day'], $_POST['date_start'.$i.'year']); + $endday = dol_mktime(12, 0, 0, $_POST['date_end'.$i.'month'], $_POST['date_end'.$i.'day'], $_POST['date_end'.$i.'year']); + $result = $object->addline($product->description, $product->price, $_POST['qty'.$i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod'.$i], $_POST['remise_percent'.$i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type, -1, 0, '', 0, 0, null, 0, '', 0, 100, '', $product->fk_unit); } } } @@ -1637,13 +1637,13 @@ if (empty($reshook)) $line->origin_id = $line->id; $line->fk_prev_id = $line->id; $line->fetch_optionals($line->id); - $line->situation_percent = $line->get_prev_progress($object->id); // get good progress including credit note + $line->situation_percent = $line->get_prev_progress($object->id); // get good progress including credit note // Si fk_remise_except defini on vérifie si la réduction à déjà été appliquée if ($line->fk_remise_except) { - $discount=new DiscountAbsolute($line->db); - $result=$discount->fetch($line->fk_remise_except); + $discount = new DiscountAbsolute($line->db); + $result = $discount->fetch($line->fk_remise_except); if ($result > 0) { // Check if discount not already affected to another invoice @@ -1694,7 +1694,7 @@ if (empty($reshook)) } // End of object creation, we show it - if ($id > 0 && ! $error) + if ($id > 0 && !$error) { $db->commit(); @@ -1705,19 +1705,19 @@ 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); $outputlangs->load('products'); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } - header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); + header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); exit(); } else @@ -1737,24 +1737,24 @@ if (empty($reshook)) $error = 0; // Set if we used free entry or predefined product - $predef=''; - $product_desc=(GETPOST('dp_desc', 'none')?GETPOST('dp_desc', 'none'):''); + $predef = ''; + $product_desc = (GETPOST('dp_desc', 'none') ?GETPOST('dp_desc', 'none') : ''); $price_ht = GETPOST('price_ht'); $price_ht_devise = GETPOST('multicurrency_price_ht'); $prod_entry_mode = GETPOST('prod_entry_mode', 'alpha'); if ($prod_entry_mode == 'free') { - $idprod=0; + $idprod = 0; $tva_tx = (GETPOST('tva_tx', 'alpha') ? GETPOST('tva_tx', 'alpha') : 0); } else { - $idprod=GETPOST('idprod', 'int'); + $idprod = GETPOST('idprod', 'int'); $tva_tx = ''; } - $qty = GETPOST('qty' . $predef); - $remise_percent = GETPOST('remise_percent' . $predef); + $qty = GETPOST('qty'.$predef); + $remise_percent = GETPOST('remise_percent'.$predef); // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -1763,7 +1763,7 @@ if (empty($reshook)) if (is_array($extralabelsline)) { // Get extra fields foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key . $predef]); + unset($_POST["options_".$key.$predef]); } } @@ -1773,7 +1773,7 @@ if (empty($reshook)) } if (!$prod_entry_mode) { - if (GETPOST('type') < 0 && ! GETPOST('search_idprod')) + if (GETPOST('type') < 0 && !GETPOST('search_idprod')) { setEventMessages($langs->trans('ErrorChooseBetweenFreeEntryOrPredefinedProduct'), null, 'errors'); $error++; @@ -1827,7 +1827,7 @@ if (empty($reshook)) } } - if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { + if (!$error && ($qty >= 0) && (!empty($product_desc) || !empty($idprod))) { $ret = $object->fetch($id); if ($ret < 0) { dol_print_error($db, $object->error); @@ -1836,8 +1836,8 @@ if (empty($reshook)) $ret = $object->fetch_thirdparty(); // 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')); + $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'); // Define special_code for special lines @@ -1849,7 +1849,7 @@ if (empty($reshook)) // Ecrase $tva_tx par celui du produit // Ecrase $base_price_type par celui du produit // Replaces $fk_unit with the product's - if (! empty($idprod)) + if (!empty($idprod)) { $prod = new Product($db); $prod->fetch($idprod); @@ -1872,7 +1872,7 @@ if (empty($reshook)) $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); // if price ht was forced (ie: from gui when 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'); @@ -1894,56 +1894,56 @@ 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); $outputlangs->load('products'); } - $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); @@ -1956,17 +1956,17 @@ if (empty($reshook)) $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); $tva_tx = str_replace('*', '', $tva_tx); - if (empty($tva_tx)) $tva_npr=0; + if (empty($tva_tx)) $tva_npr = 0; $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 must 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 must keep this value // Local Taxes $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr); @@ -1976,7 +1976,7 @@ if (empty($reshook)) if ($tva_npr) $info_bits |= 0x01; - if ($usercanproductignorepricemin && (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) { + if ($usercanproductignorepricemin && (!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 { @@ -1992,12 +1992,12 @@ 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); $outputlangs->load('products'); } - $model=$object->modelpdf; + $model = $object->modelpdf; $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -2048,9 +2048,9 @@ if (empty($reshook)) } } - elseif ($action == 'updateline' && $usercancreate && ! GETPOST('cancel', 'alpha')) + elseif ($action == 'updateline' && $usercancreate && !GETPOST('cancel', 'alpha')) { - if (! $object->fetch($id) > 0) dol_print_error($db); + if (!$object->fetch($id) > 0) dol_print_error($db); $object->fetch_thirdparty(); // Clean parameters @@ -2075,7 +2075,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 $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -2084,22 +2084,22 @@ 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; $line = new FactureLigne($db); $line->fetch(GETPOST('lineid')); $percent = $line->get_prev_progress($object->id); - if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->situation_cycle_ref>0) + if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->situation_cycle_ref > 0) { // in case of situation credit note - if(GETPOST('progress') >= 0 ) + if (GETPOST('progress') >= 0) { $mesg = $langs->trans("CantBeNullOrPositive"); setEventMessages($mesg, null, 'warnings'); @@ -2116,7 +2116,7 @@ if (empty($reshook)) } elseif (GETPOST('progress') < $percent) { - $mesg = '
' . $langs->trans("CantBeLessThanMinPercent") . '
'; + $mesg = '
'.$langs->trans("CantBeLessThanMinPercent").'
'; setEventMessages($mesg, null, 'warnings'); $error++; $result = -1; @@ -2124,7 +2124,7 @@ if (empty($reshook)) // Check minimum price $productid = GETPOST('productid', 'int'); - if (! empty($productid)) + if (!empty($productid)) { $product = new Product($db); $product->fetch($productid); @@ -2132,7 +2132,7 @@ if (empty($reshook)) $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') : ''); @@ -2174,7 +2174,7 @@ if (empty($reshook)) // Update line - if (! $error) { + if (!$error) { if (empty($usercancreatemargin)) { foreach ($object->lines as &$line) @@ -2202,7 +2202,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); $outputlangs->load('products'); @@ -2263,7 +2263,7 @@ if (empty($reshook)) { $percent = $line->get_prev_progress($object->id); if (floatval($all_progress) < floatval($percent)) { - $mesg = $langs->trans("Line") . ' ' . $i . ' '. $line->ref .' : ' . $langs->trans("CantBeLessThanMinPercent"); + $mesg = $langs->trans("Line").' '.$i.' '.$line->ref.' : '.$langs->trans("CantBeLessThanMinPercent"); setEventMessages($mesg, null, 'warnings'); $result = -1; } else @@ -2273,7 +2273,7 @@ if (empty($reshook)) } elseif ($action == 'updateline' && $usercancreate && $_POST['cancel'] == $langs->trans('Cancel')) { - header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); // Pour reaffichage de la fiche en cours d'edition + header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); // Pour reaffichage de la fiche en cours d'edition exit(); } @@ -2292,7 +2292,7 @@ if (empty($reshook)) { $outingError = 0; $newCycle = $object->newCycle(); // we need to keep the "situation behavior" so we place it on a new situation cycle - if($newCycle > 1) + if ($newCycle > 1) { // Search credit notes $lastCycle = $object->situation_cycle_ref; @@ -2301,12 +2301,12 @@ if (empty($reshook)) if (count($object->tab_next_situation_invoice) > 0) { foreach ($object->tab_next_situation_invoice as $next_invoice) { - if($next_invoice->type == Facture::TYPE_CREDIT_NOTE + if ($next_invoice->type == Facture::TYPE_CREDIT_NOTE && $next_invoice->situation_counter == $object->situation_counter && $next_invoice->fk_facture_source == $object->id ) { - $linkedCreditNotesList[] = $next_invoice->id ; + $linkedCreditNotesList[] = $next_invoice->id; } } } @@ -2314,38 +2314,38 @@ if (empty($reshook)) $object->situation_cycle_ref = $newCycle; $object->situation_counter = 1; $object->situation_final = 0; - if($object->update($user) > 0) + if ($object->update($user) > 0) { $errors = 0; - if(count($linkedCreditNotesList) > 0) + if (count($linkedCreditNotesList) > 0) { // now, credit note must follow $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture '; - $sql.= ' SET situation_cycle_ref='.$newCycle; - $sql.= ' , situation_final=0'; - $sql.= ' , situation_counter='.$object->situation_counter; - $sql.= ' WHERE rowid IN ('.implode(',', $linkedCreditNotesList).')'; + $sql .= ' SET situation_cycle_ref='.$newCycle; + $sql .= ' , situation_final=0'; + $sql .= ' , situation_counter='.$object->situation_counter; + $sql .= ' WHERE rowid IN ('.implode(',', $linkedCreditNotesList).')'; - $resql=$db->query($sql); + $resql = $db->query($sql); if (!$resql) $errors++; // Change each progression persent on each lines - foreach($object->lines as $line) + foreach ($object->lines as $line) { // no traitement for special product - if ($line->product_type == 9 ) continue; + if ($line->product_type == 9) continue; - if(!empty($object->tab_previous_situation_invoice)) + if (!empty($object->tab_previous_situation_invoice)) { // search the last invoice in cycle $lineIndex = count($object->tab_previous_situation_invoice) - 1; $searchPreviousInvoice = true; - while( $searchPreviousInvoice ) + while ($searchPreviousInvoice) { - if($object->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) + if ($object->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1) { - $searchPreviousInvoice=false; // find, exit; + $searchPreviousInvoice = false; // find, exit; break; } else @@ -2356,9 +2356,9 @@ if (empty($reshook)) $maxPrevSituationPercent = 0; - foreach($object->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) + foreach ($object->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine) { - if($prevLine->id == $line->fk_prev_id) + if ($prevLine->id == $line->fk_prev_id) { $maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent); } @@ -2367,7 +2367,7 @@ if (empty($reshook)) $line->situation_percent = $line->situation_percent - $maxPrevSituationPercent; - if($line->update()<0) $errors++; + if ($line->update() < 0) $errors++; } } } @@ -2395,7 +2395,7 @@ if (empty($reshook)) } // add lines from objectlinked - elseif($action == 'import_lines_from_object' + elseif ($action == 'import_lines_from_object' && $usercancreate && $object->statut == Facture::STATUS_DRAFT && ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION)) @@ -2404,14 +2404,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'; @@ -2419,11 +2419,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; @@ -2439,15 +2439,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; @@ -2458,18 +2458,18 @@ if (empty($reshook)) $res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $ventil, $info_bits, $fk_remise_except, $price_base_type, $pu_ttc, $type, $rang, $special_code, $origin, $origin_id, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $array_options, $situation_percent, $fk_prev_id, $fk_unit, $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'); } @@ -2480,16 +2480,16 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - if (empty($id)) $id=$facid; - $trigger_name='BILL_SENTBYMAIL'; - $paramname='id'; - $autocopy='MAIN_MAIL_AUTOCOPY_INVOICE_TO'; - $trackid='inv'.$object->id; + if (empty($id)) $id = $facid; + $trigger_name = 'BILL_SENTBYMAIL'; + $paramname = 'id'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_INVOICE_TO'; + $trackid = 'inv'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; // Actions to build doc $upload_dir = $conf->facture->multidir_output[$object->entity]; - $permissiontoadd=$usercancreate; + $permissiontoadd = $usercancreate; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; @@ -2500,7 +2500,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('BILL_MODIFY'); @@ -2515,7 +2515,7 @@ if (empty($reshook)) $action = 'edit_extras'; } - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate) { + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate) { if ($action == 'addcontact') { $result = $object->fetch($id); @@ -2570,13 +2570,13 @@ $formother = new FormOther($db); $formfile = new FormFile($db); $formmargin = new FormMargin($db); $soc = new Societe($db); -$paymentstatic=new Paiement($db); +$paymentstatic = new Paiement($db); $bankaccountstatic = new Account($db); -if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } $now = dol_now(); -$title = $langs->trans('InvoiceCustomer') . " - " . $langs->trans('Card'); +$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Card'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); @@ -2596,7 +2596,7 @@ if ($action == 'create') // Load objectsrc $remise_absolue = 0; - if (! empty($origin) && ! empty($originid)) + if (!empty($origin) && !empty($originid)) { // Parse element/subelement (ex: project_task) $element = $subelement = $origin; @@ -2620,7 +2620,7 @@ if ($action == 'create') } if (!$dateinvoice) { // Do not set 0 here (0 for a date is 1970) - $dateinvoice = (empty($dateinvoice)?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$dateinvoice); + $dateinvoice = (empty($dateinvoice) ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $dateinvoice); } } else { // For compatibility @@ -2638,7 +2638,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); @@ -2647,18 +2647,18 @@ if ($action == 'create') $objectsrc->fetch_lines(); $objectsrc->fetch_thirdparty(); - $projectid = (! empty($projectid) ? $projectid : $objectsrc->fk_project); - $ref_client = (! empty($objectsrc->ref_client) ? $objectsrc->ref_client : (! empty($objectsrc->ref_customer) ? $objectsrc->ref_customer:'')); - $ref_int = (! empty($objectsrc->ref_int) ? $objectsrc->ref_int : ''); + $projectid = (!empty($projectid) ? $projectid : $objectsrc->fk_project); + $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client : (!empty($objectsrc->ref_customer) ? $objectsrc->ref_customer : '')); + $ref_int = (!empty($objectsrc->ref_int) ? $objectsrc->ref_int : ''); // only if socid not filled else it's allready done upper if (empty($socid)) $soc = $objectsrc->thirdparty; - $dateinvoice = (empty($dateinvoice)?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$dateinvoice); + $dateinvoice = (empty($dateinvoice) ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $dateinvoice); if ($element == 'expedition') { - $ref_client = (! empty($objectsrc->ref_customer)?$objectsrc->ref_customer:''); + $ref_client = (!empty($objectsrc->ref_customer) ? $objectsrc->ref_customer : ''); $elem = $subelem = $objectsrc->origin; $expeoriginid = $objectsrc->origin_id; @@ -2668,23 +2668,23 @@ if ($action == 'create') $expesrc = new $classname($db); $expesrc->fetch($expeoriginid); - $cond_reglement_id = (! empty($expesrc->cond_reglement_id)?$expesrc->cond_reglement_id:(! empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1)); - $mode_reglement_id = (! empty($expesrc->mode_reglement_id)?$expesrc->mode_reglement_id:(! empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); - $fk_account = (! empty($expesrc->fk_account)?$expesrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0)); - $remise_percent = (! empty($expesrc->remise_percent)?$expesrc->remise_percent:(! empty($soc->remise_percent)?$soc->remise_percent:0)); - $remise_absolue = (! empty($expesrc->remise_absolue)?$expesrc->remise_absolue:(! empty($soc->remise_absolue)?$soc->remise_absolue:0)); + $cond_reglement_id = (!empty($expesrc->cond_reglement_id) ? $expesrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 1)); + $mode_reglement_id = (!empty($expesrc->mode_reglement_id) ? $expesrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0)); + $fk_account = (!empty($expesrc->fk_account) ? $expesrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0)); + $remise_percent = (!empty($expesrc->remise_percent) ? $expesrc->remise_percent : (!empty($soc->remise_percent) ? $soc->remise_percent : 0)); + $remise_absolue = (!empty($expesrc->remise_absolue) ? $expesrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); //Replicate extrafields $expesrc->fetch_optionals($expeoriginid); - $object->array_options=$expesrc->array_options; + $object->array_options = $expesrc->array_options; } else { - $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)); - $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)); + $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)); + $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)); if (!empty($conf->multicurrency->enabled)) { @@ -2705,18 +2705,18 @@ if ($action == 'create') $fk_account = $soc->fk_account; $remise_percent = $soc->remise_percent; $remise_absolue = 0; - $dateinvoice = (empty($dateinvoice)?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$dateinvoice); // Do not set 0 here (0 for a date is 1970) + $dateinvoice = (empty($dateinvoice) ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $dateinvoice); // Do not set 0 here (0 for a date is 1970) if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code; } if (!empty($soc->id)) $absolute_discount = $soc->getAvailableDiscounts(); - $note_public = $object->getDefaultCreateValueFor('note_public', ((! empty($origin) && ! empty($originid) && is_object($objectsrc) && !empty($conf->global->FACTURE_REUSE_NOTES_ON_CREATE_FROM))?$objectsrc->note_public:null)); - $note_private = $object->getDefaultCreateValueFor('note_private', ((! empty($origin) && ! empty($originid) && is_object($objectsrc) && !empty($conf->global->FACTURE_REUSE_NOTES_ON_CREATE_FROM))?$objectsrc->note_private:null)); + $note_public = $object->getDefaultCreateValueFor('note_public', ((!empty($origin) && !empty($originid) && is_object($objectsrc) && !empty($conf->global->FACTURE_REUSE_NOTES_ON_CREATE_FROM)) ? $objectsrc->note_public : null)); + $note_private = $object->getDefaultCreateValueFor('note_private', ((!empty($origin) && !empty($originid) && is_object($objectsrc) && !empty($conf->global->FACTURE_REUSE_NOTES_ON_CREATE_FROM)) ? $objectsrc->note_private : null)); - if (! empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; print ajax_combobox('fac_replacement'); print ajax_combobox('fac_avoir'); print ajax_combobox('situations'); @@ -2725,35 +2725,35 @@ if ($action == 'create') if ($origin == 'contrat') { $langs->load("admin"); - $text=$langs->trans("ToCreateARecurringInvoice"); - $text.=' '.$langs->trans("ToCreateARecurringInvoiceGene", $langs->transnoentitiesnoconv("MenuFinancial"), $langs->transnoentitiesnoconv("BillsCustomers"), $langs->transnoentitiesnoconv("ListOfTemplates")); + $text = $langs->trans("ToCreateARecurringInvoice"); + $text .= ' '.$langs->trans("ToCreateARecurringInvoiceGene", $langs->transnoentitiesnoconv("MenuFinancial"), $langs->transnoentitiesnoconv("BillsCustomers"), $langs->transnoentitiesnoconv("ListOfTemplates")); if (empty($conf->global->INVOICE_DISABLE_AUTOMATIC_RECURRING_INVOICE)) { - $text.=' '.$langs->trans("ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv('Module2300Name')); + $text .= ' '.$langs->trans("ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv('Module2300Name')); } print info_admin($text, 0, 0, 0).'
'; } - print ''; - print ''; + print ''; + print ''; print ''; - if ($soc->id > 0) print '' . "\n"; + if ($soc->id > 0) print ''."\n"; print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if (!empty($currency_tx)) print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if (!empty($currency_tx)) print ''; dol_fiche_head(''); print '
'; // Ref - print ''; + print ''; - $exampletemplateinvoice=new FactureRec($db); + $exampletemplateinvoice = new FactureRec($db); $invoice_predefined = new FactureRec($db); if (empty($origin) && empty($originid) && GETPOST('fac_rec', 'int') > 0) { @@ -2761,30 +2761,30 @@ if ($action == 'create') } // Thirdparty - if ($soc->id > 0 && (! GETPOST('fac_rec', 'int') || ! empty($invoice_predefined->frequency))) + if ($soc->id > 0 && (!GETPOST('fac_rec', 'int') || !empty($invoice_predefined->frequency))) { // If thirdparty known and not a predefined invoiced without a recurring rule - print ''; + print ''; print ''; - print '' . "\n"; + print ''."\n"; } else { - print ''; + print ''; print ''; - print '' . "\n"; + print ''."\n"; } // Overwrite some values if creation of invoice is from a predefined invoice @@ -2811,7 +2811,7 @@ if ($action == 'create') { $invoice_predefined->fetch(GETPOST('fac_rec', 'int')); - $dateinvoice = $invoice_predefined->date_when; // To use next gen date by default later + $dateinvoice = $invoice_predefined->date_when; // To use next gen date by default later if (empty($projectid)) $projectid = $invoice_predefined->fk_project; $cond_reglement_id = $invoice_predefined->cond_reglement_id; $mode_reglement_id = $invoice_predefined->mode_reglement_id; @@ -2819,12 +2819,12 @@ if ($action == 'create') $note_public = $invoice_predefined->note_public; $note_private = $invoice_predefined->note_private; - if (! empty($invoice_predefined->multicurrency_code)) $currency_code = $invoice_predefined->multicurrency_code; - if (! empty($invoice_predefined->multicurrency_tx)) $currency_tx = $invoice_predefined->multicurrency_tx; + if (!empty($invoice_predefined->multicurrency_code)) $currency_code = $invoice_predefined->multicurrency_code; + if (!empty($invoice_predefined->multicurrency_tx)) $currency_tx = $invoice_predefined->multicurrency_tx; $sql = 'SELECT r.rowid, r.titre as title, r.total_ttc'; - $sql .= ' FROM ' . MAIN_DB_PREFIX . 'facture_rec as r'; - $sql .= ' WHERE r.fk_soc = ' . $invoice_predefined->socid; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_rec as r'; + $sql .= ' WHERE r.fk_soc = '.$invoice_predefined->socid; $resql = $db->query($sql); if ($resql) @@ -2834,21 +2834,21 @@ if ($action == 'create') if ($num > 0) { - print '
' . $langs->trans('Ref') . '' . $langs->trans('Draft') . '
'.$langs->trans('Ref').''.$langs->trans('Draft').'
' . $langs->trans('Customer') . '
'.$langs->trans('Customer').''; print $soc->getNomUrl(1); - print ''; + print ''; // Outstanding Bill $arrayoutstandingbills = $soc->getOutstandingBills(); $outstandingBills = $arrayoutstandingbills['opened']; - print ' (' . $langs->trans('CurrentOutstandingBill') . ': '; + print ' ('.$langs->trans('CurrentOutstandingBill').': '; print price($outstandingBills, '', $langs, 0, 0, -1, $conf->currency); if ($soc->outstanding_limit != '') { if ($outstandingBills > $soc->outstanding_limit) print img_warning($langs->trans("OutstandingBillReached")); - print ' / ' . price($soc->outstanding_limit, '', $langs, 0, 0, -1, $conf->currency); + print ' / '.price($soc->outstanding_limit, '', $langs, 0, 0, -1, $conf->currency); } print ')'; print '
' . $langs->trans('Customer') . '
'.$langs->trans('Customer').''; print $form->select_company($soc->id, 'socid', '((s.client = 1 OR s.client = 3) AND s.status=1)', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); // Option to reload page to retrieve customer informations. Note, this clear other input @@ -2801,9 +2801,9 @@ if ($action == 'create') }); '; } - if (! GETPOST('fac_rec', 'int')) print ' '.$langs->trans("AddThirdParty").''; + if (!GETPOST('fac_rec', 'int')) print ' '.$langs->trans("AddThirdParty").''; print '
' . $langs->trans('CreateFromRepeatableInvoice') . ''; + print '
'.$langs->trans('CreateFromRepeatableInvoice').''; //print ''; - print ''; // We may want to change the template to use print ''; while ($i < $num) { $objp = $db->fetch_object($resql); - print ''; - $i ++; + print '>'.$objp->title.' ('.price($objp->total_ttc).' '.$langs->trans("TTC").')'; + $i++; } print ''; // Option to reload page to retrieve customer informations. Note, this clear other input @@ -2874,25 +2874,25 @@ if ($action == 'create') } } - print '
' . $langs->trans('Type') . ''; + print '
'.$langs->trans('Type').''; - print '
' . "\n"; + print '
'."\n"; // Standard invoice print '
'; - $tmp=' '; + $tmp = ' '; $tmp = $tmp.''; $desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceStandardDesc"), 1, 'help', '', 0, 3); print $desc; print '
'; - if ((empty($origin)) || ((($origin == 'propal') || ($origin == 'commande')) && (! empty($originid)))) + if ((empty($origin)) || ((($origin == 'propal') || ($origin == 'commande')) && (!empty($originid)))) { // Deposit if (empty($conf->global->INVOICE_DISABLE_DEPOSIT)) { print '
'; - $tmp=' '; + $tmp = ' '; print ''; - $text = ''; + $text = ''; $text .= ''; $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceReplacementDesc"), 1, 'help', '', 0, 3); @@ -3003,29 +3003,29 @@ if ($action == 'create') } else { - if (! empty($conf->global->INVOICE_USE_SITUATION)) + if (!empty($conf->global->INVOICE_USE_SITUATION)) { print '
'; - $tmp=' '; - $text = ' '; - $text.= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; + $tmp = ' '; + $text = ' '; + $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3); print $desc; print '
'; print '
'; - $tmp=' '; - $text = ' '; - $text.= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; + $tmp = ' '; + $text = ' '; + $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3); print $desc; print '
'; } print '
'; - $tmp=' '; - $text = ' '; - $text.= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; + $tmp = ' '; + $text = ' '; + $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceReplacementDesc"), 1, 'help', '', 0, 3); print $desc; print '
'; @@ -3040,7 +3040,7 @@ if ($action == 'create') if (empty($conf->global->INVOICE_DISABLE_CREDIT_NOTE)) { // Show link for credit note - $facids=$facturestatic->list_qualified_avoir_invoices($soc->id); + $facids = $facturestatic->list_qualified_avoir_invoices($soc->id); if ($facids < 0) { dol_print_error($db, $facturestatic); @@ -3056,19 +3056,19 @@ if ($action == 'create') $newinvoice_static->type = $valarray ['type']; $newinvoice_static->paye = $valarray ['paye']; - $optionsav .= ''; } print '
'; - $tmp='global->INVOICE_CREDIT_NOTE_STANDALONE)) || $invoice_predefined->id > 0) $tmp.=' disabled'; - $tmp.= '> '; + $tmp = 'global->INVOICE_CREDIT_NOTE_STANDALONE)) || $invoice_predefined->id > 0) $tmp .= ' disabled'; + $tmp .= '> '; // Show credit note options only if we checked credit note print ''; - $text = ' '; + $text = ' '; // $text.=''; $text .= ''; $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3); print $desc; print '
'; - print '    0 ? 'checked':'').' /> "; - print '
    0 ? 'checked':'').' /> "; + print '    0 ? 'checked' : '').' /> "; + print '
    0 ? 'checked' : '').' /> "; print '
'; print '
'; @@ -3111,20 +3111,20 @@ if ($action == 'create') else { print '
'; - if (empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) $tmp=' '; - else $tmp=' '; - $text = ' '; - $text.= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; + if (empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) $tmp = ' '; + else $tmp = ' '; + $text = ' '; + $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3); print $desc; - print '
' . "\n"; + print '
'."\n"; } } // Template invoice print '
'; - $tmp=' '; - $text = ' '; + $tmp = ' '; + $text = ' '; //$text.= '('.$langs->trans("YouMustCreateStandardInvoiceFirst").') '; $desc = $form->textwithpicto($text, $langs->transnoentities("YouMustCreateStandardInvoiceFirstDesc"), 1, 'help', '', 0, 3); print $desc; @@ -3133,16 +3133,16 @@ if ($action == 'create') print '
'; - if(!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) // Hidden conf + if (!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) // Hidden conf { // Add auto select default document model - $listtType=array(Facture::TYPE_STANDARD,Facture::TYPE_REPLACEMENT,Facture::TYPE_CREDIT_NOTE,Facture::TYPE_DEPOSIT,Facture::TYPE_SITUATION); - $jsListType=''; + $listtType = array(Facture::TYPE_STANDARD, Facture::TYPE_REPLACEMENT, Facture::TYPE_CREDIT_NOTE, Facture::TYPE_DEPOSIT, Facture::TYPE_SITUATION); + $jsListType = ''; foreach ($listtType as $type) { $thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type; - $curent = !empty($conf->global->{$thisTypeConfName})?$conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF; - $jsListType.=(!empty($jsListType)?',':'').'"'.$type.'":"'.$curent.'"'; + $curent = !empty($conf->global->{$thisTypeConfName}) ? $conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF; + $jsListType .= (!empty($jsListType) ? ',' : '').'"'.$type.'":"'.$curent.'"'; } print ' id . '" method="POST">'; - print ''; + print ''; + print ''; print ''; - print ''; + print ''; //dol_fiche_head('', '', '', -1); - if ((! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && ! empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) { - print $langs->trans('UseMultipriceRules'). ' price_autogen ? 'checked' : '').'>

'; + if ((!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) { + print $langs->trans('UseMultipriceRules').' price_autogen ? 'checked' : '').'>

'; } print ''; @@ -1346,48 +1346,48 @@ if ($action == 'edit_price' && $object->getRights()->creer) print ''; - for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { print ''; print ''; // VAT if (empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) { print ''; } else { // This option is kept for backward compatibility but has no sense print ''; } // Selling price print ''; // Min price print ''; } @@ -1403,9 +1403,9 @@ if ($action == 'edit_price' && $object->getRights()->creer) //dol_fiche_end(); print '
'; - print ''; + print ''; print '   '; - print '
'; + print ''; print ''; } } @@ -1413,17 +1413,17 @@ if ($action == 'edit_price' && $object->getRights()->creer) // List of price changes - log historic (ordered by descending date) -if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_price') && ! in_array($action, array('edit_price','edit_vat'))) +if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_default_price') && !in_array($action, array('edit_price', 'edit_vat'))) { $sql = "SELECT p.rowid, p.price, p.price_ttc, p.price_base_type, p.tva_tx, p.default_vat_code, p.recuperableonly, p.localtax1_tx, p.localtax1_type, p.localtax2_tx, p.localtax2_type,"; $sql .= " p.price_level, p.price_min, p.price_min_ttc,p.price_by_qty,"; $sql .= " p.date_price as dp, p.fk_price_expression, u.rowid as user_id, u.login"; - $sql .= " FROM " . MAIN_DB_PREFIX . "product_price as p,"; - $sql .= " " . MAIN_DB_PREFIX . "user as u"; - $sql .= " WHERE fk_product = " . $object->id; - $sql .= " AND p.entity IN (" . getEntity('productprice') . ")"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_price as p,"; + $sql .= " ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE fk_product = ".$object->id; + $sql .= " AND p.entity IN (".getEntity('productprice').")"; $sql .= " AND p.fk_user_author = u.rowid"; - if (! empty($socid) && ! empty($conf->global->PRODUIT_MULTIPRICES)) $sql .= " AND p.price_level = " . $soc->price_level; + if (!empty($socid) && !empty($conf->global->PRODUIT_MULTIPRICES)) $sql .= " AND p.price_level = ".$soc->price_level; $sql .= " ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC"; // $sql .= $db->plimit(); @@ -1434,15 +1434,15 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ $num = $db->num_rows($result); - if (! $num) + if (!$num) { $db->free($result); // Il doit au moins y avoir la ligne de prix initial. // On l'ajoute donc pour remettre a niveau (pb vieilles versions) //$object->updatePrice($object->price, $object->price_base_type, $user, $object->tva_tx, $object->price_min); - if (! empty($conf->global->PRODUIT_MULTIPRICES)) { - $object->updatePrice($object->multiprices[1], $object->multiprices_base_type[1], $user, (empty($object->multiprices_tva_tx[1])?0:$object->multiprices_tva_tx[1]), $object->multiprices_min[1], 1); + if (!empty($conf->global->PRODUIT_MULTIPRICES)) { + $object->updatePrice($object->multiprices[1], $object->multiprices_base_type[1], $user, (empty($object->multiprices_tva_tx[1]) ? 0 : $object->multiprices_tva_tx[1]), $object->multiprices_min[1], 1); } else { $object->updatePrice($object->price, $object->price_base_type, $user, $object->tva_tx, $object->price_min); } @@ -1455,9 +1455,9 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ { // Default prices or // Log of previous customer prices - $backbutton='' . $langs->trans("Back") . ''; + $backbutton = ''.$langs->trans("Back").''; - if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print_barre_liste($langs->trans("DefaultPrice"), 0, $_SERVER["PHP_SELF"], '', '', '', $backbutton, 0, $num, 'title_accountancy.png'); + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print_barre_liste($langs->trans("DefaultPrice"), 0, $_SERVER["PHP_SELF"], '', '', '', $backbutton, 0, $num, 'title_accountancy.png'); else print_barre_liste($langs->trans("PriceByCustomerLog"), 0, $_SERVER["PHP_SELF"], '', '', '', '', 0, $num, 'title_accountancy.png'); //if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print_barre_liste($langs->trans("DefaultPrice"),'','','','','',$backbutton, 0, 0, 'title_accountancy.png'); //else print_barre_liste($langs->trans("PriceByCustomerLog"),'','','','','','', 0, 0, 'title_accountancy.png'); @@ -1466,31 +1466,31 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ print '
'; - print $form->textwithpicto($langs->trans('SellingPrice') . ' ' . $i, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); + print $form->textwithpicto($langs->trans('SellingPrice').' '.$i, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; - print $form->load_tva("tva_tx[" . $i.']', $object->multiprices_tva_tx[$i], $mysoc, '', $object->id, false, $object->type, false, 1); + print $form->load_tva("tva_tx[".$i.']', $object->multiprices_tva_tx[$i], $mysoc, '', $object->id, false, $object->type, false, 1); print ''; if ($object->multiprices_base_type [$i] == 'TTC') { - print ''; + print ''; } else { - print ''; + print ''; } - print ' '.$form->selectPriceBaseType($object->multiprices_base_type [$i], "multiprices_base_type[" . $i."]"); + print ' '.$form->selectPriceBaseType($object->multiprices_base_type [$i], "multiprices_base_type[".$i."]"); print ''; if ($object->multiprices_base_type [$i] == 'TTC') { - print ''; + print ''; } else { - print ''; + print ''; } - if ( !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) + if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) { print ''.$langs->trans("MinimumRecommendedPrice", price($maxpricesupplier, 0, '', 1, -1, -1, 'auto')).' '.img_warning().'
'; print ''; - print ''; + print ''; - if (! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { - print ''; + if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { + print ''; } - if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { - print ''; + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { + print ''; } - print ''; + print ''; print $conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL; - if (empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) print ''; - print ''; - print ''; - if (! empty($conf->dynamicprices->enabled)) { - print ''; + if (empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) print ''; + print ''; + print ''; + if (!empty($conf->dynamicprices->enabled)) { + print ''; } - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; if ($user->rights->produit->supprimer) print ''; print ''; - $notfirstlineforlevel=array(); + $notfirstlineforlevel = array(); $i = 0; while ($i < $num) @@ -1499,17 +1499,17 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ print ''; // Date - print ""; + print ""; // Price level - if (! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { - print '"; + if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { + print '"; } // Price by quantity - if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { $type = ($objp->price_by_qty == 1) ? 'PriceByQuantity' : 'Standard'; - print '"; + print '"; } print ''; print ''; - print '"; + print '"; } else { @@ -1562,7 +1562,7 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ print price($objp->price_ttc); } print ""; - if (! empty($conf->dynamicprices->enabled)) { //Only if module is enabled + if (!empty($conf->dynamicprices->enabled)) { //Only if module is enabled print ''; } } @@ -1580,23 +1580,23 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ print ''; // User - print ''; + print ''; // Action if ($user->rights->produit->supprimer) { - $candelete=0; - if (! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) + $candelete = 0; + if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { - if (empty($notfirstlineforlevel[$objp->price_level])) $notfirstlineforlevel[$objp->price_level]=1; - else $candelete=1; + if (empty($notfirstlineforlevel[$objp->price_level])) $notfirstlineforlevel[$objp->price_level] = 1; + else $candelete = 1; } - elseif ($i > 0) $candelete=1; + elseif ($i > 0) $candelete = 1; print '
' . $langs->trans("AppliedPricesFrom") . ''.$langs->trans("AppliedPricesFrom").'' . $langs->trans("PriceLevel") . ''.$langs->trans("PriceLevel").'' . $langs->trans("Type") . ''.$langs->trans("Type").'' . $langs->trans("PriceBase") . ''.$langs->trans("PriceBase").'' . $langs->trans("DefaultTaxRate") . '' . $langs->trans("HT") . '' . $langs->trans("TTC") . '' . $langs->trans("PriceExpressionSelected") . ''.$langs->trans("DefaultTaxRate").''.$langs->trans("HT").''.$langs->trans("TTC").''.$langs->trans("PriceExpressionSelected").'' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . '' . $langs->trans("MinPrice") . ' ' . $langs->trans("TTC") . '' . $langs->trans("ChangedBy") . ''.$langs->trans("MinPrice").' '.$langs->trans("HT").''.$langs->trans("MinPrice").' '.$langs->trans("TTC").''.$langs->trans("ChangedBy").' 
" . dol_print_date($db->jdate($objp->dp), "dayhour") . "".dol_print_date($db->jdate($objp->dp), "dayhour")."' . $objp->price_level . "'.$objp->price_level."' . $langs->trans($type) . "'.$langs->trans($type)."'; @@ -1523,12 +1523,12 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ print ''; if (empty($objp->price_by_qty)) { - $positiverates=''; - if (price2num($objp->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($objp->tva_tx); - if (price2num($objp->localtax1_type)) $positiverates.=($positiverates?'/':'').price2num($objp->localtax1_tx); - if (price2num($objp->localtax2_type)) $positiverates.=($positiverates?'/':'').price2num($objp->localtax2_tx); - if (empty($positiverates)) $positiverates='0'; - echo vatrate($positiverates.($objp->default_vat_code?' ('.$objp->default_vat_code.')':''), '%', $objp->tva_npr); + $positiverates = ''; + if (price2num($objp->tva_tx)) $positiverates .= ($positiverates ? '/' : '').price2num($objp->tva_tx); + if (price2num($objp->localtax1_type)) $positiverates .= ($positiverates ? '/' : '').price2num($objp->localtax1_tx); + if (price2num($objp->localtax2_type)) $positiverates .= ($positiverates ? '/' : '').price2num($objp->localtax2_tx); + if (empty($positiverates)) $positiverates = '0'; + echo vatrate($positiverates.($objp->default_vat_code ? ' ('.$objp->default_vat_code.')' : ''), '%', $objp->tva_npr); /* if ($objp->default_vat_code) { @@ -1541,14 +1541,14 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ } // Price - if (! empty($objp->fk_price_expression) && ! empty($conf->dynamicprices->enabled)) + if (!empty($objp->fk_price_expression) && !empty($conf->dynamicprices->enabled)) { $price_expression = new PriceExpression($db); $res = $price_expression->fetch($objp->fk_price_expression); $title = $price_expression->title; print '' . $title . "'.$title."' . img_object($langs->trans("ShowUser"), 'user') . ' ' . $objp->login . ''.img_object($langs->trans("ShowUser"), 'user').' '.$objp->login.''; if ($candelete) { - print 'id . '&lineid=' . $objp->rowid . '">'; + print 'id.'&lineid='.$objp->rowid.'">'; print img_delete(); print ''; } else @@ -1622,26 +1622,26 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_ // Add area to show/add/edit a price for a dedicated customer -if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) +if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { $prodcustprice = new Productcustomerprice($db); $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 = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; - if (! $sortorder) + if (!$sortorder) $sortorder = "ASC"; - if (! $sortfield) + if (!$sortfield) $sortfield = "soc.nom"; // Build filter to diplay only concerned lines $filter = array('t.fk_product' => $object->id); - if (! empty($search_soc)) { + if (!empty($search_soc)) { $filter['soc.nom'] = $search_soc; } @@ -1652,23 +1652,23 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print load_fiche_titre($langs->trans('PriceByCustomer')); - print '
'; - print ''; + print ''; + print ''; print ''; - print ''; + print ''; dol_fiche_head(); print ''; print ''; - print ''; + print ''; print ''; print ''; // VAT - print ''; @@ -1687,9 +1687,9 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); print ''; @@ -1698,11 +1698,11 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) $text = $langs->trans('MinPrice'); print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); if ($object->price_base_type == 'TTC') { - print ''; } @@ -1720,9 +1720,9 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print $langs->trans('ForceUpdateChildPriceSoc'); print ''; - print ''; + print ''; print '     '; - print ''; + print ''; print ''; print ''; @@ -1739,23 +1739,23 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); } - print ''; - print ''; + print ''; + print ''; print ''; - print ''; + print ''; dol_fiche_head(); print '
' . $langs->trans('ThirdParty') . ''.$langs->trans('ThirdParty').''; print $form->select_company('', 'socid', 's.client IN (1,2,3)', 'SelectThirdParty', 0, 0, array(), 0, 'minwidth300'); print '
' . $langs->trans("DefaultTaxRate") . ''; + print '
'.$langs->trans("DefaultTaxRate").''; print $form->load_tva("tva_tx", $object->default_vat_code ? $object->tva_tx.' ('.$object->default_vat_code.')' : $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr, $object->type, false, 1); print '
'; if ($object->price_base_type == 'TTC') { - print ''; + print ''; } else { - print ''; + print ''; } print '
'; + print ''; } else { - print ''; + print ''; } - if ( !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) + if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) { print ''.$langs->trans("MinimumRecommendedPrice", price($maxpricesupplier, 0, '', 1, -1, -1, 'auto')).' '.img_warning().'
'; print ''; - print ''; + print ''; $staticsoc = new Societe($db); $staticsoc->fetch($prodcustprice->fk_soc); - print ""; + print ""; print ''; // VAT - print ''; @@ -1774,9 +1774,9 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); print ''; @@ -1786,12 +1786,12 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); print ''; - if ( !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) + if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) { print ''; } @@ -1814,9 +1814,9 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print $langs->trans('ForceUpdateChildPriceSoc'); print ""; - print ''; + print ''; print '     '; - print ''; + print ''; print ''; print '
'; @@ -1826,7 +1826,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) // List of all log of prices by customers print ''."\n"; - $filter = array('t.fk_product' => $object->id,'t.fk_soc' => GETPOST('socid', 'int')); + $filter = array('t.fk_product' => $object->id, 't.fk_soc' => GETPOST('socid', 'int')); // Count total nb of records $nbtotalofrecords = ''; @@ -1839,43 +1839,43 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); } - $option = '&socid=' . GETPOST('socid', 'int') . '&id=' . $object->id; + $option = '&socid='.GETPOST('socid', 'int').'&id='.$object->id; $staticsoc = new Societe($db); $staticsoc->fetch(GETPOST('socid', 'int')); - $title=$langs->trans('PriceByCustomerLog'); - $title.=' - '.$staticsoc->getNomUrl(1); + $title = $langs->trans('PriceByCustomerLog'); + $title .= ' - '.$staticsoc->getNomUrl(1); - $backbutton='' . $langs->trans("Back") . ''; + $backbutton = ''.$langs->trans("Back").''; print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $option, $sortfield, $sortorder, $backbutton, count($prodcustprice->lines), $nbtotalofrecords, 'title_accountancy.png'); if (count($prodcustprice->lines) > 0) { - print ''; - print ''; + print ''; + print ''; print '
' . $langs->trans('ThirdParty') . ''.$langs->trans('ThirdParty').'" . $staticsoc->getNomUrl(1) . "".$staticsoc->getNomUrl(1)."
' . $langs->trans("DefaultTaxRate") . ''; + print '
'.$langs->trans("DefaultTaxRate").''; print $form->load_tva("tva_tx", $prodcustprice->default_vat_code ? $prodcustprice->tva_tx.' ('.$prodcustprice->default_vat_code.')' : $prodcustprice->tva_tx, $mysoc, '', $object->id, $prodcustprice->recuperableonly, $object->type, false, 1); print '
'; if ($prodcustprice->price_base_type == 'TTC') { - print ''; + print ''; } else { - print ''; + print ''; } print '
'; if ($prodcustprice->price_base_type == 'TTC') { - print ''; + print ''; } else { - print ''; + print ''; } print ''.$langs->trans("MinimumRecommendedPrice", price($maxpricesupplier, 0, '', 1, -1, -1, 'auto')).' '.img_warning().'
'; print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { //print ''; - print ''; + print ''; } else { - print ''; + print ''; } - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; print ''; @@ -1888,19 +1888,19 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) $tva_tx = $line->default_vat_code ? $line->tva_tx.' ('.$line->default_vat_code.')' : $line->tva_tx; // Line for default price - if ($line->price_base_type=='HT') + if ($line->price_base_type == 'HT') { - $pu=$line->price; + $pu = $line->price; } else { - $pu=$line->price_ttc; + $pu = $line->price_ttc; } // Local tax is not saved into table of product. We use value linked to VAT code. - $localtaxarray=getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code?' ('.$line->default_vat_code.')':''), 0, $staticsoc, $mysoc); + $localtaxarray = getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code ? ' ('.$line->default_vat_code.')' : ''), 0, $staticsoc, $mysoc); // Define part of HT, VAT, TTC - $resultarray=calcul_price_total(1, $pu, 0, $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly, $object->type, $mysoc, $localtaxarray); + $resultarray = calcul_price_total(1, $pu, 0, $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly, $object->type, $mysoc, $localtaxarray); // Calcul du total ht sans remise $total_ht = $resultarray[0]; $total_vat = $resultarray[1]; @@ -1910,35 +1910,35 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print ''; - print ""; - print ""; - print '"; + print ""; + print ""; + print '"; print '"; - print '"; + print '"; if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { //print '"; - print ''; + print ''; } else { - print '"; + print '"; } - print ''; - print ''; + print ''; + print ''; // User $userstatic = new User($db); @@ -1969,67 +1969,67 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); } - $option = '&search_soc=' . $search_soc . '&id=' . $object->id; + $option = '&search_soc='.$search_soc.'&id='.$object->id; print_barre_liste($langs->trans('PriceByCustomer'), $page, $_SERVER ['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords, 'title_accountancy.png'); - print ''; - print ''; + print ''; + print ''; print '
' . $langs->trans("ThirdParty") . '' . $langs->trans("AppliedPricesFrom") . '' . $langs->trans("PriceBase") . '' . $langs->trans("DefaultTaxRate") . '' . $langs->trans("HT") . ''.$langs->trans("ThirdParty").''.$langs->trans("AppliedPricesFrom").''.$langs->trans("PriceBase").''.$langs->trans("DefaultTaxRate").''.$langs->trans("HT").'' . $langs->trans("INCVATONLY") . '' . $langs->trans("INCT") . ''.$langs->trans("INCT").'' . $langs->trans("TTC") . ''.$langs->trans("TTC").'' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . '' . $langs->trans("MinPrice") . ' ' . $langs->trans("TTC") . '' . $langs->trans("ChangedBy") . ''.$langs->trans("MinPrice").' '.$langs->trans("HT").''.$langs->trans("MinPrice").' '.$langs->trans("TTC").''.$langs->trans("ChangedBy").' 
" . $staticsoc->getNomUrl(1) . "" . dol_print_date($line->datec, "dayhour") . "' . $langs->trans($line->price_base_type) . "".$staticsoc->getNomUrl(1)."".dol_print_date($line->datec, "dayhour")."'.$langs->trans($line->price_base_type)."'; - $positiverates=''; - if (price2num($line->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($line->tva_tx); - if (price2num($line->localtax1_type)) $positiverates.=($positiverates?'/':'').price2num($line->localtax1_tx); - if (price2num($line->localtax2_type)) $positiverates.=($positiverates?'/':'').price2num($line->localtax2_tx); - if (empty($positiverates)) $positiverates='0'; + $positiverates = ''; + if (price2num($line->tva_tx)) $positiverates .= ($positiverates ? '/' : '').price2num($line->tva_tx); + if (price2num($line->localtax1_type)) $positiverates .= ($positiverates ? '/' : '').price2num($line->localtax1_tx); + if (price2num($line->localtax2_type)) $positiverates .= ($positiverates ? '/' : '').price2num($line->localtax2_tx); + if (empty($positiverates)) $positiverates = '0'; - echo vatrate($positiverates.($line->default_vat_code?' ('.$line->default_vat_code.')':''), '%', ($line->tva_npr?$line->tva_npr:$line->recuperableonly)); + echo vatrate($positiverates.($line->default_vat_code ? ' ('.$line->default_vat_code.')' : ''), '%', ($line->tva_npr ? $line->tva_npr : $line->recuperableonly)); //. vatrate($tva_tx, true, $line->recuperableonly) . print "' . price($line->price) . "'.price($line->price)."' . price($line->price_ttc) . "' . price($resultarray[2]) . ''.price($resultarray[2]).'' . price($line->price_ttc) . "'.price($line->price_ttc)."' . price($line->price_min) . '' . price($line->price_min_ttc) . ''.price($line->price_min).''.price($line->price_min_ttc).'
'; if (count($prodcustprice->lines) > 0 || $search_soc) { - $colspan=8; + $colspan = 8; //if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") $colspan++; print ''; - print ''; + print ''; print ''; // Print the search button print ''; print ''; } print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { //print ''; - print ''; + print ''; } else { - print ''; + print ''; } - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; print ''; // Line for default price - if ($object->price_base_type=='HT') + if ($object->price_base_type == 'HT') { - $pu=$object->price; + $pu = $object->price; } else { - $pu=$object->price_ttc; + $pu = $object->price_ttc; } // Local tax is not saved into table of product. We use value linked to VAT code. - $localtaxarray=getLocalTaxesFromRate($object->tva_tx.($object->default_vat_code?' ('.$object->default_vat_code.')':''), 0, $mysoc, $mysoc); + $localtaxarray = getLocalTaxesFromRate($object->tva_tx.($object->default_vat_code ? ' ('.$object->default_vat_code.')' : ''), 0, $mysoc, $mysoc); // Define part of HT, VAT, TTC - $resultarray=calcul_price_total(1, $pu, 0, $object->tva_tx, 1, 1, 0, $object->price_base_type, $object->recuperableonly, $object->type, $mysoc, $localtaxarray); + $resultarray = calcul_price_total(1, $pu, 0, $object->tva_tx, 1, 1, 0, $object->price_base_type, $object->recuperableonly, $object->type, $mysoc, $localtaxarray); // Calcul du total ht sans remise $total_ht = $resultarray[0]; $total_vat = $resultarray[1]; @@ -2038,48 +2038,48 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) $total_ttc = $resultarray[2]; print ''; - print ""; - print ""; + print ""; + print ""; - print '"; + print '"; print '"; - print '"; + print '"; if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { //print '"; - print ''; + print ''; } else { - print '"; + print '"; } - print ''; - print ''; + print ''; + print ''; print ''; if ($user->rights->produit->supprimer || $user->rights->service->supprimer) { print ''; - print ""; - print ""; + print ""; + print ""; - print '"; + print '"; print '"; - print '"; + print '"; if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { //print '"; - print ''; + print ''; } else { - print '"; + print '"; } - print ''; - print ''; + print ''; + print ''; // User $userstatic = new User($db); @@ -2161,15 +2161,15 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) if ($user->rights->produit->supprimer || $user->rights->service->supprimer) { print ''; diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index d87b6f7604f..5ca7992be31 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -33,33 +33,33 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -$WIDTH=DolGraph::getDefaultGraphSizeForStats('width', 380); -$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height', 160); +$WIDTH = DolGraph::getDefaultGraphSizeForStats('width', 380); +$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height', 160); // Load translation files required by the page $langs->loadLangs(array('companies', 'products', 'stocks', 'bills', 'other')); -$id = GETPOST('id', 'int'); // For this page, id can also be 'all' +$id = GETPOST('id', 'int'); // For this page, id can also be 'all' $ref = GETPOST('ref', 'alpha'); -$mode = (GETPOST('mode', 'alpha') ? GETPOST('mode', 'alpha') : 'byunit'); +$mode = (GETPOST('mode', 'alpha') ? GETPOST('mode', 'alpha') : 'byunit'); $search_year = GETPOST('search_year', 'int'); $search_categ = GETPOST('search_categ', 'int'); -$error = 0; +$error = 0; $mesg = ''; -$graphfiles=array(); +$graphfiles = array(); -$socid=''; -if (! empty($user->socid)) $socid=$user->socid; +$socid = ''; +if (!empty($user->socid)) $socid = $user->socid; // Security check -$fieldvalue = (! empty($id) ? $id : $ref); -$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); -$result=restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); +$fieldvalue = (!empty($id) ? $id : $ref); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); -$tmp=dol_getdate(dol_now()); -$currentyear=$tmp['year']; -if (empty($search_year)) $search_year=$currentyear; +$tmp = dol_getdate(dol_now()); +$currentyear = $tmp['year']; +if (empty($search_year)) $search_year = $currentyear; /* @@ -77,30 +77,30 @@ $form = new Form($db); $htmlother = new FormOther($db); $object = new Product($db); -if (! $id && empty($ref)) +if (!$id && empty($ref)) { llxHeader("", $langs->trans("ProductStatistics")); $type = GETPOST('type', 'int'); - $helpurl=''; + $helpurl = ''; if ($type == '0') { - $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; //$title=$langs->trans("StatisticsOfProducts"); - $title=$langs->trans("Statistics"); + $title = $langs->trans("Statistics"); } elseif ($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'; //$title=$langs->trans("StatisticsOfServices"); - $title=$langs->trans("Statistics"); + $title = $langs->trans("Statistics"); } else { - $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; //$title=$langs->trans("StatisticsOfProductsOrServices"); - $title=$langs->trans("Statistics"); + $title = $langs->trans("Statistics"); } print load_fiche_titre($title, $mesg, 'products'); @@ -114,39 +114,39 @@ else $shortlabel = dol_trunc($object->label, 16); if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { - $title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('Statistics'); - $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Statistics'); + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; } if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { - $title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('Statistics'); - $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Statistics'); + $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; } llxHeader('', $title, $helpurl); } -if ($result && (! empty($id) || ! empty($ref))) +if ($result && (!empty($id) || !empty($ref))) { - $head=product_prepare_head($object); - $titre=$langs->trans("CardProduct".$object->type); - $picto=($object->type==Product::TYPE_SERVICE?'service':'product'); + $head = product_prepare_head($object); + $titre = $langs->trans("CardProduct".$object->type); + $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); dol_fiche_head($head, 'stats', $titre, -1, $picto); $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'ref', $linkback, ($user->socid?0:1), 'ref', '', '', '', 0, '', '', 1); + dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', '', '', '', 0, '', '', 1); dol_fiche_end(); } if (empty($id) & empty($ref)) { - $h=0; + $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/product/stats/card.php'.($type != ''?'?type='.$type:''); + $head[$h][0] = DOL_URL_ROOT.'/product/stats/card.php'.($type != '' ? '?type='.$type : ''); $head[$h][1] = $langs->trans("Chart"); $head[$h][2] = 'chart'; $h++; @@ -159,7 +159,7 @@ if (empty($id) & empty($ref)) $title = $langs->trans("ListProductByPopularity"); } - $head[$h][0] = DOL_URL_ROOT.'/product/popuprop.php'.($type != ''?'?type='.$type:''); + $head[$h][0] = DOL_URL_ROOT.'/product/popuprop.php'.($type != '' ? '?type='.$type : ''); $head[$h][1] = $title; $head[$h][2] = 'popularityprop'; $h++; @@ -180,7 +180,7 @@ if ($result || empty($id)) { // Type print ''; @@ -189,7 +189,7 @@ if ($result || empty($id)) { print ''; @@ -198,13 +198,13 @@ if ($result || empty($id)) // Year print ''; @@ -216,32 +216,32 @@ if ($result || empty($id)) // Choice of stats mode (byunit or bynumber) - if (! empty($conf->dol_use_jmobile)) print "\n".''; else print '
'; print '
'; //print '
 '; - $searchpicto=$form->showFilterAndCheckAddButtons(0); + $searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
' . $langs->trans("ThirdParty") . '' . $langs->trans("AppliedPricesFrom") . '' . $langs->trans("PriceBase") . '' . $langs->trans("DefaultTaxRate") . '' . $langs->trans("HT") . ''.$langs->trans("ThirdParty").''.$langs->trans("AppliedPricesFrom").''.$langs->trans("PriceBase").''.$langs->trans("DefaultTaxRate").''.$langs->trans("HT").'' . $langs->trans("INCVATONLY") . '' . $langs->trans("INCT") . ''.$langs->trans("INCT").'' . $langs->trans("TTC") . ''.$langs->trans("TTC").'' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . '' . $langs->trans("MinPrice") . ' ' . $langs->trans("TTC") . '' . $langs->trans("ChangedBy") . ''.$langs->trans("MinPrice").' '.$langs->trans("HT").''.$langs->trans("MinPrice").' '.$langs->trans("TTC").''.$langs->trans("ChangedBy").' 
" . $langs->trans("Default") . "" . "".$langs->trans("Default").""."' . $langs->trans($object->price_base_type) . "'.$langs->trans($object->price_base_type)."'; - $positiverates=''; - if (price2num($object->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($object->tva_tx); - if (price2num($object->localtax1_type)) $positiverates.=($positiverates?'/':'').price2num($object->localtax1_tx); - if (price2num($object->localtax2_type)) $positiverates.=($positiverates?'/':'').price2num($object->localtax2_tx); - if (empty($positiverates)) $positiverates='0'; - echo vatrate($positiverates.($object->default_vat_code?' ('.$object->default_vat_code.')':''), '%', $object->tva_npr); + $positiverates = ''; + if (price2num($object->tva_tx)) $positiverates .= ($positiverates ? '/' : '').price2num($object->tva_tx); + if (price2num($object->localtax1_type)) $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax1_tx); + if (price2num($object->localtax2_type)) $positiverates .= ($positiverates ? '/' : '').price2num($object->localtax2_tx); + if (empty($positiverates)) $positiverates = '0'; + echo vatrate($positiverates.($object->default_vat_code ? ' ('.$object->default_vat_code.')' : ''), '%', $object->tva_npr); //print vatrate($object->tva_tx, true, $object->tva_npr); //print $object->default_vat_code?' ('.$object->default_vat_code.')':''; print "' . price($object->price) . "'.price($object->price)."' . price($object->price_ttc) . "' . price($resultarray[2]) . ''.price($resultarray[2]).'' . price($object->price_ttc) . "'.price($object->price_ttc)."' . price($object->price_min) . '' . price($object->price_min_ttc) . ''.price($object->price_min).''.price($object->price_min_ttc).''; print ''; - print 'id . '">'; + print 'id.'">'; print img_info($langs->trans('PriceByCustomerLog')); print ''; print ' '; - print 'id . '">'; + print 'id.'">'; print img_edit('default', 0, 'style="vertical-align: middle;"'); print ''; print '   '; @@ -2098,19 +2098,19 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) $tva_tx = $line->default_vat_code ? $line->tva_tx.' ('.$line->default_vat_code.')' : $line->tva_tx; // Line for default price - if ($line->price_base_type=='HT') + if ($line->price_base_type == 'HT') { - $pu=$line->price; + $pu = $line->price; } else { - $pu=$line->price_ttc; + $pu = $line->price_ttc; } // Local tax is not saved into table of product. We use value linked to VAT code. - $localtaxarray=getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code?' ('.$line->default_vat_code.')':''), 0, $staticsoc, $mysoc); + $localtaxarray = getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code ? ' ('.$line->default_vat_code.')' : ''), 0, $staticsoc, $mysoc); // Define part of HT, VAT, TTC - $resultarray=calcul_price_total(1, $pu, 0, $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly, $object->type, $mysoc, $localtaxarray); + $resultarray = calcul_price_total(1, $pu, 0, $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly, $object->type, $mysoc, $localtaxarray); // Calcul du total ht sans remise $total_ht = $resultarray[0]; $total_vat = $resultarray[1]; @@ -2120,34 +2120,34 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print '
" . $staticsoc->getNomUrl(1) . "" . dol_print_date($line->datec, "dayhour") . "".$staticsoc->getNomUrl(1)."".dol_print_date($line->datec, "dayhour")."' . $langs->trans($line->price_base_type) . "'.$langs->trans($line->price_base_type)."'; - $positiverates=''; - if (price2num($line->tva_tx)) $positiverates.=($positiverates?'/':'').price2num($line->tva_tx); - if (price2num($line->localtax1_type)) $positiverates.=($positiverates?'/':'').price2num($line->localtax1_tx); - if (price2num($line->localtax2_type)) $positiverates.=($positiverates?'/':'').price2num($line->localtax2_tx); - if (empty($positiverates)) $positiverates='0'; - echo vatrate($positiverates.($line->default_vat_code?' ('.$line->default_vat_code.')':''), '%', ($line->tva_npr?$line->tva_npr:$line->recuperableonly)); + $positiverates = ''; + if (price2num($line->tva_tx)) $positiverates .= ($positiverates ? '/' : '').price2num($line->tva_tx); + if (price2num($line->localtax1_type)) $positiverates .= ($positiverates ? '/' : '').price2num($line->localtax1_tx); + if (price2num($line->localtax2_type)) $positiverates .= ($positiverates ? '/' : '').price2num($line->localtax2_tx); + if (empty($positiverates)) $positiverates = '0'; + echo vatrate($positiverates.($line->default_vat_code ? ' ('.$line->default_vat_code.')' : ''), '%', ($line->tva_npr ? $line->tva_npr : $line->recuperableonly)); print "' . price($line->price) . "'.price($line->price)."' . price($line->price_ttc) . "' . price($resultarray[2]) . ''.price($resultarray[2]).'' . price($line->price_ttc) . "'.price($line->price_ttc)."' . price($line->price_min) . '' . price($line->price_min_ttc) . ''.price($line->price_min).''.price($line->price_min_ttc).''; - print 'id . '&socid=' . $line->fk_soc . '">'; + print 'id.'&socid='.$line->fk_soc.'">'; print img_info($langs->trans('PriceByCustomerLog')); print ''; print ' '; - print 'id . '&lineid=' . $line->id . '">'; + print 'id.'&lineid='.$line->id.'">'; print img_edit('default', 0, 'style="vertical-align: middle;"'); print ''; print ' '; - print 'id . '&lineid=' . $line->id . '">'; + print 'id.'&lineid='.$line->id.'">'; print img_delete('default', 'style="vertical-align: middle;"'); print ''; print '
'.$langs->trans("ProductsAndServices").''; - $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('type', $array, $type); print '
'.$langs->trans("Categories").''; //$moreforfilter.='
'; - $moreforfilter.=$htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ', 1); + $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ', 1); //$moreforfilter.='
'; print $moreforfilter; print '
'.$langs->trans("Year").''; - $arrayyears=array(); - for ($year = $currentyear - 10; $year < $currentyear + 10 ; $year++) + $arrayyears = array(); + for ($year = $currentyear - 10; $year < $currentyear + 10; $year++) { - $arrayyears[$year]=$year; + $arrayyears[$year] = $year; } - if (! in_array($year, $arrayyears)) $arrayyears[$year]=$year; - if (! in_array($nowyear, $arrayyears)) $arrayyears[$nowyear]=$nowyear; + if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year; + if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear; arsort($arrayyears); print $form->selectarray('search_year', $arrayyears, $search_year, 0); print '
'; // Generation des graphs - $dir = (! empty($conf->product->multidir_temp[$object->entity])?$conf->product->multidir_temp[$object->entity]:$conf->service->multidir_temp[$object->entity]); + $dir = (!empty($conf->product->multidir_temp[$object->entity]) ? $conf->product->multidir_temp[$object->entity] : $conf->service->multidir_temp[$object->entity]); if ($object->id > 0) // We are on statistics for a dedicated product { - if (! file_exists($dir.'/'.$object->id)) + if (!file_exists($dir.'/'.$object->id)) { if (dol_mkdir($dir.'/'.$object->id) < 0) { @@ -251,78 +251,78 @@ if ($result || empty($id)) } } - if($conf->propal->enabled) { - $graphfiles['propal']=array('modulepart'=>'productstats_proposals', - 'file' => $object->id.'/propal12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year?'_year'.$search_year:'').'.png', - 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsProposals"):$langs->transnoentitiesnoconv("NumberOfProposals"))); + if ($conf->propal->enabled) { + $graphfiles['propal'] = array('modulepart'=>'productstats_proposals', + 'file' => $object->id.'/propal12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsProposals") : $langs->transnoentitiesnoconv("NumberOfProposals"))); } - if($conf->supplier_proposal->enabled) { - $graphfiles['proposalssuppliers']=array('modulepart'=>'productstats_proposalssuppliers', - 'file' => $object->id.'/proposalssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year?'_year'.$search_year:'').'.png', - 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsSupplierProposals"):$langs->transnoentitiesnoconv("NumberOfSupplierProposals"))); + if ($conf->supplier_proposal->enabled) { + $graphfiles['proposalssuppliers'] = array('modulepart'=>'productstats_proposalssuppliers', + 'file' => $object->id.'/proposalssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsSupplierProposals") : $langs->transnoentitiesnoconv("NumberOfSupplierProposals"))); } - if($conf->order->enabled) { - $graphfiles['orders']=array('modulepart'=>'productstats_orders', - 'file' => $object->id.'/orders12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year?'_year'.$search_year:'').'.png', - 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsCustomerOrders"):$langs->transnoentitiesnoconv("NumberOfCustomerOrders"))); + if ($conf->order->enabled) { + $graphfiles['orders'] = array('modulepart'=>'productstats_orders', + 'file' => $object->id.'/orders12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsCustomerOrders") : $langs->transnoentitiesnoconv("NumberOfCustomerOrders"))); } - if($conf->supplier_order->enabled) { - $graphfiles['orderssuppliers']=array('modulepart'=>'productstats_orderssuppliers', - 'file' => $object->id.'/orderssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year?'_year'.$search_year:'').'.png', - 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsSupplierOrders"):$langs->transnoentitiesnoconv("NumberOfSupplierOrders"))); + if ($conf->supplier_order->enabled) { + $graphfiles['orderssuppliers'] = array('modulepart'=>'productstats_orderssuppliers', + 'file' => $object->id.'/orderssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsSupplierOrders") : $langs->transnoentitiesnoconv("NumberOfSupplierOrders"))); } - if($conf->facture->enabled) { - $graphfiles['invoices']=array('modulepart'=>'productstats_invoices', - 'file' => $object->id.'/invoices12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year?'_year'.$search_year:'').'.png', - 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsCustomerInvoices"):$langs->transnoentitiesnoconv("NumberOfCustomerInvoices"))); + if ($conf->facture->enabled) { + $graphfiles['invoices'] = array('modulepart'=>'productstats_invoices', + 'file' => $object->id.'/invoices12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsCustomerInvoices") : $langs->transnoentitiesnoconv("NumberOfCustomerInvoices"))); } - if($conf->supplier_invoice->enabled) { - $graphfiles['invoicessuppliers']=array('modulepart'=>'productstats_invoicessuppliers', - 'file' => $object->id.'/invoicessuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year?'_year'.$search_year:'').'.png', - 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsSupplierInvoices"):$langs->transnoentitiesnoconv("NumberOfSupplierInvoices"))); + if ($conf->supplier_invoice->enabled) { + $graphfiles['invoicessuppliers'] = array('modulepart'=>'productstats_invoicessuppliers', + 'file' => $object->id.'/invoicessuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsSupplierInvoices") : $langs->transnoentitiesnoconv("NumberOfSupplierInvoices"))); } - if($conf->contrat->enabled) { - $graphfiles['contracts']=array('modulepart'=>'productstats_contracts', - 'file' => $object->id.'/contracts12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year?'_year'.$search_year:'').'.png', - 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsContracts"):$langs->transnoentitiesnoconv("NumberOfContracts"))); + if ($conf->contrat->enabled) { + $graphfiles['contracts'] = array('modulepart'=>'productstats_contracts', + 'file' => $object->id.'/contracts12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsContracts") : $langs->transnoentitiesnoconv("NumberOfContracts"))); } $px = new DolGraph(); - if (! $error && count($graphfiles)>0) + if (!$error && count($graphfiles) > 0) { $mesg = $px->isGraphKo(); - if (! $mesg) + if (!$mesg) { - foreach($graphfiles as $key => $val) + foreach ($graphfiles as $key => $val) { - if (! $graphfiles[$key]['file']) continue; + if (!$graphfiles[$key]['file']) continue; $graph_data = array(); - if (dol_is_file($dir . '/' . $graphfiles[$key]['file'])) + if (dol_is_file($dir.'/'.$graphfiles[$key]['file'])) { // TODO Load cachefile $graphfiles[$key]['file'] } else { - $morefilters=''; + $morefilters = ''; if ($search_categ > 0) { - $categ=new Categorie($db); + $categ = new Categorie($db); $categ->fetch($search_categ); $listofprodids = $categ->getObjectsInCateg('product', 1); - $morefilters=' AND d.fk_product IN ('.((is_array($listofprodids) && count($listofprodids)) ? join(',', $listofprodids):'0').')'; + $morefilters = ' AND d.fk_product IN ('.((is_array($listofprodids) && count($listofprodids)) ? join(',', $listofprodids) : '0').')'; } if ($search_categ == -2) { - $morefilters=' AND d.fk_product NOT IN (SELECT cp.fk_product from '.MAIN_DB_PREFIX.'categorie_product as cp)'; + $morefilters = ' AND d.fk_product NOT IN (SELECT cp.fk_product from '.MAIN_DB_PREFIX.'categorie_product as cp)'; } if ($key == 'propal') $graph_data = $object->get_nb_propal($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); @@ -340,18 +340,18 @@ if ($result || empty($id)) { $px->SetData($graph_data); $px->SetYLabel($graphfiles[$key]['label']); - $px->SetMaxValue($px->GetCeilMaxValue()<0?0:$px->GetCeilMaxValue()); - $px->SetMinValue($px->GetFloorMinValue()>0?0:$px->GetFloorMinValue()); + $px->SetMaxValue($px->GetCeilMaxValue() < 0 ? 0 : $px->GetCeilMaxValue()); + $px->SetMinValue($px->GetFloorMinValue() > 0 ? 0 : $px->GetFloorMinValue()); $px->SetWidth($WIDTH); $px->SetHeight($HEIGHT); $px->SetHorizTickIncrement(1); $px->SetShading(3); //print 'x '.$key.' '.$graphfiles[$key]['file']; - $url=DOL_URL_ROOT.'/viewimage.php?modulepart='.$graphfiles[$key]['modulepart'].'&entity='.$object->entity.'&file='.urlencode($graphfiles[$key]['file']); + $url = DOL_URL_ROOT.'/viewimage.php?modulepart='.$graphfiles[$key]['modulepart'].'&entity='.$object->entity.'&file='.urlencode($graphfiles[$key]['file']); $px->draw($dir."/".$graphfiles[$key]['file'], $url); - $graphfiles[$key]['output']=$px->show(); + $graphfiles[$key]['output'] = $px->show(); } else { @@ -364,19 +364,19 @@ if ($result || empty($id)) } // Show graphs - $i=0; - if ( count($graphfiles)>0) + $i = 0; + if (count($graphfiles) > 0) { - foreach($graphfiles as $key => $val) + foreach ($graphfiles as $key => $val) { - if (! $graphfiles[$key]['file']) continue; + if (!$graphfiles[$key]['file']) continue; - if ($graphfiles == 'propal' && ! $user->rights->propale->lire) continue; - if ($graphfiles == 'order' && ! $user->rights->commande->lire) continue; - if ($graphfiles == 'invoices' && ! $user->rights->facture->lire) continue; - if ($graphfiles == 'proposals_suppliers' && ! $user->rights->supplier_proposal->lire) continue; - if ($graphfiles == 'invoices_suppliers' && ! $user->rights->fournisseur->facture->lire) continue; - if ($graphfiles == 'orders_suppliers' && ! $user->rights->fournisseur->commande->lire) continue; + if ($graphfiles == 'propal' && !$user->rights->propale->lire) continue; + if ($graphfiles == 'order' && !$user->rights->commande->lire) continue; + if ($graphfiles == 'invoices' && !$user->rights->facture->lire) continue; + if ($graphfiles == 'proposals_suppliers' && !$user->rights->supplier_proposal->lire) continue; + if ($graphfiles == 'invoices_suppliers' && !$user->rights->fournisseur->facture->lire) continue; + if ($graphfiles == 'orders_suppliers' && !$user->rights->fournisseur->commande->lire) continue; if ($i % 2 == 0) @@ -389,16 +389,16 @@ if ($result || empty($id)) } // Date generation - if ($graphfiles[$key]['output'] && ! $px->isGraphKo()) + if ($graphfiles[$key]['output'] && !$px->isGraphKo()) { - if (file_exists($dir."/".$graphfiles[$key]['file']) && filemtime($dir."/".$graphfiles[$key]['file'])) $dategenerated=$langs->trans("GeneratedOn", dol_print_date(filemtime($dir."/".$graphfiles[$key]['file']), "dayhour")); - else $dategenerated=$langs->trans("GeneratedOn", dol_print_date(dol_now(), "dayhour")); + if (file_exists($dir."/".$graphfiles[$key]['file']) && filemtime($dir."/".$graphfiles[$key]['file'])) $dategenerated = $langs->trans("GeneratedOn", dol_print_date(filemtime($dir."/".$graphfiles[$key]['file']), "dayhour")); + else $dategenerated = $langs->trans("GeneratedOn", dol_print_date(dol_now(), "dayhour")); } else { - $dategenerated=($mesg?''.$mesg.'':$langs->trans("ChartNotGenerated")); + $dategenerated = ($mesg ? ''.$mesg.'' : $langs->trans("ChartNotGenerated")); } - $linktoregenerate='id).((string) $type != ''?'&type='.$type:'').'&action=recalcul&mode='.$mode.'&search_year='.$search_year.'&search_categ='.$search_categ.'">'.img_picto($langs->trans("ReCalculate").' ('.$dategenerated.')', 'refresh').''; + $linktoregenerate = 'id).((string) $type != '' ? '&type='.$type : '').'&action=recalcul&mode='.$mode.'&search_year='.$search_year.'&search_categ='.$search_categ.'">'.img_picto($langs->trans("ReCalculate").' ('.$dategenerated.')', 'refresh').''; // Show graph print '
'; @@ -436,7 +436,7 @@ if ($result || empty($id)) } } -if (! $id) +if (!$id) { dol_fiche_end(); } diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php index efdaebab889..bab78114fed 100644 --- a/htdocs/product/traduction.php +++ b/htdocs/product/traduction.php @@ -36,14 +36,14 @@ $langs->loadLangs(array('products', 'languages')); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action=GETPOST('action', 'alpha'); -$cancel=GETPOST('cancel', 'alpha'); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); // Security check -$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); -$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); -if ($user->socid) $socid=$user->socid; -$result=restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); /* @@ -73,21 +73,21 @@ $cancel != $langs->trans("Cancel") && $current_lang = $langs->getDefaultLang(); // update de l'objet - if ( $_POST["forcelangprod"] == $current_lang ) + if ($_POST["forcelangprod"] == $current_lang) { $object->label = $_POST["libelle"]; - $object->description = dol_htmlcleanlastbr($_POST["desc"]); + $object->description = dol_htmlcleanlastbr($_POST["desc"]); $object->other = dol_htmlcleanlastbr($_POST["other"]); } else { $object->multilangs[$_POST["forcelangprod"]]["label"] = $_POST["libelle"]; - $object->multilangs[$_POST["forcelangprod"]]["description"] = dol_htmlcleanlastbr($_POST["desc"]); + $object->multilangs[$_POST["forcelangprod"]]["description"] = dol_htmlcleanlastbr($_POST["desc"]); $object->multilangs[$_POST["forcelangprod"]]["other"] = dol_htmlcleanlastbr($_POST["other"]); } // sauvegarde en base - if ( $object->setMultiLangs($user) > 0 ) + if ($object->setMultiLangs($user) > 0) { $action = ''; } @@ -109,21 +109,21 @@ $cancel != $langs->trans("Cancel") && foreach ($object->multilangs as $key => $value) // enregistrement des nouvelles valeurs dans l'objet { - if ( $key == $current_lang ) + if ($key == $current_lang) { $object->label = $_POST["libelle-".$key]; - $object->description = dol_htmlcleanlastbr($_POST["desc-".$key]); + $object->description = dol_htmlcleanlastbr($_POST["desc-".$key]); $object->other = dol_htmlcleanlastbr($_POST["other-".$key]); } else { $object->multilangs[$key]["label"] = $_POST["libelle-".$key]; - $object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]); + $object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]); $object->multilangs[$key]["other"] = dol_htmlcleanlastbr($_POST["other-".$key]); } } - if ( $object->setMultiLangs($user) > 0 ) + if ($object->setMultiLangs($user) > 0) { $action = ''; } @@ -141,10 +141,10 @@ $cancel != $langs->trans("Cancel") && { $object = new Product($db); $object->fetch($id); - $langtodelete=GETPOST('langdel', 'alpha'); + $langtodelete = GETPOST('langdel', 'alpha'); - if ( $object->delMultiLangs($langtodelete, $user) > 0 ) + if ($object->delMultiLangs($langtodelete, $user) > 0) { $action = ''; } @@ -168,28 +168,28 @@ $helpurl = ''; $shortlabel = dol_trunc($object->label, 16); if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { - $title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('Translation'); - $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Translation'); + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; } if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { - $title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('Translation'); - $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Translation'); + $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; } llxHeader('', $title, $helpurl); $form = new Form($db); -$formadmin=new FormAdmin($db); +$formadmin = new FormAdmin($db); -$head=product_prepare_head($object); -$titre=$langs->trans("CardProduct".$object->type); -$picto=($object->type==Product::TYPE_SERVICE?'service':'product'); +$head = product_prepare_head($object); +$titre = $langs->trans("CardProduct".$object->type); +$picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); // Calculate $cnt_trans $cnt_trans = 0; -if (! empty($object->multilangs)) +if (!empty($object->multilangs)) { foreach ($object->multilangs as $key => $value) { @@ -203,7 +203,7 @@ dol_fiche_head($head, 'translation', $titre, 0, $picto); $linkback = ''.$langs->trans("BackToList").''; $shownav = 1; -if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; +if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', '', '', '', 0, '', '', 1); @@ -242,12 +242,12 @@ if ($action == 'edit') print ''; print ''; - if (! empty($object->multilangs)) + if (!empty($object->multilangs)) { foreach ($object->multilangs as $key => $value) { - $s=picto_from_langcode($key); - print "
".($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', 'class="valigntextbottom"')."
"; + $s = picto_from_langcode($key); + print "
".($s ? $s.' ' : '')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', 'class="valigntextbottom"')."
"; print '
'; print '
'; @@ -256,7 +256,7 @@ if ($action == 'edit') $doleditor = new DolEditor("desc-$key", $object->multilangs[$key]["description"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); $doleditor->Create(); print ''; - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { print '
'.$langs->trans('Other').' ('.$langs->trans("NotUsed").')'; $doleditor = new DolEditor("other-$key", $object->multilangs[$key]["other"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); @@ -279,19 +279,19 @@ if ($action == 'edit') } elseif ($action != 'add') { - if (! empty($object->multilangs)) + if (!empty($object->multilangs)) { foreach ($object->multilangs as $key => $value) { - $s=picto_from_langcode($key); - print ($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', 'class="valigntextbottom"').''; + $s = picto_from_langcode($key); + print ($s ? $s.' ' : '')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', 'class="valigntextbottom"').''; print '
'; print '
'; print ''; print ''; print ''; - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { print ''; } @@ -299,7 +299,7 @@ elseif ($action != 'add') print ''; } } - if (! $cnt_trans && $action != 'add') print '
'. $langs->trans('NoTranslation').'
'; + if (!$cnt_trans && $action != 'add') print '
'.$langs->trans('NoTranslation').'
'; } @@ -331,7 +331,7 @@ if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service $doleditor->Create(); print ''; // Other field (not used) - if (! empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { print ''; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { - $projectid = GETPOST('projectid', 'int')?GETPOST('projectid', 'int'):0; - if(empty($projectid) && ! empty($object->fk_project)) $projectid = $object->fk_project; + $projectid = GETPOST('projectid', 'int') ?GETPOST('projectid', 'int') : 0; + if (empty($projectid) && !empty($object->fk_project)) $projectid = $object->fk_project; if ($origin == 'project') $projectid = ($originid ? $originid : 0); $langs->load("projects"); print ''; - print ''; print ''; } @@ -807,8 +807,8 @@ if ($action == 'create') print ''; print '\n"; print ''; @@ -820,7 +820,7 @@ if ($action == 'create') print ""; // Note Private - if ($object->note_private && ! $user->socid) + if ($object->note_private && !$user->socid) { print ''; print ''; // Dim @@ -844,8 +844,8 @@ if ($action == 'create') print ' x '; print ' x '; print ' '; - $text=$formproduct->selectMeasuringUnits("size_units", "size", GETPOST('size_units', 'int'), 0, 2); - $htmltext=$langs->trans("KeepEmptyForAutoCalculation"); + $text = $formproduct->selectMeasuringUnits("size_units", "size", GETPOST('size_units', 'int'), 0, 2); + $htmltext = $langs->trans("KeepEmptyForAutoCalculation"); print $form->textwithpicto($text, $htmltext); print ''; @@ -865,12 +865,12 @@ if ($action == 'create') // Other attributes $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"', 'socid'=>$socid); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $recept, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $recept, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Here $object can be of an object Order $extrafields->fetch_name_optionals_label($object->table_element); - if (empty($reshook) && ! empty($extrafields->attributes[$object->table_element]['label'])) { + if (empty($reshook) && !empty($extrafields->attributes[$object->table_element]['label'])) { // copy from order if ($object->fetch_optionals() > 0) { $recept->array_options = array_merge($recept->array_options, $object->array_options); @@ -884,12 +884,12 @@ if ($action == 'create') print ''; print ''; print ''; } // Document model - include_once DOL_DOCUMENT_ROOT . '/core/modules/reception/modules_reception.php'; + include_once DOL_DOCUMENT_ROOT.'/core/modules/reception/modules_reception.php'; $liste = ModelePdfReception::liste_modeles($db); if (count($liste) > 1) @@ -906,14 +906,14 @@ if ($action == 'create') // Reception lines - $numAsked=0; + $numAsked = 0; $dispatchLines = array(); foreach ($_POST as $key => $value) { // without batch module enabled if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) { - $numAsked ++; + $numAsked++; // $numline=$reg[2] + 1; // line of product $numline = $numAsked; @@ -922,7 +922,7 @@ if ($action == 'create') $ent = "entrepot_".$reg[1].'_'.$reg[2]; $pu = "pu_".$reg[1].'_'.$reg[2]; // This is unit price including discount $fk_commandefourndet = "fk_commandefourndet_".$reg[1].'_'.$reg[2]; - $dispatchLines[$numAsked]=array('prod' => GETPOST($prod, 'int'), 'qty' =>GETPOST($qty), 'ent' =>GETPOST($ent, 'int'), 'pu' =>GETPOST($pu), 'comment' =>GETPOST('comment'),'fk_commandefourndet' => GETPOST($fk_commandefourndet, 'int')); + $dispatchLines[$numAsked] = array('prod' => GETPOST($prod, 'int'), 'qty' =>GETPOST($qty), 'ent' =>GETPOST($ent, 'int'), 'pu' =>GETPOST($pu), 'comment' =>GETPOST('comment'), 'fk_commandefourndet' => GETPOST($fk_commandefourndet, 'int')); } // with batch module enabled @@ -941,7 +941,7 @@ if ($action == 'create') $dDLUO = dol_mktime(12, 0, 0, $_POST['dluo_'.$reg[1].'_'.$reg[2].'month'], $_POST['dluo_'.$reg[1].'_'.$reg[2].'day'], $_POST['dluo_'.$reg[1].'_'.$reg[2].'year']); $dDLC = dol_mktime(12, 0, 0, $_POST['dlc_'.$reg[1].'_'.$reg[2].'month'], $_POST['dlc_'.$reg[1].'_'.$reg[2].'day'], $_POST['dlc_'.$reg[1].'_'.$reg[2].'year']); $fk_commandefourndet = 'fk_commandefourndet_'.$reg[1].'_'.$reg[2]; - $dispatchLines[$numAsked]=array('prod' => GETPOST($prod, 'int'), 'qty' =>GETPOST($qty), 'ent' =>GETPOST($ent, 'int'), 'pu' =>GETPOST($pu), 'comment' =>GETPOST('comment'),'fk_commandefourndet' => GETPOST($fk_commandefourndet, 'int'),'DLC'=> $dDLC,'DLUO'=> $dDLUO,'lot'=> GETPOST($lot, 'alpha')); + $dispatchLines[$numAsked] = array('prod' => GETPOST($prod, 'int'), 'qty' =>GETPOST($qty), 'ent' =>GETPOST($ent, 'int'), 'pu' =>GETPOST($pu), 'comment' =>GETPOST('comment'), 'fk_commandefourndet' => GETPOST($fk_commandefourndet, 'int'), 'DLC'=> $dDLC, 'DLUO'=> $dDLUO, 'lot'=> GETPOST($lot, 'alpha')); } } @@ -949,16 +949,16 @@ if ($action == 'create') print ''; + if ($conf->global->TAKEPOS_AUTO_PRINT_TICKETS) $sectionwithinvoicelink .= ''; } /* @@ -469,9 +469,9 @@ $form = new Form($db); '."\n"; + print ''."\n"; } @@ -589,7 +589,7 @@ print ''; } -if ($_SESSION["basiclayout"]!=1) +if ($_SESSION["basiclayout"] != 1) { - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; } print "\n"; -if ($_SESSION["basiclayout"]==1) +if ($_SESSION["basiclayout"] == 1) { - if ($mobilepage=="cats") + if ($mobilepage == "cats") { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $categorie = new Categorie($db); $categories = $categorie->get_full_arbo('product'); $htmlforlines = ''; - foreach ($categories as $row){ - $htmlforlines.= ''; - $htmlforlines.= ''; - $htmlforlines.= ''."\n"; + foreach ($categories as $row) { + $htmlforlines .= ''; + $htmlforlines .= ''; + $htmlforlines .= ''."\n"; } - $htmlforlines.= '
'.$langs->trans('Label').''.$object->multilangs[$key]["label"].'
'.$langs->trans('Description').''.$object->multilangs[$key]["description"].'
'.$langs->trans('Other').' ('.$langs->trans("NotUsed").')'.$object->multilangs[$key]["other"].'
'.$langs->trans('Other').' ('.$langs->trans("NotUsed").''; $doleditor = new DolEditor('other', '', '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index c641007ecf1..cc4fad1cb60 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -44,40 +44,40 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; -if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -if (! empty($conf->fournisseur->enabled)){ +if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +if (!empty($conf->fournisseur->enabled)) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.dispatch.class.php'; } -if (! empty($conf->productbatch->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; -if (! empty($conf->projet->enabled)) { +if (!empty($conf->productbatch->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.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'; } -$langs->loadLangs(array("receptions","companies","bills",'deliveries','orders','stocks','other','propal','sendings')); +$langs->loadLangs(array("receptions", "companies", "bills", 'deliveries', 'orders', 'stocks', 'other', 'propal', 'sendings')); if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); -if (! empty($conf->productbatch->enabled)) $langs->load('productbatch'); +if (!empty($conf->productbatch->enabled)) $langs->load('productbatch'); -$origin = GETPOST('origin', 'alpha')?GETPOST('origin', 'alpha'):'reception'; // Example: commande, propal -$origin_id = GETPOST('id', 'int')?GETPOST('id', 'int'):''; +$origin = GETPOST('origin', 'alpha') ?GETPOST('origin', 'alpha') : 'reception'; // Example: commande, propal +$origin_id = GETPOST('id', 'int') ?GETPOST('id', 'int') : ''; $id = $origin_id; -if (empty($origin_id)) $origin_id = GETPOST('origin_id', 'int'); // Id of order or propal -if (empty($origin_id)) $origin_id = GETPOST('object_id', 'int'); // Id of order or propal -if (empty($origin_id)) $origin_id = GETPOST('originid', 'int'); // Id of order or propal -$ref=GETPOST('ref', 'alpha'); -$line_id = GETPOST('lineid', 'int')?GETPOST('lineid', 'int'):''; +if (empty($origin_id)) $origin_id = GETPOST('origin_id', 'int'); // Id of order or propal +if (empty($origin_id)) $origin_id = GETPOST('object_id', 'int'); // Id of order or propal +if (empty($origin_id)) $origin_id = GETPOST('originid', 'int'); // Id of order or propal +$ref = GETPOST('ref', 'alpha'); +$line_id = GETPOST('lineid', 'int') ?GETPOST('lineid', 'int') : ''; // Security check -$socid=''; -if ($user->socid) $socid=$user->socid; +$socid = ''; +if ($user->socid) $socid = $user->socid; -if ($origin == 'reception') $result=restrictedArea($user, $origin, $id); +if ($origin == 'reception') $result = restrictedArea($user, $origin, $id); else { - $result=restrictedArea($user, 'reception'); - if($origin == 'supplierorder'){ + $result = restrictedArea($user, 'reception'); + if ($origin == 'supplierorder') { if (empty($user->rights->fournisseur->commande->lire) && empty($user->rights->fournisseur->commande->read)) accessforbidden(); }elseif (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) accessforbidden(); } @@ -88,12 +88,12 @@ if (GETPOST('modelselected')) { $action = 'presend'; } $confirm = GETPOST('confirm', 'alpha'); -$cancel = GETPOST('cancel', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); //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)); $object = new Reception($db); $extrafields = new ExtraFields($db); @@ -103,12 +103,12 @@ $extrafields->fetch_name_optionals_label($object->table_element); $extrafields->fetch_name_optionals_label($object->table_element_line); // Load object. Make an object->fetch -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('receptioncard','globalcard')); +$hookmanager->initHooks(array('receptioncard', 'globalcard')); -$permissiondellink=$user->rights->reception->creer; // Used by the include of actions_dellink.inc.php +$permissiondellink = $user->rights->reception->creer; // Used by the include of actions_dellink.inc.php //var_dump($object->lines[0]->detail_batch); @@ -116,8 +116,8 @@ $permissiondellink=$user->rights->reception->creer; // Used by the include of ac * Actions */ -$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)) $object->fetch($id); // show reception also after canceling modification } - 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 // Reopen if ($action == 'reopen' && $user->rights->reception->creer) @@ -150,11 +150,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); } @@ -190,7 +190,7 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute')); if ($ret < 0) $error++; - if (! $error) + if (!$error) { // Actions on extra fields (by external module or standard code) // TODO le hook fait double emploi avec le trigger !! @@ -248,7 +248,7 @@ if (empty($reshook)) $object->socid = $objectsrc->socid; $object->ref_supplier = GETPOST('ref_supplier', 'alpha'); $object->model_pdf = GETPOST('model'); - $object->date_delivery = $date_delivery; // Date delivery planed + $object->date_delivery = $date_delivery; // Date delivery planed $object->fk_delivery_address = $objectsrc->fk_delivery_address; $object->shipping_method_id = GETPOST('shipping_method_id', 'int'); $object->tracking_number = GETPOST('tracking_number', 'alpha'); @@ -306,8 +306,8 @@ if (empty($reshook)) for ($i = 1; $i <= $num; $i++) { $lineToTest = ''; - foreach($objectsrc->lines as $linesrc){ - if($linesrc->id == GETPOST($idl, 'int'))$lineToTest=$linesrc; + foreach ($objectsrc->lines as $linesrc) { + if ($linesrc->id == GETPOST($idl, 'int'))$lineToTest = $linesrc; } $qty = "qtyl".$i; $comment = "comment".$i; @@ -350,9 +350,9 @@ if (empty($reshook)) // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; - if (! $error) + if (!$error) { - $ret=$object->create($user); // This create reception (like Odoo picking) and line of receptions. Stock movement will when validating reception. + $ret = $object->create($user); // This create reception (like Odoo picking) and line of receptions. Stock movement will when validating reception. if ($ret <= 0) { @@ -367,7 +367,7 @@ if (empty($reshook)) $error++; } - if (! $error) + if (!$error) { $db->commit(); header("Location: card.php?id=".$object->id); @@ -376,14 +376,14 @@ if (empty($reshook)) else { $db->rollback(); - $_GET["commande_id"]=GETPOST('commande_id', 'int'); - $action='create'; + $_GET["commande_id"] = GETPOST('commande_id', 'int'); + $action = 'create'; } } elseif ($action == 'confirm_valid' && $confirm == 'yes' && - ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->reception->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->reception->reception_advance->validate))) + ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->reception_advance->validate))) ) { $object->fetch_thirdparty(); @@ -404,14 +404,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); } } @@ -443,10 +443,10 @@ if (empty($reshook)) elseif ($action == 'setdate_livraison' && $user->rights->reception->creer) { //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; - $datedelivery=dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); + $datedelivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); $object->fetch($id); - $result=$object->set_date_livraison($user, $datedelivery); + $result = $object->set_date_livraison($user, $datedelivery); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -461,23 +461,23 @@ if (empty($reshook)) || $action == 'settrueDepth' || $action == 'setshipping_method_id') { - $error=0; + $error = 0; if ($action == 'settracking_number') $object->tracking_number = trim(GETPOST('tracking_number', 'alpha')); if ($action == 'settracking_url') $object->tracking_url = trim(GETPOST('tracking_url', 'int')); - if ($action == 'settrueWeight') { + if ($action == 'settrueWeight') { $object->trueWeight = trim(GETPOST('trueWeight', 'int')); $object->weight_units = GETPOST('weight_units', 'int'); } if ($action == 'settrueWidth') $object->trueWidth = trim(GETPOST('trueWidth', 'int')); - if ($action == 'settrueHeight'){ + if ($action == 'settrueHeight') { $object->trueHeight = trim(GETPOST('trueHeight', 'int')); $object->size_units = GETPOST('size_units', 'int'); } if ($action == 'settrueDepth') $object->trueDepth = trim(GETPOST('trueDepth', 'int')); if ($action == 'setshipping_method_id') $object->shipping_method_id = trim(GETPOST('shipping_method_id', 'int')); - if (! $error) + if (!$error) { if ($object->update($user) >= 0) { @@ -487,7 +487,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } - $action=""; + $action = ""; } // Build document @@ -498,10 +498,10 @@ if (empty($reshook)) // Define output language $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=$reception->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 = $reception->thirdparty->default_lang; + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); @@ -510,7 +510,7 @@ if (empty($reshook)) if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); - $action=''; + $action = ''; } } @@ -519,9 +519,9 @@ if (empty($reshook)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $upload_dir = $conf->reception->dir_output ; - $file = $upload_dir . '/' . GETPOST('file'); - $ret=dol_delete_file($file, 0, 0, 0, $object); + $upload_dir = $conf->reception->dir_output; + $file = $upload_dir.'/'.GETPOST('file'); + $ret = dol_delete_file($file, 0, 0, 0, $object); if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); } @@ -530,8 +530,8 @@ if (empty($reshook)) { $object->fetch($id); $result = $object->set_billed(); - if($result >= 0) { - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); + if ($result >= 0) { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit(); } } @@ -540,8 +540,8 @@ if (empty($reshook)) { $object->fetch($id); $result = $object->setClosed(); - if($result >= 0) { - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); + if ($result >= 0) { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit(); } } @@ -549,20 +549,20 @@ if (empty($reshook)) /* * delete a line */ - elseif ($action == 'deleteline' && ! empty($line_id)) + elseif ($action == 'deleteline' && !empty($line_id)) { $object->fetch($id); $lines = $object->lines; $line = new CommandeFournisseurDispatch($db); $num_prod = count($lines); - for ($i = 0 ; $i < $num_prod ; $i++) + for ($i = 0; $i < $num_prod; $i++) { if ($lines[$i]->id == $line_id) { // delete single warehouse line $line->id = $line_id; - if (! $error && $line->delete($user) < 0) + if (!$error && $line->delete($user) < 0) { $error++; } @@ -570,8 +570,8 @@ if (empty($reshook)) unset($_POST["lineid"]); } - if(! $error) { - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); + if (!$error) { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit(); } else @@ -619,7 +619,7 @@ if (empty($reshook)) $line->qty = GETPOST($qty, 'int'); $line->comment = GETPOST($comment, 'alpha'); - if(!empty($conf->productbatch->enabled)){ + if (!empty($conf->productbatch->enabled)) { $batch = "batch".$line_id; $dlc = "dlc".$line_id; $dluo = "dluo".$line_id; @@ -656,7 +656,7 @@ if (empty($reshook)) unset($_POST["lineid"]); - if (! $error) { + if (!$error) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; @@ -665,7 +665,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); } @@ -676,22 +676,22 @@ if (empty($reshook)) } else { - 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(); } } elseif ($action == 'updateline' && $user->rights->reception->creer && 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(); } include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - if (empty($id)) $id=$facid; - $trigger_name='RECEPTION_SENTBYMAIL'; - $paramname='id'; - $mode='emailfromreception'; - $trackid='shi'.$object->id; + if (empty($id)) $id = $facid; + $trigger_name = 'RECEPTION_SENTBYMAIL'; + $paramname = 'id'; + $mode = 'emailfromreception'; + $trackid = 'shi'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; } @@ -705,7 +705,7 @@ llxHeader('', $langs->trans('Reception'), 'Reception'); $form = new Form($db); $formfile = new FormFile($db); $formproduct = new FormProduct($db); -if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } $product_static = new Product($db); $reception_static = new Reception($db); @@ -715,7 +715,7 @@ if ($action == 'create2') { print load_fiche_titre($langs->trans("CreateReception")).'
'; print $langs->trans("ReceptionCreationIsDoneFromOrder"); - $action=''; $id=''; $ref=''; + $action = ''; $id = ''; $ref = ''; } // Mode creation. @@ -724,14 +724,14 @@ if ($action == 'create') $recept = new Reception($db); print load_fiche_titre($langs->trans("CreateReception")); - if (! $origin) + if (!$origin) { setEventMessages($langs->trans("ErrorBadParameters"), null, 'errors'); } if ($origin) { - if($origin == 'supplierorder')$classname = 'CommandeFournisseur'; + if ($origin == 'supplierorder')$classname = 'CommandeFournisseur'; else $classname = ucfirst($origin); $object = new $classname($db); @@ -743,7 +743,7 @@ if ($action == 'create') $author = new User($db); $author->fetch($object->user_author_id); - if (! empty($conf->stock->enabled)) $entrepot = new Entrepot($db); + if (!empty($conf->stock->enabled)) $entrepot = new Entrepot($db); print ''; print ''; @@ -762,11 +762,11 @@ if ($action == 'create') // Ref print '
'; - if ($origin == 'supplierorder' && ! empty($conf->fournisseur->enabled)) + if ($origin == 'supplierorder' && !empty($conf->fournisseur->enabled)) { print $langs->trans("RefOrder").''.img_object($langs->trans("ShowOrder"), 'order').' '.$object->ref; } - if ($origin == 'propal' && ! empty($conf->propal->enabled)) + if ($origin == 'propal' && !empty($conf->propal->enabled)) { print $langs->trans("RefProposal").''.img_object($langs->trans("ShowProposal"), 'propal').' '.$object->ref; } @@ -788,17 +788,17 @@ if ($action == 'create') print '
' . $langs->trans("Project") . ''; + print ''.$langs->trans("Project").''; $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0); - print '   id).'">' . $langs->trans("AddProject") . ''; + print '   id).'">'.$langs->trans("AddProject").''; print '
'.$langs->trans("DateDeliveryPlanned").''; //print dol_print_date($object->date_livraison,"day"); // date_livraison come from order and will be stored into date_delivery planed. - $date_delivery = ($date_delivery?$date_delivery:$object->date_livraison); // $date_delivery comes from GETPOST - print $form->selectDate($date_delivery?$date_delivery:-1, 'date_delivery', 1, 1, 1); + $date_delivery = ($date_delivery ? $date_delivery : $object->date_livraison); // $date_delivery comes from GETPOST + print $form->selectDate($date_delivery ? $date_delivery : -1, 'date_delivery', 1, 1, 1); print "
'.$langs->trans("NotePrivate").''; @@ -833,8 +833,8 @@ if ($action == 'create') print '
'; print $langs->trans("Weight"); print ' '; - $text=$formproduct->selectMeasuringUnits("weight_units", "weight", GETPOST('weight_units', 'int'), 0, 2); - $htmltext=$langs->trans("KeepEmptyForAutoCalculation"); + $text = $formproduct->selectMeasuringUnits("weight_units", "weight", GETPOST('weight_units', 'int'), 0, 2); + $htmltext = $langs->trans("KeepEmptyForAutoCalculation"); print $form->textwithpicto($text, $htmltext); 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 '
'; print ''; if ($conf->global->TAKEPOS_BAR_RESTAURANT) { - $sql="SELECT floor, label FROM ".MAIN_DB_PREFIX."takepos_floor_tables where rowid=".((int) $place); + $sql = "SELECT floor, label FROM ".MAIN_DB_PREFIX."takepos_floor_tables where rowid=".((int) $place); $resql = $db->query($sql); $obj = $db->fetch_object($resql); if ($obj) @@ -598,83 +598,83 @@ if ($conf->global->TAKEPOS_BAR_RESTAURANT) $floor = $obj->floor; } // In phone version only show when is invoice page - if ($mobilepage=="invoice" || $mobilepage=="") { - print $langs->trans('Place') . " " . $label . " - "; - print $langs->trans('Floor') . " " . $floor . " - "; + if ($mobilepage == "invoice" || $mobilepage == "") { + print $langs->trans('Place')." ".$label." - "; + print $langs->trans('Floor')." ".$floor." - "; } } // In phone version only show when is invoice page -if ($mobilepage=="invoice" || $mobilepage=="") { +if ($mobilepage == "invoice" || $mobilepage == "") { print $langs->trans('TotalTTC'); - print ' : ' . price($invoice->total_ttc, 1, '', 1, -1, -1, $conf->currency) . ''; - print '
' . $sectionwithinvoicelink; + print ' : '.price($invoice->total_ttc, 1, '', 1, -1, -1, $conf->currency).''; + print '
'.$sectionwithinvoicelink; print '
' . $langs->trans('ReductionShort') . '' . $langs->trans('Qty') . '' . $langs->trans('TotalTTCShort') . ''.$langs->trans('ReductionShort').''.$langs->trans('Qty').''.$langs->trans('TotalTTCShort').'
'; - $htmlforlines.= $row['label']; - $htmlforlines.= '
'; + $htmlforlines .= $row['label']; + $htmlforlines .= '
'; - $htmlforlines.= '
'; + $htmlforlines .= '
'; + $htmlforlines .= '
'; print $htmlforlines; } - if ($mobilepage=="products") + if ($mobilepage == "products") { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $object = new Categorie($db); $catid = GETPOST('catid', 'int'); - $result=$object->fetch($catid); + $result = $object->fetch($catid); $prods = $object->getObjectsInCateg("product"); $htmlforlines = ''; foreach ($prods as $row) { - $htmlforlines.= ''; - $htmlforlines.= ''; - $htmlforlines.= $row->label; - $htmlforlines.= ''; - $htmlforlines.= ''."\n"; + $htmlforlines .= ''; + $htmlforlines .= ''; + $htmlforlines .= $row->label; + $htmlforlines .= ''; + $htmlforlines .= ''."\n"; } - $htmlforlines.= ''; + $htmlforlines .= ''; print $htmlforlines; } - if ($mobilepage=="places") + if ($mobilepage == "places") { - $sql="SELECT rowid, entity, label, leftpos, toppos, floor FROM ".MAIN_DB_PREFIX."takepos_floor_tables"; + $sql = "SELECT rowid, entity, label, leftpos, toppos, floor FROM ".MAIN_DB_PREFIX."takepos_floor_tables"; $resql = $db->query($sql); $rows = array(); $htmlforlines = ''; - while($row = $db->fetch_array($resql)){ + while ($row = $db->fetch_array($resql)) { $rows[] = $row; - $htmlforlines.= ''; - $htmlforlines.= ''; - $htmlforlines.= $row['label']; - $htmlforlines.= ''; - $htmlforlines.= ''."\n"; + $htmlforlines .= ''; + $htmlforlines .= ''; + $htmlforlines .= $row['label']; + $htmlforlines .= ''; + $htmlforlines .= ''."\n"; } - $htmlforlines.= ''; + $htmlforlines .= ''; print $htmlforlines; } } @@ -682,50 +682,50 @@ if ($_SESSION["basiclayout"]==1) if ($placeid > 0) { //In Phone basic layout hide some content depends situation - if ($_SESSION["basiclayout"]==1 && $mobilepage!="invoice" && $action!="order") return; + if ($_SESSION["basiclayout"] == 1 && $mobilepage != "invoice" && $action != "order") return; if (is_array($invoice->lines) && count($invoice->lines)) { $tmplines = array_reverse($invoice->lines); - foreach($tmplines as $line) + foreach ($tmplines as $line) { $htmlforlines = ''; - $htmlforlines.= 'special_code == "4") { - $htmlforlines.= ' order'; + $htmlforlines .= ' order'; } - $htmlforlines.= '" id="' . $line->id . '">'; - $htmlforlines.= ''; + $htmlforlines .= '" id="'.$line->id.'">'; + $htmlforlines .= ''; //if ($line->product_label) $htmlforlines.= ''.$line->product_label.''; if (isset($line->product_type)) { - if (empty($line->product_type)) $htmlforlines.=img_object('', 'product').' '; - else $htmlforlines.=img_object('', 'service').' '; + if (empty($line->product_type)) $htmlforlines .= img_object('', 'product').' '; + else $htmlforlines .= img_object('', 'service').' '; } - if ($line->product_label) $htmlforlines.= $line->product_label; - if ($line->product_label && $line->desc) $htmlforlines.= '
'; + if ($line->product_label) $htmlforlines .= $line->product_label; + if ($line->product_label && $line->desc) $htmlforlines .= '
'; if ($line->product_label != $line->desc) { $firstline = dolGetFirstLineOfText($line->desc); if ($firstline != $line->desc) { - $htmlforlines.= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc); + $htmlforlines .= $form->textwithpicto(dolGetFirstLineOfText($line->desc), $line->desc); } else { - $htmlforlines.= $line->desc; + $htmlforlines .= $line->desc; } } - if (!empty($line->array_options['options_order_notes'])) $htmlforlines.= "
(".$line->array_options['options_order_notes'].")"; - if ($_SESSION["basiclayout"]!=1) + if (!empty($line->array_options['options_order_notes'])) $htmlforlines .= "
(".$line->array_options['options_order_notes'].")"; + if ($_SESSION["basiclayout"] != 1) { - $htmlforlines.= ''; - $htmlforlines.= '' . vatrate($line->remise_percent, true) . ''; - $htmlforlines.= '' . $line->qty . ''; - $htmlforlines.= '' . price($line->total_ttc) . ''; + $htmlforlines .= ''; + $htmlforlines .= ''.vatrate($line->remise_percent, true).''; + $htmlforlines .= ''.$line->qty.''; + $htmlforlines .= ''.price($line->total_ttc).''; } - $htmlforlines.= ''."\n"; + $htmlforlines .= ''."\n"; print $htmlforlines; } @@ -743,7 +743,7 @@ print ''; if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}) { - $constforcompanyid='CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; + $constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; $soc = new Societe($db); if ($invoice->socid > 0) $soc->fetch($invoice->socid); else $soc->fetch($conf->global->$constforcompanyid); @@ -752,7 +752,7 @@ if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takep print $langs->trans("Customer").': '.$soc->name; $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; - if (! empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") + if (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") { $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; $warehouse = new Entrepot($db); @@ -761,16 +761,16 @@ if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takep } // Module Adherent - if (! empty($conf->adherent->enabled)) + if (!empty($conf->adherent->enabled)) { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; $langs->load("members"); print '
'.$langs->trans("Member").': '; - $adh=new Adherent($db); - $result=$adh->fetch('', '', $invoice->socid); + $adh = new Adherent($db); + $result = $adh->fetch('', '', $invoice->socid); if ($result > 0) { - $adh->ref=$adh->getFullName($langs); + $adh->ref = $adh->getFullName($langs); print $adh->getFullName($langs); print '
'.$langs->trans("Type").': '.$adh->type; if ($adh->datefin) @@ -797,7 +797,7 @@ if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takep if ($action == "search") { print '
- '; } diff --git a/htdocs/takepos/send.php b/htdocs/takepos/send.php index 93fb753c2f3..7c5676c5a1f 100644 --- a/htdocs/takepos/send.php +++ b/htdocs/takepos/send.php @@ -25,15 +25,15 @@ //if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); -require '../main.inc.php'; // Load $user and permissions +require '../main.inc.php'; // Load $user and permissions 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.'/compta/facture/class/facture.class.php'; $invoiceid = GETPOST('facid', 'int'); @@ -48,16 +48,16 @@ if ($invoiceid > 0) } else { - $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; $resql = $db->query($sql); $obj = $db->fetch_object($resql); if ($obj) { $invoiceid = $obj->rowid; } - if (! $invoiceid) + if (!$invoiceid) { - $invoiceid=0; // Invoice does not exist yet + $invoiceid = 0; // Invoice does not exist yet } else { @@ -82,7 +82,7 @@ if ($invoice->id > 0) } $alreadypayed = (is_object($invoice) ? ($invoice->total_ttc - $remaintopay) : 0); -if ($conf->global->TAKEPOS_NUMPAD==0) print "var received='';"; +if ($conf->global->TAKEPOS_NUMPAD == 0) print "var received='';"; else print "var received=0;"; ?> @@ -98,10 +98,10 @@ else print "var received=0;"; $('.change1').val(parseFloat(received)); alreadypaydplusreceived=price2numjs(alreadypayed + parseFloat(received)); //console.log("already+received = "+alreadypaydplusreceived); - //console.log("total_ttc = "+total_ttc;?>); - if (alreadypaydplusreceived > total_ttc;?>) + //console.log("total_ttc = "+total_ttc; ?>); + if (alreadypaydplusreceived > total_ttc; ?>) { - var change=parseFloat(alreadypayed + parseFloat(received) - total_ttc;?>); + var change=parseFloat(alreadypayed + parseFloat(received) - total_ttc; ?>); $('.change2').html(pricejs(change, 'MT')); $('.change2').val(change); $('.change1').removeClass('colorred'); @@ -113,7 +113,7 @@ else print "var received=0;"; { $('.change2').html(pricejs(0, 'MT')); $('.change2').val(0); - if (alreadypaydplusreceived == total_ttc;?>) + if (alreadypaydplusreceived == total_ttc; ?>) { $('.change1').removeClass('colorred'); $('.change1').addClass('colorgreen'); @@ -140,7 +140,7 @@ function Print(id){
-
+

diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index fd7de709fe4..9df1afb01de 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -32,9 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/userbankaccount.class.php'; -if (! empty($conf->holiday->enabled)) require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; -if (! empty($conf->expensereport->enabled)) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; -if (! empty($conf->salaries->enabled)) require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; +if (!empty($conf->holiday->enabled)) require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; +if (!empty($conf->expensereport->enabled)) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +if (!empty($conf->salaries->enabled)) require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; // Load translation files required by page $langs->loadLangs(array('companies', 'commercial', 'banks', 'bills', 'trips', 'holiday', 'salaries')); @@ -45,23 +45,23 @@ $action = GETPOST("action", 'alpha'); $cancel = GETPOST('cancel', 'alpha'); // Security check -$socid=0; +$socid = 0; if ($user->socid > 0) $socid = $user->socid; -$feature2 = (($socid && $user->rights->user->self->creer)?'':'user'); +$feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user'); // Ok if user->rights->salaries->read or user->rights->hrm->read //$result = restrictedArea($user, 'salaries|hrm', $id, 'user&user', $feature2); -$ok=false; -if ($user->id == $id) $ok=true; // A user can always read its own card -if (! empty($user->rights->salaries->read)) $ok=true; -if (! empty($user->rights->hrm->read)) $ok=true; -if (! empty($user->rights->expensereport->lire) && ($user->id == $object->id || $user->rights->expensereport->readall)) $ok=true; -if (! $ok) +$ok = false; +if ($user->id == $id) $ok = true; // A user can always read its own card +if (!empty($user->rights->salaries->read)) $ok = true; +if (!empty($user->rights->hrm->read)) $ok = true; +if (!empty($user->rights->expensereport->lire) && ($user->id == $object->id || $user->rights->expensereport->readall)) $ok = true; +if (!$ok) { accessforbidden(); } $object = new User($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref, '', 1); $object->getrights(); @@ -72,7 +72,7 @@ if ($id > 0 || ! empty($ref)) * Actions */ -if ($action == 'add' && ! $cancel) +if ($action == 'add' && !$cancel) { // Modification $account = new UserBankAccount($db); @@ -94,10 +94,10 @@ if ($action == 'add' && ! $cancel) $result = $account->create($user); - if (! $result) + if (!$result) { setEventMessages($account->error, $account->errors, 'errors'); - $action='edit'; // Force chargement page edition + $action = 'edit'; // Force chargement page edition } else { @@ -106,14 +106,14 @@ if ($action == 'add' && ! $cancel) } } -if ($action == 'update' && ! $cancel) +if ($action == 'update' && !$cancel) { // Modification $account = new UserBankAccount($db); $account->fetch($bankid); - $account->userid = $object->id; + $account->userid = $object->id; $account->bank = GETPOST('bank', 'alpha'); $account->label = GETPOST('label', 'alpha'); @@ -130,10 +130,10 @@ if ($action == 'update' && ! $cancel) $result = $account->update($user); - if (! $result) + if (!$result) { setEventMessages($account->error, $account->errors, 'errors'); - $action='edit'; // Force chargement page edition + $action = 'edit'; // Force chargement page edition } else { @@ -154,7 +154,7 @@ llxHeader(null, $langs->trans("BankAccounts")); $head = user_prepare_head($object); $account = new UserBankAccount($db); -if (! $bankid) +if (!$bankid) { $account->fetch(0, '', $id); } @@ -162,7 +162,7 @@ else { $account->fetch($bankid); } -if (empty($account->userid)) $account->userid=$object->id; +if (empty($account->userid)) $account->userid = $object->id; if ($id && $bankid && $action == 'edit' && $user->rights->user->user->creer) @@ -239,9 +239,9 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco } print ''.$langs->trans("IBAN").''; - print ''.$account->iban . ' '; - if (! empty($account->iban)) { - if (! checkIbanForAccount($account)) { + print ''.$account->iban.' '; + if (!empty($account->iban)) { + if (!checkIbanForAccount($account)) { print img_picto($langs->trans("IbanNotValid"), 'warning'); } else { print img_picto($langs->trans("IbanValid"), 'info'); @@ -251,8 +251,8 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco print ''.$langs->trans("BIC").''; print ''.$account->bic.' '; - if (! empty($account->bic)) { - if (! checkSwiftForAccount($account)) { + if (!empty($account->bic)) { + if (!checkSwiftForAccount($account)) { print img_picto($langs->trans("SwiftNotValid"), 'warning'); } else { print img_picto($langs->trans("SwiftValid"), 'info'); @@ -275,7 +275,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco print ''; // Check BBAN - if ($account->label && ! checkBanForAccount($account)) + if ($account->label && !checkBanForAccount($account)) { print '
'.$langs->trans("RIBControlError").'
'; } @@ -283,24 +283,24 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco print '
'; // Nbre max d'elements des petites listes - $MAXLIST=$conf->global->MAIN_SIZE_SHORTLIST_LIMIT; + $MAXLIST = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; /* * Last salaries */ - if (! empty($conf->salaries->enabled) && + if (!empty($conf->salaries->enabled) && ($user->rights->salaries->read && $object->id == $user->id) ) { $salary = new PaymentSalary($db); $sql = "SELECT ps.rowid, ps.datesp, ps.dateep, ps.amount"; - $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as ps"; - $sql.= " WHERE ps.fk_user = ".$object->id; - $sql.= " AND ps.entity = ".$conf->entity; - $sql.= " ORDER BY ps.datesp DESC"; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as ps"; + $sql .= " WHERE ps.fk_user = ".$object->id; + $sql .= " AND ps.entity = ".$conf->entity; + $sql .= " ORDER BY ps.datesp DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -308,7 +308,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco print ''; print ''; - print '
'; + print ''; print ''; @@ -342,19 +342,19 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco /* * Last holidays */ - if (! empty($conf->holiday->enabled) && + if (!empty($conf->holiday->enabled) && ($user->rights->holiday->read_all || ($user->rights->holiday->read && $object->id == $user->id)) ) { $holiday = new Holiday($db); $sql = "SELECT h.rowid, h.statut, h.fk_type, h.date_debut, h.date_fin, h.halfday"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday as h"; - $sql.= " WHERE h.fk_user = ".$object->id; - $sql.= " AND h.entity = ".$conf->entity; - $sql.= " ORDER BY h.date_debut DESC"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday as h"; + $sql .= " WHERE h.fk_user = ".$object->id; + $sql .= " AND h.entity = ".$conf->entity; + $sql .= " ORDER BY h.date_debut DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -362,7 +362,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco print '
'.$langs->trans("LastSalaries", ($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllSalaries").''.$num.''; print '
'.$langs->trans("LastSalaries", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllSalaries").''.$num.'
'; print ''; - print '
'; + print ''; print ''; @@ -376,7 +376,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco $holiday->id = $objp->rowid; $holiday->ref = $objp->rowid; $holiday->fk_type = $objp->fk_type; - $nbopenedday=num_open_day($db->jdate($objp->date_debut), $db->jdate($objp->date_fin), 0, 1, $objp->halfday); + $nbopenedday = num_open_day($db->jdate($objp->date_debut), $db->jdate($objp->date_fin), 0, 1, $objp->halfday); print $holiday->getNomUrl(1); print '\n"; @@ -398,19 +398,19 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco /* * Last expense report */ - if (! empty($conf->expensereport->enabled) && + if (!empty($conf->expensereport->enabled) && ($user->rights->expensereport->readall || ($user->rights->expensereport->lire && $object->id == $user->id)) ) { $exp = new ExpenseReport($db); $sql = "SELECT e.rowid, e.ref, e.fk_statut, e.date_debut, e.total_ttc"; - $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as e"; - $sql.= " WHERE e.fk_user_author = ".$object->id; - $sql.= " AND e.entity = ".$conf->entity; - $sql.= " ORDER BY e.date_debut DESC"; + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as e"; + $sql .= " WHERE e.fk_user_author = ".$object->id; + $sql .= " AND e.entity = ".$conf->entity; + $sql .= " ORDER BY e.date_debut DESC"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -418,7 +418,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco print '
'.$langs->trans("LastHolidays", ($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllHolidays").''.$num.''; print '
'.$langs->trans("LastHolidays", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllHolidays").''.$num.'
'.dol_print_date($db->jdate($objp->date_debut), 'day')."
'; print ''; - print '
'; + print ''; print ''; @@ -472,7 +472,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco } // Edit -if ($id && ($action == 'edit' || $action == 'create' ) && $user->rights->user->user->creer) +if ($id && ($action == 'edit' || $action == 'create') && $user->rights->user->user->creer) { $title = $langs->trans("User"); dol_fiche_head($head, 'bank', $title, 0, 'user'); diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 62aa5027cf4..3d80906003d 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -96,19 +96,19 @@ $pagenext = $page + 1; //if (! $sortfield) $sortfield='name'; //if (! $sortorder) $sortorder='ASC'; -if (empty($action)) $action='preview'; +if (empty($action)) $action = 'preview'; -$object=new Website($db); -$objectpage=new WebsitePage($db); +$object = new Website($db); +$objectpage = new WebsitePage($db); -$object->fetchAll(); // Init $object->records with list of websites +$object->fetchAll(); // Init $object->records with list of websites // If website not defined, we take first found -if (! ($websiteid > 0) && empty($websitekey)) +if (!($websiteid > 0) && empty($websitekey)) { - foreach($object->records as $key => $valwebsite) + foreach ($object->records as $key => $valwebsite) { - $websitekey=$valwebsite->ref; + $websitekey = $valwebsite->ref; break; } } @@ -137,15 +137,15 @@ if (($pageid > 0 || $pageref) && $action != 'addcontainer') { if ($object->fk_default_home > 0) { - $res = $objectpage->fetch($object->fk_default_home, $object->id, ''); // We search first page of web site + $res = $objectpage->fetch($object->fk_default_home, $object->id, ''); // We search first page of web site if ($res > 0) $pageid = $object->fk_default_home; } else { - $res = $objectpage->fetch(0, $object->id, ''); // We search first page of web site + $res = $objectpage->fetch(0, $object->id, ''); // We search first page of web site if ($res == 0) // Page was not found, we reset it { - $objectpage=new WebsitePage($db); + $objectpage = new WebsitePage($db); } else // We found a page, we set pageid to it. { @@ -166,61 +166,61 @@ if (empty($pageid) && empty($pageref) && $object->id > 0 && $action != 'createco $pageid = $object->fk_default_home; if (empty($pageid)) { - $array=$objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl'); - if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); - $atleastonepage=(is_array($array) && count($array) > 0); + $array = $objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl'); + if (!is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); + $atleastonepage = (is_array($array) && count($array) > 0); - $firstpageid=0;$homepageid=0; - foreach($array as $key => $valpage) + $firstpageid = 0; $homepageid = 0; + foreach ($array as $key => $valpage) { - if (empty($firstpageid)) $firstpageid=$valpage->id; - if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid=$valpage->id; + if (empty($firstpageid)) $firstpageid = $valpage->id; + if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid = $valpage->id; } - $pageid=($homepageid?$homepageid:$firstpageid); // We choose home page and if not defined yet, we take first page + $pageid = ($homepageid ? $homepageid : $firstpageid); // We choose home page and if not defined yet, we take first page } } global $dolibarr_main_data_root; -$pathofwebsite=$dolibarr_main_data_root.'/website/'.$websitekey; -$filehtmlheader=$pathofwebsite.'/htmlheader.html'; -$filecss=$pathofwebsite.'/styles.css.php'; -$filejs=$pathofwebsite.'/javascript.js.php'; -$filerobot=$pathofwebsite.'/robots.txt'; -$filehtaccess=$pathofwebsite.'/.htaccess'; -$filetpl=$pathofwebsite.'/page'.$pageid.'.tpl.php'; -$fileindex=$pathofwebsite.'/index.php'; -$filewrapper=$pathofwebsite.'/wrapper.php'; -$filemanifestjson=$pathofwebsite.'/manifest.json.php'; -$filereadme=$pathofwebsite.'/README.md'; +$pathofwebsite = $dolibarr_main_data_root.'/website/'.$websitekey; +$filehtmlheader = $pathofwebsite.'/htmlheader.html'; +$filecss = $pathofwebsite.'/styles.css.php'; +$filejs = $pathofwebsite.'/javascript.js.php'; +$filerobot = $pathofwebsite.'/robots.txt'; +$filehtaccess = $pathofwebsite.'/.htaccess'; +$filetpl = $pathofwebsite.'/page'.$pageid.'.tpl.php'; +$fileindex = $pathofwebsite.'/index.php'; +$filewrapper = $pathofwebsite.'/wrapper.php'; +$filemanifestjson = $pathofwebsite.'/manifest.json.php'; +$filereadme = $pathofwebsite.'/README.md'; // 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 $permtouploadfile = $user->rights->website->write; $diroutput = $conf->medias->multidir_output[$conf->entity]; -$relativepath=$section_dir; +$relativepath = $section_dir; $upload_dir = $diroutput.'/'.$relativepath; $htmlheadercontentdefault = ''; -$htmlheadercontentdefault.=''."\n"; -$htmlheadercontentdefault.=''."\n"; -$htmlheadercontentdefault.=''."\n"; -$htmlheadercontentdefault.=''."\n"; -$htmlheadercontentdefault.=''."\n"; -$htmlheadercontentdefault.=''."\n"; -$htmlheadercontentdefault.=''."\n"; -$htmlheadercontentdefault.=''."\n"; +$htmlheadercontentdefault .= ''."\n"; +$htmlheadercontentdefault .= ''."\n"; +$htmlheadercontentdefault .= ''."\n"; +$htmlheadercontentdefault .= ''."\n"; +$htmlheadercontentdefault .= ''."\n"; +$htmlheadercontentdefault .= ''."\n"; +$htmlheadercontentdefault .= ''."\n"; +$htmlheadercontentdefault .= ''."\n"; $manifestjsoncontentdefault = ''; -$manifestjsoncontentdefault.= '{ +$manifestjsoncontentdefault .= '{ "name": "MyWebsite", "short_name": "MyWebsite", "start_url": "/", @@ -305,17 +305,17 @@ if ($cancel) } $savbacktopage = $backtopage; -$backtopage = $_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid.(GETPOST('section_dir', 'alpha')?'§ion_dir='.urlencode(GETPOST('section_dir', 'alpha')):''); // used after a confirm_deletefile into actions_linkedfiles.inc.php +$backtopage = $_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid.(GETPOST('section_dir', 'alpha') ? '§ion_dir='.urlencode(GETPOST('section_dir', 'alpha')) : ''); // used after a confirm_deletefile into actions_linkedfiles.inc.php include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; $backtopage = $savbacktopage; -if ($action == 'renamefile') $action='file_manager'; // After actions_linkedfiles, if action were renamefile, we set it to 'file_manager' +if ($action == 'renamefile') $action = 'file_manager'; // After actions_linkedfiles, if action were renamefile, we set it to 'file_manager' if ($action == 'seteditinline') { dolibarr_set_const($db, 'WEBSITE_EDITINLINE', 1); setEventMessages($langs->trans("FeatureNotYetAvailable"), null, 'warnings'); - dolibarr_set_const($db, 'WEBSITE_SUBCONTAINERSINLINE', 0); // Force disable of 'Include dynamic content' + dolibarr_set_const($db, 'WEBSITE_SUBCONTAINERSINLINE', 0); // Force disable of 'Include dynamic content' header("Location: ".$_SERVER["PHP_SELF"].'?website='.GETPOST('website', 'alphanohtml').'&pageid='.GETPOST('pageid', 'int')); exit; } @@ -328,7 +328,7 @@ if ($action == 'unseteditinline') if ($action == 'setshowsubcontainers') { dolibarr_set_const($db, 'WEBSITE_SUBCONTAINERSINLINE', 1); - dolibarr_set_const($db, 'WEBSITE_EDITINLINE', 0); // Force disable of edit inline + dolibarr_set_const($db, 'WEBSITE_EDITINLINE', 0); // Force disable of edit inline header("Location: ".$_SERVER["PHP_SELF"].'?website='.GETPOST('website', 'alphanohtml').'&pageid='.GETPOST('pageid', 'int')); exit; } @@ -374,28 +374,28 @@ if ($action == 'addsite') { $db->begin(); - if (GETPOST('virtualhost', 'alpha') && ! preg_match('/^http/', GETPOST('virtualhost', 'alpha'))) + if (GETPOST('virtualhost', 'alpha') && !preg_match('/^http/', GETPOST('virtualhost', 'alpha'))) { $error++; setEventMessages($langs->trans('ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv("VirtualHost")), null, 'errors'); } - if (! $error && ! GETPOST('WEBSITE_REF', 'alpha')) + if (!$error && !GETPOST('WEBSITE_REF', 'alpha')) { $error++; $langs->load("errors"); setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors'); } - if (! $error && ! preg_match('/^[a-z0-9_\-\.]+$/i', GETPOST('WEBSITE_REF', 'alpha'))) + if (!$error && !preg_match('/^[a-z0-9_\-\.]+$/i', GETPOST('WEBSITE_REF', 'alpha'))) { $error++; $langs->load("errors"); setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("Ref")), null, 'errors'); } - if (! $error) + if (!$error) { - $tmpobject=new Website($db); + $tmpobject = new Website($db); $tmpobject->ref = GETPOST('WEBSITE_REF', 'alpha'); $tmpobject->description = GETPOST('WEBSITE_DESCRIPTION', 'alpha'); $tmpobject->virtualhost = GETPOST('virtualhost', 'alpha'); @@ -408,11 +408,11 @@ if ($action == 'addsite') } } - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("SiteAdded", $object->ref), null, 'mesgs'); - $action=''; + $action = ''; header("Location: ".$_SERVER["PHP_SELF"].'?website='.$tmpobject->ref); exit; @@ -420,10 +420,10 @@ if ($action == 'addsite') else { $db->rollback(); - $action='createsite'; + $action = 'createsite'; } - if (! $error) + if (!$error) { $action = 'preview'; $id = $object->id; @@ -440,9 +440,9 @@ if ($action == 'addcontainer') $objectpage->fk_website = $object->id; if (GETPOSTISSET('fetchexternalurl')) { - $urltograb=GETPOST('externalurl', 'alpha'); - $grabimages=GETPOST('grabimages', 'alpha'); - $grabimagesinto=GETPOST('grabimagesinto', 'alpha'); + $urltograb = GETPOST('externalurl', 'alpha'); + $grabimages = GETPOST('grabimages', 'alpha'); + $grabimagesinto = GETPOST('grabimagesinto', 'alpha'); //var_dump($grabimages);exit; } @@ -457,7 +457,7 @@ if ($action == 'addcontainer') setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("URL")), null, 'errors'); $action = 'createcontainer'; } - elseif (! preg_match('/^http/', $urltograb)) + elseif (!preg_match('/^http/', $urltograb)) { $error++; $langs->load("errors"); @@ -465,16 +465,16 @@ if ($action == 'addcontainer') $action = 'createcontainer'; } - if (! $error) + if (!$error) { // Clean url to grab, so url can be // http://www.example.com/ or http://www.example.com/dir1/ or http://www.example.com/dir1/aaa $urltograbwithoutdomainandparam = preg_replace('/^https?:\/\/[^\/]+\/?/i', '', $urltograb); //$urltograbwithoutdomainandparam = preg_replace('/^file:\/\/[^\/]+\/?/i', '', $urltograb); $urltograbwithoutdomainandparam = preg_replace('/\?.*$/', '', $urltograbwithoutdomainandparam); - if (empty($urltograbwithoutdomainandparam) && ! preg_match('/\/$/', $urltograb)) + if (empty($urltograbwithoutdomainandparam) && !preg_match('/\/$/', $urltograb)) { - $urltograb.='/'; + $urltograb .= '/'; } $pageurl = dol_sanitizeFileName(preg_replace('/[\/\.]/', '-', preg_replace('/\/+$/', '', $urltograbwithoutdomainandparam))); @@ -493,31 +493,31 @@ if ($action == 'addcontainer') { setEventMessages($langs->trans("AliasPageAlreadyExists", $pageurl), null, 'errors'); $error++; - $action='createcontainer'; + $action = 'createcontainer'; } } - if (! $error) + if (!$error) { $tmp = getURLContent($urltograb); if ($tmp['curl_error_no']) { $error++; setEventMessages('Error getting '.$urltograb.': '.$tmp['curl_error_msg'], null, 'errors'); - $action='createcontainer'; + $action = 'createcontainer'; } elseif ($tmp['http_code'] != '200') { $error++; setEventMessages('Error getting '.$urltograb.': '.$tmp['http_code'], null, 'errors'); - $action='createcontainer'; + $action = 'createcontainer'; } else { // Remove comments $tmp['content'] = removeHtmlComment($tmp['content']); - $regs=array(); + $regs = array(); preg_match('/(.*)<\/head>/ims', $tmp['content'], $regs); $head = $regs[1]; @@ -527,21 +527,21 @@ if ($action == 'addcontainer') if (empty($objectpage->pageurl)) { $tmpdomain = getDomainFromURL($urltograb); - $objectpage->pageurl=$tmpdomain.'-home'; + $objectpage->pageurl = $tmpdomain.'-home'; } $objectpage->aliasalt = ''; if (preg_match('/^(\d+)\-/', basename($urltograb), $regs)) $objectpage->aliasalt = $regs[1]; - $regtmp=array(); + $regtmp = array(); if (preg_match('/(.*)<\/title>/ims', $head, $regtmp)) { $objectpage->title = $regtmp[1]; } if (preg_match('/<meta name="title"[^"]+content="([^"]+)"/ims', $head, $regtmp)) { - if (empty($objectpage->title)) $objectpage->title = $regtmp[1]; // If title not found into <title>, we get it from <meta title> + if (empty($objectpage->title)) $objectpage->title = $regtmp[1]; // If title not found into <title>, we get it from <meta title> } if (preg_match('/<meta name="description"[^"]+content="([^"]+)"/ims', $head, $regtmp)) { @@ -553,7 +553,7 @@ if ($action == 'addcontainer') } if (preg_match('/<html\s+lang="([^"]+)"/ims', $tmp['content'], $regtmp)) { - $tmplang=explode('-', $regtmp[1]); + $tmplang = explode('-', $regtmp[1]); $objectpage->lang = $tmplang[0].($tmplang[1] ? '_'.strtoupper($tmplang[1]) : ''); } @@ -563,7 +563,7 @@ if ($action == 'addcontainer') $objectpage->content = preg_replace('/^.*<body(\s[^>]*)*>/ims', '', $objectpage->content); $objectpage->content = preg_replace('/<\/body(\s[^>]*)*>.*$/ims', '', $objectpage->content); - $absoluteurlinaction=$urltograbdirwithoutslash; + $absoluteurlinaction = $urltograbdirwithoutslash; // TODO Replace 'action="$urltograbdirwithoutslash' into action="/" // TODO Replace 'action="$urltograbdirwithoutslash..."' into action="..." // TODO Replace 'a href="$urltograbdirwithoutslash' into a href="/" @@ -598,11 +598,11 @@ if ($action == 'addcontainer') $linkwithoutdomain = $regs[2][$key]; if (preg_match('/^\//', $regs[2][$key])) { - $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot + $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot } else { - $urltograbbis = $urltograbdirwithoutslash.'/'.$regs[2][$key]; // We use dir of grabbed file + $urltograbbis = $urltograbdirwithoutslash.'/'.$regs[2][$key]; // We use dir of grabbed file } //$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; @@ -667,11 +667,11 @@ if ($action == 'addcontainer') $linkwithoutdomain = $regs[2][$key]; if (preg_match('/^\//', $regs[2][$key])) { - $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot + $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key]; // We use dirroot } else { - $urltograbbis = $urltograbdirwithoutslash.'/'.$regs[2][$key]; // We use dir of grabbed file + $urltograbbis = $urltograbdirwithoutslash.'/'.$regs[2][$key]; // We use dir of grabbed file } //$filetosave = $conf->medias->multidir_output[$conf->entity].'/css/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; @@ -696,14 +696,14 @@ if ($action == 'addcontainer') $errorforsubresource++; setEventMessages('Error getting link tag url '.$urltograbbis.': '.$tmpgeturl['curl_error_msg'], null, 'errors'); dol_syslog('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg']); - $action='createcontainer'; + $action = 'createcontainer'; } elseif ($tmpgeturl['http_code'] != '200') { $errorforsubresource++; setEventMessages('Error getting link tag url '.$urltograbbis.': '.$tmpgeturl['http_code'], null, 'errors'); dol_syslog('Error getting '.$urltograbbis.': '.$tmpgeturl['curl_error_msg']); - $action='createcontainer'; + $action = 'createcontainer'; } else { @@ -726,7 +726,7 @@ if ($action == 'addcontainer') // @chmod($file, octdec($conf->global->MAIN_UMASK)); // $filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; - $pagecsscontent.='/* Content of file '.$urltograbbis.' */'."\n"; + $pagecsscontent .= '/* Content of file '.$urltograbbis.' */'."\n"; getAllImages($object, $objectpage, $urltograbbis, $tmpgeturl['content'], $action, 1, $grabimages, $grabimagesinto); @@ -738,19 +738,19 @@ if ($action == 'addcontainer') $contentforlessc = $lesscobj->compile($contentforlessc); //var_dump($contentforlessc); exit; - $pagecsscontent.=$contentforlessc."\n"; + $pagecsscontent .= $contentforlessc."\n"; //$pagecsscontent.=$tmpgeturl['content']."\n"; } catch (exception $e) { //echo "failed to compile lessc"; dol_syslog("Failed to compile the CSS from URL ".$urltograbbis." with lessc: ".$e->getMessage(), LOG_WARNING); - $pagecsscontent.=$tmpgeturl['content']."\n"; + $pagecsscontent .= $tmpgeturl['content']."\n"; } $objectpage->htmlheader = preg_replace('/'.preg_quote($regs[0][$key], '/').'\n*/ims', '', $objectpage->htmlheader); } } - $pagecsscontent.='</style>'; + $pagecsscontent .= '</style>'; //var_dump($pagecsscontent); //print dol_escape_htmltag($tmp);exit; @@ -786,11 +786,11 @@ if ($action == 'addcontainer') $objectpage->lang = GETPOST('WEBSITE_LANG', 'aZ09'); $objectpage->htmlheader = GETPOST('htmlheader', 'none'); - $substitutionarray=array(); - $substitutionarray['__WEBSITE_CREATE_BY__']=$user->getFullName($langs); + $substitutionarray = array(); + $substitutionarray['__WEBSITE_CREATE_BY__'] = $user->getFullName($langs); $sample = GETPOST('sample', 'alpha'); - if (empty($sample)) $sample='empty'; + if (empty($sample)) $sample = 'empty'; $pathtosample = DOL_DOCUMENT_ROOT.'/website/samples/page-sample-'.$sample.'.html'; @@ -798,57 +798,57 @@ if ($action == 'addcontainer') $objectpage->content = make_substitutions(@file_get_contents($pathtosample), $substitutionarray); } - if (! $error) + if (!$error) { if (empty($objectpage->pageurl)) { $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_PAGENAME")), null, 'errors'); $error++; - $action='createcontainer'; + $action = 'createcontainer'; } - elseif (! preg_match('/^[a-z0-9\-\_]+$/i', $objectpage->pageurl)) + elseif (!preg_match('/^[a-z0-9\-\_]+$/i', $objectpage->pageurl)) { $langs->load("errors"); setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities('WEBSITE_PAGENAME')), null, 'errors'); $error++; - $action='createcontainer'; + $action = 'createcontainer'; } if (empty($objectpage->title)) { $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_TITLE")), null, 'errors'); $error++; - $action='createcontainer'; + $action = 'createcontainer'; } } - if (! $error) + if (!$error) { $res = $objectpage->create($user); if ($res <= 0) { $error++; setEventMessages($objectpage->error, $objectpage->errors, 'errors'); - $action='createcontainer'; + $action = 'createcontainer'; } } - if (! $error) + if (!$error) { - if (! empty($objectpage->content)) + if (!empty($objectpage->content)) { - $filealias=$pathofwebsite.'/'.$objectpage->pageurl.'.php'; - $filetpl=$pathofwebsite.'/page'.$objectpage->id.'.tpl.php'; + $filealias = $pathofwebsite.'/'.$objectpage->pageurl.'.php'; + $filetpl = $pathofwebsite.'/page'.$objectpage->id.'.tpl.php'; // Save page alias - $result=dolSavePageAlias($filealias, $object, $objectpage); - if (! $result) + $result = dolSavePageAlias($filealias, $object, $objectpage); + if (!$result) { setEventMessages('Failed to write file '.$filealias, null, 'errors'); } // Save page of content - $result=dolSavePageContent($filetpl, $object, $objectpage); + $result = dolSavePageContent($filetpl, $object, $objectpage); if ($result) { setEventMessages($langs->trans("Saved"), null, 'mesgs'); @@ -860,75 +860,75 @@ if ($action == 'addcontainer') } } } - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("PageAdded", $objectpage->pageurl), null, 'mesgs'); - $action=''; + $action = ''; } else { $db->rollback(); } - if (! $error) + if (!$error) { $pageid = $objectpage->id; // To generate the CSS, robot and htmlheader file. // Check symlink to medias and restore it if ko - $pathtomedias=DOL_DATA_ROOT.'/medias'; - $pathtomediasinwebsite=$pathofwebsite.'/medias'; - if (! is_link(dol_osencode($pathtomediasinwebsite))) + $pathtomedias = DOL_DATA_ROOT.'/medias'; + $pathtomediasinwebsite = $pathofwebsite.'/medias'; + if (!is_link(dol_osencode($pathtomediasinwebsite))) { dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite); - dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists + dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists $result = symlink($pathtomedias, $pathtomediasinwebsite); } - if (! dol_is_file($filehtmlheader)) + if (!dol_is_file($filehtmlheader)) { - $htmlheadercontent ="<html>\n"; - $htmlheadercontent.=$htmlheadercontentdefault; - $htmlheadercontent.="</html>"; - $result=dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent); + $htmlheadercontent = "<html>\n"; + $htmlheadercontent .= $htmlheadercontentdefault; + $htmlheadercontent .= "</html>"; + $result = dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent); } - if (! dol_is_file($filecss)) + if (!dol_is_file($filecss)) { $csscontent = "/* CSS content (all pages) */\nbody.bodywebsite { margin: 0; font-family: 'Open Sans', sans-serif; }\n.bodywebsite h1 { margin-top: 0; margin-bottom: 0; padding: 10px;}"; - $result=dolSaveCssFile($filecss, $csscontent); + $result = dolSaveCssFile($filecss, $csscontent); } - if (! dol_is_file($filejs)) + if (!dol_is_file($filejs)) { $jscontent = "/* JS content (all pages) */\n"; - $result=dolSaveJsFile($filejs, $jscontent); + $result = dolSaveJsFile($filejs, $jscontent); } - if (! dol_is_file($filerobot)) + if (!dol_is_file($filerobot)) { $robotcontent = "# Robot file. Generated with Dolibarr\nUser-agent: *\nAllow: /public/\nDisallow: /administrator/"; - $result=dolSaveRobotFile($filerobot, $robotcontent); + $result = dolSaveRobotFile($filerobot, $robotcontent); } - if (! dol_is_file($filehtaccess)) + if (!dol_is_file($filehtaccess)) { $htaccesscontent = "# Order allow,deny\n# Deny from all"; - $result=dolSaveHtaccessFile($filehtaccess, $htaccesscontent); + $result = dolSaveHtaccessFile($filehtaccess, $htaccesscontent); } - if (! dol_is_file($filemanifestjson)) + if (!dol_is_file($filemanifestjson)) { $manifestjsoncontent = ""; - $result=dolSaveManifestJson($filemanifestjson, $manifestjsoncontent); + $result = dolSaveManifestJson($filemanifestjson, $manifestjsoncontent); } - if (! dol_is_file($filereadme)) + if (!dol_is_file($filereadme)) { $readmecontent = "Website generated by Dolibarr ERP CRM"; - $result=dolSaveReadme($filereadme, $readmecontent); + $result = dolSaveReadme($filereadme, $readmecontent); } $action = 'preview'; @@ -954,23 +954,23 @@ if ($action == 'confirm_deletesite' && $confirm == 'yes') setEventMessages($object->error, $object->errors, 'errors'); } } - if (! $error) + if (!$error) { if (GETPOST('delete_also_js', 'alpha') == 'on') { - $pathofwebsitejs=DOL_DATA_ROOT.'/medias/js/'.$object->ref; + $pathofwebsitejs = DOL_DATA_ROOT.'/medias/js/'.$object->ref; dol_delete_dir_recursive($pathofwebsitejs); } if (GETPOST('delete_also_medias', 'alpha') == 'on') { - $pathofwebsitemedias=DOL_DATA_ROOT.'/medias/image/'.$object->ref; + $pathofwebsitemedias = DOL_DATA_ROOT.'/medias/image/'.$object->ref; dol_delete_dir_recursive($pathofwebsitemedias); } } - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("SiteDeleted", $object->ref), null, 'mesgs'); @@ -1007,7 +1007,7 @@ if ($action == 'delete') } } - if (! $error) + if (!$error) { $db->commit(); setEventMessages($langs->trans("PageDeleted", $objectpage->pageurl, $websitekey), null, 'mesgs'); @@ -1026,9 +1026,9 @@ if ($action == 'delete') if ($action == 'updatecss') { // If we tried to reload another site/page, we stay on editcss mode. - if (GETPOST('refreshsite') || GETPOST('refreshsite_x') || GETPOST('refreshsite.x') || GETPOST('refreshpage') || GETPOST('refreshpage_x') || GETPOST('refreshpage.x')) + if (GETPOST('refreshsite') || GETPOST('refreshsite_x') || GETPOST('refreshsite.x') || GETPOST('refreshpage') || GETPOST('refreshpage_x') || GETPOST('refreshpage.x')) { - $action='editcss'; + $action = 'editcss'; } else { @@ -1037,14 +1037,14 @@ if ($action == 'updatecss') if (GETPOSTISSET('virtualhost')) { - if (GETPOST('virtualhost', 'alpha') && ! preg_match('/^http/', GETPOST('virtualhost', 'alpha'))) + if (GETPOST('virtualhost', 'alpha') && !preg_match('/^http/', GETPOST('virtualhost', 'alpha'))) { $error++; setEventMessages($langs->trans('ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv("VirtualHost")), null, 'errors'); - $action='editcss'; + $action = 'editcss'; } - if (! $error) + if (!$error) { $object->virtualhost = GETPOST('virtualhost', 'alpha'); @@ -1053,15 +1053,15 @@ if ($action == 'updatecss') { $error++; setEventMessages($object->error, $object->errors, 'errors'); - $action='editcss'; + $action = 'editcss'; } } } - if (! $error) + if (!$error) { // Save master.inc.php file - $filemaster=$pathofwebsite.'/master.inc.php'; + $filemaster = $pathofwebsite.'/master.inc.php'; dol_syslog("Save master file ".$filemaster); @@ -1069,7 +1069,7 @@ if ($action == 'updatecss') // Now generate the master.inc.php page $result = dolSaveMasterFile($filemaster); - if (! $result) + if (!$result) { $error++; setEventMessages('Failed to write file '.$filemaster, null, 'errors'); @@ -1077,7 +1077,7 @@ if ($action == 'updatecss') // Html header file - $htmlheadercontent =''; + $htmlheadercontent = ''; /* We disable php code since htmlheader is never executed as an include but only read by fgets_content. $htmlheadercontent.= "<?php // BEGIN PHP\n"; @@ -1089,7 +1089,7 @@ if ($action == 'updatecss') // $htmlheadercontent.= "header('Content-type: text/html');\n"; // Not required. htmlheader.html is never call as a standalone page $htmlheadercontent.= "// END PHP ?>\n";*/ - $htmlheadercontent.= preg_replace(array('/<html>\n*/ims','/<\/html>\n*/ims'), array('',''), GETPOST('WEBSITE_HTML_HEADER', 'none')); + $htmlheadercontent .= preg_replace(array('/<html>\n*/ims', '/<\/html>\n*/ims'), array('', ''), GETPOST('WEBSITE_HTML_HEADER', 'none')); /*$htmlheadercontent.= "\n".'<?php // BEGIN PHP'."\n"; $htmlheadercontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp);'."\n"; @@ -1098,7 +1098,7 @@ if ($action == 'updatecss') $htmlheadercontent = trim($htmlheadercontent)."\n"; $result = dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent); - if (! $result) + if (!$result) { $error++; setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors'); @@ -1106,30 +1106,30 @@ if ($action == 'updatecss') // Css file - $csscontent =''; + $csscontent = ''; - $csscontent.= "<?php // BEGIN PHP\n"; - $csscontent.= '$websitekey=basename(__DIR__);'."\n"; - $csscontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file. - $csscontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; - $csscontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; - $csscontent.= "ob_start();\n"; - $csscontent.= "if (! headers_sent()) { /* because file is included inline when in edit mode and we don't want warning */ \n"; - $csscontent.= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; - $csscontent.= "header('Content-type: text/css');\n"; - $csscontent.= "}\n"; - $csscontent.= "// END PHP ?>\n"; + $csscontent .= "<?php // BEGIN PHP\n"; + $csscontent .= '$websitekey=basename(__DIR__);'."\n"; + $csscontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file. + $csscontent .= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; + $csscontent .= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; + $csscontent .= "ob_start();\n"; + $csscontent .= "if (! headers_sent()) { /* because file is included inline when in edit mode and we don't want warning */ \n"; + $csscontent .= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; + $csscontent .= "header('Content-type: text/css');\n"; + $csscontent .= "}\n"; + $csscontent .= "// END PHP ?>\n"; - $csscontent.= trim(GETPOST('WEBSITE_CSS_INLINE', 'none'))."\n"; + $csscontent .= trim(GETPOST('WEBSITE_CSS_INLINE', 'none'))."\n"; - $csscontent.= '<?php // BEGIN PHP'."\n"; - $csscontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "css");'."\n"; - $csscontent.= "// END PHP ?>"."\n"; + $csscontent .= '<?php // BEGIN PHP'."\n"; + $csscontent .= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "css");'."\n"; + $csscontent .= "// END PHP ?>"."\n"; dol_syslog("Save css content into ".$filecss); $result = dolSaveCssFile($filecss, $csscontent); - if (! $result) + if (!$result) { $error++; setEventMessages('Failed to write file '.$filecss, null, 'errors'); @@ -1137,26 +1137,26 @@ if ($action == 'updatecss') // Js file - $jscontent =''; + $jscontent = ''; - $jscontent.= "<?php // BEGIN PHP\n"; - $jscontent.= '$websitekey=basename(__DIR__);'."\n"; - $jscontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file. - $jscontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; - $jscontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; - $jscontent.= "ob_start();\n"; - $jscontent.= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; - $jscontent.= "header('Content-type: application/javascript');\n"; - $jscontent.= "// END PHP ?>\n"; + $jscontent .= "<?php // BEGIN PHP\n"; + $jscontent .= '$websitekey=basename(__DIR__);'."\n"; + $jscontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file. + $jscontent .= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; + $jscontent .= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; + $jscontent .= "ob_start();\n"; + $jscontent .= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; + $jscontent .= "header('Content-type: application/javascript');\n"; + $jscontent .= "// END PHP ?>\n"; - $jscontent.= trim(GETPOST('WEBSITE_JS_INLINE', 'none'))."\n"; + $jscontent .= trim(GETPOST('WEBSITE_JS_INLINE', 'none'))."\n"; - $jscontent.= '<?php // BEGIN PHP'."\n"; - $jscontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "js");'."\n"; - $jscontent.= "// END PHP ?>"."\n"; + $jscontent .= '<?php // BEGIN PHP'."\n"; + $jscontent .= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "js");'."\n"; + $jscontent .= "// END PHP ?>"."\n"; $result = dolSaveJsFile($filejs, $jscontent); - if (! $result) + if (!$result) { $error++; setEventMessages('Failed to write file '.$filejs, null, 'errors'); @@ -1164,7 +1164,7 @@ if ($action == 'updatecss') // Robot file - $robotcontent =''; + $robotcontent = ''; /*$robotcontent.= "<?php // BEGIN PHP\n"; $robotcontent.= '$websitekey=basename(__DIR__);'."\n"; @@ -1176,14 +1176,14 @@ if ($action == 'updatecss') $robotcontent.= "header('Content-type: text/css');\n"; $robotcontent.= "// END PHP ?>\n";*/ - $robotcontent.= trim(GETPOST('WEBSITE_ROBOT', 'none'))."\n"; + $robotcontent .= trim(GETPOST('WEBSITE_ROBOT', 'none'))."\n"; /*$robotcontent.= "\n".'<?php // BEGIN PHP'."\n"; $robotcontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "robot");'."\n"; $robotcontent.= "// END PHP ?>"."\n";*/ $result = dolSaveRobotFile($filerobot, $robotcontent); - if (! $result) + if (!$result) { $error++; setEventMessages('Failed to write file '.$filerobot, null, 'errors'); @@ -1191,11 +1191,11 @@ if ($action == 'updatecss') // Htaccess file - $htaccesscontent =''; - $htaccesscontent.= trim(GETPOST('WEBSITE_HTACCESS', 'none'))."\n"; + $htaccesscontent = ''; + $htaccesscontent .= trim(GETPOST('WEBSITE_HTACCESS', 'none'))."\n"; $result = dolSaveHtaccessFile($filehtaccess, $htaccesscontent); - if (! $result) + if (!$result) { $error++; setEventMessages('Failed to write file '.$filehtaccess, null, 'errors'); @@ -1203,26 +1203,26 @@ if ($action == 'updatecss') // manifest.json file - $manifestjsoncontent =''; + $manifestjsoncontent = ''; - $manifestjsoncontent.= "<?php // BEGIN PHP\n"; - $manifestjsoncontent.= '$websitekey=basename(__DIR__);'."\n"; - $manifestjsoncontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file. - $manifestjsoncontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; - $manifestjsoncontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; - $manifestjsoncontent.= "ob_start();\n"; - $manifestjsoncontent.= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; - $manifestjsoncontent.= "header('Content-type: application/manifest+json');\n"; - $manifestjsoncontent.= "// END PHP ?>\n"; + $manifestjsoncontent .= "<?php // BEGIN PHP\n"; + $manifestjsoncontent .= '$websitekey=basename(__DIR__);'."\n"; + $manifestjsoncontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file. + $manifestjsoncontent .= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n"; + $manifestjsoncontent .= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; + $manifestjsoncontent .= "ob_start();\n"; + $manifestjsoncontent .= "header('Cache-Control: max-age=3600, public, must-revalidate');\n"; + $manifestjsoncontent .= "header('Content-type: application/manifest+json');\n"; + $manifestjsoncontent .= "// END PHP ?>\n"; - $manifestjsoncontent.= trim(GETPOST('WEBSITE_MANIFEST_JSON', 'none'))."\n"; + $manifestjsoncontent .= trim(GETPOST('WEBSITE_MANIFEST_JSON', 'none'))."\n"; - $manifestjsoncontent.= '<?php // BEGIN PHP'."\n"; - $manifestjsoncontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'."\n"; - $manifestjsoncontent.= "// END PHP ?>"."\n"; + $manifestjsoncontent .= '<?php // BEGIN PHP'."\n"; + $manifestjsoncontent .= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'."\n"; + $manifestjsoncontent .= "// END PHP ?>"."\n"; $result = dolSaveManifestJson($filemanifestjson, $manifestjsoncontent); - if (! $result) + if (!$result) { $error++; setEventMessages('Failed to write file '.$filemanifestjson, null, 'errors'); @@ -1230,7 +1230,7 @@ if ($action == 'updatecss') // README.md file - $readmecontent =''; + $readmecontent = ''; /*$readmecontent.= "<?php // BEGIN PHP\n"; $readmecontent.= '$websitekey=basename(__DIR__);'."\n"; @@ -1242,14 +1242,14 @@ if ($action == 'updatecss') $readmecontent.= "header('Content-type: application/manifest+json');\n"; $readmecontent.= "// END PHP ?>\n";*/ - $readmecontent.= trim(GETPOST('WEBSITE_README', 'none'))."\n"; + $readmecontent .= trim(GETPOST('WEBSITE_README', 'none'))."\n"; /*$readmecontent.= '<?php // BEGIN PHP'."\n"; $readmecontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'."\n"; $readmecontent.= "// END PHP ?>"."\n";*/ $result = dolSaveReadme($filereadme, $readmecontent); - if (! $result) + if (!$result) { $error++; setEventMessages('Failed to write file '.$filereadme, null, 'errors'); @@ -1257,14 +1257,14 @@ if ($action == 'updatecss') // Message if no error - if (! $error) + if (!$error) { setEventMessages($langs->trans("Saved"), null, 'mesgs'); } - if (! GETPOSTISSET('updateandstay')) // If we click on "Save And Stay", we don not make the redirect + if (!GETPOSTISSET('updateandstay')) // If we click on "Save And Stay", we don not make the redirect { - $action='preview'; + $action = 'preview'; if ($backtopage) { header("Location: ".$backtopage); @@ -1288,13 +1288,13 @@ if ($action == 'setashome') $object->fk_default_home = $pageid; $res = $object->update($user); - if (! $res > 0) + if (!$res > 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); } - if (! $error) + if (!$error) { $db->commit(); @@ -1305,7 +1305,7 @@ if ($action == 'setashome') if ($result) setEventMessages($langs->trans("Saved"), null, 'mesgs'); else setEventMessages('Failed to write file '.$fileindex, null, 'errors'); - $action='preview'; + $action = 'preview'; } else { @@ -1324,12 +1324,12 @@ if ($action == 'updatemeta') $objectpage->fk_website = $object->id; // Check parameters - if (! preg_match('/^[a-z0-9\-\_]+$/i', GETPOST('WEBSITE_PAGENAME', 'alpha'))) + if (!preg_match('/^[a-z0-9\-\_]+$/i', GETPOST('WEBSITE_PAGENAME', 'alpha'))) { $error++; $langs->load("errors"); setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities('WEBSITE_PAGENAME')), null, 'errors'); - $action='editmeta'; + $action = 'editmeta'; } $res = $objectpage->fetch($pageid, $object->id); @@ -1340,9 +1340,9 @@ if ($action == 'updatemeta') } // Check alias not exists - if (! $error && GETPOST('WEBSITE_PAGENAME', 'alpha')) + if (!$error && GETPOST('WEBSITE_PAGENAME', 'alpha')) { - $websitepagetemp=new WebsitePage($db); + $websitepagetemp = new WebsitePage($db); $result = $websitepagetemp->fetch(-1 * $objectpage->id, $object->id, GETPOST('WEBSITE_PAGENAME', 'alpha')); if ($result < 0) { @@ -1359,11 +1359,11 @@ if ($action == 'updatemeta') $action = 'editmeta'; } } - if (! $error && GETPOST('WEBSITE_ALIASALT', 'alpha')) + if (!$error && GETPOST('WEBSITE_ALIASALT', 'alpha')) { - $arrayofaliastotest=explode(',', GETPOST('WEBSITE_ALIASALT', 'alpha')); - $websitepagetemp=new WebsitePage($db); - foreach($arrayofaliastotest as $aliastotest) + $arrayofaliastotest = explode(',', GETPOST('WEBSITE_ALIASALT', 'alpha')); + $websitepagetemp = new WebsitePage($db); + foreach ($arrayofaliastotest as $aliastotest) { $result = $websitepagetemp->fetch(-1 * $objectpage->id, $object->id, $aliastotest); if ($result < 0) @@ -1385,7 +1385,7 @@ if ($action == 'updatemeta') } } - if (! $error) + if (!$error) { $objectpage->old_object = clone $objectpage; @@ -1400,11 +1400,11 @@ if ($action == 'updatemeta') $objectpage->htmlheader = trim(GETPOST('htmlheader', 'none')); $objectpage->fk_page = GETPOST('pageidfortranslation', 'int'); - $newdatecreation=dol_mktime(GETPOST('datecreationhour', 'int'), GETPOST('datecreationmin', 'int'), GETPOST('datecreationsec', 'int'), GETPOST('datecreationmonth', 'int'), GETPOST('datecreationday', 'int'), GETPOST('datecreationyear', 'int')); + $newdatecreation = dol_mktime(GETPOST('datecreationhour', 'int'), GETPOST('datecreationmin', 'int'), GETPOST('datecreationsec', 'int'), GETPOST('datecreationmonth', 'int'), GETPOST('datecreationday', 'int'), GETPOST('datecreationyear', 'int')); if ($newdatecreation) $objectpage->date_creation = $newdatecreation; $res = $objectpage->update($user); - if (! ($res > 0)) + if (!($res > 0)) { $langs->load("errors"); if ($db->lasterrno == 'DB_ERROR_RECORD_ALREADY_EXISTS') @@ -1424,7 +1424,7 @@ if ($action == 'updatemeta') } } - if (! $error) + if (!$error) { $db->commit(); } @@ -1433,32 +1433,32 @@ if ($action == 'updatemeta') $db->rollback(); } - if (! $error) + if (!$error) { - $filemaster=$pathofwebsite.'/master.inc.php'; - $fileoldalias=$pathofwebsite.'/'.$objectpage->old_object->pageurl.'.php'; - $filealias=$pathofwebsite.'/'.$objectpage->pageurl.'.php'; + $filemaster = $pathofwebsite.'/master.inc.php'; + $fileoldalias = $pathofwebsite.'/'.$objectpage->old_object->pageurl.'.php'; + $filealias = $pathofwebsite.'/'.$objectpage->pageurl.'.php'; dol_mkdir($pathofwebsite); // Now generate the master.inc.php page $result = dolSaveMasterFile($filemaster); - if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors'); + if (!$result) setEventMessages('Failed to write file '.$filemaster, null, 'errors'); // Now delete the alias.php page - if (! empty($fileoldalias)) + if (!empty($fileoldalias)) { dol_syslog("We delete old alias page name=".$fileoldalias." to build a new alias page=".$filealias); dol_delete_file($fileoldalias); } // Now delete the alternative alias.php pages - if (! empty($objectpage->old_object->aliasalt)) + if (!empty($objectpage->old_object->aliasalt)) { - $tmpaltaliases=explode(',', $objectpage->old_object->aliasalt); + $tmpaltaliases = explode(',', $objectpage->old_object->aliasalt); if (is_array($tmpaltaliases)) { - foreach($tmpaltaliases as $tmpaliasalt) + foreach ($tmpaltaliases as $tmpaliasalt) { dol_syslog("We delete old alt alias pages name=".trim($tmpaliasalt)); dol_delete_file($pathofwebsite.'/'.trim($tmpaliasalt).'.php'); @@ -1467,20 +1467,20 @@ if ($action == 'updatemeta') } // Save page alias - $result=dolSavePageAlias($filealias, $object, $objectpage); - if (! $result) setEventMessages('Failed to write file '.$filealias, null, 'errors'); + $result = dolSavePageAlias($filealias, $object, $objectpage); + if (!$result) setEventMessages('Failed to write file '.$filealias, null, 'errors'); // Save alt aliases - if (! empty($objectpage->aliasalt)) + if (!empty($objectpage->aliasalt)) { - $tmpaltaliases=explode(',', $objectpage->aliasalt); + $tmpaltaliases = explode(',', $objectpage->aliasalt); if (is_array($tmpaltaliases)) { - foreach($tmpaltaliases as $tmpaliasalt) + foreach ($tmpaltaliases as $tmpaliasalt) { if (trim($tmpaliasalt)) { - $result=dolSavePageAlias($pathofwebsite.'/'.trim($tmpaliasalt).'.php', $object, $objectpage); - if (! $result) setEventMessages('Failed to write file '.$pathofwebsite.'/'.trim($tmpaliasalt).'.php', null, 'errors'); + $result = dolSavePageAlias($pathofwebsite.'/'.trim($tmpaliasalt).'.php', $object, $objectpage); + if (!$result) setEventMessages('Failed to write file '.$pathofwebsite.'/'.trim($tmpaliasalt).'.php', null, 'errors'); } } } @@ -1488,7 +1488,7 @@ if ($action == 'updatemeta') // Save page of content - $result=dolSavePageContent($filetpl, $object, $objectpage); + $result = dolSavePageContent($filetpl, $object, $objectpage); if ($result) { setEventMessages($langs->trans("Saved"), null, 'mesgs'); @@ -1502,7 +1502,7 @@ if ($action == 'updatemeta') //exit; } - $action='preview'; + $action = 'preview'; } } @@ -1518,12 +1518,12 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf $db->begin(); $objectnew = new Website($db); - $result = $objectnew->createFromClone($user, GETPOST('id', 'int'), GETPOST('siteref', 'aZ09'), (GETPOST('newlang', 'aZ09')?GETPOST('newlang', 'aZ09'):'')); + $result = $objectnew->createFromClone($user, GETPOST('id', 'int'), GETPOST('siteref', 'aZ09'), (GETPOST('newlang', 'aZ09') ?GETPOST('newlang', 'aZ09') : '')); if ($result < 0) { $error++; setEventMessages($objectnew->error, $objectnew->errors, 'errors'); - $action='preview'; + $action = 'preview'; $db->rollback(); } @@ -1540,25 +1540,25 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf if ($action == 'confirm_createpagefromclone') { - $istranslation=(GETPOST('is_a_translation', 'aZ09')=='on'?1:0); + $istranslation = (GETPOST('is_a_translation', 'aZ09') == 'on' ? 1 : 0); if ($istranslation) { if (GETPOST('newlang', 'aZ09') == $objectpage->lang) { $error++; setEventMessages($langs->trans("LanguageMustNotBeSameThanClonedPage"), null, 'errors'); - $action='preview'; + $action = 'preview'; } } - if (! $error) + if (!$error) { $db->begin(); $newwebsiteid = GETPOST('newwebsite', 'int'); $pathofwebsitenew = $pathofwebsite; - $tmpwebsite=new Website($db); + $tmpwebsite = new Website($db); if ($newwebsiteid > 0 && $newwebsiteid != $object->id) { $tmpwebsite->fetch($newwebsiteid); @@ -1570,20 +1570,20 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf } $objectpage = new WebsitePage($db); - $resultpage = $objectpage->createFromClone($user, $pageid, GETPOST('pageurl', 'aZ09'), (GETPOST('newlang', 'aZ09')?GETPOST('newlang', 'aZ09'):''), $istranslation, $newwebsiteid); + $resultpage = $objectpage->createFromClone($user, $pageid, GETPOST('pageurl', 'aZ09'), (GETPOST('newlang', 'aZ09') ?GETPOST('newlang', 'aZ09') : ''), $istranslation, $newwebsiteid); if ($resultpage < 0) { $error++; setEventMessages($objectpage->error, $objectpage->errors, 'errors'); - $action='createpagefromclone'; + $action = 'createpagefromclone'; $db->rollback(); } else { - $fileindex=$pathofwebsitenew.'/index.php'; - $filetpl=$pathofwebsitenew.'/page'.$resultpage->id.'.tpl.php'; - $filewrapper=$pathofwebsitenew.'/wrapper.php'; + $fileindex = $pathofwebsitenew.'/index.php'; + $filetpl = $pathofwebsitenew.'/page'.$resultpage->id.'.tpl.php'; + $filewrapper = $pathofwebsitenew.'/wrapper.php'; //var_dump($pathofwebsitenew); //var_dump($filetpl); @@ -1604,15 +1604,15 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf $res = 0; - if (! $error) + if (!$error) { // Check symlink to medias and restore it if ko - $pathtomedias=DOL_DATA_ROOT.'/medias'; - $pathtomediasinwebsite=$pathofwebsite.'/medias'; - if (! is_link(dol_osencode($pathtomediasinwebsite))) + $pathtomedias = DOL_DATA_ROOT.'/medias'; + $pathtomediasinwebsite = $pathofwebsite.'/medias'; + if (!is_link(dol_osencode($pathtomediasinwebsite))) { dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite); - dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists + dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists $result = symlink($pathtomedias, $pathtomediasinwebsite); } @@ -1630,19 +1630,19 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf } else { - $res=0; + $res = 0; if ($object->fk_default_home > 0) { $res = $objectpage->fetch($object->fk_default_home); } - if (! ($res > 0)) + if (!($res > 0)) { $res = $objectpage->fetch(0, $object->id); } } } - if (! $error && $res > 0) + if (!$error && $res > 0) { if ($action == 'updatesource' || $action == 'updatecontent') { @@ -1655,12 +1655,12 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf // Security analysis $phpfullcodestring = dolKeepOnlyPhpCode($objectpage->content); //print dol_escape_htmltag($phpfullcodestring);exit; - $forbiddenphpcommands=array("exec", "passthru", "system", "shell_exec", "proc_open"); + $forbiddenphpcommands = array("exec", "passthru", "system", "shell_exec", "proc_open"); if (empty($conf->global->WEBSITE_PHP_ALLOW_WRITE)) // If option is not on, we disallow functions to write files { - $forbiddenphpcommands=array_merge($forbiddenphpcommands, array("fopen", "file_put_contents", "fputs", "fputscsv", "fwrite", "fpassthru", "unlink", "mkdir", "rmdir", "symlink", "touch", "umask")); + $forbiddenphpcommands = array_merge($forbiddenphpcommands, array("fopen", "file_put_contents", "fputs", "fputscsv", "fwrite", "fpassthru", "unlink", "mkdir", "rmdir", "symlink", "touch", "umask")); } - foreach($forbiddenphpcommands as $forbiddenphpcommand) + foreach ($forbiddenphpcommands as $forbiddenphpcommand) { if (preg_match('/'.$forbiddenphpcommand.'\s*\(/ms', $phpfullcodestring)) { @@ -1696,13 +1696,13 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf if ($action == 'updatecontent') $action = 'editcontent'; } - if (! $error) + if (!$error) { $db->commit(); - $filemaster=$pathofwebsite.'/master.inc.php'; + $filemaster = $pathofwebsite.'/master.inc.php'; //$fileoldalias=$pathofwebsite.'/'.$objectpage->old_object->pageurl.'.php'; - $filealias=$pathofwebsite.'/'.$objectpage->pageurl.'.php'; + $filealias = $pathofwebsite.'/'.$objectpage->pageurl.'.php'; dol_mkdir($pathofwebsite); @@ -1710,22 +1710,22 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf // Now generate the master.inc.php page $result = dolSaveMasterFile($filemaster); - if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors'); + if (!$result) setEventMessages('Failed to write file '.$filemaster, null, 'errors'); // Now generate the alias.php page - if (! empty($fileoldalias)) + if (!empty($fileoldalias)) { dol_syslog("We regenerate alias page new name=".$filealias.", old name=".$fileoldalias); dol_delete_file($fileoldalias); } // Save page alias - $result=dolSavePageAlias($filealias, $object, $objectpage); - if (! $result) setEventMessages('Failed to write file '.$filealias, null, 'errors'); + $result = dolSavePageAlias($filealias, $object, $objectpage); + if (!$result) setEventMessages('Failed to write file '.$filealias, null, 'errors'); // Save page content - $result=dolSavePageContent($filetpl, $object, $objectpage); + $result = dolSavePageContent($filetpl, $object, $objectpage); if ($result) { setEventMessages($langs->trans("Saved"), null, 'mesgs'); @@ -1752,7 +1752,7 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf } else { - if (! $error) + if (!$error) { if (empty($websitekey) || $websitekey == '-1') { @@ -1778,7 +1778,7 @@ if ($action == 'exportsite') header("Content-Type: application/zip"); header("Content-Disposition: attachment; filename=".$file_name); - header("Content-Length: " . filesize($fileofzip)); + header("Content-Length: ".filesize($fileofzip)); readfile($fileofzip); exit; @@ -1793,24 +1793,24 @@ if ($action == 'exportsite') // Import site if ($action == 'importsiteconfirm') { - if (empty($_FILES) && ! GETPOSTISSET('templateuserfile')) + if (empty($_FILES) && !GETPOSTISSET('templateuserfile')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("File")), null, 'errors'); $action = 'importsite'; } else { - if (! empty($_FILES) || GETPOSTISSET('templateuserfile')) + if (!empty($_FILES) || GETPOSTISSET('templateuserfile')) { // Check symlink to medias and restore it if ko - $pathtomedias=DOL_DATA_ROOT.'/medias'; - $pathtomediasinwebsite=$pathofwebsite.'/medias'; - if (! is_link(dol_osencode($pathtomediasinwebsite))) + $pathtomedias = DOL_DATA_ROOT.'/medias'; + $pathtomediasinwebsite = $pathofwebsite.'/medias'; + if (!is_link(dol_osencode($pathtomediasinwebsite))) { dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite); - dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists + dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists $result = symlink($pathtomedias, $pathtomediasinwebsite); - if (! $result) + if (!$result) { setEventMessages($langs->trans("ErrorFieldToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias), null, 'errors'); $action = 'importsite'; @@ -1822,17 +1822,17 @@ if ($action == 'importsiteconfirm') { $fileofzip = DOL_DATA_ROOT.'/doctemplates/websites/'.GETPOST('templateuserfile', 'alpha'); } - elseif (! empty($_FILES)) + elseif (!empty($_FILES)) { - if (is_array($_FILES['userfile']['tmp_name'])) $userfiles=$_FILES['userfile']['tmp_name']; - else $userfiles=array($_FILES['userfile']['tmp_name']); + if (is_array($_FILES['userfile']['tmp_name'])) $userfiles = $_FILES['userfile']['tmp_name']; + else $userfiles = array($_FILES['userfile']['tmp_name']); - foreach($userfiles as $key => $userfile) + foreach ($userfiles as $key => $userfile) { if (empty($_FILES['userfile']['tmp_name'][$key])) { $error++; - if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2){ + if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2) { setEventMessages($langs->trans('ErrorFileSizeTooLarge'), null, 'errors'); $action = 'importsite'; } @@ -1843,7 +1843,7 @@ if ($action == 'importsiteconfirm') } } - if (! $error) + if (!$error) { $upload_dir = $conf->website->dir_temp; $result = dol_add_file_process($upload_dir, 1, -1, 'userfile', ''); @@ -1851,16 +1851,16 @@ if ($action == 'importsiteconfirm') // Get name of file (take last one if several name provided) $fileofzip = $upload_dir.'/unknown'; - foreach($_FILES as $key => $ifile) + foreach ($_FILES as $key => $ifile) { - foreach($ifile['name'] as $key2 => $ifile2) + foreach ($ifile['name'] as $key2 => $ifile2) { - $fileofzip = $upload_dir . '/' .$ifile2; + $fileofzip = $upload_dir.'/'.$ifile2; } } } - if (! $error) + if (!$error) { $result = $object->importWebSite($fileofzip); if ($result < 0) @@ -1893,7 +1893,7 @@ $formadmin = new FormAdmin($db); $formwebsite = new FormWebsite($db); $formother = new FormOther($db); -$help_url=''; +$help_url = ''; $arrayofjs = array( '/includes/ace/src/ace.js', @@ -1904,16 +1904,16 @@ $arrayofjs = array( ); $arrayofcss = array(); -$moreheadcss=''; -$moreheadjs=''; +$moreheadcss = ''; +$moreheadjs = ''; -$arrayofjs[]='includes/jquery/plugins/blockUI/jquery.blockUI.js'; -$arrayofjs[]='core/js/blockUI.js'; // Used by ecm/tpl/enabledfiletreeajax.tpl.php -if (empty($conf->global->MAIN_ECM_DISABLE_JS)) $arrayofjs[]="includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js"; +$arrayofjs[] = 'includes/jquery/plugins/blockUI/jquery.blockUI.js'; +$arrayofjs[] = 'core/js/blockUI.js'; // Used by ecm/tpl/enabledfiletreeajax.tpl.php +if (empty($conf->global->MAIN_ECM_DISABLE_JS)) $arrayofjs[] = "includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js"; -$moreheadjs.='<script type="text/javascript">'."\n"; -$moreheadjs.='var indicatorBlockUI = \''.DOL_URL_ROOT."/theme/".$conf->theme."/img/working.gif".'\';'."\n"; -$moreheadjs.='</script>'."\n"; +$moreheadjs .= '<script type="text/javascript">'."\n"; +$moreheadjs .= 'var indicatorBlockUI = \''.DOL_URL_ROOT."/theme/".$conf->theme."/img/working.gif".'\';'."\n"; +$moreheadjs .= '</script>'."\n"; llxHeader($moreheadcss.$moreheadjs, $langs->trans("WebsiteSetup"), $help_url, '', 0, 0, $arrayofjs, $arrayofcss, '', '', '<!-- Begin div class="fiche" -->'."\n".'<div class="fichebutwithotherclass">'); @@ -1978,11 +1978,11 @@ if ($action == 'replacesiteconfirm') print '<div>'; // Add a margin under toolbar ? -$style=''; -if ($action != 'preview' && $action != 'editcontent' && $action != 'editsource') $style=' margin-bottom: 5px;'; +$style = ''; +if ($action != 'preview' && $action != 'editcontent' && $action != 'editsource') $style = ' margin-bottom: 5px;'; -if (! GETPOST('hide_websitemenu')) +if (!GETPOST('hide_websitemenu')) { $disabled=''; if (empty($user->rights->website->write)) $disabled=' disabled="disabled"'; @@ -2004,24 +2004,24 @@ if (! GETPOST('hide_websitemenu')) // List of website print '<span class="websiteselection">'; - $out=''; - $out.='<select name="website" class="minwidth100 maxwidth300" id="website">'; - if (empty($object->records)) $out.='<option value="-1"> </option>'; + $out = ''; + $out .= '<select name="website" class="minwidth100 maxwidth300" id="website">'; + if (empty($object->records)) $out .= '<option value="-1"> </option>'; // Loop on each sites - $i=0; - foreach($object->records as $key => $valwebsite) + $i = 0; + foreach ($object->records as $key => $valwebsite) { - if (empty($websitekey)) $websitekey=$valwebsite->ref; + if (empty($websitekey)) $websitekey = $valwebsite->ref; - $out.='<option value="'.$valwebsite->ref.'"'; - if ($websitekey == $valwebsite->ref) $out.=' selected'; // To preselect a value - $out.='>'; - $out.=$valwebsite->ref; - $out.='</option>'; + $out .= '<option value="'.$valwebsite->ref.'"'; + if ($websitekey == $valwebsite->ref) $out .= ' selected'; // To preselect a value + $out .= '>'; + $out .= $valwebsite->ref; + $out .= '</option>'; $i++; } - $out.='</select>'; - $out.=ajax_combobox('website'); + $out .= '</select>'; + $out .= ajax_combobox('website'); print $out; //print '<input type="submit" class="button" name="refreshsite" value="'.$langs->trans("Load").'">'; print '<input type="image" class="valignmiddle" src="'.img_picto('', 'refresh', '', 0, 1).'" name="refreshsite" value="'.$langs->trans("Load").'">'; @@ -2062,7 +2062,7 @@ if (! GETPOST('hide_websitemenu')) print '<input type="submit" class="button bordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("ExportSite")).'" name="exportsite">'; print '<input type="submit" class="button bordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("CloneSite")).'" name="createfromclone">'; - print '<input type="submit" class="buttonDelete bordertransp" name="deletesite" value="'.$langs->trans("Delete").'"'.($atleastonepage?' disabled="disabled"':'').'>'; + print '<input type="submit" class="buttonDelete bordertransp" name="deletesite" value="'.$langs->trans("Delete").'"'.($atleastonepage ? ' disabled="disabled"' : '').'>'; print '   '; @@ -2098,48 +2098,48 @@ if (! GETPOST('hide_websitemenu')) if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite') { - $urlext=$virtualurl; - $urlint=$urlwithroot.'/public/website/index.php?website='.$websitekey; + $urlext = $virtualurl; + $urlint = $urlwithroot.'/public/website/index.php?website='.$websitekey; print '<span class="websiteinputurl valignmiddle" id="websiteinputurl">'; - $linktotestonwebserver = '<a href="'.($virtualurl?$virtualurl:'#').'" class="valignmiddle">'; - $linktotestonwebserver.= $langs->trans("TestDeployOnWeb", $virtualurl).' '.img_picto('', 'globe'); - $linktotestonwebserver.= '</a>'; + $linktotestonwebserver = '<a href="'.($virtualurl ? $virtualurl : '#').'" class="valignmiddle">'; + $linktotestonwebserver .= $langs->trans("TestDeployOnWeb", $virtualurl).' '.img_picto('', 'globe'); + $linktotestonwebserver .= '</a>'; $htmltext = ''; if (empty($object->fk_default_home)) { - $htmltext.= '<br><span class="error">'.$langs->trans("YouMustDefineTheHomePage").'</span><br><br>'; + $htmltext .= '<br><span class="error">'.$langs->trans("YouMustDefineTheHomePage").'</span><br><br>'; } elseif (empty($virtualurl)) { - $htmltext.= '<br><span class="error">'.$langs->trans("VirtualHostUrlNotDefined").'</span><br><br>'; + $htmltext .= '<br><span class="error">'.$langs->trans("VirtualHostUrlNotDefined").'</span><br><br>'; } else { - $htmltext.= '<br><center>'.$langs->trans("GoTo").' <a href="'.$virtualurl.'" target="_website">'.$virtualurl.'</a></center><br>'; + $htmltext .= '<br><center>'.$langs->trans("GoTo").' <a href="'.$virtualurl.'" target="_website">'.$virtualurl.'</a></center><br>'; } - if (! empty($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER)) + if (!empty($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER)) { - $htmltext.= '<br>'.$langs->trans($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER); + $htmltext .= '<br>'.$langs->trans($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER); } else { - $htmltext.=$langs->trans("SetHereVirtualHost", $dataroot); - $htmltext.='<br>'; - $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); - $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website<br>'.DOL_DATA_ROOT.'/medias'); - $htmltext.='<br>'; - $htmltext.='<br>'; - $htmltext.=$langs->trans("YouCanAlsoTestWithPHPS", $dataroot); - $htmltext.='<br>'; - $htmltext.='<br>'; - $htmltext.=$langs->trans("YouCanAlsoDeployToAnotherWHP"); + $htmltext .= $langs->trans("SetHereVirtualHost", $dataroot); + $htmltext .= '<br>'; + $htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); + $htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website<br>'.DOL_DATA_ROOT.'/medias'); + $htmltext .= '<br>'; + $htmltext .= '<br>'; + $htmltext .= $langs->trans("YouCanAlsoTestWithPHPS", $dataroot); + $htmltext .= '<br>'; + $htmltext .= '<br>'; + $htmltext .= $langs->trans("YouCanAlsoDeployToAnotherWHP"); } print $form->textwithpicto($linktotestonwebserver, $htmltext, 1, 'none', 'valignmiddle', 0, 3, 'helpvirtualhost'); print '</span>'; } - if (in_array($action, array('editcss','editmenu','file_manager','replacesite','replacesiteconfirm'))) + if (in_array($action, array('editcss', 'editmenu', 'file_manager', 'replacesite', 'replacesiteconfirm'))) { if ($action == 'editcss' && $action != 'file_manager' && $action != 'replacesite' && $action != 'replacesiteconfirm') print '<input type="submit" id="savefilean stay" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("SaveAndStay")).'" name="updateandstay">'; if (preg_match('/^create/', $action) && $action != 'file_manager' && $action != 'replacesite' && $action != 'replacesiteconfirm') print '<input type="submit" id="savefile" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; @@ -2152,12 +2152,12 @@ if (! GETPOST('hide_websitemenu')) // Toolbar for pages - if ($websitekey && $websitekey != '-1' && ! in_array($action, array('editcss','editmenu','importsite'))) + if ($websitekey && $websitekey != '-1' && !in_array($action, array('editcss', 'editmenu', 'importsite'))) { - print '</div>'; // Close current websitebar to open a new one + print '</div>'; // Close current websitebar to open a new one print '<!-- Bar for websitepage -->'; - print '<div class="centpercent websitebar"'.($style?' style="'.$style.'"':'').'">'; + print '<div class="centpercent websitebar"'.($style ? ' style="'.$style.'"' : '').'">'; print '<span class="websiteselection hideonsmartphoneimp minwidth100 tdoverflowmax100">'; print $langs->trans("PageContainer").': '; @@ -2180,12 +2180,12 @@ if (! GETPOST('hide_websitemenu')) } //print '<input type="submit" class="button" name="refreshpage" value="'.$langs->trans("Load").'"'.($atleastonepage?'':' disabled="disabled"').'>'; - print '<input type="image" class="valignmiddle" src="'.img_picto('', 'refresh', '', 0, 1).'" name="refreshpage" value="'.$langs->trans("Load").'"'.(($atleastonepage && $action != 'editsource')?'':' disabled="disabled"').'>'; + print '<input type="image" class="valignmiddle" src="'.img_picto('', 'refresh', '', 0, 1).'" name="refreshpage" value="'.$langs->trans("Load").'"'.(($atleastonepage && $action != 'editsource') ? '' : ' disabled="disabled"').'>'; // Print nav arrows - $pagepreviousid=0; - $pagenextid=0; + $pagepreviousid = 0; + $pagenextid = 0; if ($pageid) { $sql = 'SELECT MAX(rowid) as pagepreviousid FROM '.MAIN_DB_PREFIX.'website_page WHERE rowid < '.$pageid.' AND fk_website = '.$object->id; @@ -2225,8 +2225,8 @@ if (! GETPOST('hide_websitemenu')) if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite') { - $disabled=''; - if (empty($user->rights->website->write)) $disabled=' disabled="disabled"'; + $disabled = ''; + if (empty($user->rights->website->write)) $disabled = ' disabled="disabled"'; // Confirmation delete site if ($action == 'deletesite') { @@ -2238,7 +2238,7 @@ if (! GETPOST('hide_websitemenu')) //array('type' => 'other','name' => 'newwebsite','label' => $langs->trans("WebSite"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0)) ); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id='.$object->id, $langs->trans('DeleteWebsite'), '', 'confirm_deletesite', $formquestion, 0, 1, 200); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteWebsite'), '', 'confirm_deletesite', $formquestion, 0, 1, 200); print $formconfirm; } @@ -2247,13 +2247,13 @@ if (! GETPOST('hide_websitemenu')) if ($action == 'createfromclone') { // Create an array for form $formquestion = array( - array('type' => 'text', 'name' => 'siteref', 'label'=> $langs->trans("WebSite") ,'value'=> 'copy_of_'.$object->ref), + array('type' => 'text', 'name' => 'siteref', 'label'=> $langs->trans("WebSite"), 'value'=> 'copy_of_'.$object->ref), //array('type' => 'checkbox', 'name' => 'is_a_translation', 'label' => $langs->trans("SiteIsANewTranslation"), 'value' => 0), //array('type' => 'other','name' => 'newlang','label' => $langs->trans("Language"), 'value' => $formadmin->select_language(GETPOST('newlang', 'aZ09')?GETPOST('newlang', 'aZ09'):$langs->defaultlang, 'newlang', 0, null, '', 0, 0, 'minwidth200')), //array('type' => 'other','name' => 'newwebsite','label' => $langs->trans("WebSite"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0)) ); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id='.$object->id, $langs->trans('CloneSite'), '', 'confirm_createfromclone', $formquestion, 0, 1, 200); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('CloneSite'), '', 'confirm_createfromclone', $formquestion, 0, 1, 200); print $formconfirm; } @@ -2267,12 +2267,12 @@ if (! GETPOST('hide_websitemenu')) $formquestion = array( array('type' => 'hidden', 'name' => 'sourcepageurl', 'value'=> $objectpage->pageurl), array('type' => 'checkbox', 'tdclass'=>'maxwidth200', 'name' => 'is_a_translation', 'label' => $langs->trans("PageIsANewTranslation"), 'value' => 0), - array('type' => 'other','name' => 'newlang', 'label' => $langs->trans("Language"), 'value' => $formadmin->select_language($preselectedlanguage, 'newlang', 0, null, 1, 0, 0, 'minwidth200', 0, 1)), - array('type' => 'other','name' => 'newwebsite', 'label' => $langs->trans("WebSite"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0)), + array('type' => 'other', 'name' => 'newlang', 'label' => $langs->trans("Language"), 'value' => $formadmin->select_language($preselectedlanguage, 'newlang', 0, null, 1, 0, 0, 'minwidth200', 0, 1)), + array('type' => 'other', 'name' => 'newwebsite', 'label' => $langs->trans("WebSite"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0)), array('type' => 'text', 'tdclass'=>'maxwidth200 fieldrequired', 'name' => 'pageurl', 'label'=> $langs->trans("WEBSITE_PAGENAME"), 'value'=> 'copy_of_'.$objectpage->pageurl), ); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?website='.$object->ref.'&pageid=' . $pageid, $langs->trans('ClonePage'), '', 'confirm_createpagefromclone', $formquestion, 0, 1, 300, 550); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?website='.$object->ref.'&pageid='.$pageid, $langs->trans('ClonePage'), '', 'confirm_createpagefromclone', $formquestion, 0, 1, 300, 550); print $formconfirm; } @@ -2291,7 +2291,7 @@ if (! GETPOST('hide_websitemenu')) print '<!-- Code to enabled edit inline ckeditor -->'."\n"; print '<script type="text/javascript"> $(document).ready(function() { - var isEditingEnabled = '.($conf->global->WEBSITE_EDITINLINE?'true':'false').'; + var isEditingEnabled = '.($conf->global->WEBSITE_EDITINLINE ? 'true' : 'false').'; if (isEditingEnabled) { switchEditorOnline(true); @@ -2389,7 +2389,7 @@ if (! GETPOST('hide_websitemenu')) print '<a href="'.$_SERVER["PHP_SEFL"].'?action=setashome&website='.$website->ref.'&pageid='.$pageid.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'"><span class="fa fa-home valignmiddle btnTitle-icon"><span></a>'; } print '<input type="submit" class="button bordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("ClonePage")).'" name="createpagefromclone">'; - print '<input type="submit" class="buttonDelete bordertransp" name="delete" value="'.$langs->trans("Delete").'"'.($atleastonepage?'':' disabled="disabled"').'>'; + print '<input type="submit" class="buttonDelete bordertransp" name="delete" value="'.$langs->trans("Delete").'"'.($atleastonepage ? '' : ' disabled="disabled"').'>'; } } @@ -2399,48 +2399,48 @@ if (! GETPOST('hide_websitemenu')) if (($pageid > 0 && $atleastonepage) && ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite')) { - $realpage=$urlwithroot.'/public/website/index.php?website='.$websitekey.'&pageref='.$websitepage->pageurl; + $realpage = $urlwithroot.'/public/website/index.php?website='.$websitekey.'&pageref='.$websitepage->pageurl; $pagealias = $websitepage->pageurl; $htmltext = $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot); - $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); - $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website<br>'.DOL_DATA_ROOT.'/medias'); + $htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); + $htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website<br>'.DOL_DATA_ROOT.'/medias'); print '<a class="websitebuttonsitepreview" id="previewpage" href="'.$realpage.'&nocache='.dol_now().'" class="button" target="tab'.$websitekey.'" alt="'.dol_escape_htmltag($htmltext).'">'; print $form->textwithpicto('', $htmltext, 1, 'preview'); - print '</a>'; // View page in new Tab + print '</a>'; // View page in new Tab print '<div class="websiteinputurl" id="websiteinputpage">'; print '<input type="text" id="previewpageurl" class="minwidth200imp" name="previewsite" value="'.$pagealias.'" disabled="disabled">'; - $htmltext=$langs->trans("PageNameAliasHelp", $langs->transnoentitiesnoconv("EditPageMeta")); + $htmltext = $langs->trans("PageNameAliasHelp", $langs->transnoentitiesnoconv("EditPageMeta")); print $form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helppagealias'); print '</div>'; - $urlext=$virtualurl.'/'.$pagealias.'.php'; - $urlint=$urlwithroot.'/public/website/index.php?website='.$websitekey; + $urlext = $virtualurl.'/'.$pagealias.'.php'; + $urlint = $urlwithroot.'/public/website/index.php?website='.$websitekey; - $htmltext = $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $virtualurl?$urlext:'<span class="error">'.$langs->trans("VirtualHostUrlNotDefined").'</span>'); + $htmltext = $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $virtualurl ? $urlext : '<span class="error">'.$langs->trans("VirtualHostUrlNotDefined").'</span>'); - print '<a class="websitebuttonsitepreview'.($virtualurl?'':' websitebuttonsitepreviewdisabled cursornotallowed').'" id="previewpageext" href="'.$urlext.'" target="tab'.$websitekey.'ext" alt="'.dol_escape_htmltag($htmltext).'">'; + print '<a class="websitebuttonsitepreview'.($virtualurl ? '' : ' websitebuttonsitepreviewdisabled cursornotallowed').'" id="previewpageext" href="'.$urlext.'" target="tab'.$websitekey.'ext" alt="'.dol_escape_htmltag($htmltext).'">'; print $form->textwithpicto('', $htmltext, 1, 'preview_ext'); print '</a>'; //print '<input type="submit" class="button" name="previewpage" target="tab'.$websitekey.'"value="'.$langs->trans("ViewPageInNewTab").'">'; // TODO Add js to save alias like we save virtual host name and use dynamic virtual host for url of id=previewpageext } - if (! in_array($action, array('editcss','editmenu','file_manager','replacesite','replacesiteconfirm','createsite','createcontainer','createfromclone','createpagefromclone','deletesite'))) + if (!in_array($action, array('editcss', 'editmenu', 'file_manager', 'replacesite', 'replacesiteconfirm', 'createsite', 'createcontainer', 'createfromclone', 'createpagefromclone', 'deletesite'))) { if (preg_match('/^create/', $action)) print '<input type="submit" id="savefile" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; if (preg_match('/^edit/', $action)) print '<input type="submit" id="savefile" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; if ($action != 'preview') print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="preview">'; } - print '</span>'; // end websitetools + print '</span>'; // end websitetools print '<span class="websitehelp">'; if (GETPOST('editsource', 'alpha') || GETPOST('editcontent', 'alpha')) { - $htmltext=$langs->transnoentitiesnoconv("YouCanEditHtmlSource").'<br>'; + $htmltext = $langs->transnoentitiesnoconv("YouCanEditHtmlSource").'<br>'; if ($conf->browser->layout == 'phone') { print $form->textwithpicto('', $htmltext, 1, 'help', 'inline-block', 1, 2, 'tooltipsubstitution'); @@ -2451,14 +2451,14 @@ if (! GETPOST('hide_websitemenu')) print $form->textwithpicto($langs->trans("SyntaxHelp").' '.img_help(2, $langs->trans("SyntaxHelp")), $htmltext, 1, 'none', 'inline-block', 1, 2, 'tooltipsubstitution'); } } - print '</span>'; // end websitehelp + print '</span>'; // end websitehelp if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone') { // Adding jquery code to change on the fly url of preview ext - if (! empty($conf->use_javascript_ajax)) + if (!empty($conf->use_javascript_ajax)) { print '<script type="text/javascript" language="javascript"> jQuery(document).ready(function() { @@ -2506,7 +2506,7 @@ if (! GETPOST('hide_websitemenu')) } } - print '</div>'; // end current websitebar + print '</div>'; // end current websitebar } @@ -2524,7 +2524,7 @@ if ($action == 'editcss') print '<br>'; - if (! GETPOSTISSET('WEBSITE_CSS_INLINE')) + if (!GETPOSTISSET('WEBSITE_CSS_INLINE')) { $csscontent = @file_get_contents($filecss); // Clean the php css file to remove php code and get only css part @@ -2534,9 +2534,9 @@ if ($action == 'editcss') { $csscontent = GETPOST('WEBSITE_CSS_INLINE', 'none'); } - if (! trim($csscontent)) $csscontent='/* CSS content (all pages) */'."\n"."body.bodywebsite { margin: 0; font-family: 'Open Sans', sans-serif; }\n.bodywebsite h1 { margin-top: 0; margin-bottom: 0; padding: 10px;}"; + if (!trim($csscontent)) $csscontent = '/* CSS content (all pages) */'."\n"."body.bodywebsite { margin: 0; font-family: 'Open Sans', sans-serif; }\n.bodywebsite h1 { margin-top: 0; margin-bottom: 0; padding: 10px;}"; - if (! GETPOSTISSET('WEBSITE_JS_INLINE')) + if (!GETPOSTISSET('WEBSITE_JS_INLINE')) { $jscontent = @file_get_contents($filejs); // Clean the php js file to remove php code and get only js part @@ -2546,9 +2546,9 @@ if ($action == 'editcss') { $jscontent = GETPOST('WEBSITE_JS_INLINE', 'none'); } - if (! trim($jscontent)) $jscontent='/* JS content (all pages) */'."\n"; + if (!trim($jscontent)) $jscontent = '/* JS content (all pages) */'."\n"; - if (! GETPOSTISSET('WEBSITE_HTML_HEADER')) + if (!GETPOSTISSET('WEBSITE_HTML_HEADER')) { $htmlheadercontent = @file_get_contents($filehtmlheader); // Clean the php htmlheader file to remove php code and get only html part @@ -2558,20 +2558,20 @@ if ($action == 'editcss') { $htmlheadercontent = GETPOST('WEBSITE_HTML_HEADER', 'none'); } - if (! trim($htmlheadercontent)) + if (!trim($htmlheadercontent)) { - $htmlheadercontent ="<html>\n"; - $htmlheadercontent.=$htmlheadercontentdefault; - $htmlheadercontent.="</html>"; + $htmlheadercontent = "<html>\n"; + $htmlheadercontent .= $htmlheadercontentdefault; + $htmlheadercontent .= "</html>"; } else { $htmlheadercontent = preg_replace('/^\s*<html>/ims', '', $htmlheadercontent); $htmlheadercontent = preg_replace('/<\/html>\s*$/ims', '', $htmlheadercontent); - $htmlheadercontent='<html>'."\n".trim($htmlheadercontent)."\n".'</html>'; + $htmlheadercontent = '<html>'."\n".trim($htmlheadercontent)."\n".'</html>'; } - if (! GETPOSTISSET('WEBSITE_ROBOT')) + if (!GETPOSTISSET('WEBSITE_ROBOT')) { $robotcontent = @file_get_contents($filerobot); // Clean the php htmlheader file to remove php code and get only html part @@ -2581,15 +2581,15 @@ if ($action == 'editcss') { $robotcontent = GETPOST('WEBSITE_ROBOT', 'nothtml'); } - if (! trim($robotcontent)) + if (!trim($robotcontent)) { - $robotcontent.="# Robot file. Generated with ".DOL_APPLICATION_TITLE."\n"; - $robotcontent.="User-agent: *\n"; - $robotcontent.="Allow: /public/\n"; - $robotcontent.="Disallow: /administrator/\n"; + $robotcontent .= "# Robot file. Generated with ".DOL_APPLICATION_TITLE."\n"; + $robotcontent .= "User-agent: *\n"; + $robotcontent .= "Allow: /public/\n"; + $robotcontent .= "Disallow: /administrator/\n"; } - if (! GETPOSTISSET('WEBSITE_HTACCESS')) + if (!GETPOSTISSET('WEBSITE_HTACCESS')) { $htaccesscontent = @file_get_contents($filehtaccess); // Clean the php htaccesscontent file to remove php code and get only html part @@ -2599,14 +2599,14 @@ if ($action == 'editcss') { $htaccesscontent = GETPOST('WEBSITE_HTACCESS', 'nohtml'); } - if (! trim($htaccesscontent)) + if (!trim($htaccesscontent)) { - $htaccesscontent.="# Order allow,deny\n"; - $htaccesscontent.="# Deny from all\n"; + $htaccesscontent .= "# Order allow,deny\n"; + $htaccesscontent .= "# Deny from all\n"; } - if (! GETPOSTISSET('WEBSITE_MANIFEST_JSON')) + if (!GETPOSTISSET('WEBSITE_MANIFEST_JSON')) { $manifestjsoncontent = @file_get_contents($filemanifestjson); // Clean the manifestjson file to remove php code and get only html part @@ -2616,12 +2616,12 @@ if ($action == 'editcss') { $manifestjsoncontent = GETPOST('WEBSITE_MANIFEST_JSON', 'none'); } - if (! trim($manifestjsoncontent)) + if (!trim($manifestjsoncontent)) { //$manifestjsoncontent.=""; } - if (! GETPOSTISSET('WEBSITE_README')) + if (!GETPOSTISSET('WEBSITE_README')) { $readmecontent = @file_get_contents($filereadme); // Clean the readme file to remove php code and get only html part @@ -2631,7 +2631,7 @@ if ($action == 'editcss') { $readmecontent = GETPOST('WEBSITE_README', 'none'); } - if (! trim($readmecontent)) + if (!trim($readmecontent)) { //$readmecontent.=""; } @@ -2652,9 +2652,9 @@ if ($action == 'editcss') print '<tr><td class="tdtop">'; $htmltext = $langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/<i>'.$websitekey.'</i>'); - $htmltext.='<br>'; - $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); - $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website<br>'.DOL_DATA_ROOT.'/medias'); + $htmltext .= '<br>'; + $htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); + $htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website<br>'.DOL_DATA_ROOT.'/medias'); print $form->textwithpicto($langs->trans('Virtualhost'), $htmltext, 1, 'help', '', 0, 2, 'virtualhosttooltip'); print '</td><td>'; @@ -2664,11 +2664,11 @@ if ($action == 'editcss') // CSS file print '<tr><td class="tdtop">'; - $htmlhelp=$langs->trans("CSSContentTooltipHelp"); + $htmlhelp = $langs->trans("CSSContentTooltipHelp"); print $form->textwithpicto($langs->trans('WEBSITE_CSS_INLINE'), $htmlhelp, 1, 'help', '', 0, 2, 'csstooltip'); print '</td><td>'; - $doleditor=new DolEditor('WEBSITE_CSS_INLINE', $csscontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); + $doleditor = new DolEditor('WEBSITE_CSS_INLINE', $csscontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); print $doleditor->Create(1, '', true, 'CSS', 'css'); print '</td></tr>'; @@ -2678,7 +2678,7 @@ if ($action == 'editcss') print $langs->trans('WEBSITE_JS_INLINE'); print '</td><td>'; - $doleditor=new DolEditor('WEBSITE_JS_INLINE', $jscontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); + $doleditor = new DolEditor('WEBSITE_JS_INLINE', $jscontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); print $doleditor->Create(1, '', true, 'JS', 'javascript'); print '</td></tr>'; @@ -2686,14 +2686,14 @@ if ($action == 'editcss') // Common HTML header print '<tr><td class="tdtop">'; print $langs->trans('WEBSITE_HTML_HEADER'); - $htmlhelp=$langs->trans("Example").' :<br>'; - $htmlhelp.=dol_htmlentitiesbr($htmlheadercontentdefault); + $htmlhelp = $langs->trans("Example").' :<br>'; + $htmlhelp .= dol_htmlentitiesbr($htmlheadercontentdefault); $textwithhelp = $form->textwithpicto('', $htmlhelp, 1, 'help', '', 0, 2, 'htmlheadertooltip'); - $htmlhelp2=$langs->trans("LinkAndScriptsHereAreNotLoadedInEditor").'<br>'; + $htmlhelp2 = $langs->trans("LinkAndScriptsHereAreNotLoadedInEditor").'<br>'; print $form->textwithpicto($textwithhelp, $htmlhelp2, 1, 'warning', '', 0, 2, 'htmlheadertooltip2'); print '</td><td>'; - $doleditor=new DolEditor('WEBSITE_HTML_HEADER', $htmlheadercontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); + $doleditor = new DolEditor('WEBSITE_HTML_HEADER', $htmlheadercontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); print $doleditor->Create(1, '', true, 'HTML Header', 'html'); print '</td></tr>'; @@ -2703,7 +2703,7 @@ if ($action == 'editcss') print $langs->trans('WEBSITE_ROBOT'); print '</td><td>'; - $doleditor=new DolEditor('WEBSITE_ROBOT', $robotcontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); + $doleditor = new DolEditor('WEBSITE_ROBOT', $robotcontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); print $doleditor->Create(1, '', true, 'Robot file', 'text'); print '</td></tr>'; @@ -2713,30 +2713,30 @@ if ($action == 'editcss') print $langs->trans('WEBSITE_HTACCESS'); print '</td><td>'; - $doleditor=new DolEditor('WEBSITE_HTACCESS', $htaccesscontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); + $doleditor = new DolEditor('WEBSITE_HTACCESS', $htaccesscontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); print $doleditor->Create(1, '', true, $langs->trans("File").' .htaccess', 'text'); print '</td></tr>'; // Manifest.json print '<tr><td class="tdtop">'; - $htmlhelp=$langs->trans("Example").' :<br>'; - $htmlhelp.=dol_htmlentitiesbr($manifestjsoncontentdefault); + $htmlhelp = $langs->trans("Example").' :<br>'; + $htmlhelp .= dol_htmlentitiesbr($manifestjsoncontentdefault); print $form->textwithpicto($langs->trans('WEBSITE_MANIFEST_JSON'), $htmlhelp, 1, 'help', '', 0, 2, 'manifestjsontooltip'); print '</td><td>'; - $doleditor=new DolEditor('WEBSITE_MANIFEST_JSON', $manifestjsoncontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); + $doleditor = new DolEditor('WEBSITE_MANIFEST_JSON', $manifestjsoncontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); print $doleditor->Create(1, '', true, $langs->trans("File").' manifest.json', 'text'); print '</td></tr>'; // README.md print '<tr><td class="tdtop">'; - $htmlhelp=$langs->trans("EnterHereLicenseInformation"); + $htmlhelp = $langs->trans("EnterHereLicenseInformation"); print $form->textwithpicto($langs->trans('WEBSITE_README'), $htmlhelp, 1, 'help', '', 0, 2, 'readmetooltip'); print '</td><td>'; - $doleditor=new DolEditor('WEBSITE_README', $readmecontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); + $doleditor = new DolEditor('WEBSITE_README', $readmecontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); print $doleditor->Create(1, '', true, $langs->trans("File").' README.md', 'text'); print '</td></tr>'; @@ -2774,8 +2774,8 @@ if ($action == 'createsite') print '<table class="border centpercent">'; - if (GETPOST('WEBSITE_REF')) $siteref=GETPOST('WEBSITE_REF', 'alpha'); - if (GETPOST('WEBSITE_DESCRIPTION')) $sitedesc=GETPOST('WEBSITE_DESCRIPTION', 'alpha'); + if (GETPOST('WEBSITE_REF')) $siteref = GETPOST('WEBSITE_REF', 'alpha'); + if (GETPOST('WEBSITE_DESCRIPTION')) $sitedesc = GETPOST('WEBSITE_DESCRIPTION', 'alpha'); print '<tr><td class="titlefieldcreate fieldrequired">'; print $langs->trans('Ref'); @@ -2792,9 +2792,9 @@ if ($action == 'createsite') print '<tr><td>'; $htmltext = $langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/<i>websiteref</i>'); - $htmltext.='<br>'; - $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); - $htmltext.='<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website<br>'.DOL_DATA_ROOT.'/medias'); + $htmltext .= '<br>'; + $htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); + $htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website<br>'.DOL_DATA_ROOT.'/medias'); print $form->textwithpicto($langs->trans('Virtualhost'), $htmltext, 1, 'help', '', 0, 2, 'virtualhosttooltip'); print '</td><td>'; @@ -2882,15 +2882,15 @@ if ($action == 'editmeta' || $action == 'createcontainer') if (GETPOST('radiocreatefrom') == 'checkboxcreatemanually') $hiddenmanuallyafterload = ''; if ($action == 'editmeta' || empty($conf->use_javascript_ajax)) { // No autohide/show in such case - $hiddenfromfetchingafterload=''; - $hiddenmanuallyafterload=''; + $hiddenfromfetchingafterload = ''; + $hiddenmanuallyafterload = ''; } if ($action == 'createcontainer') { print '<br>'; - if (! empty($conf->use_javascript_ajax)) print '<input type="radio" name="radiocreatefrom" id="checkboxcreatefromfetching" value="checkboxcreatefromfetching"'.(GETPOST('radiocreatefrom') == 'checkboxcreatefromfetching' ? ' checked' : '').'> '; + if (!empty($conf->use_javascript_ajax)) print '<input type="radio" name="radiocreatefrom" id="checkboxcreatefromfetching" value="checkboxcreatefromfetching"'.(GETPOST('radiocreatefrom') == 'checkboxcreatefromfetching' ? ' checked' : '').'> '; print '<label for="checkboxcreatefromfetching"><span class="opacitymedium">'.$langs->trans("CreateByFetchingExternalPage").'</span></label><br>'; print '<hr class="tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.'">'; print '<table class="tableforfield centpercent tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.'">'; @@ -2902,8 +2902,8 @@ if ($action == 'editmeta' || $action == 'createcontainer') print '<br><input class="flat paddingtop" type="checkbox" name="grabimages" value="1" checked="checked"> '.$langs->trans("GrabImagesInto"); print ' '; print $langs->trans("ImagesShouldBeSavedInto").' '; - $arraygrabimagesinto=array('root'=>$langs->trans("WebsiteRootOfImages"), 'subpage'=>$langs->trans("SubdirOfPage")); - print $form->selectarray('grabimagesinto', $arraygrabimagesinto, GETPOSTISSET('grabimagesinto')?GETPOST('grabimagesinto'):'root'); + $arraygrabimagesinto = array('root'=>$langs->trans("WebsiteRootOfImages"), 'subpage'=>$langs->trans("SubdirOfPage")); + print $form->selectarray('grabimagesinto', $arraygrabimagesinto, GETPOSTISSET('grabimagesinto') ?GETPOST('grabimagesinto') : 'root'); print '<br>'; print '<input class="button" style="margin-top: 5px" type="submit" name="fetchexternalurl" value="'.dol_escape_htmltag($langs->trans("FetchAndCreate")).'">'; print '</td></tr>'; @@ -2911,7 +2911,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') print '<br>'; - if (! empty($conf->use_javascript_ajax)) print '<input type="radio" name="radiocreatefrom" id="checkboxcreatemanually" value="checkboxcreatemanually"'.(GETPOST('radiocreatefrom') == 'checkboxcreatemanually' ? ' checked' : '').'> '; + if (!empty($conf->use_javascript_ajax)) print '<input type="radio" name="radiocreatefrom" id="checkboxcreatemanually" value="checkboxcreatemanually"'.(GETPOST('radiocreatefrom') == 'checkboxcreatemanually' ? ' checked' : '').'> '; print '<label for="checkboxcreatemanually"><span class="opacitymedium">'.$langs->trans("OrEnterPageInfoManually").'</span></label><br>'; print '<hr class="tablecheckboxcreatemanually'.$hiddenmanuallyafterload.'">'; } @@ -2933,35 +2933,35 @@ if ($action == 'editmeta' || $action == 'createcontainer') //if ($objectpage->grabbed_from) print ' - <span class="opacitymedium">'.$langs->trans('InitiallyGrabbedFrom').' '.$objectpage->grabbed_from.'</span>'; print '</td></tr>'; - $type_container=$objectpage->type_container; - $pageurl=$objectpage->pageurl; - $pagealiasalt=$objectpage->aliasalt; - $pagetitle=$objectpage->title; - $pagedescription=$objectpage->description; - $pageimage=$objectpage->image; - $pagekeywords=$objectpage->keywords; - $pagelang=$objectpage->lang; - $pagehtmlheader=$objectpage->htmlheader; - $pagedatecreation=$objectpage->date_creation; - $pagedatemodification=$objectpage->date_modification; - $pageauthorid=$objectpage->fk_user_creat; - $pageusermodifid=$objectpage->fk_user_modif; + $type_container = $objectpage->type_container; + $pageurl = $objectpage->pageurl; + $pagealiasalt = $objectpage->aliasalt; + $pagetitle = $objectpage->title; + $pagedescription = $objectpage->description; + $pageimage = $objectpage->image; + $pagekeywords = $objectpage->keywords; + $pagelang = $objectpage->lang; + $pagehtmlheader = $objectpage->htmlheader; + $pagedatecreation = $objectpage->date_creation; + $pagedatemodification = $objectpage->date_modification; + $pageauthorid = $objectpage->fk_user_creat; + $pageusermodifid = $objectpage->fk_user_modif; } else { $type_container = 'page'; - $pagedatecreation=dol_now(); - $pageauthorid=$user->id; - $pageusermodifid=0; + $pagedatecreation = dol_now(); + $pageauthorid = $user->id; + $pageusermodifid = 0; } - if (GETPOST('WEBSITE_TITLE', 'alpha')) $pagetitle=GETPOST('WEBSITE_TITLE', 'alpha'); - if (GETPOST('WEBSITE_PAGENAME', 'alpha')) $pageurl=GETPOST('WEBSITE_PAGENAME', 'alpha'); - if (GETPOST('WEBSITE_ALIASALT', 'alpha')) $pagealiasalt=GETPOST('WEBSITE_ALIASALT', 'alpha'); - if (GETPOST('WEBSITE_DESCRIPTION', 'alpha')) $pagedescription=GETPOST('WEBSITE_DESCRIPTION', 'alpha'); - if (GETPOST('WEBSITE_IMAGE', 'alpha')) $pageimage=GETPOST('WEBSITE_IMAGE', 'alpha'); - if (GETPOST('WEBSITE_KEYWORDS', 'alpha')) $pagekeywords=GETPOST('WEBSITE_KEYWORDS', 'alpha'); - if (GETPOST('WEBSITE_LANG', 'aZ09')) $pagelang=GETPOST('WEBSITE_LANG', 'aZ09'); - if (GETPOST('htmlheader', 'none')) $pagehtmlheader=GETPOST('htmlheader', 'none'); + if (GETPOST('WEBSITE_TITLE', 'alpha')) $pagetitle = GETPOST('WEBSITE_TITLE', 'alpha'); + if (GETPOST('WEBSITE_PAGENAME', 'alpha')) $pageurl = GETPOST('WEBSITE_PAGENAME', 'alpha'); + if (GETPOST('WEBSITE_ALIASALT', 'alpha')) $pagealiasalt = GETPOST('WEBSITE_ALIASALT', 'alpha'); + if (GETPOST('WEBSITE_DESCRIPTION', 'alpha')) $pagedescription = GETPOST('WEBSITE_DESCRIPTION', 'alpha'); + if (GETPOST('WEBSITE_IMAGE', 'alpha')) $pageimage = GETPOST('WEBSITE_IMAGE', 'alpha'); + if (GETPOST('WEBSITE_KEYWORDS', 'alpha')) $pagekeywords = GETPOST('WEBSITE_KEYWORDS', 'alpha'); + if (GETPOST('WEBSITE_LANG', 'aZ09')) $pagelang = GETPOST('WEBSITE_LANG', 'aZ09'); + if (GETPOST('htmlheader', 'none')) $pagehtmlheader = GETPOST('htmlheader', 'none'); // Title print '<tr><td class="fieldrequired">'; @@ -2981,7 +2981,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') print '<tr><td class="titlefield fieldrequired">'; print $langs->trans('WEBSITE_TYPE_CONTAINER'); print '</td><td>'; - print $formwebsite->selectTypeOfContainer('WEBSITE_TYPE_CONTAINER', (GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha')?GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha'):$type_container)); + print $formwebsite->selectTypeOfContainer('WEBSITE_TYPE_CONTAINER', (GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha') ?GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha') : $type_container)); print '</td></tr>'; if ($action == 'createcontainer') @@ -2989,7 +2989,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') print '<tr><td class="titlefield fieldrequired">'; print $langs->trans('WEBSITE_PAGE_EXAMPLE'); print '</td><td>'; - print $formwebsite->selectSampleOfContainer('sample', (GETPOSTISSET('sample')?GETPOST('sample', 'alpha'):'empty')); + print $formwebsite->selectSampleOfContainer('sample', (GETPOSTISSET('sample') ?GETPOST('sample', 'alpha') : 'empty')); print '</td></tr>'; } @@ -3000,7 +3000,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') print '</td></tr>'; print '<tr><td>'; - $htmlhelp=$langs->trans("WEBSITE_IMAGEDesc"); + $htmlhelp = $langs->trans("WEBSITE_IMAGEDesc"); print $form->textwithpicto($langs->trans('WEBSITE_IMAGE'), $htmlhelp, 1, 'help', '', 0, 2, 'imagetooltip'); print '</td><td>'; print '<input type="text" class="flat quatrevingtpercent" name="WEBSITE_IMAGE" value="'.dol_escape_htmltag($pageimage).'">'; @@ -3015,19 +3015,19 @@ if ($action == 'editmeta' || $action == 'createcontainer') print '<tr><td>'; print $langs->trans('Language'); print '</td><td>'; - print $formadmin->select_language($pagelang?$pagelang:$langs->defaultlang, 'WEBSITE_LANG', 0, null, '1'); + print $formadmin->select_language($pagelang ? $pagelang : $langs->defaultlang, 'WEBSITE_LANG', 0, null, '1'); print '</td></tr>'; // Translation of - $translationof=0; - $translatedby=0; + $translationof = 0; + $translatedby = 0; print '<!-- Translation of --><tr><td>'; print $langs->trans('TranslationLinks'); print '</td><td>'; if ($action != 'createcontainer') { // Has translation pages - $sql='SELECT rowid, lang from '.MAIN_DB_PREFIX.'website_page where fk_page = '.$objectpage->id; + $sql = 'SELECT rowid, lang from '.MAIN_DB_PREFIX.'website_page where fk_page = '.$objectpage->id; $resql = $db->query($sql); if ($resql) { @@ -3035,10 +3035,10 @@ if ($action == 'editmeta' || $action == 'createcontainer') if ($num_rows > 0) { print '<span class="opacitymedium">'.$langs->trans('ThisPageHasTranslationPages').':</span><br>'; - $i=0; + $i = 0; while ($obj = $db->fetch_object($resql)) { - $tmppage=new WebsitePage($db); + $tmppage = new WebsitePage($db); $tmppage->fetch($obj->rowid); if ($i > 0) print ' - '; print $tmppage->getNomUrl(1).' ('.$tmppage->lang.')<br>'; @@ -3051,7 +3051,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') } if (empty($translatedby) && ($action == 'editmeta' || $action == 'createcontainer' || $objectpage->fk_page > 0)) { - $sourcepage=new WebsitePage($db); + $sourcepage = new WebsitePage($db); $result = $sourcepage->fetch($objectpage->fk_page); if ($result == 0) { @@ -3067,13 +3067,13 @@ if ($action == 'editmeta' || $action == 'createcontainer') print '</td></tr>'; print '<tr><td class="titlefieldcreate">'; - $htmlhelp=$langs->trans("WEBSITE_ALIASALTDesc"); + $htmlhelp = $langs->trans("WEBSITE_ALIASALTDesc"); print $form->textwithpicto($langs->trans('WEBSITE_ALIASALT'), $htmlhelp, 1, 'help', '', 0, 2, 'aliastooltip'); print '</td><td>'; print '<input type="text" class="flat minwidth300" name="WEBSITE_ALIASALT" value="'.dol_escape_htmltag($pagealiasalt).'">'; print '</td></tr>'; - $fuser=new User($db); + $fuser = new User($db); print '<tr><td>'; print $langs->trans('Author'); @@ -3112,12 +3112,12 @@ if ($action == 'editmeta' || $action == 'createcontainer') } print '<tr><td class="tdhtmlheader tdtop">'; - $htmlhelp =$langs->trans("EditTheWebSiteForACommonHeader").'<br><br>'; - $htmlhelp.=$langs->trans("Example").' :<br>'; - $htmlhelp.=dol_htmlentitiesbr($htmlheadercontentdefault); + $htmlhelp = $langs->trans("EditTheWebSiteForACommonHeader").'<br><br>'; + $htmlhelp .= $langs->trans("Example").' :<br>'; + $htmlhelp .= dol_htmlentitiesbr($htmlheadercontentdefault); print $form->textwithpicto($langs->trans('HtmlHeaderPage'), $htmlhelp, 1, 'help', '', 0, 2, 'htmlheadertooltip'); print '</td><td>'; - $doleditor=new DolEditor('htmlheader', $pagehtmlheader, '', '120', 'ace', 'In', true, false, 'ace', ROWS_3, '100%', ''); + $doleditor = new DolEditor('htmlheader', $pagehtmlheader, '', '120', 'ace', 'In', true, false, 'ace', ROWS_3, '100%', ''); print $doleditor->Create(1, '', true, 'HTML Header', 'html'); print '</td></tr>'; @@ -3185,7 +3185,7 @@ if ($action == 'editfile' || $action == 'file_manager') //print '<div class="center">'.$langs->trans("FeatureNotYetAvailable").'</center>'; $module = 'medias'; - if (empty($url)) $url=DOL_URL_ROOT.'/website/index.php'; // Must be an url without param + if (empty($url)) $url = DOL_URL_ROOT.'/website/index.php'; // Must be an url without param include DOL_DOCUMENT_ROOT.'/core/tpl/filemanager.tpl.php'; print '</div>'; @@ -3207,15 +3207,15 @@ if ($action == 'editsource') //$contentforedit.='</style>'."\n"; $contentforedit .= $objectpage->content; //var_dump($_SESSION["dol_screenheight"]); - $maxheightwin=480; + $maxheightwin = 480; if (isset($_SESSION["dol_screenheight"])) { - if ($_SESSION["dol_screenheight"] > 680) $maxheightwin = $_SESSION["dol_screenheight"]-400; - if ($_SESSION["dol_screenheight"] > 800) $maxheightwin = $_SESSION["dol_screenheight"]-490; + if ($_SESSION["dol_screenheight"] > 680) $maxheightwin = $_SESSION["dol_screenheight"] - 400; + if ($_SESSION["dol_screenheight"] > 800) $maxheightwin = $_SESSION["dol_screenheight"] - 490; } //var_dump($_SESSION["dol_screenheight"]); require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('PAGE_CONTENT', $contentforedit, '', $maxheightwin, 'Full', '', true, true, 'ace', ROWS_5, '40%'); + $doleditor = new DolEditor('PAGE_CONTENT', $contentforedit, '', $maxheightwin, 'Full', '', true, true, 'ace', ROWS_5, '40%'); $doleditor->Create(0, '', false, 'HTML Source', 'php'); } @@ -3262,9 +3262,9 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') print $langs->trans("SearchReplaceInto"); print '</div>'; print '<div class="tagtd">'; - print '<input type="checkbox" name="optioncontent" value="content"'.((! GETPOSTISSET('buttonreplacesitesearch') || GETPOST('optioncontent', 'aZ09'))?' checked':'').'> '.$langs->trans("Content"); - print '<input type="checkbox" class="marginleftonly" name="optionmeta" value="meta"'.(GETPOST('optionmeta', 'aZ09')?' checked':'').'> '.$langs->trans("Title").' | '.$langs->trans("Description").' | '.$langs->trans("Keywords"); - print '<input type="checkbox" class="marginleftonly" name="optionsitefiles" value="sitefiles"'.(GETPOST('optionsitefiles', 'aZ09')?' checked':'').'> '.$langs->trans("GlobalCSSorJS"); + print '<input type="checkbox" name="optioncontent" value="content"'.((!GETPOSTISSET('buttonreplacesitesearch') || GETPOST('optioncontent', 'aZ09')) ? ' checked' : '').'> '.$langs->trans("Content"); + print '<input type="checkbox" class="marginleftonly" name="optionmeta" value="meta"'.(GETPOST('optionmeta', 'aZ09') ? ' checked' : '').'> '.$langs->trans("Title").' | '.$langs->trans("Description").' | '.$langs->trans("Keywords"); + print '<input type="checkbox" class="marginleftonly" name="optionsitefiles" value="sitefiles"'.(GETPOST('optionsitefiles', 'aZ09') ? ' checked' : '').'> '.$langs->trans("GlobalCSSorJS"); print '</div>'; print '</div>'; @@ -3286,9 +3286,9 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') if ($action == 'replacesiteconfirm') { $algo = ''; - if (GETPOST('optionmeta')) $algo.='meta'; - if (GETPOST('optioncontent')) $algo.='content'; - if (GETPOST('optionsitefiles')) $algo.='sitefiles'; + if (GETPOST('optionmeta')) $algo .= 'meta'; + if (GETPOST('optioncontent')) $algo .= 'content'; + if (GETPOST('optionsitefiles')) $algo .= 'sitefiles'; $listofpages = getPagesFromSearchCriterias('', $algo, $searchkey, 1000); @@ -3322,7 +3322,7 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') print '<th>'.$langs->trans("Description").'</th>'; print '</tr>'; - foreach($listofpages['list'] as $answerrecord) + foreach ($listofpages['list'] as $answerrecord) { if (get_class($answerrecord) == 'WebsitePage') { @@ -3383,11 +3383,11 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa { $out .= "<iframe><body></html>"; }*/ - $out.="\n<html><head>\n"; - $out.="<!-- htmlheader/style of page from database -->\n"; - $out.=dolWebsiteReplacementOfLinks($object, $objectpage->htmlheader, 1, 'htmlheader'); + $out .= "\n<html><head>\n"; + $out .= "<!-- htmlheader/style of page from database -->\n"; + $out .= dolWebsiteReplacementOfLinks($object, $objectpage->htmlheader, 1, 'htmlheader'); - $out.="<!-- htmlheader/style of website from files -->\n"; + $out .= "<!-- htmlheader/style of website from files -->\n"; // TODO Keep only the <link> or the <script> tags /* $htmlheadercontent = @file_get_contents($filehtmlheader); @@ -3405,51 +3405,51 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa } */ - $out.="</head>\n"; - $out.="\n<body>"; + $out .= "</head>\n"; + $out .= "\n<body>"; - $out.='<div id="websitecontentundertopmenu" class="websitecontentundertopmenu boostrap-iso">'."\n"; + $out .= '<div id="websitecontentundertopmenu" class="websitecontentundertopmenu boostrap-iso">'."\n"; // REPLACEMENT OF LINKS When page called by website editor - $out.='<!-- style of website from file -->'."\n"; - $out.='<style scoped>'."\n"; // "scoped" means "apply to parent element only". No more supported by browsers, snif ! - $tmpout=''; - $tmpout.= '/* Include website CSS file */'."\n"; + $out .= '<!-- style of website from file -->'."\n"; + $out .= '<style scoped>'."\n"; // "scoped" means "apply to parent element only". No more supported by browsers, snif ! + $tmpout = ''; + $tmpout .= '/* Include website CSS file */'."\n"; //$csscontent = @file_get_contents($filecss); ob_start(); include $filecss; $csscontent = ob_get_contents(); ob_end_clean(); - $tmpout.= dolWebsiteReplacementOfLinks($object, $csscontent, 1, 'css'); - $tmpout.= '/* Include style from the HTML header of page */'."\n"; + $tmpout .= dolWebsiteReplacementOfLinks($object, $csscontent, 1, 'css'); + $tmpout .= '/* Include style from the HTML header of page */'."\n"; // Clean the html header of page to get only <style> content $tmp = preg_split('(<style[^>]*>|</style>)', $objectpage->htmlheader); - $tmpstyleinheader =''; - $i=0; - foreach($tmp as $valtmp) + $tmpstyleinheader = ''; + $i = 0; + foreach ($tmp as $valtmp) { $i++; - if ($i % 2 == 0) $tmpstyleinheader.=$valtmp."\n"; + if ($i % 2 == 0) $tmpstyleinheader .= $valtmp."\n"; } - $tmpout.= $tmpstyleinheader."\n"; + $tmpout .= $tmpstyleinheader."\n"; // Clean style that may affect global style of Dolibarr - $tmpout=preg_replace('/}[\s\n]*body\s*{[^}]+}/ims', '}', $tmpout); - $out.=$tmpout; - $out.='</style>'."\n"; + $tmpout = preg_replace('/}[\s\n]*body\s*{[^}]+}/ims', '}', $tmpout); + $out .= $tmpout; + $out .= '</style>'."\n"; // Note: <div> or <section> with contenteditable="true" inside this can be edited with inline ckeditor // Do not enable the contenteditable when page was grabbed, ckeditor is removing span and adding borders, // so editable will be available only from container created from scratch //$out.='<div id="bodywebsite" class="bodywebsite"'.($objectpage->grabbed_from ? ' contenteditable="true"' : '').'>'."\n"; - $out.='<div id="divbodywebsite" class="bodywebsite bodywebpage-'.$objectpage->ref.'">'."\n"; + $out .= '<div id="divbodywebsite" class="bodywebsite bodywebpage-'.$objectpage->ref.'">'."\n"; $newcontent = $objectpage->content; // If mode WEBSITE_SUBCONTAINERSINLINE is on - if (! empty($conf->global->WEBSITE_SUBCONTAINERSINLINE)) + if (!empty($conf->global->WEBSITE_SUBCONTAINERSINLINE)) { //var_dump($filetpl); $filephp = $filetpl; @@ -3469,12 +3469,12 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa { // Keep the contenteditable="true" when mode Edit Inline is on } - $out.=dolWebsiteReplacementOfLinks($object, $newcontent, 0, 'html', $objectpage->id)."\n"; + $out .= dolWebsiteReplacementOfLinks($object, $newcontent, 0, 'html', $objectpage->id)."\n"; //$out.=$newcontent; - $out.='</div>'; + $out .= '</div>'; - $out.='</div> <!-- End div id=websitecontentundertopmenu -->'; + $out .= '</div> <!-- End div id=websitecontentundertopmenu -->'; /*if ($includepageintoaframeoradiv == 'iframe') { @@ -3482,7 +3482,7 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa }*/ $out .= "\n</body></html>\n"; - $out.= "\n".'<!-- End page content '.$filetpl.' -->'."\n\n"; + $out .= "\n".'<!-- End page content '.$filetpl.' -->'."\n\n"; print $out;
'.$langs->trans("LastExpenseReports", ($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllExpenseReports").''.$num.''; print '
'.$langs->trans("LastExpenseReports", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllExpenseReports").''.$num.'