diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 894284f8603..9de858da26b 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -49,10 +49,10 @@ $search_pcgsubtype = GETPOST('search_pcgsubtype', 'alpha'); // Security check if ($user->socid > 0) accessforbidden(); -if (! $user->rights->accounting->chartofaccount) accessforbidden(); +if (!$user->rights->accounting->chartofaccount) accessforbidden(); // 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'); @@ -211,7 +211,7 @@ if (strlen(trim($search_account))) { $search_account_tmp = $search_account; $weremovedsomezero = 0; if (strlen($search_account_tmp) <= $lengthpaddingaccount) { - for($i = 0; $i < $lengthpaddingaccount; $i++) { + for ($i = 0; $i < $lengthpaddingaccount; $i++) { if (preg_match('/0$/', $search_account_tmp)) { $weremovedsomezero++; $search_account_tmp = preg_replace('/0$/', '', $search_account_tmp); @@ -271,7 +271,7 @@ if ($resql) if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; if ($search_account) $param .= '&search_account='.urlencode($search_account); if ($search_label) $param .= '&search_label='.urlencode($search_label); - if ($search_labelshort) $param.= '&search_labelshort='.urlencode($search_labelshort); + if ($search_labelshort) $param .= '&search_labelshort='.urlencode($search_labelshort); if ($search_accountparent > 0 || $search_accountparent == '0') $param .= '&search_accountparent='.urlencode($search_accountparent); if ($search_pcgtype) $param .= '&search_pcgtype='.urlencode($search_pcgtype); if ($search_pcgsubtype) $param .= '&search_pcgsubtype='.urlencode($search_pcgsubtype); @@ -356,7 +356,7 @@ if ($resql) print ''; if (!empty($arrayfields['aa.account_number']['checked'])) print ''; if (!empty($arrayfields['aa.label']['checked'])) print ''; - if (!empty($arrayfields['aa.labelshort']['checked'])) print ''; + if (!empty($arrayfields['aa.labelshort']['checked'])) print ''; if (!empty($arrayfields['aa.account_parent']['checked'])) { print ''; print $formaccounting->select_account($search_accountparent, 'search_accountparent', 2); @@ -416,12 +416,12 @@ if ($resql) } // Account label to show (label short) - if (! empty($arrayfields['aa.labelshort']['checked'])) + if (!empty($arrayfields['aa.labelshort']['checked'])) { print ""; print $obj->labelshort; print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Account parent diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index ef1d8e710d4..e8163c72f56 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -472,11 +472,11 @@ foreach ($dirmodels as $reldir) print ''; // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); if ($module->type == 'pdf') { - $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; } $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index 0e2680f3d0b..ae0c9c89b38 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -409,7 +409,7 @@ foreach ($dirmodels as $reldir) // Info $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); if ($module->type == 'pdf') { $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index b84d77cae16..8d917088d51 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -36,13 +36,13 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'errors', 'other', 'bills')); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); $action = GETPOST('action', 'alpha'); $value = GETPOST('value', 'alpha'); $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); -$type='invoice'; +$type = 'invoice'; /* @@ -53,22 +53,22 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstinvoice=GETPOST('maskconstinvoice', 'alpha'); - $maskconstreplacement=GETPOST('maskconstreplacement', 'alpha'); - $maskconstcredit=GETPOST('maskconstcredit', 'alpha'); - $maskconstdeposit=GETPOST('maskconstdeposit', 'alpha'); - $maskinvoice=GETPOST('maskinvoice', 'alpha'); - $maskreplacement=GETPOST('maskreplacement', 'alpha'); - $maskcredit=GETPOST('maskcredit', 'alpha'); - $maskdeposit=GETPOST('maskdeposit', 'alpha'); + $maskconstinvoice = GETPOST('maskconstinvoice', 'alpha'); + $maskconstreplacement = GETPOST('maskconstreplacement', 'alpha'); + $maskconstcredit = GETPOST('maskconstcredit', 'alpha'); + $maskconstdeposit = GETPOST('maskconstdeposit', 'alpha'); + $maskinvoice = GETPOST('maskinvoice', 'alpha'); + $maskreplacement = GETPOST('maskreplacement', 'alpha'); + $maskcredit = GETPOST('maskcredit', 'alpha'); + $maskdeposit = GETPOST('maskdeposit', 'alpha'); if ($maskconstinvoice) $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity); if ($maskconstreplacement) $res = dolibarr_set_const($db, $maskconstreplacement, $maskreplacement, 'chaine', 0, '', $conf->entity); if ($maskconstcredit) $res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity); if ($maskconstdeposit) $res = dolibarr_set_const($db, $maskconstdeposit, $maskdeposit, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -79,20 +79,20 @@ if ($action == 'updateMask') } elseif ($action == 'specimen') { - $modele=GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); $facture = new Facture($db); $facture->initAsSpecimen(); // Search template files - $file=''; $classname=''; $filefound=0; - $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach($dirmodels as $reldir) + $file = ''; $classname = ''; $filefound = 0; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { - $file=dol_buildpath($reldir."core/modules/facture/doc/pdf_".$modele.".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/facture/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound=1; + $filefound = 1; $classname = "pdf_".$modele; break; } @@ -167,9 +167,9 @@ elseif ($action == 'setribchq') $res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -184,9 +184,9 @@ elseif ($action == 'set_FACTURE_DRAFT_WATERMARK') $res = dolibarr_set_const($db, "FACTURE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -198,13 +198,13 @@ elseif ($action == 'set_FACTURE_DRAFT_WATERMARK') elseif ($action == 'set_INVOICE_FREE_TEXT') { - $freetext = GETPOST('INVOICE_FREE_TEXT', 'none'); // No alpha here, we want exact string + $freetext = GETPOST('INVOICE_FREE_TEXT', 'none'); // No alpha here, we want exact string $res = dolibarr_set_const($db, "INVOICE_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -219,9 +219,9 @@ elseif ($action == 'setforcedate') $res = dolibarr_set_const($db, "FAC_FORCE_DATE_VALIDATION", $forcedate, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -232,19 +232,19 @@ elseif ($action == 'setforcedate') } elseif ($action == 'setDefaultPDFModulesByType') { - $invoicetypemodels = GETPOST('invoicetypemodels'); + $invoicetypemodels = GETPOST('invoicetypemodels'); - if(!empty($invoicetypemodels) && is_array($invoicetypemodels)) + if (!empty($invoicetypemodels) && is_array($invoicetypemodels)) { $error = 0; foreach ($invoicetypemodels as $type => $value) { $res = dolibarr_set_const($db, 'FACTURE_ADDON_PDF_'.intval($type), $value, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; } - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -260,14 +260,14 @@ elseif ($action == 'setDefaultPDFModulesByType') * View */ -$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); llxHeader("", $langs->trans("BillsSetup"), 'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura'); -$form=new Form($db); +$form = new Form($db); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("BillsSetup"), $linkback, 'title_setup'); $head = invoice_admin_prepare_head(); @@ -298,24 +298,24 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { - if (! is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) + if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) { $filebis = $file; $classname = preg_replace('/\.php$/', '', $file); // For compatibility - if (! is_file($dir.$filebis)) + if (!is_file($dir.$filebis)) { $filebis = $file."/".$file.".modules.php"; $classname = "mod_facture_".$file; } // Check if there is a filter on country preg_match('/\-(.*)_(.*)$/', $classname, $reg); - if (! empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; + if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; $classname = preg_replace('/\-.*$/', '', $classname); - if (! class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis)-3, 3) == 'php') + if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') { // Charging the numbering class require_once $dir.$filebis; @@ -323,7 +323,7 @@ foreach ($dirmodels as $reldir) $module = new $classname($db); // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; if ($module->isEnabled()) @@ -338,9 +338,9 @@ foreach ($dirmodels as $reldir) // Show example of numbering module print ''; - $tmp=$module->getExample(); + $tmp = $module->getExample(); if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp=='NotConfigured') print $langs->trans($tmp); + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print ''."\n"; @@ -356,62 +356,62 @@ foreach ($dirmodels as $reldir) } print ''; - $facture=new Facture($db); + $facture = new Facture($db); $facture->initAsSpecimen(); // Example for standard invoice - $htmltooltip=''; - $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; - $facture->type=0; - $nextval=$module->getNextValue($mysoc, $facture); + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $facture->type = 0; + $nextval = $module->getNextValue($mysoc, $facture); if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip.=$langs->trans("NextValueForInvoices").': '; + $htmltooltip .= $langs->trans("NextValueForInvoices").': '; if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured') + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') $nextval = $langs->trans($nextval); - $htmltooltip.=$nextval.'
'; + $htmltooltip .= $nextval.'
'; } else { - $htmltooltip.=$langs->trans($module->error).'
'; + $htmltooltip .= $langs->trans($module->error).'
'; } } // Example for remplacement - $facture->type=1; - $nextval=$module->getNextValue($mysoc, $facture); + $facture->type = 1; + $nextval = $module->getNextValue($mysoc, $facture); if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip.=$langs->trans("NextValueForReplacements").': '; + $htmltooltip .= $langs->trans("NextValueForReplacements").': '; if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured') + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') $nextval = $langs->trans($nextval); - $htmltooltip.=$nextval.'
'; + $htmltooltip .= $nextval.'
'; } else { - $htmltooltip.=$langs->trans($module->error).'
'; + $htmltooltip .= $langs->trans($module->error).'
'; } } // Example for credit invoice - $facture->type=2; - $nextval=$module->getNextValue($mysoc, $facture); + $facture->type = 2; + $nextval = $module->getNextValue($mysoc, $facture); if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip.=$langs->trans("NextValueForCreditNotes").': '; + $htmltooltip .= $langs->trans("NextValueForCreditNotes").': '; if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured') + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') $nextval = $langs->trans($nextval); - $htmltooltip.=$nextval.'
'; + $htmltooltip .= $nextval.'
'; } else { - $htmltooltip.=$langs->trans($module->error).'
'; + $htmltooltip .= $langs->trans($module->error).'
'; } } // Example for deposit invoice - $facture->type=3; - $nextval=$module->getNextValue($mysoc, $facture); + $facture->type = 3; + $nextval = $module->getNextValue($mysoc, $facture); if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip.=$langs->trans("NextValueForDeposit").': '; + $htmltooltip .= $langs->trans("NextValueForDeposit").': '; if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured') + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') $nextval = $langs->trans($nextval); - $htmltooltip.=$nextval; + $htmltooltip .= $nextval; } else { - $htmltooltip.=$langs->trans($module->error); + $htmltooltip .= $langs->trans($module->error); } } @@ -420,7 +420,7 @@ foreach ($dirmodels as $reldir) if ($conf->global->FACTURE_ADDON.'.php' == $file) // If module is the one used, we show existing errors { - if (! empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1); + if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1); } print ''; @@ -445,17 +445,17 @@ print '
'; print load_fiche_titre($langs->trans("BillsPDFModules"), '', ''); // Load array def with activated templates -$type='invoice'; +$type = 'invoice'; $def = array(); $sql = "SELECT nom"; -$sql.= " FROM ".MAIN_DB_PREFIX."document_model"; -$sql.= " WHERE type = '".$type."'"; -$sql.= " AND entity = ".$conf->entity; -$resql=$db->query($sql); +$sql .= " FROM ".MAIN_DB_PREFIX."document_model"; +$sql .= " WHERE type = '".$type."'"; +$sql .= " AND entity = ".$conf->entity; +$resql = $db->query($sql); if ($resql) { $i = 0; - $num_rows=$db->num_rows($resql); + $num_rows = $db->num_rows($resql); while ($i < $num_rows) { $array = $db->fetch_array($resql); @@ -484,43 +484,43 @@ $activatedModels = array(); foreach ($dirmodels as $reldir) { - foreach (array('','/doc') as $valdir) + foreach (array('', '/doc') as $valdir) { $realpath = $reldir."core/modules/facture".$valdir; $dir = dol_buildpath($realpath); if (is_dir($dir)) { - $handle=opendir($dir); + $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { - $filelist[]=$file; + $filelist[] = $file; } closedir($handle); arsort($filelist); - foreach($filelist as $file) + foreach ($filelist as $file) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { if (file_exists($dir.'/'.$file)) { - $name = substr($file, 4, dol_strlen($file) -16); - $classname = substr($file, 0, dol_strlen($file) -12); + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); require_once $dir.'/'.$file; $module = new $classname($db); - $modulequalified=1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; if ($modulequalified) { print ''; - print (empty($module->name)?$name:$module->name); + print (empty($module->name) ? $name : $module->name); print "\n"; if (method_exists($module, 'info')) print $module->info($langs); else print $module->description; @@ -555,8 +555,8 @@ foreach ($dirmodels as $reldir) print ''; // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); if ($module->type == 'pdf') { $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; @@ -600,7 +600,7 @@ foreach ($dirmodels as $reldir) } print ''; -if(!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) // Hidden conf +if (!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) // Hidden conf { /* * Document templates generators @@ -617,13 +617,13 @@ if(!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) // Hidden conf print ''; print "\n"; - $listtype=array( + $listtype = array( Facture::TYPE_STANDARD=>$langs->trans("InvoiceStandard"), Facture::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"), Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"), Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"), ); - if (! empty($conf->global->INVOICE_USE_SITUATION)) + if (!empty($conf->global->INVOICE_USE_SITUATION)) { $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation"); } @@ -631,7 +631,7 @@ if(!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) // Hidden conf foreach ($listtype as $type => $trans) { $thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type; - $current = !empty($conf->global->{$thisTypeConfName})?$conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF; + $current = !empty($conf->global->{$thisTypeConfName}) ? $conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF; print ''; print ''.$trans.''; print ''.$form->selectarray('invoicetypemodels['.$type.']', ModelePDFFactures::liste_modeles($db), $current, 0, 0, 0).''; @@ -663,14 +663,14 @@ print "\n"; print ''; print "".$langs->trans("SuggestPaymentByRIBOnAccount").""; print ""; -if (! empty($conf->banque->enabled)) +if (!empty($conf->banque->enabled)) { $sql = "SELECT rowid, label"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; - $sql.= " WHERE clos = 0"; - $sql.= " AND courant = 1"; - $sql.= " AND entity IN (".getEntity('bank_account').")"; - $resql=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."bank_account"; + $sql .= " WHERE clos = 0"; + $sql .= " AND courant = 1"; + $sql .= " AND entity IN (".getEntity('bank_account').")"; + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -684,7 +684,7 @@ if (! empty($conf->banque->enabled)) $row = $db->fetch_row($resql); print ''; $i++; @@ -708,15 +708,15 @@ print "".$langs->trans("SuggestPaymentByChequeToAddress").""; print ""; print '\n"; print ''; -$substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2); -$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); +$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $htmltext = ''.$langs->trans("AvailableVariables").':
'; -foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; -$htmltext.='
'; +foreach ($substitutionarray as $key => $val) $htmltext .= $key.'
'; +$htmltext .= ''; print '
'; print ''; print ''; print ''; print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; -$variablename='INVOICE_FREE_TEXT'; +$variablename = 'INVOICE_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { print ''; @@ -780,7 +780,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 474c6020610..f74ee2fac7d 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -638,7 +638,7 @@ else $liste['user'] = $langs->trans('UserEmail'); $liste['company'] = $langs->trans('CompanyEmail').' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? $langs->trans("NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).')'; $sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile'; - $sql.= ' WHERE active = 1 AND (private = 0 OR private = '.$user->id.')'; + $sql .= ' WHERE active = 1 AND (private = 0 OR private = '.$user->id.')'; $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index a0ebbc16e34..137d4129929 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -108,9 +108,9 @@ if (is_array($extrafields->attributes[$object->table_element]['label']) && count if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) { $arrayfields["ef.".$key] = array( 'label'=>$extrafields->attributes[$object->table_element]['label'][$key], - 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), + 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], - 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key]) + 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]) ); } } @@ -451,7 +451,7 @@ foreach ($object->fields as $key => $val) elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } - elseif (! preg_match('/^(date|timestamp)/', $val['type'])) print ''; + elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; print ''; } } @@ -555,10 +555,10 @@ while ($i < ($limit ? min($num, $limit) : $num)) // Action column print ''; $url = $_SERVER["PHP_SELF"].'?action=list&id='.$obj->rowid; - if ($limit) $url.='&limit='.urlencode($limit); - if ($page) $url.='&page='.urlencode($page); - if ($sortfield) $url.='&sortfield='.urlencode($sortfield); - if ($sortorder) $url.='&page='.urlencode($sortorder); + if ($limit) $url .= '&limit='.urlencode($limit); + if ($page) $url .= '&page='.urlencode($page); + if ($sortfield) $url .= '&sortfield='.urlencode($sortfield); + if ($sortorder) $url .= '&page='.urlencode($sortorder); //print ''.img_edit().''; //print '   '; print ''.img_delete().'   '; diff --git a/htdocs/admin/mrp.php b/htdocs/admin/mrp.php index a686422a21e..9c59b5cf6da 100644 --- a/htdocs/admin/mrp.php +++ b/htdocs/admin/mrp.php @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/mrp/lib/mrp.lib.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'errors', 'mrp', 'other')); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); $action = GETPOST('action', 'alpha'); $value = GETPOST('value', 'alpha'); @@ -48,14 +48,14 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstmrp=GETPOST('maskconstMo', 'alpha'); - $maskmrp=GETPOST('maskMo', 'alpha'); + $maskconstmrp = GETPOST('maskconstMo', 'alpha'); + $maskmrp = GETPOST('maskMo', 'alpha'); if ($maskconstmrp) $res = dolibarr_set_const($db, $maskconstmrp, $maskmrp, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -67,20 +67,20 @@ if ($action == 'updateMask') elseif ($action == 'specimen') { - $modele=GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); $mo = new MO($db); $mrp->initAsSpecimen(); // Search template files - $file=''; $classname=''; $filefound=0; - $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach($dirmodels as $reldir) + $file = ''; $classname = ''; $filefound = 0; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { - $file=dol_buildpath($reldir."core/modules/mrp/doc/pdf_".$modele.".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/mrp/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound=1; + $filefound = 1; $classname = "pdf_".$modele; break; } @@ -156,9 +156,9 @@ elseif ($action == 'set_MRP_MO_DRAFT_WATERMARK') $draft = GETPOST("MRP_MO_DRAFT_WATERMARK"); $res = dolibarr_set_const($db, "MRP_MO_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -170,13 +170,13 @@ elseif ($action == 'set_MRP_MO_DRAFT_WATERMARK') elseif ($action == 'set_MRP_MO_FREE_TEXT') { - $freetext = GETPOST("MRP_MO_FREE_TEXT", 'none'); // No alpha here, we want exact string + $freetext = GETPOST("MRP_MO_FREE_TEXT", 'none'); // No alpha here, we want exact string $res = dolibarr_set_const($db, "MRP_MO_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -191,13 +191,13 @@ elseif ($action == 'set_MRP_MO_FREE_TEXT') * View */ -$form=new Form($db); +$form = new Form($db); -$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); llxHeader("", $langs->trans("MrpSetupPage")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("MrpSetupPage"), $linkback, 'title_setup'); $head = mrpAdminPrepareHead(); @@ -230,18 +230,18 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { - if (substr($file, 0, 7) == 'mod_mo_' && substr($file, dol_strlen($file)-3, 3) == 'php') + if (substr($file, 0, 7) == 'mod_mo_' && substr($file, dol_strlen($file) - 3, 3) == 'php') { - $file = substr($file, 0, dol_strlen($file)-4); + $file = substr($file, 0, dol_strlen($file) - 4); require_once $dir.$file.'.php'; $module = new $file($db); // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; if ($module->isEnabled()) @@ -252,9 +252,9 @@ foreach ($dirmodels as $reldir) // Show example of numbering model print ''; - $tmp=$module->getExample(); + $tmp = $module->getExample(); if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp=='NotConfigured') print $langs->trans($tmp); + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print ''."\n"; @@ -271,22 +271,22 @@ foreach ($dirmodels as $reldir) } print ''; - $mrp=new MO($db); + $mrp = new MO($db); $mrp->initAsSpecimen(); // Info - $htmltooltip=''; - $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; - $mrp->type=0; - $nextval=$module->getNextValue($mysoc, $mrp); + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $mrp->type = 0; + $nextval = $module->getNextValue($mysoc, $mrp); if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip.=''.$langs->trans("NextValue").': '; + $htmltooltip .= ''.$langs->trans("NextValue").': '; if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured') + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') $nextval = $langs->trans($nextval); - $htmltooltip.=$nextval.'
'; + $htmltooltip .= $nextval.'
'; } else { - $htmltooltip.=$langs->trans($module->error).'
'; + $htmltooltip .= $langs->trans($module->error).'
'; } } @@ -314,14 +314,14 @@ print load_fiche_titre($langs->trans("MOsModelModule"), '', ''); // Load array def with activated templates $def = array(); $sql = "SELECT nom"; -$sql.= " FROM ".MAIN_DB_PREFIX."document_model"; -$sql.= " WHERE type = '".$type."'"; -$sql.= " AND entity = ".$conf->entity; -$resql=$db->query($sql); +$sql .= " FROM ".MAIN_DB_PREFIX."document_model"; +$sql .= " WHERE type = '".$type."'"; +$sql .= " AND entity = ".$conf->entity; +$resql = $db->query($sql); if ($resql) { $i = 0; - $num_rows=$db->num_rows($resql); + $num_rows = $db->num_rows($resql); while ($i < $num_rows) { $array = $db->fetch_array($resql); @@ -349,43 +349,43 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('','/doc') as $valdir) + foreach (array('', '/doc') as $valdir) { $realpath = $reldir."core/modules/mrp".$valdir; $dir = dol_buildpath($realpath); if (is_dir($dir)) { - $handle=opendir($dir); + $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { - $filelist[]=$file; + $filelist[] = $file; } closedir($handle); arsort($filelist); - foreach($filelist as $file) + foreach ($filelist as $file) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { if (file_exists($dir.'/'.$file)) { - $name = substr($file, 4, dol_strlen($file) -16); - $classname = substr($file, 0, dol_strlen($file) -12); + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); require_once $dir.'/'.$file; $module = new $classname($db); - $modulequalified=1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; if ($modulequalified) { print ''; - print (empty($module->name)?$name:$module->name); + print (empty($module->name) ? $name : $module->name); print "\n"; if (method_exists($module, 'info')) print $module->info($langs); else print $module->description; @@ -420,11 +420,11 @@ foreach ($dirmodels as $reldir) print ''; // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); if ($module->type == 'pdf') { - $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; } $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; @@ -474,18 +474,18 @@ print ''.$langs->trans("Value").''; print " \n"; print "\n"; -$substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2); -$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); +$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $htmltext = ''.$langs->trans("AvailableVariables").':
'; -foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; -$htmltext.='
'; +foreach ($substitutionarray as $key => $val) $htmltext .= $key.'
'; +$htmltext .= ''; print ''; print ''; print ''; print ''; print $form->textwithpicto($langs->trans("FreeLegalTextOnMOs"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; -$variablename='MRP_MO_FREE_TEXT'; +$variablename = 'MRP_MO_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { print ''; @@ -493,7 +493,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); print $doleditor->Create(); } print ''; diff --git a/htdocs/admin/order_extrafields.php b/htdocs/admin/order_extrafields.php index eba9fd76ff6..2c72c55697f 100644 --- a/htdocs/admin/order_extrafields.php +++ b/htdocs/admin/order_extrafields.php @@ -41,13 +41,13 @@ $extrafields = new ExtraFields($db); $form = new Form($db); // List of supported format -$tmptype2label=ExtraFields::$type2label; -$type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); -$action=GETPOST('action', 'alpha'); -$attrname=GETPOST('attrname', 'alpha'); -$elementtype='commande'; //Must be the $table_element of the class that manage extrafield +$action = GETPOST('action', 'alpha'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'commande'; //Must be the $table_element of the class that manage extrafield if (!$user->admin) accessforbidden(); @@ -64,11 +64,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ -$textobject=$langs->transnoentitiesnoconv("Orders"); +$textobject = $langs->transnoentitiesnoconv("Orders"); llxHeader('', $langs->trans("OrdersSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("OrdersSetup"), $linkback, 'title_setup'); $head = order_admin_prepare_head(); @@ -108,7 +108,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && ! empty($attrname)) +if ($action == 'edit' && !empty($attrname)) { print "
"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/admin/orderdet_extrafields.php b/htdocs/admin/orderdet_extrafields.php index 9204bbc251c..55732a40a51 100644 --- a/htdocs/admin/orderdet_extrafields.php +++ b/htdocs/admin/orderdet_extrafields.php @@ -42,13 +42,13 @@ $extrafields = new ExtraFields($db); $form = new Form($db); // List of supported format -$tmptype2label=ExtraFields::$type2label; -$type2label=array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); +$tmptype2label = ExtraFields::$type2label; +$type2label = array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); -$action=GETPOST('action', 'alpha'); -$attrname=GETPOST('attrname', 'alpha'); -$elementtype='commandedet'; //Must be the $table_element of the class that manage extrafield +$action = GETPOST('action', 'alpha'); +$attrname = GETPOST('attrname', 'alpha'); +$elementtype = 'commandedet'; //Must be the $table_element of the class that manage extrafield if (!$user->admin) accessforbidden(); @@ -65,11 +65,11 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ -$textobject=$langs->transnoentitiesnoconv("Orders"); +$textobject = $langs->transnoentitiesnoconv("Orders"); llxHeader('', $langs->trans("OrdersSetup")); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("OrdersSetup"), $linkback, 'title_setup'); $head = order_admin_prepare_head(); @@ -109,7 +109,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && ! empty($attrname)) +if ($action == 'edit' && !empty($attrname)) { print "
"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php index 51e5bd4b249..52717200bce 100644 --- a/htdocs/admin/tools/listevents.php +++ b/htdocs/admin/tools/listevents.php @@ -28,11 +28,11 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -if (! $user->admin) +if (!$user->admin) accessforbidden(); -$action=GETPOST('action', 'alpha'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); // Security check if ($user->socid > 0) @@ -42,10 +42,10 @@ if ($user->socid > 0) } // Load translation files required by the page -$langs->loadLangs(array("companies","admin","users","other")); +$langs->loadLangs(array("companies", "admin", "users", "other")); // 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'); @@ -53,8 +53,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="dateevent"; -if (! $sortorder) $sortorder="DESC"; +if (!$sortfield) $sortfield = "dateevent"; +if (!$sortorder) $sortorder = "DESC"; $search_code = GETPOST("search_code", "alpha"); $search_ip = GETPOST("search_ip", "alpha"); @@ -63,24 +63,24 @@ $search_desc = GETPOST("search_desc", "alpha"); $search_ua = GETPOST("search_ua", "none"); $search_prefix_session = GETPOST("search_prefix_session", "none"); -if (GETPOST("date_startmonth") == '' || GETPOST("date_startmonth") > 0) $date_start=dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); -else $date_start=-1; -if (GETPOST("date_endmonth") == '' || GETPOST("date_endmonth") > 0) $date_end=dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); -else $date_end=-1; +if (GETPOST("date_startmonth") == '' || GETPOST("date_startmonth") > 0) $date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); +else $date_start = -1; +if (GETPOST("date_endmonth") == '' || GETPOST("date_endmonth") > 0) $date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); +else $date_end = -1; // checks:if date_start>date_end then date_end=date_start + 24 hours -if ($date_start > 0 && $date_end > 0 && $date_start > $date_end) $date_end=$date_start+86400; +if ($date_start > 0 && $date_end > 0 && $date_start > $date_end) $date_end = $date_start + 86400; $now = dol_now(); $nowarray = dol_getdate($now); if (empty($date_start)) // We define date_start and date_end { - $date_start=dol_get_first_day($nowarray['year'], $nowarray['mon'], false); + $date_start = dol_get_first_day($nowarray['year'], $nowarray['mon'], false); } if (empty($date_end)) { - $date_end=dol_mktime(23, 59, 59, $nowarray['mon'], $nowarray['mday'], $nowarray['year']); + $date_end = dol_mktime(23, 59, 59, $nowarray['mon'], $nowarray['mday'], $nowarray['year']); } // Set $date_startmonth... $tmp = dol_getdate($date_start); @@ -92,56 +92,56 @@ $date_endday = $tmp['mday']; $date_endmonth = $tmp['mon']; $date_endyear = $tmp['year']; -$arrayfields=array(); +$arrayfields = array(); /* * Actions */ -$now=dol_now(); +$now = dol_now(); // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers { - $date_start=-1; - $date_end=-1; - $search_code=''; - $search_ip=''; - $search_user=''; - $search_desc=''; - $search_ua=''; - $search_prefix_session=''; + $date_start = -1; + $date_end = -1; + $search_code = ''; + $search_ip = ''; + $search_user = ''; + $search_desc = ''; + $search_ua = ''; + $search_prefix_session = ''; } // Purge audit events if ($action == 'confirm_purge' && $confirm == 'yes' && $user->admin) { - $error=0; + $error = 0; $db->begin(); - $securityevents=new Events($db); + $securityevents = new Events($db); // Delete events $sql = "DELETE FROM ".MAIN_DB_PREFIX."events"; - $sql.= " WHERE entity = ".$conf->entity; + $sql .= " WHERE entity = ".$conf->entity; dol_syslog("listevents purge", LOG_DEBUG); $resql = $db->query($sql); - if (! $resql) + if (!$resql) { $error++; setEventMessages($db->lasterror(), null, 'errors'); } // Add event purge - $text=$langs->trans("SecurityEventsPurged"); - $securityevent=new Events($db); - $securityevent->type='SECURITY_EVENTS_PURGE'; - $securityevent->dateevent=$now; - $securityevent->description=$text; + $text = $langs->trans("SecurityEventsPurged"); + $securityevent = new Events($db); + $securityevent->type = 'SECURITY_EVENTS_PURGE'; + $securityevent->dateevent = $now; + $securityevent->description = $text; - $result=$securityevent->create($user); + $result = $securityevent->create($user); if ($result > 0) { $db->commit(); @@ -162,26 +162,26 @@ if ($action == 'confirm_purge' && $confirm == 'yes' && $user->admin) llxHeader('', $langs->trans("Audit")); -$form=new Form($db); +$form = new Form($db); -$userstatic=new User($db); -$usefilter=0; +$userstatic = new User($db); +$usefilter = 0; $sql = "SELECT e.rowid, e.type, e.ip, e.user_agent, e.dateevent,"; -$sql.= " e.fk_user, e.description, e.prefix_session,"; -$sql.= " u.login"; -$sql.= " FROM ".MAIN_DB_PREFIX."events as e"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = e.fk_user"; -$sql.= " WHERE e.entity IN (".getEntity('event').")"; -if ($date_start > 0) $sql.= " AND e.dateevent >= '".$db->idate($date_start)."'"; -if ($date_end > 0) $sql.= " AND e.dateevent <= '".$db->idate($date_end)."'"; -if ($search_code) { $usefilter++; $sql.=natural_search("e.type", $search_code, 0); } -if ($search_ip) { $usefilter++; $sql.=natural_search("e.ip", $search_ip, 0); } -if ($search_user) { $usefilter++; $sql.=natural_search("u.login", $search_user, 0); } -if ($search_desc) { $usefilter++; $sql.=natural_search("e.description", $search_desc, 0); } -if ($search_ua) { $usefilter++; $sql.=natural_search("e.user_agent", $search_ua, 0); } -if ($search_prefix_session) { $usefilter++; $sql.=natural_search("e.prefix_session", $search_prefix_session, 0); } -$sql.= $db->order($sortfield, $sortorder); +$sql .= " e.fk_user, e.description, e.prefix_session,"; +$sql .= " u.login"; +$sql .= " FROM ".MAIN_DB_PREFIX."events as e"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = e.fk_user"; +$sql .= " WHERE e.entity IN (".getEntity('event').")"; +if ($date_start > 0) $sql .= " AND e.dateevent >= '".$db->idate($date_start)."'"; +if ($date_end > 0) $sql .= " AND e.dateevent <= '".$db->idate($date_end)."'"; +if ($search_code) { $usefilter++; $sql .= natural_search("e.type", $search_code, 0); } +if ($search_ip) { $usefilter++; $sql .= natural_search("e.ip", $search_ip, 0); } +if ($search_user) { $usefilter++; $sql .= natural_search("u.login", $search_user, 0); } +if ($search_desc) { $usefilter++; $sql .= natural_search("e.description", $search_desc, 0); } +if ($search_ua) { $usefilter++; $sql .= natural_search("e.user_agent", $search_ua, 0); } +if ($search_prefix_session) { $usefilter++; $sql .= natural_search("e.prefix_session", $search_prefix_session, 0); } +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -196,7 +196,7 @@ $nbtotalofrecords = ''; } }*/ -$sql.= $db->plimit($conf->liste_limit+1, $offset); +$sql .= $db->plimit($conf->liste_limit + 1, $offset); //print $sql; $result = $db->query($sql); if ($result) @@ -204,27 +204,27 @@ if ($result) $num = $db->num_rows($result); $i = 0; - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); - if ($search_code) $param.='&search_code='.urlencode($search_code); - if ($search_ip) $param.='&search_ip='.urlencode($search_ip); - if ($search_user) $param.='&search_user='.urlencode($search_user); - if ($search_desc) $param.='&search_desc='.urlencode($search_desc); - if ($search_ua) $param.='&search_ua='.urlencode($search_ua); - if ($search_prefix_sessiona) $param.='&search_prefix_session='.urlencode($search_prefix_session); - if ($date_startmonth) $param.= "&date_startmonth=".urlencode($date_startmonth); - if ($date_startday) $param.= "&date_startday=".urlencode($date_startday); - if ($date_startyear) $param.= "&date_startyear=".urlencode($date_startyear); - if ($date_endmonth) $param.= "&date_endmonth=".urlencode($date_endmonth); - if ($date_endday) $param.= "&date_endday=".urlencode($date_endday); - if ($date_endyear) $param.= "&date_endyear=".urlencode($date_endyear); + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + if ($search_code) $param .= '&search_code='.urlencode($search_code); + if ($search_ip) $param .= '&search_ip='.urlencode($search_ip); + if ($search_user) $param .= '&search_user='.urlencode($search_user); + if ($search_desc) $param .= '&search_desc='.urlencode($search_desc); + if ($search_ua) $param .= '&search_ua='.urlencode($search_ua); + if ($search_prefix_sessiona) $param .= '&search_prefix_session='.urlencode($search_prefix_session); + if ($date_startmonth) $param .= "&date_startmonth=".urlencode($date_startmonth); + if ($date_startday) $param .= "&date_startday=".urlencode($date_startday); + if ($date_startyear) $param .= "&date_startyear=".urlencode($date_startyear); + if ($date_endmonth) $param .= "&date_endmonth=".urlencode($date_endmonth); + if ($date_endday) $param .= "&date_endday=".urlencode($date_endday); + if ($date_endyear) $param .= "&date_endyear=".urlencode($date_endyear); $langs->load('withdrawals'); if ($num) { - $center=''.$langs->trans("Purge").''; + $center = ''.$langs->trans("Purge").''; } print ''; @@ -233,7 +233,7 @@ if ($result) if ($action == 'purge') { - $formquestion=array(); + $formquestion = array(); print $form->formconfirm($_SERVER["PHP_SELF"].'?noparam=noparam', $langs->trans('PurgeAuditEvents'), $langs->trans('ConfirmPurgeAuditEvents'), 'confirm_purge', $formquestion, 'no', 1); } @@ -262,14 +262,14 @@ if ($result) //print ''; print ''; - if (! empty($arrayfields['e.user_agent']['checked'])) + if (!empty($arrayfields['e.user_agent']['checked'])) { print ''; print ''; print ''; } - if (! empty($arrayfields['e.prefix_session']['checked'])) + if (!empty($arrayfields['e.prefix_session']['checked'])) { print ''; print ''; @@ -277,7 +277,7 @@ if ($result) } print ''; - $searchpicto=$form->showFilterAndCheckAddButtons(0); + $searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print ''; @@ -290,11 +290,11 @@ if ($result) print_liste_field_titre("IP", $_SERVER["PHP_SELF"], "e.ip", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("User", $_SERVER["PHP_SELF"], "u.login", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "e.description", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['e.user_agent']['checked'])) + if (!empty($arrayfields['e.user_agent']['checked'])) { print_liste_field_titre("UserAgent", $_SERVER["PHP_SELF"], "e.user_agent", "", $param, '', $sortfield, $sortorder); } - if (! empty($arrayfields['e.prefix_session']['checked'])) + if (!empty($arrayfields['e.prefix_session']['checked'])) { print_liste_field_titre("PrefixSession", $_SERVER["PHP_SELF"], "e.prefix_session", "", $param, '', $sortfield, $sortorder); } @@ -322,8 +322,8 @@ if ($result) print ''; if ($obj->fk_user) { - $userstatic->id=$obj->fk_user; - $userstatic->login=$obj->login; + $userstatic->id = $obj->fk_user; + $userstatic->login = $obj->login; print $userstatic->getLoginUrl(1); } else print ' '; @@ -331,18 +331,18 @@ if ($result) // Description print ''; - $text=$langs->trans($obj->description); + $text = $langs->trans($obj->description); $reg = array(); if (preg_match('/\((.*)\)(.*)/i', $obj->description, $reg)) { - $val=explode(',', $reg[1]); - $text=$langs->trans($val[0], isset($val[1])?$val[1]:'', isset($val[2])?$val[2]:'', isset($val[3])?$val[3]:'', isset($val[4])?$val[4]:''); - if (! empty($reg[2])) $text.=$reg[2]; + $val = explode(',', $reg[1]); + $text = $langs->trans($val[0], isset($val[1]) ? $val[1] : '', isset($val[2]) ? $val[2] : '', isset($val[3]) ? $val[3] : '', isset($val[4]) ? $val[4] : ''); + if (!empty($reg[2])) $text .= $reg[2]; } print dol_escape_htmltag($text); print ''; - if (! empty($arrayfields['e.user_agent']['checked'])) + if (!empty($arrayfields['e.user_agent']['checked'])) { // User agent print ''; @@ -350,7 +350,7 @@ if ($result) print ''; } - if (! empty($arrayfields['e.prefix_session']['checked'])) + if (!empty($arrayfields['e.prefix_session']['checked'])) { // User agent print ''; @@ -360,8 +360,8 @@ if ($result) // More informations print ''; - $htmltext=''.$langs->trans("UserAgent").': '.($obj->user_agent ? dol_string_nohtmltag($obj->user_agent) : $langs->trans("Unknown")); - $htmltext.='
'.$langs->trans("PrefixSession").': '.($obj->prefix_session ? dol_string_nohtmltag($obj->prefix_session) : $langs->trans("Unknown")); + $htmltext = ''.$langs->trans("UserAgent").': '.($obj->user_agent ? dol_string_nohtmltag($obj->user_agent) : $langs->trans("Unknown")); + $htmltext .= '
'.$langs->trans("PrefixSession").': '.($obj->prefix_session ? dol_string_nohtmltag($obj->prefix_session) : $langs->trans("Unknown")); print $form->textwithpicto('', $htmltext); print ''; diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 0183ffb004a..ddfb5e78d17 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -747,7 +747,7 @@ class BOM extends CommonObject $label .= '
'; $label .= ''.$langs->trans('Ref').': '.$this->ref; if (isset($this->status)) { - $label.= '
' . $langs->trans("Status").": ".$this->getLibStatut(5); + $label .= '
'.$langs->trans("Status").": ".$this->getLibStatut(5); } $url = dol_buildpath('/bom/bom_card.php', 1).'?id='.$this->id; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 0d8fcaa7ff1..f75244dcf7d 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -272,7 +272,7 @@ class ActionComm extends CommonObject /** * @var int Id of linked object */ - public $fk_element; // Id of record + public $fk_element; // Id of record /** * @var int Id of record alternative for API @@ -302,7 +302,7 @@ class ActionComm extends CommonObject /** * @var array Actions */ - public $actions=array(); + public $actions = array(); /** * @var string Email msgid @@ -839,11 +839,11 @@ class ActionComm extends CommonObject public function fetch_userassigned($override = true) { // phpcs:enable - $sql ="SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency"; - $sql.=" FROM ".MAIN_DB_PREFIX."actioncomm_resources"; - $sql.=" WHERE element_type = 'user' AND fk_actioncomm = ".$this->id; + $sql = "SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency"; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm_resources"; + $sql .= " WHERE element_type = 'user' AND fk_actioncomm = ".$this->id; - $resql2=$this->db->query($sql); + $resql2 = $this->db->query($sql); if ($resql2) { $this->userassigned = array(); @@ -894,35 +894,35 @@ class ActionComm extends CommonObject { global $user; - $error=0; + $error = 0; $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm"; - $sql.= " WHERE id=".$this->id; + $sql .= " WHERE id=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $res=$this->db->query($sql); + $res = $this->db->query($sql); if ($res < 0) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } - if (! $error) { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_resources"; - $sql.= " WHERE fk_actioncomm=".$this->id; + $sql .= " WHERE fk_actioncomm=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $res=$this->db->query($sql); + $res = $this->db->query($sql); if ($res < 0) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } } // Removed extrafields - if (! $error) { - $result=$this->deleteExtraFields(); + if (!$error) { + $result = $this->deleteExtraFields(); if ($result < 0) { $error++; @@ -1186,52 +1186,52 @@ class ActionComm extends CommonObject // phpcs:enable global $conf, $langs; - if(empty($load_state_board)) $sql = "SELECT a.id, a.datep as dp"; + if (empty($load_state_board)) $sql = "SELECT a.id, a.datep as dp"; else { - $this->nb=array(); + $this->nb = array(); $sql = "SELECT count(a.id) as nb"; } - $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; - if (! $user->rights->societe->client->voir && ! $user->socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; - $sql.= " WHERE 1 = 1"; - if(empty($load_state_board)) $sql.= " AND a.percent >= 0 AND a.percent < 100"; - $sql.= " AND a.entity IN (".getEntity('agenda').")"; - if (! $user->rights->societe->client->voir && ! $user->socid) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; - if ($user->socid) $sql.=" AND a.fk_soc = ".$user->socid; - if (! $user->rights->agenda->allactions->read) $sql.= " AND (a.fk_user_author = ".$user->id . " OR a.fk_user_action = ".$user->id . " OR a.fk_user_done = ".$user->id . ")"; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; + $sql .= " WHERE 1 = 1"; + if (empty($load_state_board)) $sql .= " AND a.percent >= 0 AND a.percent < 100"; + $sql .= " AND a.entity IN (".getEntity('agenda').")"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; + if ($user->socid) $sql .= " AND a.fk_soc = ".$user->socid; + if (!$user->rights->agenda->allactions->read) $sql .= " AND (a.fk_user_author = ".$user->id." OR a.fk_user_action = ".$user->id." OR a.fk_user_done = ".$user->id.")"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - if(empty($load_state_board)) { + if (empty($load_state_board)) { $agenda_static = new ActionComm($this->db); $response = new WorkboardResponse(); - $response->warning_delay = $conf->agenda->warning_delay/60/60/24; + $response->warning_delay = $conf->agenda->warning_delay / 60 / 60 / 24; $response->label = $langs->trans("ActionsToDo"); $response->labelShort = $langs->trans("ActionsToDoShort"); $response->url = DOL_URL_ROOT.'/comm/action/list.php?actioncode=0&status=todo&mainmenu=agenda'; - if ($user->rights->agenda->allactions->read) $response->url.='&filtert=-1'; + if ($user->rights->agenda->allactions->read) $response->url .= '&filtert=-1'; $response->img = img_object('', "action", 'class="inline-block valigntextmiddle"'); } // This assignment in condition is not a bug. It allows walking the results. - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - if(empty($load_state_board)) { + if (empty($load_state_board)) { $response->nbtodo++; $agenda_static->datep = $this->db->jdate($obj->dp); if ($agenda_static->hasDelay()) $response->nbtodolate++; - } else $this->nb["actionscomm"]=$obj->nb; + } else $this->nb["actionscomm"] = $obj->nb; } $this->db->free($resql); - if(empty($load_state_board)) return $response; + if (empty($load_state_board)) return $response; else return 1; } else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -1394,10 +1394,10 @@ class ActionComm extends CommonObject if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $canread = 0; - if ($user->rights->agenda->myactions->read && $this->authorid == $user->id) $canread = 1; // Can read my event - if ($user->rights->agenda->myactions->read && array_key_exists($user->id, $this->userassigned)) $canread = 1; // Can read my event i am assigned - if ($user->rights->agenda->allactions->read) $canread = 1; // Can read all event of other - if (! $canread) + if ($user->rights->agenda->myactions->read && $this->authorid == $user->id) $canread = 1; // Can read my event + if ($user->rights->agenda->myactions->read && array_key_exists($user->id, $this->userassigned)) $canread = 1; // Can read my event i am assigned + if ($user->rights->agenda->allactions->read) $canread = 1; // Can read all event of other + if (!$canread) { $option = 'nolink'; } @@ -1529,12 +1529,12 @@ class ActionComm extends CommonObject public function setCategories($categories) { // Handle single category - if (! is_array($categories)) { + if (!is_array($categories)) { $categories = array($categories); } // Get current categories - include_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $c = new Categorie($this->db); $existing = $c->containing($this->id, Categorie::TYPE_ACTIONCOMM, 'id'); @@ -1548,7 +1548,7 @@ class ActionComm extends CommonObject } // Process - foreach($to_del as $del) { + foreach ($to_del as $del) { if ($c->fetch($del) > 0) { $c->del_type($this, Categorie::TYPE_ACTIONCOMM); } @@ -1622,105 +1622,105 @@ class ActionComm extends CommonObject if ($buildfile) { // Build event array - $eventarray=array(); + $eventarray = array(); $sql = "SELECT a.id,"; - $sql.= " a.datep,"; // Start - $sql.= " a.datep2,"; // End - $sql.= " a.durationp,"; // deprecated - $sql.= " a.datec, a.tms as datem,"; - $sql.= " a.label, a.code, a.note, a.fk_action as type_id,"; - $sql.= " a.fk_soc,"; - $sql.= " a.fk_user_author, a.fk_user_mod,"; - $sql.= " a.fk_user_action,"; - $sql.= " a.fk_contact, a.percent as percentage,"; - $sql.= " a.fk_element, a.elementtype,"; - $sql.= " a.priority, a.fulldayevent, a.location, a.punctual, a.transparency,"; - $sql.= " u.firstname, u.lastname, u.email,"; - $sql.= " s.nom as socname,"; - $sql.= " c.id as type_id, c.code as type_code, c.libelle as type_label"; - $sql.= " FROM (".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."actioncomm as a)"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author"; // Link to get author of event for export - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc"; + $sql .= " a.datep,"; // Start + $sql .= " a.datep2,"; // End + $sql .= " a.durationp,"; // deprecated + $sql .= " a.datec, a.tms as datem,"; + $sql .= " a.label, a.code, a.note, a.fk_action as type_id,"; + $sql .= " a.fk_soc,"; + $sql .= " a.fk_user_author, a.fk_user_mod,"; + $sql .= " a.fk_user_action,"; + $sql .= " a.fk_contact, a.percent as percentage,"; + $sql .= " a.fk_element, a.elementtype,"; + $sql .= " a.priority, a.fulldayevent, a.location, a.punctual, a.transparency,"; + $sql .= " u.firstname, u.lastname, u.email,"; + $sql .= " s.nom as socname,"; + $sql .= " c.id as type_id, c.code as type_code, c.libelle as type_label"; + $sql .= " FROM (".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."actioncomm as a)"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author"; // Link to get author of event for export + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc"; - $parameters=array('filters' => $filters); - $reshook=$hookmanager->executeHooks('printFieldListFrom', $parameters); // Note that $action and $object may have been modified by hook - $sql.=$hookmanager->resPrint; + $parameters = array('filters' => $filters); + $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; // We must filter on assignement table - if ($filters['logint']) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; - $sql.= " WHERE a.fk_action=c.id"; - $sql.= " AND a.entity IN (".getEntity('agenda').")"; + if ($filters['logint']) $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; + $sql .= " WHERE a.fk_action=c.id"; + $sql .= " AND a.entity IN (".getEntity('agenda').")"; foreach ($filters as $key => $value) { - if ($key == 'notolderthan' && $value != '') $sql.=" AND a.datep >= '".$this->db->idate($now-($value*24*60*60))."'"; - if ($key == 'year') $sql.=" AND a.datep BETWEEN '".$this->db->idate(dol_get_first_day($value, 1))."' AND '".$this->db->idate(dol_get_last_day($value, 12))."'"; - if ($key == 'id') $sql.=" AND a.id=".(is_numeric($value)?$value:0); - if ($key == 'idfrom') $sql.=" AND a.id >= ".(is_numeric($value)?$value:0); - if ($key == 'idto') $sql.=" AND a.id <= ".(is_numeric($value)?$value:0); - if ($key == 'project') $sql.=" AND a.fk_project=".(is_numeric($value)?$value:0); - if ($key == 'actiontype') $sql.=" AND c.type = '".$this->db->escape($value)."'"; - if ($key == 'notactiontype') $sql.=" AND c.type <> '".$this->db->escape($value)."'"; + if ($key == 'notolderthan' && $value != '') $sql .= " AND a.datep >= '".$this->db->idate($now - ($value * 24 * 60 * 60))."'"; + if ($key == 'year') $sql .= " AND a.datep BETWEEN '".$this->db->idate(dol_get_first_day($value, 1))."' AND '".$this->db->idate(dol_get_last_day($value, 12))."'"; + if ($key == 'id') $sql .= " AND a.id=".(is_numeric($value) ? $value : 0); + if ($key == 'idfrom') $sql .= " AND a.id >= ".(is_numeric($value) ? $value : 0); + if ($key == 'idto') $sql .= " AND a.id <= ".(is_numeric($value) ? $value : 0); + if ($key == 'project') $sql .= " AND a.fk_project=".(is_numeric($value) ? $value : 0); + if ($key == 'actiontype') $sql .= " AND c.type = '".$this->db->escape($value)."'"; + if ($key == 'notactiontype') $sql .= " AND c.type <> '".$this->db->escape($value)."'"; // We must filter on assignement table - if ($key == 'logint') $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; + if ($key == 'logint') $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; if ($key == 'logina') { - $logina=$value; - $condition='='; + $logina = $value; + $condition = '='; if (preg_match('/^!/', $logina)) { - $logina=preg_replace('/^!/', '', $logina); - $condition='<>'; + $logina = preg_replace('/^!/', '', $logina); + $condition = '<>'; } - $userforfilter=new User($this->db); - $result=$userforfilter->fetch('', $logina); - if ($result > 0) $sql.= " AND a.fk_user_author ".$condition." ".$userforfilter->id; - elseif ($result < 0 || $condition == '=') $sql.= " AND a.fk_user_author = 0"; + $userforfilter = new User($this->db); + $result = $userforfilter->fetch('', $logina); + if ($result > 0) $sql .= " AND a.fk_user_author ".$condition." ".$userforfilter->id; + elseif ($result < 0 || $condition == '=') $sql .= " AND a.fk_user_author = 0"; } if ($key == 'logint') { - $logint=$value; - $condition='='; + $logint = $value; + $condition = '='; if (preg_match('/^!/', $logint)) { - $logint=preg_replace('/^!/', '', $logint); - $condition='<>'; + $logint = preg_replace('/^!/', '', $logint); + $condition = '<>'; } - $userforfilter=new User($this->db); - $result=$userforfilter->fetch('', $logint); - if ($result > 0) $sql.= " AND ar.fk_element = ".$userforfilter->id; - elseif ($result < 0 || $condition == '=') $sql.= " AND ar.fk_element = 0"; + $userforfilter = new User($this->db); + $result = $userforfilter->fetch('', $logint); + if ($result > 0) $sql .= " AND ar.fk_element = ".$userforfilter->id; + elseif ($result < 0 || $condition == '=') $sql .= " AND ar.fk_element = 0"; } } - $sql.= " AND a.datep IS NOT NULL"; // To exclude corrupted events and avoid errors in lightning/sunbird import + $sql .= " AND a.datep IS NOT NULL"; // To exclude corrupted events and avoid errors in lightning/sunbird import - $parameters=array('filters' => $filters); - $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook - $sql.=$hookmanager->resPrint; + $parameters = array('filters' => $filters); + $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; - $sql.= " ORDER by datep"; + $sql .= " ORDER by datep"; //print $sql;exit; dol_syslog(get_class($this)."::build_exportfile select events", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { // Note: Output of sql request is encoded in $conf->file->character_set_client // This assignment in condition is not a bug. It allows walking the results. $diff = 0; - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $qualified=true; + $qualified = true; // 'eid','startdate','duration','enddate','title','summary','category','email','url','desc','author' - $event=array(); - $event['uid']='dolibarragenda-'.$this->db->database_name.'-'.$obj->id."@".$_SERVER["SERVER_NAME"]; - $event['type']=$type; - $datestart=$this->db->jdate($obj->datep)-(empty($conf->global->AGENDA_EXPORT_FIX_TZ)?0:($conf->global->AGENDA_EXPORT_FIX_TZ*3600)); + $event = array(); + $event['uid'] = 'dolibarragenda-'.$this->db->database_name.'-'.$obj->id."@".$_SERVER["SERVER_NAME"]; + $event['type'] = $type; + $datestart = $this->db->jdate($obj->datep) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600)); // fix for -> Warning: A non-numeric value encountered - if(is_numeric($this->db->jdate($obj->datep2))) + if (is_numeric($this->db->jdate($obj->datep2))) { $dateend = $this->db->jdate($obj->datep2) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600)); @@ -1731,28 +1731,28 @@ class ActionComm extends CommonObject $dateend = $datestart; } - $duration=($datestart && $dateend)?($dateend - $datestart):0; - $event['summary']=$obj->label.($obj->socname?" (".$obj->socname.")":""); - $event['desc']=$obj->note; - $event['startdate']=$datestart; - $event['enddate']=$dateend; // Not required with type 'journal' - $event['duration']=$duration; // Not required with type 'journal' - $event['author']=dolGetFirstLastname($obj->firstname, $obj->lastname); - $event['priority']=$obj->priority; - $event['fulldayevent']=$obj->fulldayevent; - $event['location']=$obj->location; - $event['transparency']=(($obj->transparency > 0)?'OPAQUE':'TRANSPARENT'); // OPAQUE (busy) or TRANSPARENT (not busy) - $event['punctual']=$obj->punctual; - $event['category']=$obj->type_label; - $event['email']=$obj->email; + $duration = ($datestart && $dateend) ? ($dateend - $datestart) : 0; + $event['summary'] = $obj->label.($obj->socname ? " (".$obj->socname.")" : ""); + $event['desc'] = $obj->note; + $event['startdate'] = $datestart; + $event['enddate'] = $dateend; // Not required with type 'journal' + $event['duration'] = $duration; // Not required with type 'journal' + $event['author'] = dolGetFirstLastname($obj->firstname, $obj->lastname); + $event['priority'] = $obj->priority; + $event['fulldayevent'] = $obj->fulldayevent; + $event['location'] = $obj->location; + $event['transparency'] = (($obj->transparency > 0) ? 'OPAQUE' : 'TRANSPARENT'); // OPAQUE (busy) or TRANSPARENT (not busy) + $event['punctual'] = $obj->punctual; + $event['category'] = $obj->type_label; + $event['email'] = $obj->email; // 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 - $url=$urlwithroot.'/comm/action/card.php?id='.$obj->id; - $event['url']=$url; - $event['created']=$this->db->jdate($obj->datec)-(empty($conf->global->AGENDA_EXPORT_FIX_TZ)?0:($conf->global->AGENDA_EXPORT_FIX_TZ*3600)); - $event['modified']=$this->db->jdate($obj->datem)-(empty($conf->global->AGENDA_EXPORT_FIX_TZ)?0:($conf->global->AGENDA_EXPORT_FIX_TZ*3600)); + $url = $urlwithroot.'/comm/action/card.php?id='.$obj->id; + $event['url'] = $url; + $event['created'] = $this->db->jdate($obj->datec) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600)); + $event['modified'] = $this->db->jdate($obj->datem) - (empty($conf->global->AGENDA_EXPORT_FIX_TZ) ? 0 : ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600)); // TODO: find a way to call "$this->fetch_userassigned();" without override "$this" properties $this->id = $obj->id; @@ -1760,25 +1760,25 @@ class ActionComm extends CommonObject $assignedUserArray = array(); - foreach($this->userassigned as $key => $value) + foreach ($this->userassigned as $key => $value) { $assignedUser = new User($this->db); $assignedUser->fetch($value['id']); - $assignedUserArray[$key]=$assignedUser; + $assignedUserArray[$key] = $assignedUser; } - $event['assignedUsers']=$assignedUserArray; + $event['assignedUsers'] = $assignedUserArray; if ($qualified && $datestart) { - $eventarray[]=$event; + $eventarray[] = $event; } $diff++; } - $parameters=array('filters' => $filters, 'eventarray' => &$eventarray); - $reshook=$hookmanager->executeHooks('addMoreEventsExport', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('filters' => $filters, 'eventarray' => &$eventarray); + $reshook = $hookmanager->executeHooks('addMoreEventsExport', $parameters); // Note that $action and $object may have been modified by hook if ($reshook > 0) { $eventarray = $hookmanager->resArray; diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 268c3ecf1ed..31808d35991 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -757,29 +757,29 @@ if ($showbirthday) } } -if($conf->global->AGENDA_SHOW_HOLIDAYS) +if ($conf->global->AGENDA_SHOW_HOLIDAYS) { $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.statut, x.rowid, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.statut as status"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE u.rowid = x.fk_user"; - $sql.= " AND u.statut = '1'"; // Show only active users (0 = inactive user, 1 = active user) - $sql.= " AND (x.statut = '2' OR x.statut = '3')"; // Show only public leaves (2 = leave wait for approval, 3 = leave approved) + $sql .= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE u.rowid = x.fk_user"; + $sql .= " AND u.statut = '1'"; // Show only active users (0 = inactive user, 1 = active user) + $sql .= " AND (x.statut = '2' OR x.statut = '3')"; // Show only public leaves (2 = leave wait for approval, 3 = leave approved) - if($action == 'show_day') + if ($action == 'show_day') { // Request only leaves for the current selected day - $sql.= " AND '".$year."-".$month."-".$day."' BETWEEN x.date_debut AND x.date_fin"; + $sql .= " AND '".$year."-".$month."-".$day."' BETWEEN x.date_debut AND x.date_fin"; } - elseif($action == 'show_week') + elseif ($action == 'show_week') { // TODO: Add filter to reduce database request } - elseif($action == 'show_month') + elseif ($action == 'show_month') { // TODO: Add filter to reduce database request } - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -803,22 +803,22 @@ if($conf->global->AGENDA_SHOW_HOLIDAYS) $event->date_start_in_calendar = $event->datep; $event->date_end_in_calendar = $event->datef; - if($obj->status == 3) + if ($obj->status == 3) { // Show no symbol for leave with state "leave approved" $event->percentage = -1; } - elseif($obj->status == 2) + elseif ($obj->status == 2) { // Show TO-DO symbol for leave with state "leave wait for approval" $event->percentage = 0; } - if($obj->halfday == 1) + if ($obj->halfday == 1) { $event->label = $obj->lastname.' ('.$langs->trans("Morning").')'; } - elseif($obj->halfday == -1) + elseif ($obj->halfday == -1) { $event->label = $obj->lastname.' ('.$langs->trans("Afternoon").')'; } @@ -836,7 +836,7 @@ if($conf->global->AGENDA_SHOW_HOLIDAYS) { $eventarray[$daykey][] = $event; - $daykey += 60*60*24; + $daykey += 60 * 60 * 24; } while ($daykey <= $event->date_end_in_calendar); @@ -1835,12 +1835,12 @@ function dol_color_minus($color, $minus, $minusunit = 16) function sort_events_by_date($a, $b) { // Sort holidays at first - if($a->type_code === 'HOLIDAY') + if ($a->type_code === 'HOLIDAY') { return -1; } - if($b->type_code === 'HOLIDAY') + if ($b->type_code === 'HOLIDAY') { return 1; } diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 6df7aaa55ba..3ac82178810 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -554,7 +554,7 @@ if ($resql) $actionstatic->type_picto = $obj->type_picto; $actionstatic->label = $obj->label; $actionstatic->location = $obj->location; - $actionstatic->note = dol_htmlentitiesbr($obj->note); // deprecated + $actionstatic->note = dol_htmlentitiesbr($obj->note); // deprecated $actionstatic->note_public = dol_htmlentitiesbr($obj->note); $actionstatic->fetchResources(); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 778f00fbf31..32c3d67a18b 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -810,7 +810,7 @@ class Propal extends CommonObject if (is_array($array_options) && count($array_options) > 0) { // We replace values in this->line->array_options only for entries defined into $array_options - foreach($array_options as $key => $value) { + foreach ($array_options as $key => $value) { $this->line->array_options[$key] = $array_options[$key]; } } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 1d8c5bb0f30..21b8c983d8e 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -164,7 +164,7 @@ class Commande extends CommonOrder */ public $availability; - public $demand_reason_id; // Source reason. Why we receive order (after a phone campaign, ...) + public $demand_reason_id; // Source reason. Why we receive order (after a phone campaign, ...) public $demand_reason_code; /** * @var int Date of order @@ -343,11 +343,11 @@ class Commande extends CommonOrder */ public function valid($user, $idwarehouse = 0, $notrigger = 0) { - global $conf,$langs; + global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $error=0; + $error = 0; // Protection if ($this->statut == self::STATUS_VALIDATED) @@ -388,31 +388,31 @@ class Commande extends CommonOrder // Validate $sql = "UPDATE ".MAIN_DB_PREFIX."commande"; - $sql.= " SET ref = '".$this->db->escape($num)."',"; - $sql.= " fk_statut = ".self::STATUS_VALIDATED.","; - $sql.= " date_valid='".$this->db->idate($now)."',"; - $sql.= " fk_user_valid = ".$user->id; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " SET ref = '".$this->db->escape($num)."',"; + $sql .= " fk_statut = ".self::STATUS_VALIDATED.","; + $sql .= " date_valid='".$this->db->idate($now)."',"; + $sql .= " fk_user_valid = ".$user->id; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::valid()", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { dol_print_error($this->db); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } - if (! $error) + if (!$error) { // If stock is incremented on validate order, we must increment it - if ($result >= 0 && ! empty($conf->stock->enabled) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) + if ($result >= 0 && !empty($conf->stock->enabled) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); // Loop on each line - $cpt=count($this->lines); + $cpt = count($this->lines); for ($i = 0; $i < $cpt; $i++) { if ($this->lines[$i]->fk_product > 0) @@ -448,17 +448,17 @@ class Commande extends CommonOrder if (preg_match('/^[\(]?PROV/i', $this->ref)) { // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'commande/".$this->db->escape($this->newref)."'"; - $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'commande/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'commande/".$this->db->escape($this->newref)."'"; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'commande/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->error = $this->db->lasterror(); } + if (!$resql) { $error++; $this->error = $this->db->lasterror(); } // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($num); $dirsource = $conf->commande->multidir_output[$this->entity].'/'.$oldref; $dirdest = $conf->commande->multidir_output[$this->entity].'/'.$newref; - if (! $error && file_exists($dirsource)) + if (!$error && file_exists($dirsource)) { dol_syslog(get_class($this)."::valid() rename dir ".$dirsource." into ".$dirdest); @@ -466,13 +466,13 @@ class Commande extends CommonOrder { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref - $listoffiles=dol_dir_list($conf->commande->multidir_output[$this->entity].'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach($listoffiles as $fileentry) + $listoffiles = dol_dir_list($conf->commande->multidir_output[$this->entity].'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) { - $dirsource=$fileentry['name']; - $dirdest=preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); - $dirsource=$fileentry['path'].'/'.$dirsource; - $dirdest=$fileentry['path'].'/'.$dirdest; + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource = $fileentry['path'].'/'.$dirsource; + $dirdest = $fileentry['path'].'/'.$dirdest; @rename($dirsource, $dirdest); } } @@ -661,34 +661,34 @@ class Commande extends CommonOrder { global $conf; - $error=0; + $error = 0; - if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate))) + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->commande->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->commande->order_advance->validate))) { $this->db->begin(); - $now=dol_now(); + $now = dol_now(); $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= ' SET fk_statut = '.self::STATUS_CLOSED.','; - $sql.= ' fk_user_cloture = '.$user->id.','; - $sql.= " date_cloture = '".$this->db->idate($now)."'"; - $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT; + $sql .= ' SET fk_statut = '.self::STATUS_CLOSED.','; + $sql .= ' fk_user_cloture = '.$user->id.','; + $sql .= " date_cloture = '".$this->db->idate($now)."'"; + $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT; if ($this->db->query($sql)) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('ORDER_CLOSE', $user); + $result = $this->call_trigger('ORDER_CLOSE', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { - $this->statut=self::STATUS_CLOSED; + $this->statut = self::STATUS_CLOSED; $this->db->commit(); return 1; @@ -835,88 +835,88 @@ class Commande extends CommonOrder } $soc = new Societe($this->db); - $result=$soc->fetch($this->socid); + $result = $soc->fetch($this->socid); if ($result < 0) { - $this->error="Failed to fetch company"; + $this->error = "Failed to fetch company"; dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); return -2; } - if (! empty($conf->global->COMMANDE_REQUIRE_SOURCE) && $this->source < 0) + if (!empty($conf->global->COMMANDE_REQUIRE_SOURCE) && $this->source < 0) { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Source")); + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Source")); dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); return -1; } - $now=dol_now(); + $now = dol_now(); $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande ("; - $sql.= " ref, fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note_private, note_public, ref_ext, ref_client, ref_int"; - $sql.= ", model_pdf, fk_cond_reglement, fk_mode_reglement, fk_account, fk_availability, fk_input_reason, date_livraison, fk_delivery_address"; - $sql.= ", fk_shipping_method"; - $sql.= ", fk_warehouse"; - $sql.= ", remise_absolue, remise_percent"; - $sql.= ", fk_incoterms, location_incoterms"; - $sql.= ", entity, module_source, pos_source"; - $sql.= ", fk_multicurrency"; - $sql.= ", multicurrency_code"; - $sql.= ", multicurrency_tx"; - $sql.= ")"; - $sql.= " VALUES ('(PROV)', ".$this->socid.", '".$this->db->idate($now)."', ".$user->id; - $sql.= ", ".($this->fk_project>0?$this->fk_project:"null"); - $sql.= ", '".$this->db->idate($date)."'"; - $sql.= ", ".($this->source>=0 && $this->source != '' ?$this->db->escape($this->source):'null'); - $sql.= ", '".$this->db->escape($this->note_private)."'"; - $sql.= ", '".$this->db->escape($this->note_public)."'"; - $sql.= ", ".($this->ref_ext?"'".$this->db->escape($this->ref_ext)."'":"null"); - $sql.= ", ".($this->ref_client?"'".$this->db->escape($this->ref_client)."'":"null"); - $sql.= ", ".($this->ref_int?"'".$this->db->escape($this->ref_int)."'":"null"); - $sql.= ", '".$this->db->escape($this->modelpdf)."'"; - $sql.= ", ".($this->cond_reglement_id>0?$this->cond_reglement_id:"null"); - $sql.= ", ".($this->mode_reglement_id>0?$this->mode_reglement_id:"null"); - $sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL'); - $sql.= ", ".($this->availability_id>0?$this->availability_id:"null"); - $sql.= ", ".($this->demand_reason_id>0?$this->demand_reason_id:"null"); - $sql.= ", ".($this->date_livraison?"'".$this->db->idate($this->date_livraison)."'":"null"); - $sql.= ", ".($this->fk_delivery_address>0?$this->fk_delivery_address:'NULL'); - $sql.= ", ".($this->shipping_method_id>0?$this->shipping_method_id:'NULL'); - $sql.= ", ".($this->warehouse_id>0?$this->warehouse_id:'NULL'); - $sql.= ", ".($this->remise_absolue>0?$this->db->escape($this->remise_absolue):'NULL'); - $sql.= ", ".($this->remise_percent>0?$this->db->escape($this->remise_percent):0); - $sql.= ", ".(int) $this->fk_incoterms; - $sql.= ", '".$this->db->escape($this->location_incoterms)."'"; - $sql.= ", ".setEntity($this); - $sql.= ", ".($this->module_source ? "'".$this->db->escape($this->module_source)."'" : "null"); - $sql.= ", ".($this->pos_source != '' ? "'".$this->db->escape($this->pos_source)."'" : "null"); - $sql.= ", ".(int) $this->fk_multicurrency; - $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; - $sql.= ", ".(double) $this->multicurrency_tx; - $sql.= ")"; + $sql .= " ref, fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note_private, note_public, ref_ext, ref_client, ref_int"; + $sql .= ", model_pdf, fk_cond_reglement, fk_mode_reglement, fk_account, fk_availability, fk_input_reason, date_livraison, fk_delivery_address"; + $sql .= ", fk_shipping_method"; + $sql .= ", fk_warehouse"; + $sql .= ", remise_absolue, remise_percent"; + $sql .= ", fk_incoterms, location_incoterms"; + $sql .= ", entity, module_source, pos_source"; + $sql .= ", fk_multicurrency"; + $sql .= ", multicurrency_code"; + $sql .= ", multicurrency_tx"; + $sql .= ")"; + $sql .= " VALUES ('(PROV)', ".$this->socid.", '".$this->db->idate($now)."', ".$user->id; + $sql .= ", ".($this->fk_project > 0 ? $this->fk_project : "null"); + $sql .= ", '".$this->db->idate($date)."'"; + $sql .= ", ".($this->source >= 0 && $this->source != '' ? $this->db->escape($this->source) : 'null'); + $sql .= ", '".$this->db->escape($this->note_private)."'"; + $sql .= ", '".$this->db->escape($this->note_public)."'"; + $sql .= ", ".($this->ref_ext ? "'".$this->db->escape($this->ref_ext)."'" : "null"); + $sql .= ", ".($this->ref_client ? "'".$this->db->escape($this->ref_client)."'" : "null"); + $sql .= ", ".($this->ref_int ? "'".$this->db->escape($this->ref_int)."'" : "null"); + $sql .= ", '".$this->db->escape($this->modelpdf)."'"; + $sql .= ", ".($this->cond_reglement_id > 0 ? $this->cond_reglement_id : "null"); + $sql .= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : "null"); + $sql .= ", ".($this->fk_account > 0 ? $this->fk_account : 'NULL'); + $sql .= ", ".($this->availability_id > 0 ? $this->availability_id : "null"); + $sql .= ", ".($this->demand_reason_id > 0 ? $this->demand_reason_id : "null"); + $sql .= ", ".($this->date_livraison ? "'".$this->db->idate($this->date_livraison)."'" : "null"); + $sql .= ", ".($this->fk_delivery_address > 0 ? $this->fk_delivery_address : 'NULL'); + $sql .= ", ".($this->shipping_method_id > 0 ? $this->shipping_method_id : 'NULL'); + $sql .= ", ".($this->warehouse_id > 0 ? $this->warehouse_id : 'NULL'); + $sql .= ", ".($this->remise_absolue > 0 ? $this->db->escape($this->remise_absolue) : 'NULL'); + $sql .= ", ".($this->remise_percent > 0 ? $this->db->escape($this->remise_percent) : 0); + $sql .= ", ".(int) $this->fk_incoterms; + $sql .= ", '".$this->db->escape($this->location_incoterms)."'"; + $sql .= ", ".setEntity($this); + $sql .= ", ".($this->module_source ? "'".$this->db->escape($this->module_source)."'" : "null"); + $sql .= ", ".($this->pos_source != '' ? "'".$this->db->escape($this->pos_source)."'" : "null"); + $sql .= ", ".(int) $this->fk_multicurrency; + $sql .= ", '".$this->db->escape($this->multicurrency_code)."'"; + $sql .= ", ".(double) $this->multicurrency_tx; + $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'commande'); if ($this->id) { - $fk_parent_line=0; - $num=count($this->lines); + $fk_parent_line = 0; + $num = count($this->lines); /* * Insert products details into db */ - for ($i=0;$i<$num;$i++) + for ($i = 0; $i < $num; $i++) { $line = $this->lines[$i]; // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array //if (! is_object($line)) $line=json_decode(json_encode($line), false); // convert recursively array into object. - if (! is_object($line)) $line = (object) $line; + if (!is_object($line)) $line = (object) $line; // Reset fk_parent_line for no child products and special product if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { @@ -1499,69 +1499,69 @@ class Commande extends CommonOrder } // Insert line - $this->line=new OrderLine($this->db); + $this->line = new OrderLine($this->db); $this->line->context = $this->context; - $this->line->fk_commande=$this->id; - $this->line->label=$label; - $this->line->desc=$desc; - $this->line->qty=$qty; + $this->line->fk_commande = $this->id; + $this->line->label = $label; + $this->line->desc = $desc; + $this->line->qty = $qty; - $this->line->vat_src_code=$vat_src_code; - $this->line->tva_tx=$txtva; - $this->line->localtax1_tx=($total_localtax1?$localtaxes_type[1]:0); - $this->line->localtax2_tx=($total_localtax2?$localtaxes_type[3]:0); - $this->line->localtax1_type=$localtaxes_type[0]; - $this->line->localtax2_type=$localtaxes_type[2]; - $this->line->fk_product=$fk_product; - $this->line->product_type=$product_type; - $this->line->fk_remise_except=$fk_remise_except; - $this->line->remise_percent=$remise_percent; - $this->line->subprice=$pu_ht; - $this->line->rang=$ranktouse; - $this->line->info_bits=$info_bits; - $this->line->total_ht=$total_ht; - $this->line->total_tva=$total_tva; - $this->line->total_localtax1=$total_localtax1; - $this->line->total_localtax2=$total_localtax2; - $this->line->total_ttc=$total_ttc; - $this->line->special_code=$special_code; - $this->line->origin=$origin; - $this->line->origin_id=$origin_id; - $this->line->fk_parent_line=$fk_parent_line; - $this->line->fk_unit=$fk_unit; + $this->line->vat_src_code = $vat_src_code; + $this->line->tva_tx = $txtva; + $this->line->localtax1_tx = ($total_localtax1 ? $localtaxes_type[1] : 0); + $this->line->localtax2_tx = ($total_localtax2 ? $localtaxes_type[3] : 0); + $this->line->localtax1_type = $localtaxes_type[0]; + $this->line->localtax2_type = $localtaxes_type[2]; + $this->line->fk_product = $fk_product; + $this->line->product_type = $product_type; + $this->line->fk_remise_except = $fk_remise_except; + $this->line->remise_percent = $remise_percent; + $this->line->subprice = $pu_ht; + $this->line->rang = $ranktouse; + $this->line->info_bits = $info_bits; + $this->line->total_ht = $total_ht; + $this->line->total_tva = $total_tva; + $this->line->total_localtax1 = $total_localtax1; + $this->line->total_localtax2 = $total_localtax2; + $this->line->total_ttc = $total_ttc; + $this->line->special_code = $special_code; + $this->line->origin = $origin; + $this->line->origin_id = $origin_id; + $this->line->fk_parent_line = $fk_parent_line; + $this->line->fk_unit = $fk_unit; - $this->line->date_start=$date_start; - $this->line->date_end=$date_end; + $this->line->date_start = $date_start; + $this->line->date_end = $date_end; $this->line->fk_fournprice = $fk_fournprice; $this->line->pa_ht = $pa_ht; // Multicurrency - $this->line->fk_multicurrency = $this->fk_multicurrency; - $this->line->multicurrency_code = $this->multicurrency_code; + $this->line->fk_multicurrency = $this->fk_multicurrency; + $this->line->multicurrency_code = $this->multicurrency_code; $this->line->multicurrency_subprice = $pu_ht_devise; $this->line->multicurrency_total_ht = $multicurrency_total_ht; $this->line->multicurrency_total_tva = $multicurrency_total_tva; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; // TODO Ne plus utiliser - $this->line->price=$price; - $this->line->remise=$remise; + $this->line->price = $price; + $this->line->remise = $remise; - if (is_array($array_options) && count($array_options)>0) { - $this->line->array_options=$array_options; + if (is_array($array_options) && count($array_options) > 0) { + $this->line->array_options = $array_options; } - $result=$this->line->insert($user); + $result = $this->line->insert($user); if ($result > 0) { // Reorder if child line - if (! empty($fk_parent_line)) $this->line_order(true, 'DESC'); + if (!empty($fk_parent_line)) $this->line_order(true, 'DESC'); // Mise a jour informations denormalisees au niveau de la commande meme - $result=$this->update_price(1, 'auto', 0, $mysoc); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. + $result = $this->update_price(1, 'auto', 0, $mysoc); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. if ($result > 0) { $this->db->commit(); @@ -1695,35 +1695,35 @@ class Commande extends CommonOrder if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; $sql = 'SELECT c.rowid, c.entity, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_user_valid, c.fk_statut'; - $sql.= ', c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability, c.fk_input_reason'; - $sql.= ', c.fk_account'; - $sql.= ', c.date_commande, c.date_valid, c.tms'; - $sql.= ', c.date_livraison'; - $sql.= ', c.fk_shipping_method'; - $sql.= ', c.fk_warehouse'; - $sql.= ', c.fk_projet as fk_project, c.remise_percent, c.remise, c.remise_absolue, c.source, c.facture as billed'; - $sql.= ', c.note_private, c.note_public, c.ref_client, c.ref_ext, c.ref_int, c.model_pdf, c.last_main_doc, c.fk_delivery_address, c.extraparams'; - $sql.= ', c.fk_incoterms, c.location_incoterms'; - $sql.= ", c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva, c.multicurrency_total_ttc"; - $sql.= ", c.module_source, c.pos_source"; - $sql.= ", i.libelle as label_incoterms"; - $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; - $sql.= ', cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle, cr.libelle_facture as cond_reglement_libelle_doc'; - $sql.= ', ca.code as availability_code, ca.label as availability_label'; - $sql.= ', dr.code as demand_reason_code'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'commande as c'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON c.fk_cond_reglement = cr.rowid'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON c.fk_mode_reglement = p.id'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON c.fk_availability = ca.rowid'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON c.fk_input_reason = dr.rowid'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid'; + $sql .= ', c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability, c.fk_input_reason'; + $sql .= ', c.fk_account'; + $sql .= ', c.date_commande, c.date_valid, c.tms'; + $sql .= ', c.date_livraison'; + $sql .= ', c.fk_shipping_method'; + $sql .= ', c.fk_warehouse'; + $sql .= ', c.fk_projet as fk_project, c.remise_percent, c.remise, c.remise_absolue, c.source, c.facture as billed'; + $sql .= ', c.note_private, c.note_public, c.ref_client, c.ref_ext, c.ref_int, c.model_pdf, c.last_main_doc, c.fk_delivery_address, c.extraparams'; + $sql .= ', c.fk_incoterms, c.location_incoterms'; + $sql .= ", c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva, c.multicurrency_total_ttc"; + $sql .= ", c.module_source, c.pos_source"; + $sql .= ", i.libelle as label_incoterms"; + $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; + $sql .= ', cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle, cr.libelle_facture as cond_reglement_libelle_doc'; + $sql .= ', ca.code as availability_code, ca.label as availability_label'; + $sql .= ', dr.code as demand_reason_code'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'commande as c'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON c.fk_cond_reglement = cr.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON c.fk_mode_reglement = p.id'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON c.fk_availability = ca.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON c.fk_input_reason = dr.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid'; - if ($id) $sql.= " WHERE c.rowid=".$id; - else $sql.= " WHERE c.entity IN (".getEntity('commande').")"; // Dont't use entity if you use rowid + if ($id) $sql .= " WHERE c.rowid=".$id; + else $sql .= " WHERE c.entity IN (".getEntity('commande').")"; // Dont't use entity if you use rowid - if ($ref) $sql.= " AND c.ref='".$this->db->escape($ref)."'"; - if ($ref_ext) $sql.= " AND c.ref_ext='".$this->db->escape($ref_ext)."'"; - if ($ref_int) $sql.= " AND c.ref_int='".$this->db->escape($ref_int)."'"; + if ($ref) $sql .= " AND c.ref='".$this->db->escape($ref)."'"; + if ($ref_ext) $sql .= " AND c.ref_ext='".$this->db->escape($ref_ext)."'"; + if ($ref_int) $sql .= " AND c.ref_int='".$this->db->escape($ref_int)."'"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); @@ -2017,7 +2017,7 @@ class Commande extends CommonOrder $line->fetch_optionals(); // multilangs - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($objp->fk_product) && ! empty($loadalsotranslation)) { + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($objp->fk_product) && !empty($loadalsotranslation)) { $line = new Product($this->db); $line->fetch($objp->fk_product); $line->getMultiLangs(); @@ -2860,44 +2860,44 @@ class Commande extends CommonOrder $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET facture = 1'; - $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT; + $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT; dol_syslog(get_class($this)."::classifyBilled", LOG_DEBUG); if ($this->db->query($sql)) { - if (! $error) + if (!$error) { - $this->oldcopy= clone $this; - $this->billed=1; + $this->oldcopy = clone $this; + $this->billed = 1; } - if (! $notrigger && empty($error)) + if (!$notrigger && empty($error)) { // Call trigger - $result=$this->call_trigger('ORDER_CLASSIFY_BILLED', $user); + $result = $this->call_trigger('ORDER_CLASSIFY_BILLED', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; } else { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::classifyBilled ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -3100,18 +3100,18 @@ class Commande extends CommonOrder $this->line->context = $this->context; // Reorder if fk_parent_line change - if (! empty($fk_parent_line) && ! empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) + if (!empty($fk_parent_line) && !empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line) { $rangmax = $this->line_max($fk_parent_line); $this->line->rang = $rangmax + 1; } - $this->line->id=$rowid; - $this->line->label=$label; - $this->line->desc=$desc; - $this->line->qty=$qty; + $this->line->id = $rowid; + $this->line->label = $label; + $this->line->desc = $desc; + $this->line->qty = $qty; - $this->line->vat_src_code = $vat_src_code; + $this->line->vat_src_code = $vat_src_code; $this->line->tva_tx = $txtva; $this->line->localtax1_tx = $txlocaltax1; $this->line->localtax2_tx = $txlocaltax2; @@ -3148,7 +3148,7 @@ class Commande extends CommonOrder if (is_array($array_options) && count($array_options) > 0) { // We replace values in this->line->array_options only for entries defined into $array_options - foreach($array_options as $key => $value) { + foreach ($array_options as $key => $value) { $this->line->array_options[$key] = $array_options[$key]; } } @@ -3347,30 +3347,30 @@ class Commande extends CommonOrder } } - if (! $error) + if (!$error) { // Delete object $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commande WHERE rowid = ".$this->id; - if (! $this->db->query($sql) ) + if (!$this->db->query($sql)) { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); } } - if (! $error) + if (!$error) { // Remove directory with files $comref = dol_sanitizeFileName($this->ref); if ($conf->commande->multidir_output[$this->entity] && !empty($this->ref)) { - $dir = $conf->commande->multidir_output[$this->entity] . "/" . $comref ; - $file = $conf->commande->multidir_output[$this->entity] . "/" . $comref . "/" . $comref . ".pdf"; + $dir = $conf->commande->multidir_output[$this->entity]."/".$comref; + $file = $conf->commande->multidir_output[$this->entity]."/".$comref."/".$comref.".pdf"; if (file_exists($file)) // We must delete all files before deleting directory { dol_delete_preview($this); - if (! dol_delete_file($file, 0, 0, 0, $this)) // For triggers + if (!dol_delete_file($file, 0, 0, 0, $this)) // For triggers { $this->db->rollback(); return 0; @@ -3420,34 +3420,34 @@ class Commande extends CommonOrder $clause = " WHERE"; $sql = "SELECT c.rowid, c.date_creation as datec, c.date_commande, c.date_livraison as delivery_date, c.fk_statut, c.total_ht"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; if (!$user->rights->societe->client->voir && !$user->socid) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc"; - $sql.= " WHERE sc.fk_user = " .$user->id; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc"; + $sql .= " WHERE sc.fk_user = ".$user->id; $clause = " AND"; } - $sql.= $clause." c.entity IN (".getEntity('commande').")"; + $sql .= $clause." c.entity IN (".getEntity('commande').")"; //$sql.= " AND c.fk_statut IN (1,2,3) AND c.facture = 0"; - $sql.= " AND ((c.fk_statut IN (".self::STATUS_VALIDATED.",".self::STATUS_SHIPMENTONPROCESS.")) OR (c.fk_statut = ".self::STATUS_CLOSED." AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected - if ($user->socid) $sql.=" AND c.fk_soc = ".$user->socid; + $sql .= " AND ((c.fk_statut IN (".self::STATUS_VALIDATED.",".self::STATUS_SHIPMENTONPROCESS.")) OR (c.fk_statut = ".self::STATUS_CLOSED." AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected + if ($user->socid) $sql .= " AND c.fk_soc = ".$user->socid; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $response = new WorkboardResponse(); - $response->warning_delay=$conf->commande->client->warning_delay/60/60/24; - $response->label=$langs->trans("OrdersToProcess"); + $response->warning_delay = $conf->commande->client->warning_delay / 60 / 60 / 24; + $response->label = $langs->trans("OrdersToProcess"); $response->labelShort = $langs->trans("Opened"); - $response->url=DOL_URL_ROOT.'/commande/list.php?viewstatut=-3&mainmenu=commercial&leftmenu=orders'; - $response->img=img_object('', "order"); + $response->url = DOL_URL_ROOT.'/commande/list.php?viewstatut=-3&mainmenu=commercial&leftmenu=orders'; + $response->img = img_object('', "order"); $generic_commande = new Commande($this->db); - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { $response->nbtodo++; - $response->total+= $obj->total_ht; + $response->total += $obj->total_ht; $generic_commande->statut = $obj->fk_statut; $generic_commande->date_commande = $this->db->jdate($obj->date_commande); @@ -3509,47 +3509,47 @@ class Commande extends CommonOrder global $langs, $conf; $billedtext = ''; - if (empty($donotshowbilled)) $billedtext .= ($billed?' - '.$langs->trans("Billed"):''); + if (empty($donotshowbilled)) $billedtext .= ($billed ? ' - '.$langs->trans("Billed") : ''); - if ($status==self::STATUS_CANCELED){ + if ($status == self::STATUS_CANCELED) { $labelStatus = $langs->trans('StatusOrderCanceled'); $labelStatusShort = $langs->trans('StatusOrderCanceledShort'); - $statusType='status5'; + $statusType = 'status5'; } - elseif ($status==self::STATUS_DRAFT){ + elseif ($status == self::STATUS_DRAFT) { $labelStatus = $langs->trans('StatusOrderDraft'); $labelStatusShort = $langs->trans('StatusOrderDraftShort'); - $statusType='status0'; + $statusType = 'status0'; } - elseif ($status==self::STATUS_VALIDATED){ + elseif ($status == self::STATUS_VALIDATED) { $labelStatus = $langs->trans('StatusOrderValidated').$billedtext; $labelStatusShort = $langs->trans('StatusOrderValidatedShort').$billedtext; - $statusType='status1'; + $statusType = 'status1'; } - elseif ($status==self::STATUS_SHIPMENTONPROCESS){ + elseif ($status == self::STATUS_SHIPMENTONPROCESS) { $labelStatus = $langs->trans('StatusOrderSentShort').$billedtext; $labelStatusShort = $langs->trans('StatusOrderSentShort').$billedtext; - $statusType='status3'; + $statusType = 'status3'; } - elseif ($status==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))){ + elseif ($status == self::STATUS_CLOSED && (!$billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) { $labelStatus = $langs->trans('StatusOrderToBill'); $labelStatusShort = $langs->trans('StatusOrderToBillShort'); - $statusType='status4'; + $statusType = 'status4'; } - elseif ($status==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))){ + elseif ($status == self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) { $labelStatus = $langs->trans('StatusOrderProcessed').$billedtext; $labelStatusShort = $langs->trans('StatusOrderProcessed').$billedtext; - $statusType='status6'; + $statusType = 'status6'; } - elseif ($status==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))){ + elseif ($status == self::STATUS_CLOSED && (!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) { $labelStatus = $langs->trans('StatusOrderDelivered'); $labelStatusShort = $langs->trans('StatusOrderDelivered'); - $statusType='status6'; + $statusType = 'status6'; } - else{ + else { $labelStatus = $langs->trans('Unknown'); $labelStatusShort = ''; - $statusType=''; + $statusType = ''; $mode = 0; } @@ -3818,26 +3818,26 @@ class Commande extends CommonOrder // phpcs:enable global $user; - $this->nb=array(); + $this->nb = array(); $clause = "WHERE"; $sql = "SELECT count(co.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande as co"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON co.fk_soc = s.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande as co"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON co.fk_soc = s.rowid"; if (!$user->rights->societe->client->voir && !$user->socid) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; - $sql.= " WHERE sc.fk_user = " .$user->id; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; + $sql .= " WHERE sc.fk_user = ".$user->id; $clause = "AND"; } - $sql.= " ".$clause." co.entity IN (".getEntity('commande').")"; + $sql .= " ".$clause." co.entity IN (".getEntity('commande').")"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $this->nb["orders"]=$obj->nb; + $this->nb["orders"] = $obj->nb; } $this->db->free($resql); return 1; @@ -3873,16 +3873,16 @@ class Commande extends CommonOrder */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { - global $conf,$langs; + global $conf, $langs; $langs->load("orders"); - if (! dol_strlen($modele)) { + if (!dol_strlen($modele)) { $modele = 'einstein'; if ($this->modelpdf) { $modele = $this->modelpdf; - } elseif (! empty($conf->global->COMMANDE_ADDON_PDF)) { + } elseif (!empty($conf->global->COMMANDE_ADDON_PDF)) { $modele = $conf->global->COMMANDE_ADDON_PDF; } } @@ -4113,13 +4113,13 @@ class OrderLine extends CommonOrderLine { global $conf, $langs; - $error=0; + $error = 0; // check if order line is not in a shipment line before deleting $sqlCheckShipmentLine = "SELECT"; $sqlCheckShipmentLine .= " ed.rowid"; - $sqlCheckShipmentLine .= " FROM " . MAIN_DB_PREFIX . "expeditiondet ed"; - $sqlCheckShipmentLine .= " WHERE ed.fk_origin_line = " . $this->rowid; + $sqlCheckShipmentLine .= " FROM ".MAIN_DB_PREFIX."expeditiondet ed"; + $sqlCheckShipmentLine .= " WHERE ed.fk_origin_line = ".$this->rowid; $resqlCheckShipmentLine = $this->db->query($sqlCheckShipmentLine); if (!$resqlCheckShipmentLine) { @@ -4132,13 +4132,13 @@ class OrderLine extends CommonOrderLine if ($num > 0) { $error++; $objCheckShipmentLine = $this->db->fetch_object($resqlCheckShipmentLine); - $this->error = $langs->trans('ErrorRecordAlreadyExists') . ' : ' . $langs->trans('ShipmentLine') . ' ' . $objCheckShipmentLine->rowid; + $this->error = $langs->trans('ErrorRecordAlreadyExists').' : '.$langs->trans('ShipmentLine').' '.$objCheckShipmentLine->rowid; $this->errors[] = $this->error; } $this->db->free($resqlCheckShipmentLine); } if ($error) { - dol_syslog(__METHOD__ . 'Error ; ' . $this->error, LOG_ERR); + dol_syslog(__METHOD__.'Error ; '.$this->error, LOG_ERR); return -1; } @@ -4147,14 +4147,14 @@ class OrderLine extends CommonOrderLine $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE rowid=".$this->rowid; dol_syslog("OrderLine::delete", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { // Remove extrafields - if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used + if ((!$error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used { - $this->id=$this->rowid; - $result=$this->deleteExtraFields(); + $this->id = $this->rowid; + $result = $this->deleteExtraFields(); if ($result < 0) { $error++; @@ -4243,73 +4243,73 @@ class OrderLine extends CommonOrderLine // Insertion dans base de la ligne $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commandedet'; - $sql.= ' (fk_commande, fk_parent_line, label, description, qty, '; - $sql.= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; - $sql.= ' fk_product, product_type, remise_percent, subprice, price, remise, fk_remise_except,'; - $sql.= ' special_code, rang, fk_product_fournisseur_price, buy_price_ht,'; - $sql.= ' info_bits, total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, date_start, date_end,'; - $sql.= ' fk_unit'; - $sql.= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; - $sql.= ')'; - $sql.= " VALUES (".$this->fk_commande.","; - $sql.= " ".($this->fk_parent_line>0?"'".$this->db->escape($this->fk_parent_line)."'":"null").","; - $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").","; - $sql.= " '".$this->db->escape($this->desc)."',"; - $sql.= " '".price2num($this->qty)."',"; - $sql.= " ".(empty($this->vat_src_code)?"''":"'".$this->db->escape($this->vat_src_code)."'").","; - $sql.= " '".price2num($this->tva_tx)."',"; - $sql.= " '".price2num($this->localtax1_tx)."',"; - $sql.= " '".price2num($this->localtax2_tx)."',"; - $sql.= " '".$this->db->escape($this->localtax1_type)."',"; - $sql.= " '".$this->db->escape($this->localtax2_type)."',"; - $sql.= ' '.(! empty($this->fk_product)?$this->fk_product:"null").','; - $sql.= " '".$this->db->escape($this->product_type)."',"; - $sql.= " '".price2num($this->remise_percent)."',"; - $sql.= " ".(price2num($this->subprice)!==''?price2num($this->subprice):"null").","; - $sql.= " ".($this->price!=''?"'".price2num($this->price)."'":"null").","; - $sql.= " '".price2num($this->remise)."',"; - $sql.= ' '.(! empty($this->fk_remise_except)?$this->fk_remise_except:"null").','; - $sql.= ' '.$this->special_code.','; - $sql.= ' '.$this->rang.','; - $sql.= ' '.(! empty($this->fk_fournprice)?$this->fk_fournprice:"null").','; - $sql.= ' '.price2num($this->pa_ht).','; - $sql.= " '".$this->db->escape($this->info_bits)."',"; - $sql.= " ".price2num($this->total_ht).","; - $sql.= " ".price2num($this->total_tva).","; - $sql.= " ".price2num($this->total_localtax1).","; - $sql.= " ".price2num($this->total_localtax2).","; - $sql.= " ".price2num($this->total_ttc).","; - $sql.= " ".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null").','; - $sql.= " ".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null").','; - $sql.= ' '.(!$this->fk_unit ? 'NULL' : $this->fk_unit); - $sql.= ", ".(! empty($this->fk_multicurrency) ? $this->fk_multicurrency : 'NULL'); - $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; - $sql.= ", ".$this->multicurrency_subprice; - $sql.= ", ".$this->multicurrency_total_ht; - $sql.= ", ".$this->multicurrency_total_tva; - $sql.= ", ".$this->multicurrency_total_ttc; - $sql.= ')'; + $sql .= ' (fk_commande, fk_parent_line, label, description, qty, '; + $sql .= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; + $sql .= ' fk_product, product_type, remise_percent, subprice, price, remise, fk_remise_except,'; + $sql .= ' special_code, rang, fk_product_fournisseur_price, buy_price_ht,'; + $sql .= ' info_bits, total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, date_start, date_end,'; + $sql .= ' fk_unit'; + $sql .= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; + $sql .= ')'; + $sql .= " VALUES (".$this->fk_commande.","; + $sql .= " ".($this->fk_parent_line > 0 ? "'".$this->db->escape($this->fk_parent_line)."'" : "null").","; + $sql .= " ".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null").","; + $sql .= " '".$this->db->escape($this->desc)."',"; + $sql .= " '".price2num($this->qty)."',"; + $sql .= " ".(empty($this->vat_src_code) ? "''" : "'".$this->db->escape($this->vat_src_code)."'").","; + $sql .= " '".price2num($this->tva_tx)."',"; + $sql .= " '".price2num($this->localtax1_tx)."',"; + $sql .= " '".price2num($this->localtax2_tx)."',"; + $sql .= " '".$this->db->escape($this->localtax1_type)."',"; + $sql .= " '".$this->db->escape($this->localtax2_type)."',"; + $sql .= ' '.(!empty($this->fk_product) ? $this->fk_product : "null").','; + $sql .= " '".$this->db->escape($this->product_type)."',"; + $sql .= " '".price2num($this->remise_percent)."',"; + $sql .= " ".(price2num($this->subprice) !== '' ?price2num($this->subprice) : "null").","; + $sql .= " ".($this->price != '' ? "'".price2num($this->price)."'" : "null").","; + $sql .= " '".price2num($this->remise)."',"; + $sql .= ' '.(!empty($this->fk_remise_except) ? $this->fk_remise_except : "null").','; + $sql .= ' '.$this->special_code.','; + $sql .= ' '.$this->rang.','; + $sql .= ' '.(!empty($this->fk_fournprice) ? $this->fk_fournprice : "null").','; + $sql .= ' '.price2num($this->pa_ht).','; + $sql .= " '".$this->db->escape($this->info_bits)."',"; + $sql .= " ".price2num($this->total_ht).","; + $sql .= " ".price2num($this->total_tva).","; + $sql .= " ".price2num($this->total_localtax1).","; + $sql .= " ".price2num($this->total_localtax2).","; + $sql .= " ".price2num($this->total_ttc).","; + $sql .= " ".(!empty($this->date_start) ? "'".$this->db->idate($this->date_start)."'" : "null").','; + $sql .= " ".(!empty($this->date_end) ? "'".$this->db->idate($this->date_end)."'" : "null").','; + $sql .= ' '.(!$this->fk_unit ? 'NULL' : $this->fk_unit); + $sql .= ", ".(!empty($this->fk_multicurrency) ? $this->fk_multicurrency : 'NULL'); + $sql .= ", '".$this->db->escape($this->multicurrency_code)."'"; + $sql .= ", ".$this->multicurrency_subprice; + $sql .= ", ".$this->multicurrency_total_ht; + $sql .= ", ".$this->multicurrency_total_tva; + $sql .= ", ".$this->multicurrency_total_ttc; + $sql .= ')'; dol_syslog(get_class($this)."::insert", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX.'commandedet'); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'commandedet'); $this->rowid = $this->id; if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('LINEORDER_INSERT', $user); + $result = $this->call_trigger('LINEORDER_INSERT', $user); if ($result < 0) $error++; // End call triggers } diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 507bc24e803..0fa53f6c314 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -75,7 +75,7 @@ $search_user = GETPOST('search_user', 'int'); $search_sale = GETPOST('search_sale', 'int'); $search_total_ht = GETPOST('search_total_ht', 'alpha'); $search_total_ttc = GETPOST('search_total_ttc', 'alpha'); -$search_login=GETPOST('search_login', 'alpha'); +$search_login = GETPOST('search_login', 'alpha'); $search_categ_cus = trim(GETPOST("search_categ_cus", 'int')); $optioncss = GETPOST('optioncss', 'alpha'); $billed = GETPOST('billed', 'int'); @@ -197,7 +197,7 @@ if (empty($reshook)) $search_total_ht = ''; $search_total_vat = ''; $search_total_ttc = ''; - $search_login=''; + $search_login = ''; $search_dateorder_start = ''; $search_dateorder_end = ''; $search_datedelivery_start = ''; @@ -249,11 +249,11 @@ if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; $sql .= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; $sql .= " typent.code as typent_code,"; $sql .= " state.code_departement as state_code, state.nom as state_name,"; -$sql.= ' c.rowid, c.ref, c.total_ht, c.tva as total_tva, c.total_ttc, c.ref_client, c.fk_user_author,'; +$sql .= ' c.rowid, c.ref, c.total_ht, c.tva as total_tva, c.total_ttc, c.ref_client, c.fk_user_author,'; $sql .= ' c.date_valid, c.date_commande, c.note_private, c.date_livraison as date_delivery, c.fk_statut, c.facture as billed,'; $sql .= ' c.date_creation as date_creation, c.tms as date_update, c.date_cloture as date_cloture,'; $sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_label,"; -$sql.= " u.login"; +$sql .= " u.login"; if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) @@ -272,7 +272,7 @@ if (is_array($extrafields->attributes[$object->table_element]['label']) && count if ($sall || $search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet as pd ON c.rowid=pd.fk_commande'; if ($search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = c.fk_projet"; -$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON c.fk_user_author = u.rowid'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON c.fk_user_author = u.rowid'; // We'll need this table joined to the select in order to filter by sale if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -424,7 +424,7 @@ if ($resql) if ($search_total_ht != '') $param .= '&search_total_ht='.urlencode($search_total_ht); if ($search_total_vat != '') $param .= '&search_total_vat='.urlencode($search_total_vat); if ($search_total_ttc != '') $param .= '&search_total_ttc='.urlencode($search_total_ttc); - if ($search_login) $param.='&search_login='.urlencode($search_login); + if ($search_login) $param .= '&search_login='.urlencode($search_login); if ($search_project_ref >= 0) $param .= "&search_project_ref=".urlencode($search_project_ref); if ($search_town != '') $param .= '&search_town='.urlencode($search_town); if ($search_zip != '') $param .= '&search_zip='.urlencode($search_zip); @@ -697,7 +697,7 @@ if ($resql) print ''; print ''; } - if (! empty($arrayfields['u.login']['checked'])) + if (!empty($arrayfields['u.login']['checked'])) { // Author print ''; @@ -775,7 +775,7 @@ if ($resql) if (!empty($arrayfields['c.total_ht']['checked'])) print_liste_field_titre($arrayfields['c.total_ht']['label'], $_SERVER["PHP_SELF"], 'c.total_ht', '', $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['c.total_vat']['checked'])) print_liste_field_titre($arrayfields['c.total_vat']['label'], $_SERVER["PHP_SELF"], 'c.tva', '', $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['c.total_ttc']['checked'])) print_liste_field_titre($arrayfields['c.total_ttc']['label'], $_SERVER["PHP_SELF"], 'c.total_ttc', '', $param, '', $sortfield, $sortorder, 'right '); - if (! empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; @@ -1097,17 +1097,17 @@ if ($resql) $totalarray['val']['c.total_ttc'] += $obj->total_ttc; } - $userstatic->id=$obj->fk_user_author; - $userstatic->login=$obj->login; + $userstatic->id = $obj->fk_user_author; + $userstatic->login = $obj->login; // Author - if (! empty($arrayfields['u.login']['checked'])) + if (!empty($arrayfields['u.login']['checked'])) { print ''; if ($userstatic->id) print $userstatic->getLoginUrl(1); else print ' '; print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Extra fields diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index e8aea86681c..8cd74f1cccf 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -39,15 +39,15 @@ $langs->load("bills"); $id = GETPOST('id', 'int'); -$_GET['optioncss']="print"; -$cashcontrol= new CashControl($db); +$_GET['optioncss'] = "print"; +$cashcontrol = new CashControl($db); $cashcontrol->fetch($id); //$limit = GETPOST('limit')?GETPOST('limit', 'int'):$conf->liste_limit; -$sortorder='ASC'; -$sortfield='b.datev,b.dateo,b.rowid'; +$sortorder = 'ASC'; +$sortfield = 'b.datev,b.dateo,b.rowid'; -$arrayfields=array( +$arrayfields = array( 'b.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'b.dateo'=>array('label'=>$langs->trans("DateOperationShort"), 'checked'=>1), 'b.num_chq'=>array('label'=>$langs->trans("Number"), 'checked'=>1), @@ -99,12 +99,12 @@ $sql.=" OR b.fk_account=".$conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE; $sql.=")"; */ $sql = "SELECT f.rowid as facid, f.ref, f.datef as do, pf.amount as amount, b.fk_account as bankid, cp.code"; -$sql.= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."c_paiement as cp, ".MAIN_DB_PREFIX."bank as b"; -$sql.= " WHERE pf.fk_facture = f.rowid AND p.rowid = pf.fk_paiement AND cp.id = p.fk_paiement AND p.fk_bank = b.rowid"; -$sql.= " AND f.module_source = '".$db->escape($posmodule)."'"; -$sql.= " AND f.pos_source = '".$db->escape($terminalid)."'"; -$sql.= " AND f.paye = 1"; -$sql.= " AND p.entity IN (".getEntity('facture').")"; +$sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."c_paiement as cp, ".MAIN_DB_PREFIX."bank as b"; +$sql .= " WHERE pf.fk_facture = f.rowid AND p.rowid = pf.fk_paiement AND cp.id = p.fk_paiement AND p.fk_bank = b.rowid"; +$sql .= " AND f.module_source = '".$db->escape($posmodule)."'"; +$sql .= " AND f.pos_source = '".$db->escape($terminalid)."'"; +$sql .= " AND f.paye = 1"; +$sql .= " AND p.entity IN (".getEntity('facture').")"; /*if ($key == 'cash') $sql.=" AND cp.code = 'LIQ'"; elseif ($key == 'cheque') $sql.=" AND cp.code = 'CHQ'"; elseif ($key == 'card') $sql.=" AND cp.code = 'CB'"; @@ -113,9 +113,9 @@ else dol_print_error('Value for key = '.$key.' not supported'); exit; }*/ -if ($syear && ! $smonth) $sql.= " AND datef BETWEEN '".$db->idate(dol_get_first_day($syear, 1))."' AND '".$db->idate(dol_get_last_day($syear, 12))."'"; -elseif ($syear && $smonth && ! $sday) $sql.= " AND datef BETWEEN '".$db->idate(dol_get_first_day($syear, $smonth))."' AND '".$db->idate(dol_get_last_day($syear, $smonth))."'"; -elseif ($syear && $smonth && $sday) $sql.= " AND datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $smonth, $sday, $syear))."'"; +if ($syear && !$smonth) $sql .= " AND datef BETWEEN '".$db->idate(dol_get_first_day($syear, 1))."' AND '".$db->idate(dol_get_last_day($syear, 12))."'"; +elseif ($syear && $smonth && !$sday) $sql .= " AND datef BETWEEN '".$db->idate(dol_get_first_day($syear, $smonth))."' AND '".$db->idate(dol_get_last_day($syear, $smonth))."'"; +elseif ($syear && $smonth && $sday) $sql .= " AND datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $smonth, $sday, $syear))."'"; else dol_print_error('', 'Year not defined'); $resql = $db->query($sql); @@ -125,7 +125,7 @@ if ($resql) $i = 0; print "

"; - if ($cashcontrol->status==2) print $langs->trans("CashControl")." ".$cashcontrol->id; + if ($cashcontrol->status == 2) print $langs->trans("CashControl")." ".$cashcontrol->id; else print $langs->trans("CashControl")." - ".$langs->trans("Draft"); print "
".$langs->trans("DateCreationShort").": ".dol_print_date($cashcontrol->date_creation, 'dayhour')."

"; @@ -154,7 +154,7 @@ if ($resql) // Loop on each record $sign = 1; - $cash=$bank=$cheque=$other=0; + $cash = $bank = $cheque = $other = 0; $totalarray = array(); $cachebankaccount = array(); @@ -167,7 +167,7 @@ if ($resql) { $bankaccounttmp = new Account($db); $bankaccounttmp->fetch($objp->bankid); - $cachebankaccount[$objp->bankid]=$bankaccounttmp; + $cachebankaccount[$objp->bankid] = $bankaccounttmp; $bankaccount = $bankaccounttmp; } else @@ -192,21 +192,21 @@ if ($resql) print ''; print $invoicetmp->getNomUrl(1); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Date ope print ''; print ''.dol_print_date($db->jdate($objp->do), "day").""; print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Bank account print ''; print $bankaccount->getNomUrl(1); - if ($cashcontrol->posmodule=="takepos"){ + if ($cashcontrol->posmodule == "takepos") { $var1 = 'CASHDESK_ID_BANKACCOUNT_CASH'.$cashcontrol->posnumber; } - else{ + else { $var1 = 'CASHDESK_ID_BANKACCOUNT_CASH'; } if ($objp->code == 'CHQ') { @@ -220,14 +220,14 @@ if ($resql) else $other += $objp->amount; } print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Type print ''; print $objp->code; if (empty($amountpertype[$objp->code])) $amountpertype[$objp->code] = 0; print "\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Debit print ''; @@ -238,8 +238,8 @@ if ($resql) $amountpertype[$objp->code] += $objp->amount; } print "\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='totaldebfield'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totaldebfield'; // Credit print ''; @@ -250,8 +250,8 @@ if ($resql) $amountpertype[$objp->code] -= $objp->amount; } print "\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='totalcredfield'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalcredfield'; print ""; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 15200582ced..7b7306ef6a8 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -298,14 +298,14 @@ if (empty($reshook)) // Note: Other solution if you want to add a negative line on invoice, is to create a discount for customer and consumme it (but this is possible on standard invoice only). $array_of_pu_ht_per_vat_rate = array(); $array_of_pu_ht_devise_per_vat_rate = array(); - foreach($object->lines as $line) { + foreach ($object->lines as $line) { if (empty($array_of_pu_ht_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code])) $array_of_pu_ht_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code] = 0; if (empty($array_of_pu_ht_devise_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code])) $array_of_pu_ht_devise_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code] = 0; $array_of_pu_ht_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code] += $line->subprice; $array_of_pu_ht_devise_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code] += $line->multicurrency_subprice; } //var_dump($array_of_pu_ht_per_vat_rate);exit; - foreach($array_of_pu_ht_per_vat_rate as $vatrate => $tmpvalue) + foreach ($array_of_pu_ht_per_vat_rate as $vatrate => $tmpvalue) { $pu_ht = $array_of_pu_ht_per_vat_rate[$vatrate]; $pu_ht_devise = $array_of_pu_ht_devise_per_vat_rate[$vatrate]; @@ -818,11 +818,11 @@ if (empty($reshook)) } // If some payments were already done, we change the amount to pay using same prorate - if (! empty($conf->global->INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED)) { - $alreadypaid = $object->getSommePaiement(); // This can be not 0 if we allow to create credit to reuse from credit notes partially refunded. + if (!empty($conf->global->INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED)) { + $alreadypaid = $object->getSommePaiement(); // This can be not 0 if we allow to create credit to reuse from credit notes partially refunded. if ($alreadypaid && abs($alreadypaid) < abs($object->total_ttc)) { $ratio = abs(($object->total_ttc - $alreadypaid) / $object->total_ttc); - foreach($amount_ht as $vatrate => $val) { + foreach ($amount_ht as $vatrate => $val) { $amount_ht[$vatrate] = price2num($amount_ht[$vatrate] * $ratio, 'MU'); $amount_tva[$vatrate] = price2num($amount_tva[$vatrate] * $ratio, 'MU'); $amount_ttc[$vatrate] = price2num($amount_ttc[$vatrate] * $ratio, 'MU'); @@ -3903,7 +3903,7 @@ elseif ($id > 0 || !empty($ref)) $morehtmlref = '
'; // Ref invoice - if ($object->status == $object::STATUS_DRAFT && ! $mysoc->isInEEC() && ! empty($conf->global->INVOICE_ALLOW_FREE_REF)) { + if ($object->status == $object::STATUS_DRAFT && !$mysoc->isInEEC() && !empty($conf->global->INVOICE_ALLOW_FREE_REF)) { $morehtmlref .= $form->editfieldkey("Ref", 'ref', $object->ref, $object, $usercancreate, 'string', '', 0, 1); $morehtmlref .= $form->editfieldval("Ref", 'ref', $object->ref, $object, $usercancreate, 'string', '', null, null, '', 1); $morehtmlref .= '
'; @@ -5095,7 +5095,7 @@ elseif ($id > 0 || !empty($ref)) } // For credit note if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $usercancreate - && (! empty($conf->global->INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED) || $object->getSommePaiement() == 0) + && (!empty($conf->global->INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED) || $object->getSommePaiement() == 0) ) { print ''.$langs->trans('ConvertToReduc').''; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index f877a353003..b94e9373dda 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1272,7 +1272,7 @@ class Facture extends CommonInvoice $this->availability_id = $object->availability_id; $this->demand_reason_id = $object->demand_reason_id; $this->date_livraison = $object->date_livraison; - $this->fk_delivery_address = $object->fk_delivery_address; // deprecated + $this->fk_delivery_address = $object->fk_delivery_address; // deprecated $this->contact_id = $object->contactid; $this->ref_client = $object->ref_client; @@ -1688,7 +1688,7 @@ class Facture extends CommonInvoice $line->special_code = $objp->special_code; $line->fk_parent_line = $objp->fk_parent_line; $line->situation_percent = $objp->situation_percent; - $line->fk_prev_id = $objp->fk_prev_id; + $line->fk_prev_id = $objp->fk_prev_id; $line->fk_unit = $objp->fk_unit; // Accountancy @@ -3231,7 +3231,7 @@ class Facture extends CommonInvoice $this->line->rang = $rangmax + 1; } - $this->line->id = $rowid; + $this->line->id = $rowid; $this->line->rowid = $rowid; $this->line->label = $label; $this->line->desc = $desc; @@ -3272,7 +3272,7 @@ class Facture extends CommonInvoice if (is_array($array_options) && count($array_options) > 0) { // We replace values in this->line->array_options only for entries defined into $array_options - foreach($array_options as $key => $value) { + foreach ($array_options as $key => $value) { $this->line->array_options[$key] = $array_options[$key]; } } diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index fdb4284e909..d998554b533 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -362,14 +362,14 @@ if ($id > 0 || $ref) $urladd = "&id=".$id; - print '' . "\n"; - print ''; - print ''; - if (! empty($page)) { - print ''; + print ''."\n"; + print ''; + print ''; + if (!empty($page)) { + print ''; } - if (! empty($limit)) { - print ''; + if (!empty($limit)) { + print ''; } print_barre_liste($langs->trans("Lines"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit); diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 9fad5db2a68..d1b6361cc34 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -40,19 +40,19 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies', 'bills')); // Security check -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'prelevement', '', '', 'bons'); // Get supervariables $action = GETPOST('action', 'alpha'); -$mode = GETPOST('mode', 'alpha')?GETPOST('mode', 'alpha'):'real'; +$mode = GETPOST('mode', 'alpha') ?GETPOST('mode', 'alpha') : 'real'; $format = GETPOST('format', 'aZ09'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $page = GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; -$hookmanager->initHooks(array('directdebitcreatecard','globalcard')); +$hookmanager->initHooks(array('directdebitcreatecard', 'globalcard')); /* @@ -68,7 +68,7 @@ if (empty($reshook)) // Change customer bank information to withdraw if ($action == 'modify') { - for ($i = 1 ; $i < 9 ; $i++) + for ($i = 1; $i < 9; $i++) { dolibarr_set_const($db, GETPOST("nom$i"), GETPOST("value$i"), 'chaine', 0, '', $conf->entity); } @@ -77,7 +77,7 @@ if (empty($reshook)) { // $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty $bprev = new BonPrelevement($db); - $executiondate = dol_mktime(0, 0, 0, GETPOST('remonth'), (GETPOST('reday')+$conf->global->PRELEVEMENT_ADDDAYS), GETPOST('reyear')); + $executiondate = dol_mktime(0, 0, 0, GETPOST('remonth'), (GETPOST('reday') + $conf->global->PRELEVEMENT_ADDDAYS), GETPOST('reyear')); $result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate); if ($result < 0) @@ -86,12 +86,12 @@ if (empty($reshook)) } elseif ($result == 0) { - $mesg=$langs->trans("NoInvoiceCouldBeWithdrawed", $format); + $mesg = $langs->trans("NoInvoiceCouldBeWithdrawed", $format); setEventMessages($mesg, null, 'errors'); - $mesg.='
'."\n"; - foreach($bprev->invoice_in_error as $key => $val) + $mesg .= '
'."\n"; + foreach ($bprev->invoice_in_error as $key => $val) { - $mesg.=''.$val."
\n"; + $mesg .= ''.$val."
\n"; } } else @@ -108,8 +108,8 @@ if (empty($reshook)) $form = new Form($db); -$thirdpartystatic=new Societe($db); -$invoicestatic=new Facture($db); +$thirdpartystatic = new Societe($db); +$invoicestatic = new Facture($db); $bprev = new BonPrelevement($db); llxHeader('', $langs->trans("NewStandingOrder")); @@ -134,10 +134,10 @@ print load_fiche_titre($langs->trans("NewStandingOrder")); dol_fiche_head(); -$nb=$bprev->NbFactureAPrelever(); -$nb1=$bprev->NbFactureAPrelever(1); -$nb11=$bprev->NbFactureAPrelever(1, 1); -$pricetowithdraw=$bprev->SommeAPrelever(); +$nb = $bprev->NbFactureAPrelever(); +$nb1 = $bprev->NbFactureAPrelever(1); +$nb11 = $bprev->NbFactureAPrelever(1, 1); +$pricetowithdraw = $bprev->SommeAPrelever(); if ($nb < 0 || $nb1 < 0 || $nb11 < 0) { dol_print_error($bprev->error); @@ -162,17 +162,17 @@ if ($mesg) print $mesg; print "
\n"; -print ''; -print ''; +print ''; +print ''; if ($nb) { if ($pricetowithdraw) { print $langs->trans('ExecutionDate').' '; print $form->selectDate(); if ($mysoc->isInEEC()) { print ''; - print ''; + print ''; } else { - print '' . $langs->trans("CreateAll") . "\n"; + print ''.$langs->trans("CreateAll")."\n"; } } else @@ -205,20 +205,20 @@ print '
'; */ $sql = "SELECT f.ref, f.rowid, f.total_ttc, s.nom as name, s.rowid as socid,"; -$sql.= " pfd.date_demande, pfd.amount"; -$sql.= " FROM ".MAIN_DB_PREFIX."facture as f,"; -$sql.= " ".MAIN_DB_PREFIX."societe as s,"; -$sql.= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; -$sql.= " WHERE s.rowid = f.fk_soc"; -$sql.= " AND f.entity IN (".getEntity('invoice').")"; +$sql .= " pfd.date_demande, pfd.amount"; +$sql .= " FROM ".MAIN_DB_PREFIX."facture as f,"; +$sql .= " ".MAIN_DB_PREFIX."societe as s,"; +$sql .= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; +$sql .= " WHERE s.rowid = f.fk_soc"; +$sql .= " AND f.entity IN (".getEntity('invoice').")"; if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) { - $sql.= " AND f.fk_statut = ".Facture::STATUS_VALIDATED; + $sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED; } -$sql.= " AND f.total_ttc > 0"; -$sql.= " AND pfd.traite = 0"; -$sql.= " AND pfd.fk_facture = f.rowid"; -if ($socid > 0) $sql.= " AND f.fk_soc = ".$socid; +$sql .= " AND f.total_ttc > 0"; +$sql .= " AND pfd.traite = 0"; +$sql .= " AND pfd.fk_facture = f.rowid"; +if ($socid > 0) $sql .= " AND f.fk_soc = ".$socid; $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -232,24 +232,24 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit+1, $offset); +$sql .= $db->plimit($limit + 1, $offset); -$resql=$db->query($sql); +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; - $param=''; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if($socid) $param .= '&socid='.urlencode($socid); - if($option) $param .= "&option=".urlencode($option); + $param = ''; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($socid) $param .= '&socid='.urlencode($socid); + if ($option) $param .= "&option=".urlencode($option); print ''; print ''; print ''; - if (! empty($limit)) { - print ''; + if (!empty($limit)) { + print ''; } print_barre_liste($langs->trans("InvoiceWaitingWithdraw"), $page, $_SERVER['PHP_SELF'], $param, '', '', '', $num, $nbtotalofrecords, 'invoicing', 0, '', '', $limit); @@ -266,7 +266,7 @@ if ($resql) if ($num) { - require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; + require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; $bac = new CompanyBankAccount($db); while ($i < $num && $i < $limit) @@ -275,8 +275,8 @@ if ($resql) print ''; print ''; - $invoicestatic->id=$obj->rowid; - $invoicestatic->ref=$obj->ref; + $invoicestatic->id = $obj->rowid; + $invoicestatic->ref = $obj->ref; print $invoicestatic->getNomUrl(1, 'withdraw'); print ''; // Thirdparty diff --git a/htdocs/compta/prelevement/demandes.php b/htdocs/compta/prelevement/demandes.php index 80dbe3e02da..61c457c9b17 100644 --- a/htdocs/compta/prelevement/demandes.php +++ b/htdocs/compta/prelevement/demandes.php @@ -36,18 +36,18 @@ $langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies')); // Security check $socid = GETPOST('socid', 'int'); $status = GETPOST('status', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'prelevement', '', '', 'bons'); -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'myobjectlist'; // To manage different context of search -$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') $search_facture = GETPOST('search_facture', 'alpha'); $search_societe = trim(GETPOST('search_societe', 'alpha')); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); @@ -55,8 +55,8 @@ if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST( $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="DESC"; -if (! $sortfield) $sortfield="f.ref"; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "f.ref"; $massactionbutton = ''; @@ -96,34 +96,34 @@ else llxHeader('', $title); -$thirdpartystatic=new Societe($db); -$invoicestatic=new Facture($db); +$thirdpartystatic = new Societe($db); +$invoicestatic = new Facture($db); // List of requests -$sql= "SELECT f.ref, f.rowid, f.total_ttc,"; -$sql.= " s.nom as name, s.rowid as socid,"; -$sql.= " pfd.date_demande as date_demande,"; -$sql.= " pfd.fk_user_demande"; -$sql.= " FROM ".MAIN_DB_PREFIX."facture as f,"; -$sql.= " ".MAIN_DB_PREFIX."societe as s,"; -$sql.= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; -if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= " WHERE s.rowid = f.fk_soc"; -$sql.= " AND f.entity IN (".getEntity('invoice').")"; -if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -if ($socid) $sql.= " AND f.fk_soc = ".$socid; -if (!$status) $sql.= " AND pfd.traite = 0"; -if ($status) $sql.= " AND pfd.traite = ".$status; -$sql.= " AND f.total_ttc > 0"; +$sql = "SELECT f.ref, f.rowid, f.total_ttc,"; +$sql .= " s.nom as name, s.rowid as socid,"; +$sql .= " pfd.date_demande as date_demande,"; +$sql .= " pfd.fk_user_demande"; +$sql .= " FROM ".MAIN_DB_PREFIX."facture as f,"; +$sql .= " ".MAIN_DB_PREFIX."societe as s,"; +$sql .= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql .= " WHERE s.rowid = f.fk_soc"; +$sql .= " AND f.entity IN (".getEntity('invoice').")"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if ($socid) $sql .= " AND f.fk_soc = ".$socid; +if (!$status) $sql .= " AND pfd.traite = 0"; +if ($status) $sql .= " AND pfd.traite = ".$status; +$sql .= " AND f.total_ttc > 0"; if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) { - $sql.= " AND f.fk_statut = ".Facture::STATUS_VALIDATED; + $sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED; } -$sql.= " AND pfd.fk_facture = f.rowid"; -if ($search_facture) $sql.= natural_search("f.ref", $search_facture); -if ($search_societe) $sql.= natural_search("s.nom", $search_societe); -$sql.=$db->order($sortfield, $sortorder); +$sql .= " AND pfd.fk_facture = f.rowid"; +if ($search_facture) $sql .= natural_search("f.ref", $search_facture); +if ($search_societe) $sql .= natural_search("s.nom", $search_societe); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records @@ -145,10 +145,10 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) } else { - $sql.= $db->plimit($limit+1, $offset); + $sql .= $db->plimit($limit + 1, $offset); - $resql=$db->query($sql); - if (! $resql) + $resql = $db->query($sql); + if (!$resql) { dol_print_error($db); exit; @@ -201,20 +201,20 @@ $i = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) break; // Should not happen print ''; // Ref facture print ''; - $invoicestatic->id=$obj->rowid; - $invoicestatic->ref=$obj->ref; + $invoicestatic->id = $obj->rowid; + $invoicestatic->ref = $obj->ref; print $invoicestatic->getNomUrl(1, 'withdraw'); print ''; print ''; - $thirdpartystatic->id=$obj->socid; - $thirdpartystatic->name=$obj->name; + $thirdpartystatic->id = $obj->socid; + $thirdpartystatic->name = $obj->name; print $thirdpartystatic->getNomUrl(1, 'customer'); print ''; diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index 29c7a1f2aab..c5e142ca7ca 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -30,26 +30,26 @@ require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php' require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -if (! empty($conf->projet->enabled)) +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'; } -if (! empty($conf->accounting->enabled)) { - include_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +if (!empty($conf->accounting->enabled)) { + include_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; } // Load translation files required by the page $langs->loadLangs(array('compta', 'bills', 'banks')); -$id=GETPOST('id', 'int'); -$action=GETPOST('action', 'aZ09'); -$confirm=GETPOST('confirm'); +$id = GETPOST('id', 'int'); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm'); $projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0); // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'tax', $id, 'chargesociales', 'charges'); $object = new ChargeSociales($db); @@ -159,44 +159,44 @@ if ($action == 'add' && $user->rights->tax->charges->creer) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors'); $action = 'create'; } - elseif (! is_numeric($amount)) + elseif (!is_numeric($amount)) { setEventMessages($langs->trans("ErrorFieldMustBeANumeric", $langs->transnoentities("Amount")), null, 'errors'); $action = 'create'; } else { - $object->type = $actioncode; - $object->label = GETPOST('label', 'alpha'); - $object->date_ech = $dateech; + $object->type = $actioncode; + $object->label = GETPOST('label', 'alpha'); + $object->date_ech = $dateech; $object->periode = $dateperiod; $object->amount = $amount; - $object->mode_reglement_id = GETPOST('mode_reglement_id'); + $object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->fk_account = GETPOST('fk_account', 'int'); $object->fk_project = GETPOST('fk_project'); - $id=$object->create($user); + $id = $object->create($user); if ($id <= 0) { setEventMessages($object->error, $object->errors, 'errors'); - $action='create'; + $action = 'create'; } } } -if ($action == 'update' && ! $_POST["cancel"] && $user->rights->tax->charges->creer) +if ($action == 'update' && !$_POST["cancel"] && $user->rights->tax->charges->creer) { - $dateech=dol_mktime(GETPOST('echhour'), GETPOST('echmin'), GETPOST('echsec'), GETPOST('echmonth'), GETPOST('echday'), GETPOST('echyear')); - $dateperiod=dol_mktime(GETPOST('periodhour'), GETPOST('periodmin'), GETPOST('periodsec'), GETPOST('periodmonth'), GETPOST('periodday'), GETPOST('periodyear')); - $amount=price2num(GETPOST('amount')); + $dateech = dol_mktime(GETPOST('echhour'), GETPOST('echmin'), GETPOST('echsec'), GETPOST('echmonth'), GETPOST('echday'), GETPOST('echyear')); + $dateperiod = dol_mktime(GETPOST('periodhour'), GETPOST('periodmin'), GETPOST('periodsec'), GETPOST('periodmonth'), GETPOST('periodday'), GETPOST('periodyear')); + $amount = price2num(GETPOST('amount')); - if (! $dateech) + if (!$dateech) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors'); $action = 'edit'; } - elseif (! $dateperiod) + elseif (!$dateperiod) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Period")), null, 'errors'); $action = 'edit'; @@ -444,14 +444,14 @@ if ($id > 0) if ($action == 'paid') { - $text=$langs->trans('ConfirmPaySocialContribution'); + $text = $langs->trans('ConfirmPaySocialContribution'); print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans('PaySocialContribution'), $text, "confirm_paid", '', '', 2); } // Confirmation of the removal of the Social Contribution if ($action == 'delete') { - $text=$langs->trans('ConfirmDeleteSocialContribution'); + $text = $langs->trans('ConfirmDeleteSocialContribution'); print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('DeleteSocialContribution'), $text, 'confirm_delete', '', '', 2); } @@ -463,48 +463,48 @@ if ($id > 0) dol_fiche_head($head, 'card', $langs->trans("SocialContribution"), -1, 'bill'); - $morehtmlref='
'; + $morehtmlref = '
'; // Ref customer - $morehtmlref.=$form->editfieldkey("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1); + $morehtmlref .= $form->editfieldkey("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 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->tax->charges->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(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects(0, $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 .= '
'; - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index bf2d04515bf..f6ff04ebe54 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -132,41 +132,41 @@ class ChargeSociales extends CommonObject public function fetch($id, $ref = '') { $sql = "SELECT cs.rowid, cs.date_ech"; - $sql.= ", cs.libelle as label, cs.fk_type, cs.amount, cs.fk_projet as fk_project, cs.paye, cs.periode, cs.import_key"; - $sql.= ", cs.fk_account, cs.fk_mode_reglement"; - $sql.= ", c.libelle"; - $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; - $sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as cs"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as c ON cs.fk_type = c.id"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON cs.fk_mode_reglement = p.id'; - $sql.= ' WHERE cs.entity IN ('.getEntity('tax').')'; - if ($ref) $sql.= " AND cs.rowid = ".$ref; - else $sql.= " AND cs.rowid = ".$id; + $sql .= ", cs.libelle as label, cs.fk_type, cs.amount, cs.fk_projet as fk_project, cs.paye, cs.periode, cs.import_key"; + $sql .= ", cs.fk_account, cs.fk_mode_reglement"; + $sql .= ", c.libelle"; + $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; + $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as cs"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as c ON cs.fk_type = c.id"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON cs.fk_mode_reglement = p.id'; + $sql .= ' WHERE cs.entity IN ('.getEntity('tax').')'; + if ($ref) $sql .= " AND cs.rowid = ".$ref; + else $sql .= " AND cs.rowid = ".$id; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->ref = $obj->rowid; - $this->date_ech = $this->db->jdate($obj->date_ech); + $this->date_ech = $this->db->jdate($obj->date_ech); $this->lib = $obj->label; $this->label = $obj->label; $this->type = $obj->fk_type; $this->type_label = $obj->libelle; $this->fk_account = $obj->fk_account; - $this->mode_reglement_id = $obj->fk_mode_reglement; - $this->mode_reglement_code = $obj->mode_reglement_code; - $this->mode_reglement = $obj->mode_reglement_libelle; - $this->amount = $obj->amount; - $this->fk_project = $obj->fk_project; - $this->paye = $obj->paye; - $this->periode = $this->db->jdate($obj->periode); - $this->import_key = $this->import_key; + $this->mode_reglement_id = $obj->fk_mode_reglement; + $this->mode_reglement_code = $obj->mode_reglement_code; + $this->mode_reglement = $obj->mode_reglement_libelle; + $this->amount = $obj->amount; + $this->fk_project = $obj->fk_project; + $this->paye = $obj->paye; + $this->periode = $this->db->jdate($obj->periode); + $this->import_key = $this->import_key; $this->db->free($resql); @@ -497,7 +497,7 @@ class ChargeSociales extends CommonObject global $langs; // Load translation files required by the page - $langs->loadLangs(array("customers","bills")); + $langs->loadLangs(array("customers", "bills")); // We reinit status array to force to redefine them because label may change according to properties values. $this->labelStatus = array(); @@ -548,41 +548,41 @@ class ChargeSociales extends CommonObject if ($option !== 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } - if (empty($this->ref)) $this->ref=$this->label; + if (empty($this->ref)) $this->ref = $this->label; $label = ''.$langs->trans("ShowSocialContribution").''; - if (! empty($this->ref)) - $label .= '
'.$langs->trans('Ref') . ': ' . $this->ref; - if (! empty($this->label)) - $label .= '
'.$langs->trans('Label') . ': ' . $this->label; - if (! empty($this->type_label)) - $label .= '
'.$langs->trans('Type') . ': ' . $this->type_label; + if (!empty($this->ref)) + $label .= '
'.$langs->trans('Ref').': '.$this->ref; + if (!empty($this->label)) + $label .= '
'.$langs->trans('Label').': '.$this->label; + if (!empty($this->type_label)) + $label .= '
'.$langs->trans('Type').': '.$this->type_label; - $linkclose=''; + $linkclose = ''; if (empty($notooltip) && $user->rights->facture->lire) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowSocialContribution"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowSocialContribution"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; } - $linkstart=''; - $linkend=''; + $linkstart = ''; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= ($maxlen?dol_trunc($this->ref, $maxlen):$this->ref); + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref); $result .= $linkend; return $result; diff --git a/htdocs/compta/tva/document.php b/htdocs/compta/tva/document.php index 6c1816589f4..7f860491a8d 100644 --- a/htdocs/compta/tva/document.php +++ b/htdocs/compta/tva/document.php @@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/vat.lib.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'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; @@ -48,7 +48,7 @@ $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); // Security check -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'tax', '', 'vat', 'charges'); @@ -63,22 +63,22 @@ if (empty($page) || $page == -1) { $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="name"; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "name"; $object = new Tva($db); if ($id > 0) $object->fetch($id); $upload_dir = $conf->tax->dir_output.'/'.dol_sanitizeFileName($object->ref); -$modulepart='tax'; +$modulepart = 'tax'; /* * Actions */ -include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; +include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; if ($action == 'setlib' && $user->rights->tax->charges->creer) { @@ -94,29 +94,29 @@ if ($action == 'setlib' && $user->rights->tax->charges->creer) */ $form = new Form($db); -if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } -$title = $langs->trans("VATPayment") . ' - ' . $langs->trans("Documents"); -$help_url='EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:Módulo Impuestos y cargas sociales (IVA, impuestos)'; +$title = $langs->trans("VATPayment").' - '.$langs->trans("Documents"); +$help_url = 'EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:Módulo Impuestos y cargas sociales (IVA, impuestos)'; llxHeader("", $title, $help_url); if ($object->id) { - $alreadypayed=$object->getSommePaiement(); + $alreadypayed = $object->getSommePaiement(); - $head=vat_prepare_head($object); + $head = vat_prepare_head($object); dol_fiche_head($head, 'documents', $langs->trans("VATPayment"), -1, 'bill'); - $morehtmlref='
'; + $morehtmlref = '
'; // Label of social contribution - $morehtmlref.=$form->editfieldkey("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1); - $morehtmlref.='
'; + $morehtmlref .= $form->editfieldkey("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1); + $morehtmlref .= '
'; - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = ''.$langs->trans("BackToList").''; - $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); @@ -124,11 +124,11 @@ if ($object->id) print '
'; // Build file list - $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); - $totalsize=0; - foreach($filearray as $key => $file) + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); + $totalsize = 0; + foreach ($filearray as $key => $file) { - $totalsize+=$file['size']; + $totalsize += $file['size']; } @@ -147,8 +147,8 @@ if ($object->id) $modulepart = 'tax'; $permission = $user->rights->tax->charges->creer; $permtoedit = $user->rights->fournisseur->facture->creer; - $param = '&id=' . $object->id; - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; + $param = '&id='.$object->id; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index c80dda1da91..1fc63769af3 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -724,7 +724,7 @@ if (empty($reshook)) if (is_array($array_options) && count($array_options) > 0) { // We replace values in this->line->array_options only for entries defined into $array_options - foreach($array_options as $key => $value) { + foreach ($array_options as $key => $value) { $objectline->array_options[$key] = $array_options[$key]; } } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index aba614f3c74..ecf12e11484 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -901,7 +901,7 @@ class Contrat extends CommonObject $line->fk_user_author = $objp->fk_user_author; $line->fk_user_ouverture = $objp->fk_user_ouverture; - $line->fk_user_cloture = $objp->fk_user_cloture; + $line->fk_user_cloture = $objp->fk_user_cloture; $line->fk_unit = $objp->fk_unit; $line->ref = $objp->product_ref; // deprecated @@ -1807,7 +1807,7 @@ class Contrat extends CommonObject $contractline->fetch_optionals(); // We replace values in $contractline->array_options only for entries defined into $array_options - foreach($array_options as $key => $value) { + foreach ($array_options as $key => $value) { $contractline->array_options[$key] = $array_options[$key]; } diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index 29501ddee88..952a286d773 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -86,36 +86,36 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label('contratdet'); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Security check $contratid = GETPOST('id', 'int'); -if (! empty($user->socid)) $socid=$user->socid; +if (!empty($user->socid)) $socid = $user->socid; $result = restrictedArea($user, 'contrat', $contratid); if ($search_status != '') { - $tmp=explode('&', $search_status); - $mode=$tmp[0]; - if (empty($tmp[1])) $filter=''; + $tmp = explode('&', $search_status); + $mode = $tmp[0]; + if (empty($tmp[1])) $filter = ''; else { - if ($tmp[1] == 'filter=notexpired') $filter='notexpired'; - if ($tmp[1] == 'filter=expired') $filter='expired'; + if ($tmp[1] == 'filter=notexpired') $filter = 'notexpired'; + if ($tmp[1] == 'filter=expired') $filter = 'expired'; } } else { $search_status = $mode; - if ($filter == 'expired') $search_status.='&filter=expired'; - if ($filter == 'notexpired') $search_status.='&filter=notexpired'; + if ($filter == 'expired') $search_status .= '&filter=expired'; + if ($filter == 'notexpired') $search_status .= '&filter=notexpired'; } -$staticcontrat=new Contrat($db); -$staticcontratligne=new ContratLigne($db); -$companystatic=new Societe($db); +$staticcontrat = new Contrat($db); +$staticcontratligne = new ContratLigne($db); +$companystatic = new Societe($db); -$arrayfields=array( +$arrayfields = array( 'c.ref'=>array('label'=>$langs->trans("Contract"), 'checked'=>1, 'position'=>80), 'p.description'=>array('label'=>$langs->trans("Service"), 'checked'=>1, 'position'=>80), 'cd.qty'=>array('label'=>$langs->trans("Qty"), 'checked'=>0, 'position'=>100), @@ -198,71 +198,71 @@ if (empty($reshook)) * View */ -$now=dol_now(); +$now = dol_now(); -$form=new Form($db); +$form = new Form($db); $sql = "SELECT c.rowid as cid, c.ref, c.statut as cstatut,"; -$sql.= " s.rowid as socid, s.nom as name, s.email, s.client, s.fournisseur,"; -$sql.= " cd.rowid, cd.description, cd.statut,"; -$sql.= " p.rowid as pid, p.ref as pref, p.label as label, p.fk_product_type as ptype, p.entity as pentity,"; +$sql .= " s.rowid as socid, s.nom as name, s.email, s.client, s.fournisseur,"; +$sql .= " cd.rowid, cd.description, cd.statut,"; +$sql .= " p.rowid as pid, p.ref as pref, p.label as label, p.fk_product_type as ptype, p.entity as pentity,"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " sc.fk_soc, sc.fk_user,"; -$sql.= " cd.date_ouverture_prevue,"; -$sql.= " cd.date_ouverture,"; -$sql.= " cd.date_fin_validite,"; -$sql.= " cd.date_cloture,"; -$sql.= " cd.qty,"; -$sql.= " cd.total_ht,"; -$sql.= " cd.total_tva,"; -$sql.= " cd.tva_tx,"; -$sql.= " cd.subprice,"; +$sql .= " cd.date_ouverture_prevue,"; +$sql .= " cd.date_ouverture,"; +$sql .= " cd.date_fin_validite,"; +$sql .= " cd.date_cloture,"; +$sql .= " cd.qty,"; +$sql .= " cd.total_ht,"; +$sql .= " cd.total_tva,"; +$sql .= " cd.tva_tx,"; +$sql .= " cd.subprice,"; //$sql.= " cd.date_c as date_creation,"; -$sql.= " cd.tms as date_update"; +$sql .= " cd.tms as date_update"; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql.= " FROM ".MAIN_DB_PREFIX."contrat as c,"; -$sql.= " ".MAIN_DB_PREFIX."societe as s,"; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= " FROM ".MAIN_DB_PREFIX."contrat as c,"; +$sql .= " ".MAIN_DB_PREFIX."societe as s,"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,"; -$sql.= " ".MAIN_DB_PREFIX."contratdet as cd"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (cd.rowid = ef.fk_object)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; -if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=cd.fk_product'; -$sql.= " WHERE c.entity = ".$conf->entity; -$sql.= " AND c.rowid = cd.fk_contrat"; -if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$search_product_category; -$sql.= " AND c.fk_soc = s.rowid"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -if ($mode == "0") $sql.= " AND cd.statut = 0"; -if ($mode == "4") $sql.= " AND cd.statut = 4"; -if ($mode == "5") $sql.= " AND cd.statut = 5"; -if ($filter == "expired") $sql.= " AND cd.date_fin_validite < '".$db->idate($now)."'"; -if ($filter == "notexpired") $sql.= " AND cd.date_fin_validite >= '".$db->idate($now)."'"; -if ($search_name) $sql.= " AND s.nom LIKE '%".$db->escape($search_name)."%'"; -if ($search_contract) $sql.= " AND c.ref LIKE '%".$db->escape($search_contract)."%' "; -if ($search_service) $sql.= " AND (p.ref LIKE '%".$db->escape($search_service)."%' OR p.description LIKE '%".$db->escape($search_service)."%' OR cd.description LIKE '%".$db->escape($search_service)."%')"; -if ($socid > 0) $sql.= " AND s.rowid = ".$socid; -$filter_dateouvertureprevue=dol_mktime(0, 0, 0, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear); +$sql .= " ".MAIN_DB_PREFIX."contratdet as cd"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (cd.rowid = ef.fk_object)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; +if ($search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=cd.fk_product'; +$sql .= " WHERE c.entity = ".$conf->entity; +$sql .= " AND c.rowid = cd.fk_contrat"; +if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$search_product_category; +$sql .= " AND c.fk_soc = s.rowid"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if ($mode == "0") $sql .= " AND cd.statut = 0"; +if ($mode == "4") $sql .= " AND cd.statut = 4"; +if ($mode == "5") $sql .= " AND cd.statut = 5"; +if ($filter == "expired") $sql .= " AND cd.date_fin_validite < '".$db->idate($now)."'"; +if ($filter == "notexpired") $sql .= " AND cd.date_fin_validite >= '".$db->idate($now)."'"; +if ($search_name) $sql .= " AND s.nom LIKE '%".$db->escape($search_name)."%'"; +if ($search_contract) $sql .= " AND c.ref LIKE '%".$db->escape($search_contract)."%' "; +if ($search_service) $sql .= " AND (p.ref LIKE '%".$db->escape($search_service)."%' OR p.description LIKE '%".$db->escape($search_service)."%' OR cd.description LIKE '%".$db->escape($search_service)."%')"; +if ($socid > 0) $sql .= " AND s.rowid = ".$socid; +$filter_dateouvertureprevue = dol_mktime(0, 0, 0, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear); if ($filter_dateouvertureprevue != '' && $filter_opouvertureprevue == -1) $filter_opouvertureprevue = '='; -$filter_date1=dol_mktime(0, 0, 0, $op1month, $op1day, $op1year); +$filter_date1 = dol_mktime(0, 0, 0, $op1month, $op1day, $op1year); if ($filter_date1 != '' && $filter_op1 == -1) $filter_op1 = '='; -$filter_date2=dol_mktime(0, 0, 0, $op2month, $op2day, $op2year); +$filter_date2 = dol_mktime(0, 0, 0, $op2month, $op2day, $op2year); if ($filter_date2 != '' && $filter_op2 == -1) $filter_op2 = '='; -$filter_datecloture=dol_mktime(0, 0, 0, $opcloturemonth, $opclotureday, $opclotureyear); +$filter_datecloture = dol_mktime(0, 0, 0, $opcloturemonth, $opclotureday, $opclotureyear); if ($filter_datecloture != '' && $filter_opcloture == -1) $filter_opcloture = '='; -if (! empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1 && $filter_dateouvertureprevue != '') $sql.= " AND cd.date_ouverture_prevue ".$filter_opouvertureprevue." '".$db->idate($filter_dateouvertureprevue)."'"; -if (! empty($filter_op1) && $filter_op1 != -1 && $filter_date1 != '') $sql.= " AND cd.date_ouverture ".$filter_op1." '".$db->idate($filter_date1)."'"; -if (! empty($filter_op2) && $filter_op2 != -1 && $filter_date2 != '') $sql.= " AND cd.date_fin_validite ".$filter_op2." '".$db->idate($filter_date2)."'"; -if (! empty($filter_opcloture) && $filter_opcloture != -1 && $filter_datecloture != '') $sql.= " AND cd.date_cloture ".$filter_opcloture." '".$db->idate($filter_datecloture)."'"; +if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1 && $filter_dateouvertureprevue != '') $sql .= " AND cd.date_ouverture_prevue ".$filter_opouvertureprevue." '".$db->idate($filter_dateouvertureprevue)."'"; +if (!empty($filter_op1) && $filter_op1 != -1 && $filter_date1 != '') $sql .= " AND cd.date_ouverture ".$filter_op1." '".$db->idate($filter_date1)."'"; +if (!empty($filter_op2) && $filter_op2 != -1 && $filter_date2 != '') $sql .= " AND cd.date_fin_validite ".$filter_op2." '".$db->idate($filter_date2)."'"; +if (!empty($filter_opcloture) && $filter_opcloture != -1 && $filter_datecloture != '') $sql .= " AND cd.date_cloture ".$filter_opcloture." '".$db->idate($filter_datecloture)."'"; // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; $sql .= $db->order($sortfield, $sortorder); @@ -594,120 +594,120 @@ while ($i < min($num, $limit)) if ($obj->type == 1) print img_object($obj->description, 'service').' '.dol_trunc($obj->description, 24); } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['cd.qty']['checked'])) + if (!empty($arrayfields['cd.qty']['checked'])) { print ''; print $obj->qty; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['cd.total_ht']['checked'])) + if (!empty($arrayfields['cd.total_ht']['checked'])) { print ''; print price($obj->total_ht); print ''; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='cd.total_ht'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'cd.total_ht'; $totalarray['val']['cd.total_ht'] += $obj->total_ht; } - if (! empty($arrayfields['cd.total_tva']['checked'])) + if (!empty($arrayfields['cd.total_tva']['checked'])) { print ''; print price($obj->total_tva); print ''; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='cd.total_tva'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'cd.total_tva'; $totalarray['val']['cd.total_tva'] += $obj->total_tva; } - if (! empty($arrayfields['cd.tva_tx']['checked'])) + if (!empty($arrayfields['cd.tva_tx']['checked'])) { print ''; print price2num($obj->tva_tx).'%'; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['cd.subprice']['checked'])) + if (!empty($arrayfields['cd.subprice']['checked'])) { print ''; print price($obj->subprice); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Third party - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print ''; print $companystatic->getNomUrl(1, 'customer', 28); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Start date - if (! empty($arrayfields['cd.date_ouverture_prevue']['checked'])) + if (!empty($arrayfields['cd.date_ouverture_prevue']['checked'])) { print ''; - print ($obj->date_ouverture_prevue?dol_print_date($db->jdate($obj->date_ouverture_prevue), 'dayhour'):' '); + print ($obj->date_ouverture_prevue ?dol_print_date($db->jdate($obj->date_ouverture_prevue), 'dayhour') : ' '); if ($db->jdate($obj->date_ouverture_prevue) && ($db->jdate($obj->date_ouverture_prevue) < ($now - $conf->contrat->services->inactifs->warning_delay)) && $obj->statut == 0) print ' '.img_picto($langs->trans("Late"), "warning"); else print '    '; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['cd.date_ouverture']['checked'])) + if (!empty($arrayfields['cd.date_ouverture']['checked'])) { - print ''.($obj->date_ouverture?dol_print_date($db->jdate($obj->date_ouverture), 'dayhour'):' ').''; - if (! $i) $totalarray['nbfield']++; + print ''.($obj->date_ouverture ?dol_print_date($db->jdate($obj->date_ouverture), 'dayhour') : ' ').''; + if (!$i) $totalarray['nbfield']++; } // End date - if (! empty($arrayfields['cd.date_fin_validite']['checked'])) + if (!empty($arrayfields['cd.date_fin_validite']['checked'])) { - print ''.($obj->date_fin_validite?dol_print_date($db->jdate($obj->date_fin_validite), 'dayhour'):' '); + print ''.($obj->date_fin_validite ?dol_print_date($db->jdate($obj->date_fin_validite), 'dayhour') : ' '); if ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < ($now - $conf->contrat->services->expires->warning_delay) && $obj->statut < 5) { - $warning_delay=$conf->contrat->services->expires->warning_delay / 3600 / 24; + $warning_delay = $conf->contrat->services->expires->warning_delay / 3600 / 24; $textlate = $langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($warning_delay) >= 0 ? '+' : '').ceil($warning_delay).' '.$langs->trans("days"); print img_warning($textlate); } else print '    '; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Close date (real end date) - if (! empty($arrayfields['cd.date_cloture']['checked'])) + if (!empty($arrayfields['cd.date_cloture']['checked'])) { print ''.dol_print_date($db->jdate($obj->date_cloture), 'dayhour').''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['cd.datec']['checked'])) + if (!empty($arrayfields['cd.datec']['checked'])) { print ''; print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date modification - if (! empty($arrayfields['cd.tms']['checked'])) + if (!empty($arrayfields['cd.tms']['checked'])) { print ''; print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Status - if (! empty($arrayfields['status']['checked'])) + if (!empty($arrayfields['status']['checked'])) { print ''; if ($obj->cstatut == 0) @@ -717,21 +717,21 @@ while ($i < min($num, $limit)) } else { - print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now)?1:0); + print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now) ? 1 : 0); } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Action column print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print "\n"; $i++; diff --git a/htdocs/core/actions_setmoduleoptions.inc.php b/htdocs/core/actions_setmoduleoptions.inc.php index d3f1d48064d..9ade3c148a4 100644 --- a/htdocs/core/actions_setmoduleoptions.inc.php +++ b/htdocs/core/actions_setmoduleoptions.inc.php @@ -31,22 +31,22 @@ if ($action == 'update' && is_array($arrayofparameters)) { $db->begin(); - $ok=true; - foreach($arrayofparameters as $key => $val) + $ok = true; + foreach ($arrayofparameters as $key => $val) { // Modify constant only if key was posted (avoid resetting key to the null value) if (GETPOSTISSET($key)) { - $result=dolibarr_set_const($db, $key, GETPOST($key, 'alpha'), 'chaine', 0, '', $conf->entity); + $result = dolibarr_set_const($db, $key, GETPOST($key, 'alpha'), 'chaine', 0, '', $conf->entity); if ($result < 0) { - $ok=false; + $ok = false; break; } } } - if (! $error) + if (!$error) { $db->commit(); if (empty($nomessageinupdate)) setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -66,16 +66,16 @@ if ($action == 'setModuleOptions') // Process common param fields if (is_array($_POST)) { - foreach($_POST as $key => $val) + foreach ($_POST as $key => $val) { if (preg_match('/^param(\d*)$/', $key, $reg)) // Works for POST['param'], POST['param1'], POST['param2'], ... { - $param=GETPOST("param".$reg[1], 'alpha'); - $value=GETPOST("value".$reg[1], 'alpha'); + $param = GETPOST("param".$reg[1], 'alpha'); + $value = GETPOST("value".$reg[1], 'alpha'); if ($param) { $res = dolibarr_set_const($db, $param, $value, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; } } } @@ -85,19 +85,19 @@ if ($action == 'setModuleOptions') if (GETPOST('upload', 'alpha') && GETPOST('keyforuploaddir', 'aZ09')) { include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $keyforuploaddir=GETPOST('keyforuploaddir', 'aZ09'); - $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->$keyforuploaddir))); - foreach($listofdir as $key=>$tmpdir) + $keyforuploaddir = GETPOST('keyforuploaddir', 'aZ09'); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->$keyforuploaddir))); + foreach ($listofdir as $key=>$tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); else { - $upload_dir=$tmpdir; + $upload_dir = $tmpdir; } } if ($upload_dir) @@ -107,7 +107,7 @@ if ($action == 'setModuleOptions') } } - if (! $error) + if (!$error) { $db->commit(); if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index 883dec19981..ab9dc42fca9 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -33,9 +33,9 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; */ class box_factures_imp extends ModeleBoxes { - public $boxcode="oldestunpaidcustomerbills"; - public $boximg="object_bill"; - public $boxlabel="BoxOldestUnpaidCustomerBills"; + public $boxcode = "oldestunpaidcustomerbills"; + public $boximg = "object_bill"; + public $boxlabel = "BoxOldestUnpaidCustomerBills"; public $depends = array("facture"); /** @@ -61,7 +61,7 @@ class box_factures_imp extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->facture->lire); + $this->hidden = !($user->rights->facture->lire); } /** @@ -74,7 +74,7 @@ class box_factures_imp extends ModeleBoxes { global $conf, $user, $langs; - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; @@ -89,37 +89,37 @@ class box_factures_imp extends ModeleBoxes if ($user->rights->facture->lire) { $sql = "SELECT s.nom as name, s.rowid as socid, s.email,"; - $sql.= " s.code_client,"; - $sql.= " s.logo,"; - $sql.= " f.ref, f.date_lim_reglement as datelimite,"; - $sql.= " f.type,"; - $sql.= " f.amount, f.datef as df,"; - $sql.= " f.total as total_ht,"; - $sql.= " f.tva as total_tva,"; - $sql.= " f.total_ttc,"; - $sql.= " f.paye, f.fk_statut, f.rowid as facid"; - $sql.= ", sum(pf.amount) as am"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ", ".MAIN_DB_PREFIX."facture as f"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid=pf.fk_facture "; - $sql.= " WHERE f.fk_soc = s.rowid"; - $sql.= " AND f.entity IN (".getEntity('invoice').")"; - $sql.= " AND f.paye = 0"; - $sql.= " AND fk_statut = 1"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if($user->socid) $sql.= " AND s.rowid = ".$user->socid; - $sql.= " GROUP BY s.nom, s.rowid, s.email, s.code_client, s.logo, f.ref, f.date_lim_reglement,"; - $sql.= " f.type, f.amount, f.datef, f.total, f.tva, f.total_ttc, f.paye, f.fk_statut, f.rowid"; + $sql .= " s.code_client,"; + $sql .= " s.logo,"; + $sql .= " f.ref, f.date_lim_reglement as datelimite,"; + $sql .= " f.type,"; + $sql .= " f.amount, f.datef as df,"; + $sql .= " f.total as total_ht,"; + $sql .= " f.tva as total_tva,"; + $sql .= " f.total_ttc,"; + $sql .= " f.paye, f.fk_statut, f.rowid as facid"; + $sql .= ", sum(pf.amount) as am"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."facture as f"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid=pf.fk_facture "; + $sql .= " WHERE f.fk_soc = s.rowid"; + $sql .= " AND f.entity IN (".getEntity('invoice').")"; + $sql .= " AND f.paye = 0"; + $sql .= " AND fk_statut = 1"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; + $sql .= " GROUP BY s.nom, s.rowid, s.email, s.code_client, s.logo, f.ref, f.date_lim_reglement,"; + $sql .= " f.type, f.amount, f.datef, f.total, f.tva, f.total_ttc, f.paye, f.fk_statut, f.rowid"; //$sql.= " ORDER BY f.datef DESC, f.ref DESC "; - $sql.= " ORDER BY datelimite ASC, f.ref ASC "; - $sql.= $this->db->plimit($max, 0); + $sql .= " ORDER BY datelimite ASC, f.ref ASC "; + $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); - $now=dol_now(); + $now = dol_now(); $line = 0; $l_due_date = $langs->trans('Late').' ('.strtolower($langs->trans('DateDue')).': %s)'; @@ -127,7 +127,7 @@ class box_factures_imp extends ModeleBoxes while ($line < $num) { $objp = $this->db->fetch_object($result); - $datelimite=$this->db->jdate($objp->datelimite); + $datelimite = $this->db->jdate($objp->datelimite); $facturestatic->id = $objp->facid; $facturestatic->ref = $objp->ref; $facturestatic->type = $objp->type; @@ -144,7 +144,7 @@ class box_factures_imp extends ModeleBoxes $societestatic->code_client = $objp->code_client; $societestatic->logo = $objp->logo; - $late=''; + $late = ''; if ($facturestatic->hasDelay()) { $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); } @@ -180,7 +180,7 @@ class box_factures_imp extends ModeleBoxes $line++; } - if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoUnpaidCustomerBills")); + if ($num == 0) $this->info_box_contents[$line][0] = array('td' => 'class="center"', 'text'=>$langs->trans("NoUnpaidCustomerBills")); $this->db->free($result); } diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php index 295c358caf0..94b4764eeae 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.php @@ -94,7 +94,7 @@ class box_services_expired extends ModeleBoxes if ($user->socid) $sql .= ' AND c.fk_soc = '.$user->socid; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; $sql .= " GROUP BY c.rowid, c.ref, c.statut, c.date_contrat, c.ref_customer, c.ref_supplier, s.nom, s.rowid"; - $sql.= ", s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; + $sql .= ", s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; $sql .= " ORDER BY date_line ASC"; $sql .= $this->db->plimit($max, 0); diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 32ac5d2365c..06b6ec2d949 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -226,7 +226,7 @@ class DolEditor }); } }, - disableNativeSpellChecker: '.(empty($conf->global->CKEDITOR_NATIVE_SPELLCHECKER)?'true':'false'); + disableNativeSpellChecker: '.(empty($conf->global->CKEDITOR_NATIVE_SPELLCHECKER) ? 'true' : 'false'); if ($this->uselocalbrowser) { diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index f32621f93ac..4425e43cda2 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -101,7 +101,7 @@ * */ -require_once DOL_DOCUMENT_ROOT .'/includes/mike42/escpos-php/autoload.php'; +require_once DOL_DOCUMENT_ROOT.'/includes/mike42/escpos-php/autoload.php'; use Mike42\Escpos\PrintConnectors\FilePrintConnector; use Mike42\Escpos\PrintConnectors\NetworkPrintConnector; use Mike42\Escpos\PrintConnectors\WindowsPrintConnector; @@ -137,7 +137,7 @@ class dolReceiptPrinter extends Printer /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var string[] Error codes (or messages) @@ -151,7 +151,7 @@ class dolReceiptPrinter extends Printer */ public function __construct($db) { - $this->db=$db; + $this->db = $db; $this->tags = array( 'dol_line_feed', 'dol_line_feed_reverse', @@ -251,8 +251,8 @@ class dolReceiptPrinter extends Printer $line = 0; $obj = array(); $sql = 'SELECT rowid, name, fk_type, fk_profile, parameter'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'printer_receipt'; - $sql.= ' WHERE entity = '.$conf->entity; + $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt'; + $sql .= ' WHERE entity = '.$conf->entity; $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -319,8 +319,8 @@ class dolReceiptPrinter extends Printer $line = 0; $obj = array(); $sql = 'SELECT rowid, name, template'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'printer_receipt_template'; - $sql.= ' WHERE entity = '.$conf->entity; + $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt_template'; + $sql .= ' WHERE entity = '.$conf->entity; $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -399,10 +399,10 @@ class dolReceiptPrinter extends Printer global $conf; $error = 0; $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'printer_receipt'; - $sql.= ' (name, fk_type, fk_profile, parameter, entity)'; - $sql.= ' VALUES ("'.$this->db->escape($name).'", '.$type.', '.$profile.', "'.$this->db->escape($parameter).'", '.$conf->entity.')'; + $sql .= ' (name, fk_type, fk_profile, parameter, entity)'; + $sql .= ' VALUES ("'.$this->db->escape($name).'", '.$type.', '.$profile.', "'.$this->db->escape($parameter).'", '.$conf->entity.')'; $resql = $this->db->query($sql); - if (! $resql) { + if (!$resql) { $error++; $this->errors[] = $this->db->lasterror; } @@ -424,13 +424,13 @@ class dolReceiptPrinter extends Printer global $conf; $error = 0; $sql = 'UPDATE '.MAIN_DB_PREFIX.'printer_receipt'; - $sql.= ' SET name="'.$this->db->escape($name).'"'; - $sql.= ', fk_type='.$type; - $sql.= ', fk_profile='.$profile; - $sql.= ', parameter="'.$this->db->escape($parameter).'"'; - $sql.= ' WHERE rowid='.$printerid; + $sql .= ' SET name="'.$this->db->escape($name).'"'; + $sql .= ', fk_type='.$type; + $sql .= ', fk_profile='.$profile; + $sql .= ', parameter="'.$this->db->escape($parameter).'"'; + $sql .= ' WHERE rowid='.$printerid; $resql = $this->db->query($sql); - if (! $resql) { + if (!$resql) { $error++; $this->errors[] = $this->db->lasterror; } @@ -448,9 +448,9 @@ class dolReceiptPrinter extends Printer global $conf; $error = 0; $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'printer_receipt'; - $sql.= ' WHERE rowid='.$printerid; + $sql .= ' WHERE rowid='.$printerid; $resql = $this->db->query($sql); - if (! $resql) { + if (!$resql) { $error++; $this->errors[] = $this->db->lasterror; } @@ -469,10 +469,10 @@ class dolReceiptPrinter extends Printer global $conf; $error = 0; $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'printer_receipt_template'; - $sql.= ' (name, template, entity) VALUES ("'.$this->db->escape($name).'"'; - $sql.= ', "'.$this->db->escape($template).'", '.$conf->entity.')'; + $sql .= ' (name, template, entity) VALUES ("'.$this->db->escape($name).'"'; + $sql .= ', "'.$this->db->escape($template).'", '.$conf->entity.')'; $resql = $this->db->query($sql); - if (! $resql) { + if (!$resql) { $error++; $this->errors[] = $this->db->lasterror; } @@ -493,11 +493,11 @@ class dolReceiptPrinter extends Printer global $conf; $error = 0; $sql = 'UPDATE '.MAIN_DB_PREFIX.'printer_receipt_template'; - $sql.= ' SET name="'.$this->db->escape($name).'"'; - $sql.= ', template="'.$this->db->escape($template).'"'; - $sql.= ' WHERE rowid='.$templateid; + $sql .= ' SET name="'.$this->db->escape($name).'"'; + $sql .= ', template="'.$this->db->escape($template).'"'; + $sql .= ' WHERE rowid='.$templateid; $resql = $this->db->query($sql); - if (! $resql) { + if (!$resql) { $error++; $this->errors[] = $this->db->lasterror; } @@ -515,10 +515,10 @@ class dolReceiptPrinter extends Printer { global $conf; $error = 0; - $img = EscposImage::load(DOL_DOCUMENT_ROOT .'/theme/common/dolibarr_logo_bw.png'); + $img = EscposImage::load(DOL_DOCUMENT_ROOT.'/theme/common/dolibarr_logo_bw.png'); //$this->profile = CapabilityProfile::load("TM-T88IV"); $ret = $this->initPrinter($printerid); - if ($ret>0) { + if ($ret > 0) { setEventMessages($this->error, $this->errors, 'errors'); } else { try { @@ -532,7 +532,7 @@ class dolReceiptPrinter extends Printer $this->printer->cut(); // If is DummyPrintConnector send to log to debugging - if($this->printer->connector instanceof DummyPrintConnector) + if ($this->printer->connector instanceof DummyPrintConnector) { $data = $this->printer->connector-> getData(); dol_syslog($data); @@ -609,11 +609,11 @@ class dolReceiptPrinter extends Printer $level = 0; $nbcharactbyline = 48; $ret = $this->initPrinter($printerid); - if ($ret>0) { + if ($ret > 0) { setEventMessages($this->error, $this->errors, 'errors'); } else { $nboflines = count($vals); - for ($tplline=0; $tplline < $nboflines; $tplline++) { + for ($tplline = 0; $tplline < $nboflines; $tplline++) { //var_dump($vals[$tplline]['value']); switch ($vals[$tplline]['tag']) { case 'DOL_PRINT_TEXT': @@ -622,7 +622,7 @@ class dolReceiptPrinter extends Printer case 'DOL_PRINT_OBJECT_LINES': foreach ($object->lines as $line) { //var_dump($line); - $spacestoadd = $nbcharactbyline - strlen($line->ref)- strlen($line->qty) - 10 - 1; + $spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen($line->qty) - 10 - 1; $spaces = str_repeat(' ', $spacestoadd); $this->printer->text($line->ref.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n"); $this->printer->text(strip_tags(htmlspecialchars_decode($line->desc))."\n"); @@ -634,10 +634,10 @@ class dolReceiptPrinter extends Printer foreach ($object->lines as $line) { $vatarray[$line->tva_tx] += $line->total_tva; } - foreach($vatarray as $vatkey => $vatvalue) { - $spacestoadd = $nbcharactbyline - strlen($vatkey)- 12; + foreach ($vatarray as $vatkey => $vatvalue) { + $spacestoadd = $nbcharactbyline - strlen($vatkey) - 12; $spaces = str_repeat(' ', $spacestoadd); - $this->printer->text($spaces. $vatkey.'% '.str_pad(price($vatvalue), 10, ' ', STR_PAD_LEFT)."\n"); + $this->printer->text($spaces.$vatkey.'% '.str_pad(price($vatvalue), 10, ' ', STR_PAD_LEFT)."\n"); } break; case 'DOL_PRINT_OBJECT_TOTAL': @@ -686,11 +686,11 @@ class dolReceiptPrinter extends Printer } break; case 'DOL_PRINT_LOGO': - $img = EscposImage::load(DOL_DATA_ROOT .'/mycompany/logos/'.$mysoc->logo); + $img = EscposImage::load(DOL_DATA_ROOT.'/mycompany/logos/'.$mysoc->logo); $this->printer->graphics($img); break; case 'DOL_PRINT_LOGO_OLD': - $img = EscposImage::load(DOL_DATA_ROOT .'/mycompany/logos/'.$mysoc->logo); + $img = EscposImage::load(DOL_DATA_ROOT.'/mycompany/logos/'.$mysoc->logo); $this->printer->bitImage($img); break; case 'DOL_PRINT_QRCODE': @@ -721,7 +721,7 @@ class dolReceiptPrinter extends Printer } } // If is DummyPrintConnector send to log to debugging - if($this->printer->connector instanceof DummyPrintConnector) + if ($this->printer->connector instanceof DummyPrintConnector) { $data = $this->printer->connector->getData(); dol_syslog($data); @@ -743,9 +743,9 @@ class dolReceiptPrinter extends Printer global $conf; $error = 0; $sql = 'SELECT template'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'printer_receipt_template'; - $sql.= ' WHERE rowid='.$templateid; - $sql.= ' AND entity = '.$conf->entity; + $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt_template'; + $sql .= ' WHERE rowid='.$templateid; + $sql .= ' AND entity = '.$conf->entity; $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_array($resql); @@ -773,11 +773,11 @@ class dolReceiptPrinter extends Printer public function initPrinter($printerid) { global $conf; - $error=0; + $error = 0; $sql = 'SELECT rowid, name, fk_type, fk_profile, parameter'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'printer_receipt'; - $sql.= ' WHERE rowid = '.$printerid; - $sql.= ' AND entity = '.$conf->entity; + $sql .= ' FROM '.MAIN_DB_PREFIX.'printer_receipt'; + $sql .= ' WHERE rowid = '.$printerid; + $sql .= ' AND entity = '.$conf->entity; $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_array($resql); @@ -789,7 +789,7 @@ class dolReceiptPrinter extends Printer $error++; $this->errors[] = 'PrinterDontExist'; } - if (! $error) { + if (!$error) { $parameter = $obj['parameter']; try { switch ($obj['fk_type']) { diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 816dde6a619..e4716947822 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -232,24 +232,24 @@ class ExtraFields if (empty($attrname)) return -1; if (empty($label)) return -1; - if ($elementtype == 'thirdparty') $elementtype='societe'; - if ($elementtype == 'contact') $elementtype='socpeople'; + if ($elementtype == 'thirdparty') $elementtype = 'societe'; + if ($elementtype == 'contact') $elementtype = 'socpeople'; // Create field into database except for separator type which is not stored in database if ($type != 'separate') { - $result=$this->create($attrname, $type, $size, $elementtype, $unique, $required, $default_value, $param, $perms, $list, $computed, $help); + $result = $this->create($attrname, $type, $size, $elementtype, $unique, $required, $default_value, $param, $perms, $list, $computed, $help); } - $err1=$this->errno; + $err1 = $this->errno; if ($result > 0 || $err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' || $type == 'separate') { // Add declaration of field into table - $result2=$this->create_label($attrname, $label, $type, $pos, $size, $elementtype, $unique, $required, $param, $alwayseditable, $perms, $list, $help, $default_value, $computed, $entity, $langfile, $enabled, $totalizable); - $err2=$this->errno; + $result2 = $this->create_label($attrname, $label, $type, $pos, $size, $elementtype, $unique, $required, $param, $alwayseditable, $perms, $list, $help, $default_value, $computed, $entity, $langfile, $enabled, $totalizable); + $err2 = $this->errno; if ($result2 > 0 || ($err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' && $err2 == 'DB_ERROR_RECORD_ALREADY_EXISTS')) { - $this->error=''; - $this->errno=0; + $this->error = ''; + $this->errno = 0; return 1; } else return -2; @@ -402,56 +402,56 @@ class ExtraFields } else { - $params=''; + $params = ''; } $sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields("; - $sql.= " name,"; - $sql.= " label,"; - $sql.= " type,"; - $sql.= " pos,"; - $sql.= " size,"; - $sql.= " entity,"; - $sql.= " elementtype,"; - $sql.= " fieldunique,"; - $sql.= " fieldrequired,"; - $sql.= " param,"; - $sql.= " alwayseditable,"; - $sql.= " perms,"; - $sql.= " langs,"; - $sql.= " list,"; - $sql.= " fielddefault,"; - $sql.= " fieldcomputed,"; - $sql.= " fk_user_author,"; - $sql.= " fk_user_modif,"; - $sql.= " datec,"; - $sql.= " enabled,"; - $sql.= " help,"; - $sql.= " totalizable"; - $sql.= " )"; - $sql.= " VALUES('".$attrname."',"; - $sql.= " '".$this->db->escape($label)."',"; - $sql.= " '".$this->db->escape($type)."',"; - $sql.= " ".$pos.","; - $sql.= " '".$this->db->escape($size)."',"; - $sql.= " ".($entity===''?$conf->entity:$entity).","; - $sql.= " '".$this->db->escape($elementtype)."',"; - $sql.= " ".$unique.","; - $sql.= " ".$required.","; - $sql.= " '".$this->db->escape($params)."',"; - $sql.= " ".$alwayseditable.","; - $sql.= " ".($perms?"'".$this->db->escape($perms)."'":"null").","; - $sql.= " ".($langfile?"'".$this->db->escape($langfile)."'":"null").","; - $sql.= " '".$this->db->escape($list)."',"; - $sql.= " ".($default?"'".$this->db->escape($default)."'":"null").","; - $sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").","; - $sql .= " " . (is_object($user) ? $user->id : 0). ","; - $sql .= " " . (is_object($user) ? $user->id : 0). ","; - $sql .= "'" . $this->db->idate(dol_now()) . "',"; - $sql.= " ".($enabled?"'".$this->db->escape($enabled)."'":"1").","; - $sql.= " ".($help?"'".$this->db->escape($help)."'":"null").","; - $sql.= " ".($totalizable?'1':'0'); - $sql.=')'; + $sql .= " name,"; + $sql .= " label,"; + $sql .= " type,"; + $sql .= " pos,"; + $sql .= " size,"; + $sql .= " entity,"; + $sql .= " elementtype,"; + $sql .= " fieldunique,"; + $sql .= " fieldrequired,"; + $sql .= " param,"; + $sql .= " alwayseditable,"; + $sql .= " perms,"; + $sql .= " langs,"; + $sql .= " list,"; + $sql .= " fielddefault,"; + $sql .= " fieldcomputed,"; + $sql .= " fk_user_author,"; + $sql .= " fk_user_modif,"; + $sql .= " datec,"; + $sql .= " enabled,"; + $sql .= " help,"; + $sql .= " totalizable"; + $sql .= " )"; + $sql .= " VALUES('".$attrname."',"; + $sql .= " '".$this->db->escape($label)."',"; + $sql .= " '".$this->db->escape($type)."',"; + $sql .= " ".$pos.","; + $sql .= " '".$this->db->escape($size)."',"; + $sql .= " ".($entity === '' ? $conf->entity : $entity).","; + $sql .= " '".$this->db->escape($elementtype)."',"; + $sql .= " ".$unique.","; + $sql .= " ".$required.","; + $sql .= " '".$this->db->escape($params)."',"; + $sql .= " ".$alwayseditable.","; + $sql .= " ".($perms ? "'".$this->db->escape($perms)."'" : "null").","; + $sql .= " ".($langfile ? "'".$this->db->escape($langfile)."'" : "null").","; + $sql .= " '".$this->db->escape($list)."',"; + $sql .= " ".($default ? "'".$this->db->escape($default)."'" : "null").","; + $sql .= " ".($computed ? "'".$this->db->escape($computed)."'" : "null").","; + $sql .= " ".(is_object($user) ? $user->id : 0).","; + $sql .= " ".(is_object($user) ? $user->id : 0).","; + $sql .= "'".$this->db->idate(dol_now())."',"; + $sql .= " ".($enabled ? "'".$this->db->escape($enabled)."'" : "1").","; + $sql .= " ".($help ? "'".$this->db->escape($help)."'" : "null").","; + $sql .= " ".($totalizable ? '1' : '0'); + $sql .= ')'; dol_syslog(get_class($this)."::create_label", LOG_DEBUG); if ($this->db->query($sql)) @@ -896,55 +896,55 @@ class ExtraFields // We can add this attribute to object. TODO Remove this and return $this->attributes[$elementtype]['label'] if ($tab->type != 'separate') { - $array_name_label[$tab->name]=$tab->label; + $array_name_label[$tab->name] = $tab->label; } // Old usage - $this->attribute_type[$tab->name]=$tab->type; - $this->attribute_label[$tab->name]=$tab->label; - $this->attribute_size[$tab->name]=$tab->size; - $this->attribute_elementtype[$tab->name]=$tab->elementtype; - $this->attribute_default[$tab->name]=$tab->fielddefault; - $this->attribute_computed[$tab->name]=$tab->fieldcomputed; - $this->attribute_unique[$tab->name]=$tab->fieldunique; - $this->attribute_required[$tab->name]=$tab->fieldrequired; - $this->attribute_param[$tab->name]=($tab->param ? unserialize($tab->param) : ''); - $this->attribute_pos[$tab->name]=$tab->pos; - $this->attribute_alwayseditable[$tab->name]=$tab->alwayseditable; - $this->attribute_perms[$tab->name]=(strlen($tab->perms) == 0 ? 1 : $tab->perms); - $this->attribute_langfile[$tab->name]=$tab->langs; - $this->attribute_list[$tab->name]=$tab->list; - $this->attribute_totalizable[$tab->name]=$tab->totalizable; - $this->attribute_entityid[$tab->name]=$tab->entity; + $this->attribute_type[$tab->name] = $tab->type; + $this->attribute_label[$tab->name] = $tab->label; + $this->attribute_size[$tab->name] = $tab->size; + $this->attribute_elementtype[$tab->name] = $tab->elementtype; + $this->attribute_default[$tab->name] = $tab->fielddefault; + $this->attribute_computed[$tab->name] = $tab->fieldcomputed; + $this->attribute_unique[$tab->name] = $tab->fieldunique; + $this->attribute_required[$tab->name] = $tab->fieldrequired; + $this->attribute_param[$tab->name] = ($tab->param ? unserialize($tab->param) : ''); + $this->attribute_pos[$tab->name] = $tab->pos; + $this->attribute_alwayseditable[$tab->name] = $tab->alwayseditable; + $this->attribute_perms[$tab->name] = (strlen($tab->perms) == 0 ? 1 : $tab->perms); + $this->attribute_langfile[$tab->name] = $tab->langs; + $this->attribute_list[$tab->name] = $tab->list; + $this->attribute_totalizable[$tab->name] = $tab->totalizable; + $this->attribute_entityid[$tab->name] = $tab->entity; // New usage - $this->attributes[$tab->elementtype]['type'][$tab->name]=$tab->type; - $this->attributes[$tab->elementtype]['label'][$tab->name]=$tab->label; - $this->attributes[$tab->elementtype]['size'][$tab->name]=$tab->size; - $this->attributes[$tab->elementtype]['elementtype'][$tab->name]=$tab->elementtype; - $this->attributes[$tab->elementtype]['default'][$tab->name]=$tab->fielddefault; - $this->attributes[$tab->elementtype]['computed'][$tab->name]=$tab->fieldcomputed; - $this->attributes[$tab->elementtype]['unique'][$tab->name]=$tab->fieldunique; - $this->attributes[$tab->elementtype]['required'][$tab->name]=$tab->fieldrequired; - $this->attributes[$tab->elementtype]['param'][$tab->name]=($tab->param ? unserialize($tab->param) : ''); - $this->attributes[$tab->elementtype]['pos'][$tab->name]=$tab->pos; - $this->attributes[$tab->elementtype]['alwayseditable'][$tab->name]=$tab->alwayseditable; - $this->attributes[$tab->elementtype]['perms'][$tab->name]=(strlen($tab->perms) == 0 ? 1 : $tab->perms); - $this->attributes[$tab->elementtype]['langfile'][$tab->name]=$tab->langs; - $this->attributes[$tab->elementtype]['list'][$tab->name]=$tab->list; - $this->attributes[$tab->elementtype]['totalizable'][$tab->name]=$tab->totalizable; - $this->attributes[$tab->elementtype]['entityid'][$tab->name]=$tab->entity; - $this->attributes[$tab->elementtype]['enabled'][$tab->name]=$tab->enabled; - $this->attributes[$tab->elementtype]['help'][$tab->name]=$tab->help; + $this->attributes[$tab->elementtype]['type'][$tab->name] = $tab->type; + $this->attributes[$tab->elementtype]['label'][$tab->name] = $tab->label; + $this->attributes[$tab->elementtype]['size'][$tab->name] = $tab->size; + $this->attributes[$tab->elementtype]['elementtype'][$tab->name] = $tab->elementtype; + $this->attributes[$tab->elementtype]['default'][$tab->name] = $tab->fielddefault; + $this->attributes[$tab->elementtype]['computed'][$tab->name] = $tab->fieldcomputed; + $this->attributes[$tab->elementtype]['unique'][$tab->name] = $tab->fieldunique; + $this->attributes[$tab->elementtype]['required'][$tab->name] = $tab->fieldrequired; + $this->attributes[$tab->elementtype]['param'][$tab->name] = ($tab->param ? unserialize($tab->param) : ''); + $this->attributes[$tab->elementtype]['pos'][$tab->name] = $tab->pos; + $this->attributes[$tab->elementtype]['alwayseditable'][$tab->name] = $tab->alwayseditable; + $this->attributes[$tab->elementtype]['perms'][$tab->name] = (strlen($tab->perms) == 0 ? 1 : $tab->perms); + $this->attributes[$tab->elementtype]['langfile'][$tab->name] = $tab->langs; + $this->attributes[$tab->elementtype]['list'][$tab->name] = $tab->list; + $this->attributes[$tab->elementtype]['totalizable'][$tab->name] = $tab->totalizable; + $this->attributes[$tab->elementtype]['entityid'][$tab->name] = $tab->entity; + $this->attributes[$tab->elementtype]['enabled'][$tab->name] = $tab->enabled; + $this->attributes[$tab->elementtype]['help'][$tab->name] = $tab->help; - $this->attributes[$tab->elementtype]['loaded']=1; + $this->attributes[$tab->elementtype]['loaded'] = 1; } } - if ($elementtype) $this->attributes[$elementtype]['loaded']=1; // If nothing found, we also save tag 'loaded' + if ($elementtype) $this->attributes[$elementtype]['loaded'] = 1; // If nothing found, we also save tag 'loaded' } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); dol_syslog(get_class($this)."::fetch_name_optionals_label ".$this->error, LOG_ERR); } @@ -1594,60 +1594,60 @@ class ExtraFields */ public function showOutputField($key, $value, $moreparam = '', $extrafieldsobjectkey = '') { - global $conf,$langs; + global $conf, $langs; - if (! empty($extrafieldsobjectkey)) + if (!empty($extrafieldsobjectkey)) { - $label=$this->attributes[$extrafieldsobjectkey]['label'][$key]; - $type=$this->attributes[$extrafieldsobjectkey]['type'][$key]; - $size=$this->attributes[$extrafieldsobjectkey]['size'][$key]; - $default=$this->attributes[$extrafieldsobjectkey]['default'][$key]; - $computed=$this->attributes[$extrafieldsobjectkey]['computed'][$key]; - $unique=$this->attributes[$extrafieldsobjectkey]['unique'][$key]; - $required=$this->attributes[$extrafieldsobjectkey]['required'][$key]; - $param=$this->attributes[$extrafieldsobjectkey]['param'][$key]; - $perms=dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1); - $langfile=$this->attributes[$extrafieldsobjectkey]['langfile'][$key]; - $list=dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1); - $help=$this->attributes[$extrafieldsobjectkey]['help'][$key]; - $hidden=(empty($list) ? 1 : 0); // If $list empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) + $label = $this->attributes[$extrafieldsobjectkey]['label'][$key]; + $type = $this->attributes[$extrafieldsobjectkey]['type'][$key]; + $size = $this->attributes[$extrafieldsobjectkey]['size'][$key]; + $default = $this->attributes[$extrafieldsobjectkey]['default'][$key]; + $computed = $this->attributes[$extrafieldsobjectkey]['computed'][$key]; + $unique = $this->attributes[$extrafieldsobjectkey]['unique'][$key]; + $required = $this->attributes[$extrafieldsobjectkey]['required'][$key]; + $param = $this->attributes[$extrafieldsobjectkey]['param'][$key]; + $perms = dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1); + $langfile = $this->attributes[$extrafieldsobjectkey]['langfile'][$key]; + $list = dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1); + $help = $this->attributes[$extrafieldsobjectkey]['help'][$key]; + $hidden = (empty($list) ? 1 : 0); // If $list empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) } else // Old usage { //dol_syslog("Warning: parameter 'extrafieldsobjectkey' is missing", LOG_WARNING); - $label=$this->attribute_label[$key]; - $type=$this->attribute_type[$key]; - $size=$this->attribute_size[$key]; - $default=$this->attribute_default[$key]; - $computed=$this->attribute_computed[$key]; - $unique=$this->attribute_unique[$key]; - $required=$this->attribute_required[$key]; - $param=$this->attribute_param[$key]; - $perms=dol_eval($this->attribute_perms[$key], 1); - $langfile=$this->attribute_langfile[$key]; - $list=dol_eval($this->attribute_list[$key], 1); - $help=''; // Not supported with old syntax - $hidden=(empty($list) ? 1 : 0); // If $list empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) + $label = $this->attribute_label[$key]; + $type = $this->attribute_type[$key]; + $size = $this->attribute_size[$key]; + $default = $this->attribute_default[$key]; + $computed = $this->attribute_computed[$key]; + $unique = $this->attribute_unique[$key]; + $required = $this->attribute_required[$key]; + $param = $this->attribute_param[$key]; + $perms = dol_eval($this->attribute_perms[$key], 1); + $langfile = $this->attribute_langfile[$key]; + $list = dol_eval($this->attribute_list[$key], 1); + $help = ''; // Not supported with old syntax + $hidden = (empty($list) ? 1 : 0); // If $list empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) } - if ($hidden) return ''; // This is a protection. If field is hidden, we should just not call this method. + if ($hidden) return ''; // This is a protection. If field is hidden, we should just not call this method. //if ($computed) $value = // $value is already calculated into $value before calling this method - $showsize=0; + $showsize = 0; if ($type == 'date') { - $showsize=10; - $value=dol_print_date($value, 'day'); + $showsize = 10; + $value = dol_print_date($value, 'day'); } elseif ($type == 'datetime') { - $showsize=19; - $value=dol_print_date($value, 'dayhour'); + $showsize = 19; + $value = dol_print_date($value, 'dayhour'); } elseif ($type == 'int') { - $showsize=10; + $showsize = 10; } elseif ($type == 'double') { @@ -1802,20 +1802,20 @@ class ExtraFields $keyList .= implode(', ', $fields_label); } - $sql = 'SELECT ' . $keyList; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0]; + $sql = 'SELECT '.$keyList; + $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0]; if (strpos($InfoFieldList[4], 'extra') !== false) { $sql .= ' as main'; } // $sql.= " WHERE ".$selectkey."='".$this->db->escape($value)."'"; // $sql.= ' AND entity = '.$conf->entity; - dol_syslog(get_class($this) . ':showOutputField:$type=chkbxlst', LOG_DEBUG); + dol_syslog(get_class($this).':showOutputField:$type=chkbxlst', LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $value = ''; // value was used, so now we reste it to use it to build final output - $toprint=array(); - while ( $obj = $this->db->fetch_object($resql) ) { + $toprint = array(); + while ($obj = $this->db->fetch_object($resql)) { // Several field into label (eq table:code|libelle:rowid) $fields_label = explode('|', $InfoFieldList[1]); if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { @@ -2068,35 +2068,35 @@ class ExtraFields { // Clean parameters // TODO GMT date in memory must be GMT so we should add gm=true in parameters - $value_key=dol_mktime(0, 0, 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]); + $value_key = dol_mktime(0, 0, 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]); } elseif (in_array($key_type, array('datetime'))) { // Clean parameters // TODO GMT date in memory must be GMT so we should add gm=true in parameters - $value_key=dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]); + $value_key = dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]); } - elseif (in_array($key_type, array('checkbox','chkbxlst'))) + elseif (in_array($key_type, array('checkbox', 'chkbxlst'))) { - $value_arr=GETPOST("options_".$key, 'array'); // check if an array + $value_arr = GETPOST("options_".$key, 'array'); // check if an array if (!empty($value_arr)) { - $value_key=implode($value_arr, ','); - }else { - $value_key=''; + $value_key = implode($value_arr, ','); + } else { + $value_key = ''; } } - elseif (in_array($key_type, array('price','double'))) + elseif (in_array($key_type, array('price', 'double'))) { - $value_arr=GETPOST("options_".$key, 'alpha'); - $value_key=price2num($value_arr); + $value_arr = GETPOST("options_".$key, 'alpha'); + $value_key = price2num($value_arr); } else { - $value_key=GETPOST("options_".$key); + $value_key = GETPOST("options_".$key); if (in_array($key_type, array('link')) && $value_key == '-1') $value_key = ''; } - $object->array_options["options_".$key]=$value_key; + $object->array_options["options_".$key] = $value_key; } if ($nofillrequired) { @@ -2149,13 +2149,13 @@ class ExtraFields if (in_array($key_type, array('date', 'datetime'))) { - if (! GETPOSTISSET($keysuffix."options_".$key.$keyprefix)."year") continue; // Value was not provided, we should not set it. + if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)."year") continue; // Value was not provided, we should not set it. // Clean parameters $value_key = dol_mktime(GETPOST($keysuffix."options_".$key.$keyprefix."hour", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."min", 'int'), 0, GETPOST($keysuffix."options_".$key.$keyprefix."month", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."day", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."year", 'int')); } elseif (in_array($key_type, array('checkbox', 'chkbxlst'))) { - if (! GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it. + if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it. $value_arr = GETPOST($keysuffix."options_".$key.$keyprefix); // Make sure we get an array even if there's only one checkbox $value_arr = (array) $value_arr; @@ -2163,13 +2163,13 @@ class ExtraFields } elseif (in_array($key_type, array('price', 'double', 'int'))) { - if (! GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it. + if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it. $value_arr = GETPOST($keysuffix."options_".$key.$keyprefix); $value_key = price2num($value_arr); } else { - if (! GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it. + if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it. $value_key = GETPOST($keysuffix."options_".$key.$keyprefix); } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 734f6f229c1..305a34d5036 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -767,7 +767,7 @@ class Form { //if (empty($showempty) && empty($row['rowid'])) continue; if (empty($row['rowid'])) continue; - if (is_array($exclude_country_code) && count($exclude_country_code) && in_array($row['code_iso'], $exclude_country_code)) continue; // exclude some countries + if (is_array($exclude_country_code) && count($exclude_country_code) && in_array($row['code_iso'], $exclude_country_code)) continue; // exclude some countries if (empty($disablefavorites) && $row['favorite'] && $row['code_iso']) $atleastonefavorite++; if (empty($row['favorite']) && $atleastonefavorite) @@ -2643,7 +2643,7 @@ class Form $langs->load("stocks"); $tmpproduct = new Product($this->db); - $tmpproduct->fetch($objp->rowid, '', '', '', 1, 1, 1); // Load product without lang and prices arrays (we just need to make ->virtual_stock() after) + $tmpproduct->fetch($objp->rowid, '', '', '', 1, 1, 1); // Load product without lang and prices arrays (we just need to make ->virtual_stock() after) $tmpproduct->load_virtual_stock(); $virtualstock = $tmpproduct->stock_theorique; @@ -6242,7 +6242,7 @@ class Form if (is_array($id)) { if (in_array($key, $id) && !$disabled) $out .= ' selected'; // To preselect a value } else { - $id = (string) $id; // if $id = 0, then $id = '0' + $id = (string) $id; // if $id = 0, then $id = '0' if ($id != '' && $id == $key && !$disabled) $out .= ' selected'; // To preselect a value } if ($nohtmlescape) $out .= ' data-html="'.dol_escape_htmltag($selectOptionValue).'"'; diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index fca9a9ae3d7..64e027db537 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -309,7 +309,7 @@ class FormAccounting extends Form return -1; } - $selected = $selectid; // selectid can be -1, 0, 123 + $selected = $selectid; // selectid can be -1, 0, 123 while ($obj = $this->db->fetch_object($resql)) { if (empty($obj->labelshort)) @@ -321,7 +321,7 @@ class FormAccounting extends Form $labeltoshow = $obj->labelshort; } - $label = length_accountg($obj->account_number) . ' - ' . $labeltoshow; + $label = length_accountg($obj->account_number).' - '.$labeltoshow; $label = dol_trunc($label, $trunclength); $select_value_in = $obj->rowid; @@ -459,7 +459,7 @@ class FormAccounting extends Form $sql = "SELECT DISTINCT date_format(doc_date, '%Y') as dtyear"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping"; - $sql .= " WHERE entity IN (" . getEntity('accountancy') . ")"; + $sql .= " WHERE entity IN (".getEntity('accountancy').")"; $sql .= " ORDER BY date_format(doc_date, '%Y')"; dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index f80d2f1547a..39c7d3ba778 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -117,10 +117,10 @@ class SMTPs /** * Message Sensitivity */ - private $_arySensitivity = array ( false, + private $_arySensitivity = array(false, 'Personal', 'Private', - 'Company Confidential' ); + 'Company Confidential'); /** * Message Sensitivity @@ -131,12 +131,12 @@ class SMTPs /** * Message Priority */ - private $_aryPriority = array ( 'Bulk', + private $_aryPriority = array('Bulk', 'Highest', 'High', 'Normal', 'Low', - 'Lowest' ); + 'Lowest'); /** * Content-Transfer-Encoding @@ -147,13 +147,13 @@ class SMTPs /** * Content-Transfer-Encoding */ - private $_smtpsTransEncodeTypes = array( '7bit', // Simple 7-bit ASCII - '8bit', // 8-bit coding with line termination characters - 'base64', // 3 octets encoded into 4 sextets with offset - 'binary', // Arbitrary binary stream - 'mac-binhex40', // Macintosh binary to hex encoding - 'quoted-printable', // Mostly 7-bit, with 8-bit characters encoded as "=HH" - 'uuencode' ); // UUENCODE encoding + private $_smtpsTransEncodeTypes = array('7bit', // Simple 7-bit ASCII + '8bit', // 8-bit coding with line termination characters + 'base64', // 3 octets encoded into 4 sextets with offset + 'binary', // Arbitrary binary stream + 'mac-binhex40', // Macintosh binary to hex encoding + 'quoted-printable', // Mostly 7-bit, with 8-bit characters encoded as "=HH" + 'uuencode'); // UUENCODE encoding /** * Content-Transfer-Encoding @@ -300,7 +300,7 @@ class SMTPs */ public function setErrorsTo($_strErrorsTo) { - if ( $_strErrorsTo ) + if ($_strErrorsTo) $this->_errorsTo = $this->_strip_email($_strErrorsTo); } @@ -314,7 +314,7 @@ class SMTPs { $_retValue = ''; - if ( $_part === true ) + if ($_part === true) $_retValue = $this->_errorsTo; else $_retValue = $this->_errorsTo[$_part]; @@ -359,29 +359,29 @@ class SMTPs // We have to make sure the HOST given is valid // This is done here because '@fsockopen' will not give me this // information if it failes to connect because it can't find the HOST - $host=$this->getHost(); + $host = $this->getHost(); $usetls = preg_match('@tls://@i', $host); - $host=preg_replace('@tcp://@i', '', $host); // Remove prefix - $host=preg_replace('@ssl://@i', '', $host); // Remove prefix - $host=preg_replace('@tls://@i', '', $host); // Remove prefix + $host = preg_replace('@tcp://@i', '', $host); // Remove prefix + $host = preg_replace('@ssl://@i', '', $host); // Remove prefix + $host = preg_replace('@tls://@i', '', $host); // Remove prefix // @CHANGE LDR include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - if ( (! is_ip($host)) && ((gethostbyname($host)) == $host)) + if ((!is_ip($host)) && ((gethostbyname($host)) == $host)) { - $this->_setErr(99, $host . ' is either offline or is an invalid host name.'); + $this->_setErr(99, $host.' is either offline or is an invalid host name.'); $_retVal = false; } else { //See if we can connect to the SMTP server if ($this->socket = @fsockopen( - preg_replace('@tls://@i', '', $this->getHost()), // Host to 'hit', IP or domain - $this->getPort(), // which Port number to use - $this->errno, // actual system level error - $this->errstr, // and any text that goes with the error + preg_replace('@tls://@i', '', $this->getHost()), // Host to 'hit', IP or domain + $this->getPort(), // which Port number to use + $this->errno, // actual system level error + $this->errstr, // and any text that goes with the error $this->_smtpTimeout // timeout for reading/writing data over the socket )) { // Fix from PHP SMTP class by 'Chris Ryan' @@ -391,14 +391,14 @@ class SMTPs if (function_exists('stream_set_timeout')) stream_set_timeout($this->socket, $this->_smtpTimeout, 0); // Check response from Server - if ( $_retVal = $this->server_parse($this->socket, "220") ) + if ($_retVal = $this->server_parse($this->socket, "220")) $_retVal = $this->socket; } // This connection attempt failed. else { // @CHANGE LDR - if (empty($this->errstr)) $this->errstr='Failed to connect with fsockopen host='.$this->getHost().' port='.$this->getPort(); + if (empty($this->errstr)) $this->errstr = 'Failed to connect with fsockopen host='.$this->getHost().' port='.$this->getPort(); $this->_setErr($this->errno, $this->errstr); $_retVal = false; } @@ -421,18 +421,18 @@ class SMTPs // Send the RFC2554 specified EHLO. // This improvment as provided by 'SirSir' to // accomodate both SMTP AND ESMTP capable servers - $host=$this->getHost(); + $host = $this->getHost(); $usetls = preg_match('@tls://@i', $host); - $host=preg_replace('@tcp://@i', '', $host); // Remove prefix - $host=preg_replace('@ssl://@i', '', $host); // Remove prefix - $host=preg_replace('@tls://@i', '', $host); // Remove prefix + $host = preg_replace('@tcp://@i', '', $host); // Remove prefix + $host = preg_replace('@ssl://@i', '', $host); // Remove prefix + $host = preg_replace('@tls://@i', '', $host); // Remove prefix - if ($usetls) $host='tls://'.$host; + if ($usetls) $host = 'tls://'.$host; $hosth = $host; - if (! empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) + if (!empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) { // If the from to is 'aaa ', we will keep 'ccc.com' $hosth = $this->getFrom('addr'); @@ -441,7 +441,7 @@ class SMTPs $hosth = preg_replace('/.*@/', '', $hosth); } - if ( $_retVal = $this->socket_send_str('EHLO ' . $hosth, '250') ) + if ($_retVal = $this->socket_send_str('EHLO '.$hosth, '250')) { if ($usetls) { @@ -492,7 +492,7 @@ class SMTPs // the answer with list of supported AUTH methods. They may differs between non STARTTLS and with STARTTLS. if (!$_retVal = $this->socket_send_str('EHLO '.$host, '250')) { - $this->_setErr(126, '"' . $host . '" does not support authenticated connections.'); + $this->_setErr(126, '"'.$host.'" does not support authenticated connections.'); return $_retVal; } } @@ -506,7 +506,7 @@ class SMTPs case 'PLAIN': $this->socket_send_str('AUTH PLAIN', '334'); // The error here just means the ID/password combo doesn't work. - $_retVal = $this->socket_send_str(base64_encode("\0" . $this->_smtpsID . "\0" . $this->_smtpsPW), '235'); + $_retVal = $this->socket_send_str(base64_encode("\0".$this->_smtpsID."\0".$this->_smtpsPW), '235'); break; case 'LOGIN': // most common case default: @@ -518,13 +518,13 @@ class SMTPs $_retVal = $this->socket_send_str(base64_encode($this->_smtpsPW), '235'); break; } - if (! $_retVal) { + if (!$_retVal) { $this->_setErr(130, 'Invalid Authentication Credentials.'); } } else { - $this->_setErr(126, '"' . $host . '" does not support authenticated connections.'); + $this->_setErr(126, '"'.$host.'" does not support authenticated connections.'); } return $_retVal; @@ -548,10 +548,10 @@ class SMTPs $_retVal = false; // Connect to Server - if ( $this->socket = $this->_server_connect() ) + if ($this->socket = $this->_server_connect()) { // If a User ID *and* a password is given, assume Authentication is desired - if( !empty($this->_smtpsID) && !empty($this->_smtpsPW) ) + if (!empty($this->_smtpsID) && !empty($this->_smtpsPW)) { // Send the RFC2554 specified EHLO. $_retVal = $this->_server_authenticate(); @@ -561,16 +561,16 @@ class SMTPs else { // Send the RFC821 specified HELO. - $host=$this->getHost(); + $host = $this->getHost(); $usetls = preg_match('@tls://@i', $host); - $host=preg_replace('@tcp://@i', '', $host); // Remove prefix - $host=preg_replace('@ssl://@i', '', $host); // Remove prefix - $host=preg_replace('@tls://@i', '', $host); // Remove prefix + $host = preg_replace('@tcp://@i', '', $host); // Remove prefix + $host = preg_replace('@ssl://@i', '', $host); // Remove prefix + $host = preg_replace('@tls://@i', '', $host); // Remove prefix $hosth = $host; - if (! empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) + if (!empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) { // If the from to is 'aaa ', we will keep 'ccc.com' $hosth = $this->getFrom('addr'); @@ -579,17 +579,17 @@ class SMTPs $hosth = preg_replace('/.*@/', '', $hosth); } - $_retVal = $this->socket_send_str('HELO ' . $hosth, '250'); + $_retVal = $this->socket_send_str('HELO '.$hosth, '250'); } // Well, did we get to the server? - if ( $_retVal ) + if ($_retVal) { // From this point onward most server response codes should be 250 // Specify who the mail is from.... // This has to be the raw email address, strip the "name" off - $resultmailfrom = $this->socket_send_str('MAIL FROM: ' . $this->getFrom('addr'), '250'); - if (! $resultmailfrom) { + $resultmailfrom = $this->socket_send_str('MAIL FROM: '.$this->getFrom('addr'), '250'); + if (!$resultmailfrom) { fclose($this->socket); return false; } @@ -613,7 +613,7 @@ class SMTPs * mark the last address as "bad" and start the address loop over again. * If any address fails, the entire message fails. */ - $this->socket_send_str('RCPT TO: <' . $_address . '>', '250'); + $this->socket_send_str('RCPT TO: <'.$_address.'>', '250'); } // Tell the server we are ready to start sending data @@ -623,7 +623,7 @@ class SMTPs // Now we are ready for the message... // Ok, all the ingredients are mixed in let's cook this puppy... - $this->socket_send_str($this->getHeader().$this->getBodyContent() . "\r\n" . '.', '250'); + $this->socket_send_str($this->getHeader().$this->getBodyContent()."\r\n".'.', '250'); // Now tell the server we are done and close the socket... fputs($this->socket, 'QUIT'); @@ -673,13 +673,13 @@ class SMTPs $_retVal = true; // if we have a path... - if ( ! empty($_strConfigPath) ) + if (!empty($_strConfigPath)) { // If the path is not valid, this will NOT generate an error, // it will simply return false. - if ( ! @include $_strConfigPath) + if (!@include $_strConfigPath) { - $this->_setErr(110, '"' . $_strConfigPath . '" is not a valid path.'); + $this->_setErr(110, '"'.$_strConfigPath.'" is not a valid path.'); $_retVal = false; } } @@ -689,13 +689,13 @@ class SMTPs { // Set these properties ONLY if they are set in the php.ini file. // Otherwise the default values will be used. - if ( $_host = ini_get('SMTPs') ) + if ($_host = ini_get('SMTPs')) $this->setHost($_host); - if ( $_port = ini_get('smtp_port') ) + if ($_port = ini_get('smtp_port')) $this->setPort($_port); - if ( $_from = ini_get('sendmail_from') ) + if ($_from = ini_get('sendmail_from')) $this->setFrom($_from); } @@ -757,7 +757,7 @@ class SMTPs */ public function setHost($_strHost) { - if ( $_strHost ) + if ($_strHost) $this->_smtpsHost = $_strHost; } @@ -782,8 +782,8 @@ class SMTPs */ public function setPort($_intPort) { - if ( ( is_numeric($_intPort) ) && - ( ( $_intPort >= 1 ) && ( $_intPort <= 65536 ) ) ) + if ((is_numeric($_intPort)) && + (($_intPort >= 1) && ($_intPort <= 65536))) $this->_smtpsPort = $_intPort; } @@ -849,7 +849,7 @@ class SMTPs */ public function setCharSet($_strCharSet) { - if ( $_strCharSet ) + if ($_strCharSet) $this->_smtpsCharSet = $_strCharSet; } @@ -937,7 +937,7 @@ class SMTPs */ public function setFrom($_strFrom) { - if ( $_strFrom ) + if ($_strFrom) $this->_msgFrom = $this->_strip_email($_strFrom); } @@ -951,7 +951,7 @@ class SMTPs { $_retValue = ''; - if ( $_part === true ) + if ($_part === true) $_retValue = $this->_msgFrom; else $_retValue = $this->_msgFrom[$_part]; @@ -967,7 +967,7 @@ class SMTPs */ public function setReplyTo($_strReplyTo) { - if ( $_strReplyTo ) + if ($_strReplyTo) $this->_msgReplyTo = $this->_strip_email($_strReplyTo); } @@ -981,7 +981,7 @@ class SMTPs { $_retValue = ''; - if ( $_part === true ) + if ($_part === true) $_retValue = $this->_msgReplyTo; else $_retValue = $this->_msgReplyTo[$_part]; @@ -1007,13 +1007,13 @@ class SMTPs $aryHost = $this->_msgRecipients; // Only run this if we have something - if ( !empty($_addrList)) + if (!empty($_addrList)) { // $_addrList can be a STRING or an array - if ( is_string($_addrList) ) + if (is_string($_addrList)) { // This could be a COMMA delimited string - if ( strstr($_addrList, ',') ) + if (strstr($_addrList, ',')) // "explode "list" into an array $_addrList = explode(',', $_addrList); @@ -1033,7 +1033,7 @@ class SMTPs $_tmpaddr = explode('<', $_strAddr); // We have a "Real Name" and eMail address - if ( count($_tmpaddr) == 2 ) + if (count($_tmpaddr) == 2) { $_tmpHost = explode('@', $_tmpaddr[1]); $_tmpaddr[0] = trim($_tmpaddr[0], ' ">'); @@ -1090,10 +1090,10 @@ class SMTPs $_tmpAry = explode('<', $_strAddr); // Do we have a "Real name" - if ( count($_tmpAry) == 2 ) + if (count($_tmpAry) == 2) { // We may not really have a "Real Name" - if ( $_tmpAry[0]) + if ($_tmpAry[0]) $_aryEmail['real'] = trim($_tmpAry[0], ' ">'); $_aryEmail['addr'] = $_tmpAry[1]; @@ -1102,10 +1102,10 @@ class SMTPs $_aryEmail['addr'] = $_tmpAry[0]; // Pull User Name and Host.tld apart - list($_aryEmail['user'], $_aryEmail['host'] ) = explode('@', $_aryEmail['addr']); + list($_aryEmail['user'], $_aryEmail['host']) = explode('@', $_aryEmail['addr']); // Put the brackets back around the address - $_aryEmail['addr'] = '<' . $_aryEmail['addr'] . '>'; + $_aryEmail['addr'] = '<'.$_aryEmail['addr'].'>'; return $_aryEmail; } @@ -1124,7 +1124,7 @@ class SMTPs /** * An array of bares addresses for use with 'RCPT TO:' */ - $_RCPT_list=array(); + $_RCPT_list = array(); // walk down Recipients array and pull just email addresses foreach ($this->_msgRecipients as $_host => $_list) @@ -1134,7 +1134,7 @@ class SMTPs foreach ($_subList as $_name => $_addr) { // build RCPT list - $_RCPT_list[] = $_name . '@' . $_host; + $_RCPT_list[] = $_name.'@'.$_host; } } } @@ -1153,27 +1153,27 @@ class SMTPs { // phpcs:enable // We need to know which address segment to pull - if ( $_which ) + if ($_which) { // Make sure we have addresses to process - if ( $this->_msgRecipients ) + if ($this->_msgRecipients) { - $_RCPT_list=array(); + $_RCPT_list = array(); // walk down Recipients array and pull just email addresses foreach ($this->_msgRecipients as $_host => $_list) { - if ( $this->_msgRecipients[$_host][$_which] ) + if ($this->_msgRecipients[$_host][$_which]) { foreach ($this->_msgRecipients[$_host][$_which] as $_addr => $_realName) { - if ( $_realName ) // @CHANGE LDR + if ($_realName) // @CHANGE LDR { - $_realName = '"' . $_realName . '"'; - $_RCPT_list[] = $_realName . ' <' . $_addr . '@' . $_host . '>'; + $_realName = '"'.$_realName.'"'; + $_RCPT_list[] = $_realName.' <'.$_addr.'@'.$_host.'>'; } else { - $_RCPT_list[] = $_addr . '@' . $_host; + $_RCPT_list[] = $_addr.'@'.$_host; } } } @@ -1202,7 +1202,7 @@ class SMTPs */ public function setTO($_addrTo) { - if ( $_addrTo ) + if ($_addrTo) $this->_buildAddrList('to', $_addrTo); } @@ -1224,7 +1224,7 @@ class SMTPs */ public function setCC($_strCC) { - if ( $_strCC ) + if ($_strCC) $this->_buildAddrList('cc', $_strCC); } @@ -1246,7 +1246,7 @@ class SMTPs */ public function setBCC($_strBCC) { - if ( $_strBCC ) + if ($_strBCC) $this->_buildAddrList('bcc', $_strBCC); } @@ -1268,7 +1268,7 @@ class SMTPs */ public function setSubject($_strSubject = '') { - if ( $_strSubject ) + if ($_strSubject) $this->_msgSubject = $_strSubject; } @@ -1291,11 +1291,11 @@ class SMTPs { global $conf; - $_header = 'From: ' . $this->getFrom('org') . "\r\n" - . 'To: ' . $this->getTO() . "\r\n"; + $_header = 'From: '.$this->getFrom('org')."\r\n" + . 'To: '.$this->getTO()."\r\n"; - if ( $this->getCC() ) - $_header .= 'Cc: ' . $this->getCC() . "\r\n"; + if ($this->getCC()) + $_header .= 'Cc: '.$this->getCC()."\r\n"; /* Note: * BCC email addresses must be listed in the RCPT TO command list, @@ -1308,50 +1308,50 @@ class SMTPs $_header .= 'Bcc: ' . $this->getBCC() . "\r\n"; */ - $host=dol_getprefix('email'); + $host = dol_getprefix('email'); //NOTE: Message-ID should probably contain the username of the user who sent the msg - $_header .= 'Subject: ' . $this->getSubject() . "\r\n"; - $_header .= 'Date: ' . date("r") . "\r\n"; + $_header .= 'Subject: '.$this->getSubject()."\r\n"; + $_header .= 'Date: '.date("r")."\r\n"; $trackid = $this->getTrackId(); if ($trackid) { // References is kept in response and Message-ID is returned into In-Reply-To: - $_header .= 'Message-ID: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n"; - $_header .= 'References: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n"; - $_header .= 'X-Dolibarr-TRACKID: ' . $trackid . '@' . $host . "\r\n"; + $_header .= 'Message-ID: <'.time().'.SMTPs-dolibarr-'.$trackid.'@'.$host.">\r\n"; + $_header .= 'References: <'.time().'.SMTPs-dolibarr-'.$trackid.'@'.$host.">\r\n"; + $_header .= 'X-Dolibarr-TRACKID: '.$trackid.'@'.$host."\r\n"; } else { - $_header .= 'Message-ID: <' . time() . '.SMTPs@' . $host . ">\r\n"; + $_header .= 'Message-ID: <'.time().'.SMTPs@'.$host.">\r\n"; } - if (! empty($_SERVER['REMOTE_ADDR'])) $_header .= "X-RemoteAddr: " . $_SERVER['REMOTE_ADDR']. "\r\n"; - if ( $this->getMoreInHeader() ) - $_header .= $this->getMoreInHeader(); // Value must include the "\r\n"; + if (!empty($_SERVER['REMOTE_ADDR'])) $_header .= "X-RemoteAddr: ".$_SERVER['REMOTE_ADDR']."\r\n"; + if ($this->getMoreInHeader()) + $_header .= $this->getMoreInHeader(); // Value must include the "\r\n"; //$_header .= // 'Read-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n" // 'Return-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n"; - if ( $this->getSensitivity() ) - $_header .= 'Sensitivity: ' . $this->getSensitivity() . "\r\n"; + if ($this->getSensitivity()) + $_header .= 'Sensitivity: '.$this->getSensitivity()."\r\n"; - if ( $this->_msgPriority != 3 ) + if ($this->_msgPriority != 3) $_header .= $this->getPriority(); // @CHANGE LDR - if ( $this->getDeliveryReceipt() ) - $_header .= 'Disposition-Notification-To: '.$this->getFrom('addr') . "\r\n"; - if ( $this->getErrorsTo() ) - $_header .= 'Errors-To: '.$this->getErrorsTo('addr') . "\r\n"; - if ( $this->getReplyTo() ) - $_header .= "Reply-To: ".$this->getReplyTo('addr') ."\r\n"; + if ($this->getDeliveryReceipt()) + $_header .= 'Disposition-Notification-To: '.$this->getFrom('addr')."\r\n"; + if ($this->getErrorsTo()) + $_header .= 'Errors-To: '.$this->getErrorsTo('addr')."\r\n"; + if ($this->getReplyTo()) + $_header .= "Reply-To: ".$this->getReplyTo('addr')."\r\n"; - $_header .= 'X-Mailer: Dolibarr version ' . DOL_VERSION .' (using SMTPs Mailer)' . "\r\n"; - $_header .= 'X-Dolibarr-Option: '.($conf->global->MAIN_MAIL_USE_MULTI_PART?'MAIN_MAIL_USE_MULTI_PART':'No MAIN_MAIL_USE_MULTI_PART') . "\r\n"; - $_header .= 'Mime-Version: 1.0' . "\r\n"; + $_header .= 'X-Mailer: Dolibarr version '.DOL_VERSION.' (using SMTPs Mailer)'."\r\n"; + $_header .= 'X-Dolibarr-Option: '.($conf->global->MAIN_MAIL_USE_MULTI_PART ? 'MAIN_MAIL_USE_MULTI_PART' : 'No MAIN_MAIL_USE_MULTI_PART')."\r\n"; + $_header .= 'Mime-Version: 1.0'."\r\n"; return $_header; @@ -1368,7 +1368,7 @@ class SMTPs { //if ( $strContent ) //{ - if ( $strType == 'html' ) + if ($strType == 'html') $strMimeType = 'text/html'; else $strMimeType = 'text/plain'; @@ -1387,7 +1387,7 @@ class SMTPs // Make RFC2045 Compliant //$strContent = rtrim(chunk_split($strContent)); // Function chunck_split seems ko if not used on a base64 content - $strContent = rtrim(wordwrap($strContent, 75, "\r\n")); // TODO Using this method creates unexpected line break on text/plain content. + $strContent = rtrim(wordwrap($strContent, 75, "\r\n")); // TODO Using this method creates unexpected line break on text/plain content. $this->_msgContent[$strType] = array(); @@ -1395,7 +1395,7 @@ class SMTPs $this->_msgContent[$strType]['data'] = $strContent; $this->_msgContent[$strType]['dataText'] = $strContentAltText; - if ( $this->getMD5flag() ) + if ($this->getMD5flag()) $this->_msgContent[$strType]['md5'] = dol_hash($strContent, 3); //} } @@ -1419,49 +1419,49 @@ class SMTPs $keyCount = count($_types); // If we have ZERO, we have a problem - if( $keyCount === 0 ) + if ($keyCount === 0) die("Sorry, no content"); // If we have ONE, we can use the simple format - elseif( $keyCount === 1 && empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) + elseif ($keyCount === 1 && empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) { $_msgData = $this->_msgContent; $_msgData = $_msgData[$_types[0]]; - $content = 'Content-Type: ' . $_msgData['mimeType'] . '; charset="' . $this->getCharSet() . '"' . "\r\n" - . 'Content-Transfer-Encoding: ' . $this->getTransEncodeType() . "\r\n" - . 'Content-Disposition: inline' . "\r\n" - . 'Content-Description: Message' . "\r\n"; + $content = 'Content-Type: '.$_msgData['mimeType'].'; charset="'.$this->getCharSet().'"'."\r\n" + . 'Content-Transfer-Encoding: '.$this->getTransEncodeType()."\r\n" + . 'Content-Disposition: inline'."\r\n" + . 'Content-Description: Message'."\r\n"; - if ( $this->getMD5flag() ) - $content .= 'Content-MD5: ' . $_msgData['md5'] . "\r\n"; + if ($this->getMD5flag()) + $content .= 'Content-MD5: '.$_msgData['md5']."\r\n"; $content .= "\r\n" - . $_msgData['data'] . "\r\n"; + . $_msgData['data']."\r\n"; } // If we have more than ONE, we use the multi-part format - elseif( $keyCount >= 1 || ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) + elseif ($keyCount >= 1 || !empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) { // Since this is an actual multi-part message // We need to define a content message Boundary // NOTE: This was 'multipart/alternative', but Windows based mail servers have issues with this. //$content = 'Content-Type: multipart/related; boundary="' . $this->_getBoundary() . '"' . "\r\n"; - $content = 'Content-Type: multipart/mixed; boundary="' . $this->_getBoundary('mixed') . '"' . "\r\n"; + $content = 'Content-Type: multipart/mixed; boundary="'.$this->_getBoundary('mixed').'"'."\r\n"; // . "\r\n" // . 'This is a multi-part message in MIME format.' . "\r\n"; $content .= "Content-Transfer-Encoding: 8bit\r\n"; $content .= "\r\n"; - $content .= "--" . $this->_getBoundary('mixed') . "\r\n"; + $content .= "--".$this->_getBoundary('mixed')."\r\n"; if (key_exists('image', $this->_msgContent)) // If inline image found { - $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n"; + $content .= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"'."\r\n"; $content .= "\r\n"; - $content .= "--" . $this->_getBoundary('alternative') . "\r\n"; + $content .= "--".$this->_getBoundary('alternative')."\r\n"; } @@ -1471,91 +1471,91 @@ class SMTPs // Loop through message content array foreach ($this->_msgContent as $type => $_content) { - if ( $type == 'attachment' ) + if ($type == 'attachment') { // loop through all attachments foreach ($_content as $_file => $_data) { - $content .= "--" . $this->_getBoundary('mixed') . "\r\n" - . 'Content-Disposition: attachment; filename="' . $_data['fileName'] . '"' . "\r\n" - . 'Content-Type: ' . $_data['mimeType'] . '; name="' . $_data['fileName'] . '"' . "\r\n" - . 'Content-Transfer-Encoding: base64' . "\r\n" - . 'Content-Description: ' . $_data['fileName'] ."\r\n"; + $content .= "--".$this->_getBoundary('mixed')."\r\n" + . 'Content-Disposition: attachment; filename="'.$_data['fileName'].'"'."\r\n" + . 'Content-Type: '.$_data['mimeType'].'; name="'.$_data['fileName'].'"'."\r\n" + . 'Content-Transfer-Encoding: base64'."\r\n" + . 'Content-Description: '.$_data['fileName']."\r\n"; - if ( $this->getMD5flag() ) - $content .= 'Content-MD5: ' . $_data['md5'] . "\r\n"; + if ($this->getMD5flag()) + $content .= 'Content-MD5: '.$_data['md5']."\r\n"; - $content .= "\r\n" . $_data['data'] . "\r\n\r\n"; + $content .= "\r\n".$_data['data']."\r\n\r\n"; } } // @CHANGE LDR - elseif ( $type == 'image' ) + elseif ($type == 'image') { // loop through all images foreach ($_content as $_image => $_data) { - $content .= "--" . $this->_getBoundary('related') . "\r\n"; // always related for an inline image + $content .= "--".$this->_getBoundary('related')."\r\n"; // always related for an inline image - $content .= 'Content-Type: ' . $_data['mimeType'] . '; name="' . $_data['imageName'] . '"' . "\r\n" - . 'Content-Transfer-Encoding: base64' . "\r\n" - . 'Content-Disposition: inline; filename="' . $_data['imageName'] . '"' . "\r\n" - . 'Content-ID: <' . $_data['cid'] . '> ' . "\r\n"; + $content .= 'Content-Type: '.$_data['mimeType'].'; name="'.$_data['imageName'].'"'."\r\n" + . 'Content-Transfer-Encoding: base64'."\r\n" + . 'Content-Disposition: inline; filename="'.$_data['imageName'].'"'."\r\n" + . 'Content-ID: <'.$_data['cid'].'> '."\r\n"; - if ( $this->getMD5flag() ) - $content .= 'Content-MD5: ' . $_data['md5'] . "\r\n"; + if ($this->getMD5flag()) + $content .= 'Content-MD5: '.$_data['md5']."\r\n"; $content .= "\r\n" - . $_data['data'] . "\r\n"; + . $_data['data']."\r\n"; } // always end related and end alternative after inline images - $content.= "--" . $this->_getBoundary('related') . "--" . "\r\n"; - $content.= "\r\n" . "--" . $this->_getBoundary('alternative') . "--" . "\r\n"; - $content.= "\r\n"; + $content .= "--".$this->_getBoundary('related')."--"."\r\n"; + $content .= "\r\n"."--".$this->_getBoundary('alternative')."--"."\r\n"; + $content .= "\r\n"; } else { if (key_exists('image', $this->_msgContent)) { - $content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n"; - $content.= "\r\n" . ($_content['dataText']?$_content['dataText']:strip_tags($_content['data'])) . "\r\n"; // Add plain text message - $content.= "--" . $this->_getBoundary('alternative') . "\r\n"; - $content.= 'Content-Type: multipart/related; boundary="' . $this->_getBoundary('related') . '"' . "\r\n"; - $content.= "\r\n"; - $content.= "--" . $this->_getBoundary('related') . "\r\n"; - } - - if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part before html part - { - $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n"; + $content .= "Content-Type: text/plain; charset=".$this->getCharSet()."\r\n"; + $content .= "\r\n".($_content['dataText'] ? $_content['dataText'] : strip_tags($_content['data']))."\r\n"; // Add plain text message + $content .= "--".$this->_getBoundary('alternative')."\r\n"; + $content .= 'Content-Type: multipart/related; boundary="'.$this->_getBoundary('related').'"'."\r\n"; $content .= "\r\n"; - $content .= "--" . $this->_getBoundary('alternative') . "\r\n"; - - $content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n"; - $content.= "\r\n". $_content['dataText'] . "\r\n"; - $content.= "--" . $this->_getBoundary('alternative') . "\r\n"; + $content .= "--".$this->_getBoundary('related')."\r\n"; } - $content .= 'Content-Type: ' . $_content['mimeType'] . '; ' + if (!key_exists('image', $this->_msgContent) && $_content['dataText'] && !empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part before html part + { + $content .= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"'."\r\n"; + $content .= "\r\n"; + $content .= "--".$this->_getBoundary('alternative')."\r\n"; + + $content .= "Content-Type: text/plain; charset=".$this->getCharSet()."\r\n"; + $content .= "\r\n".$_content['dataText']."\r\n"; + $content .= "--".$this->_getBoundary('alternative')."\r\n"; + } + + $content .= 'Content-Type: '.$_content['mimeType'].'; ' // . 'charset="' . $this->getCharSet() . '"'; - . 'charset=' . $this->getCharSet() . ''; + . 'charset='.$this->getCharSet().''; // $content .= ( $type == 'html') ? '; name="HTML Part"' : ''; - $content .= "\r\n"; + $content .= "\r\n"; // $content .= 'Content-Transfer-Encoding: '; // $content .= ($type == 'html') ? 'quoted-printable' : $this->getTransEncodeType(); // $content .= "\r\n" // . 'Content-Disposition: inline' . "\r\n" // . 'Content-Description: ' . $type . ' message' . "\r\n"; - if ( $this->getMD5flag() ) - $content .= 'Content-MD5: ' . $_content['md5'] . "\r\n"; + if ($this->getMD5flag()) + $content .= 'Content-MD5: '.$_content['md5']."\r\n"; - $content .= "\r\n" . $_content['data'] . "\r\n"; + $content .= "\r\n".$_content['data']."\r\n"; - if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part after html part + if (!key_exists('image', $this->_msgContent) && $_content['dataText'] && !empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part after html part { - $content.= "--" . $this->_getBoundary('alternative') . "--". "\r\n"; + $content .= "--".$this->_getBoundary('alternative')."--"."\r\n"; } $content .= "\r\n"; @@ -1564,7 +1564,7 @@ class SMTPs // Close message boundries // $content .= "\r\n--" . $this->_getBoundary() . '--' . "\r\n" ; - $content .= "--" . $this->_getBoundary('mixed') . '--' . "\r\n" ; + $content .= "--".$this->_getBoundary('mixed').'--'."\r\n"; } return $content; @@ -1581,15 +1581,15 @@ class SMTPs */ public function setAttachment($strContent, $strFileName = 'unknown', $strMimeType = 'unknown') { - if ( $strContent ) + if ($strContent) { - $strContent = rtrim(chunk_split(base64_encode($strContent), 76, "\r\n")); // 76 max is defined into http://tools.ietf.org/html/rfc2047 + $strContent = rtrim(chunk_split(base64_encode($strContent), 76, "\r\n")); // 76 max is defined into http://tools.ietf.org/html/rfc2047 $this->_msgContent['attachment'][$strFileName]['mimeType'] = $strMimeType; $this->_msgContent['attachment'][$strFileName]['fileName'] = $strFileName; $this->_msgContent['attachment'][$strFileName]['data'] = $strContent; - if ( $this->getMD5flag() ) + if ($this->getMD5flag()) $this->_msgContent['attachment'][$strFileName]['md5'] = dol_hash($strContent, 3); } } @@ -1616,7 +1616,7 @@ class SMTPs $this->_msgContent['image'][$strImageName]['cid'] = $strImageCid; $this->_msgContent['image'][$strImageName]['data'] = $strContent; - if ( $this->getMD5flag() ) + if ($this->getMD5flag()) $this->_msgContent['image'][$strImageName]['md5'] = dol_hash($strContent, 3); } } @@ -1636,8 +1636,8 @@ class SMTPs */ public function setSensitivity($_value = 0) { - if ( ( is_numeric($_value) ) && - ( ( $_value >= 0 ) && ( $_value <= 3 ) ) ) + if ((is_numeric($_value)) && + (($_value >= 0) && ($_value <= 3))) $this->_msgSensitivity = $_value; } @@ -1671,8 +1671,8 @@ class SMTPs */ public function setPriority($_value = 3) { - if ( ( is_numeric($_value) ) && - ( ( $_value >= 0 ) && ( $_value <= 5 ) ) ) + if ((is_numeric($_value)) && + (($_value >= 0) && ($_value <= 5))) $this->_msgPriority = $_value; } @@ -1690,9 +1690,9 @@ class SMTPs */ public function getPriority() { - return 'Importance: ' . $this->_aryPriority[$this->_msgPriority] . "\r\n" - . 'Priority: ' . $this->_aryPriority[$this->_msgPriority] . "\r\n" - . 'X-Priority: ' . $this->_msgPriority . ' (' . $this->_aryPriority[$this->_msgPriority] . ')' . "\r\n"; + return 'Importance: '.$this->_aryPriority[$this->_msgPriority]."\r\n" + . 'Priority: '.$this->_aryPriority[$this->_msgPriority]."\r\n" + . 'X-Priority: '.$this->_msgPriority.' ('.$this->_aryPriority[$this->_msgPriority].')'."\r\n"; } /** @@ -1726,7 +1726,7 @@ class SMTPs */ public function setXheader($strXdata) { - if ( $strXdata ) + if ($strXdata) $this->_msgXheader[] = $strXdata; } @@ -1747,7 +1747,7 @@ class SMTPs */ private function _setBoundary() { - $this->_smtpsBoundary = "multipart_x." . time() . ".x_boundary"; + $this->_smtpsBoundary = "multipart_x.".time().".x_boundary"; $this->_smtpsRelatedBoundary = 'mul_'.dol_hash(uniqid("dolibarr2"), 3); $this->_smtpsAlternativeBoundary = 'mul_'.dol_hash(uniqid("dolibarr3"), 3); } @@ -1786,11 +1786,11 @@ class SMTPs $server_response = ''; // avoid infinite loop - $limit=0; + $limit = 0; - while (substr($server_response, 3, 1) != ' ' && $limit<100) + while (substr($server_response, 3, 1) != ' ' && $limit < 100) { - if (! ($server_response = fgets($socket, 256))) + if (!($server_response = fgets($socket, 256))) { $this->_setErr(121, "Couldn't get mail server response codes"); $_retVal = false; @@ -1800,7 +1800,7 @@ class SMTPs $limit++; } - if (! (substr($server_response, 0, 3) == $response)) + if (!(substr($server_response, 0, 3) == $response)) { $this->_setErr(120, "Ran into problems sending Mail.\r\nResponse: $server_response"); $_retVal = false; @@ -1821,11 +1821,11 @@ class SMTPs public function socket_send_str($_strSend, $_returnCode = null, $CRLF = "\r\n") { // phpcs:enable - if ($this->_debug) $this->log.=$_strSend; // @CHANGE LDR for log - fputs($this->socket, $_strSend . $CRLF); - if ($this->_debug) $this->log.=' ('.$_returnCode.')' . $CRLF; + if ($this->_debug) $this->log .= $_strSend; // @CHANGE LDR for log + fputs($this->socket, $_strSend.$CRLF); + if ($this->_debug) $this->log .= ' ('.$_returnCode.')'.$CRLF; - if ( $_returnCode ) + if ($_returnCode) return $this->server_parse($this->socket, $_returnCode); } @@ -1860,7 +1860,7 @@ class SMTPs { foreach ($this->_smtpsErrors as $_err => $_info) { - $_errMsg[] = 'Error [' . $_info['num'] .']: '. $_info['msg']; + $_errMsg[] = 'Error ['.$_info['num'].']: '.$_info['msg']; } } diff --git a/htdocs/core/extrafieldsinexport.inc.php b/htdocs/core/extrafieldsinexport.inc.php index e9d10138d1e..4f85610e657 100644 --- a/htdocs/core/extrafieldsinexport.inc.php +++ b/htdocs/core/extrafieldsinexport.inc.php @@ -8,67 +8,67 @@ if (empty($keyforselect) || empty($keyforelement) || empty($keyforaliasextra)) } // Add extra fields -$sql="SELECT name, label, type, param, fieldcomputed, fielddefault FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = '".$keyforselect."' AND type != 'separate' AND entity IN (0, ".$conf->entity.') ORDER BY pos ASC'; +$sql = "SELECT name, label, type, param, fieldcomputed, fielddefault FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = '".$keyforselect."' AND type != 'separate' AND entity IN (0, ".$conf->entity.') ORDER BY pos ASC'; //print $sql; -$resql=$this->db->query($sql); +$resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $fieldname=$keyforaliasextra.'.'.$obj->name; - $fieldlabel=ucfirst($obj->label); - $typeFilter="Text"; - $typefield=preg_replace('/\(.*$/', '', $obj->type); // double(24,8) -> double + $fieldname = $keyforaliasextra.'.'.$obj->name; + $fieldlabel = ucfirst($obj->label); + $typeFilter = "Text"; + $typefield = preg_replace('/\(.*$/', '', $obj->type); // double(24,8) -> double switch ($typefield) { case 'int': case 'integer': case 'double': case 'price': - $typeFilter="Numeric"; + $typeFilter = "Numeric"; break; case 'date': case 'datetime': case 'timestamp': - $typeFilter="Date"; + $typeFilter = "Date"; break; case 'boolean': - $typeFilter="Boolean"; + $typeFilter = "Boolean"; break; case 'select': - if (! empty($conf->global->EXPORT_LABEL_FOR_SELECT)) + if (!empty($conf->global->EXPORT_LABEL_FOR_SELECT)) { - $tmpparam=unserialize($obj->param); // $tmpparam may be array with 'options' = array(key1=>val1, key2=>val2 ...) + $tmpparam = unserialize($obj->param); // $tmpparam may be array with 'options' = array(key1=>val1, key2=>val2 ...) if ($tmpparam['options'] && is_array($tmpparam['options'])) { - $typeFilter="Select:".$obj->param; + $typeFilter = "Select:".$obj->param; } } break; case 'sellist': - $tmp=''; - $tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null + $tmp = ''; + $tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null if ($tmpparam['options'] && is_array($tmpparam['options'])) { - $tmpkeys=array_keys($tmpparam['options']); - $tmp=array_shift($tmpkeys); + $tmpkeys = array_keys($tmpparam['options']); + $tmp = array_shift($tmpkeys); } - if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp; + if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp; break; } - if ($obj->type!='separate') + if ($obj->type != 'separate') { // If not a computed field if (empty($obj->fieldcomputed)) { - $this->export_fields_array[$r][$fieldname]=$fieldlabel; - $this->export_TypeFields_array[$r][$fieldname]=$typeFilter; - $this->export_entities_array[$r][$fieldname]=$keyforelement; + $this->export_fields_array[$r][$fieldname] = $fieldlabel; + $this->export_TypeFields_array[$r][$fieldname] = $typeFilter; + $this->export_entities_array[$r][$fieldname] = $keyforelement; } // If this is a computed field else { - $this->export_fields_array[$r][$fieldname]=$fieldlabel; - $this->export_TypeFields_array[$r][$fieldname]=$typeFilter.'Compute'; - $this->export_special_array[$r][$fieldname]=$obj->fieldcomputed; - $this->export_entities_array[$r][$fieldname]=$keyforelement; + $this->export_fields_array[$r][$fieldname] = $fieldlabel; + $this->export_TypeFields_array[$r][$fieldname] = $typeFilter.'Compute'; + $this->export_special_array[$r][$fieldname] = $obj->fieldcomputed; + $this->export_entities_array[$r][$fieldname] = $keyforelement; } } } diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 0051d28caf3..4568ab2774d 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -195,7 +195,7 @@ function dol_dir_list($path, $types = "all", $recursive = 0, $filter = "", $excl closedir($dir); // Obtain a list of columns - if (! empty($sortcriteria) && $sortorder) + if (!empty($sortcriteria) && $sortorder) { $file_list = dol_sort_array($file_list, $sortcriteria, ($sortorder == SORT_ASC ? 'asc' : 'desc')); } @@ -1435,21 +1435,21 @@ function dol_meta_create($object) if (is_dir($dir)) { $nblines = count($object->lines); - $client = $object->thirdparty->name . " " . $object->thirdparty->address . " " . $object->thirdparty->zip . " " . $object->thirdparty->town; - $meta = "REFERENCE=\"" . $object->ref . "\" - DATE=\"" . dol_print_date($object->date, '') . "\" - NB_ITEMS=\"" . $nblines . "\" - CLIENT=\"" . $client . "\" - AMOUNT_EXCL_TAX=\"" . $object->total_ht . "\" - AMOUNT=\"" . $object->total_ttc . "\"\n"; + $client = $object->thirdparty->name." ".$object->thirdparty->address." ".$object->thirdparty->zip." ".$object->thirdparty->town; + $meta = "REFERENCE=\"".$object->ref."\" + DATE=\"" . dol_print_date($object->date, '')."\" + NB_ITEMS=\"" . $nblines."\" + CLIENT=\"" . $client."\" + AMOUNT_EXCL_TAX=\"" . $object->total_ht."\" + AMOUNT=\"" . $object->total_ttc."\"\n"; - for ($i = 0 ; $i < $nblines ; $i++) + for ($i = 0; $i < $nblines; $i++) { //Pour les articles - $meta .= "ITEM_" . $i . "_QUANTITY=\"" . $object->lines[$i]->qty . "\" - ITEM_" . $i . "_AMOUNT_WO_TAX=\"" . $object->lines[$i]->total_ht . "\" - ITEM_" . $i . "_VAT=\"" .$object->lines[$i]->tva_tx . "\" - ITEM_" . $i . "_DESCRIPTION=\"" . str_replace("\r\n", "", nl2br($object->lines[$i]->desc)) . "\" + $meta .= "ITEM_".$i."_QUANTITY=\"".$object->lines[$i]->qty."\" + ITEM_" . $i."_AMOUNT_WO_TAX=\"".$object->lines[$i]->total_ht."\" + ITEM_" . $i."_VAT=\"".$object->lines[$i]->tva_tx."\" + ITEM_" . $i."_DESCRIPTION=\"".str_replace("\r\n", "", nl2br($object->lines[$i]->desc))."\" "; } } @@ -1543,21 +1543,21 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess for ($i = 0; $i < $nbfile; $i++) { // Define $destfull (path to file including filename) and $destfile (only filename) - $destfull=$upload_dir . "/" . $TFile['name'][$i]; - $destfile=$TFile['name'][$i]; + $destfull = $upload_dir."/".$TFile['name'][$i]; + $destfile = $TFile['name'][$i]; if ($savingdocmask) { - $destfull=$upload_dir . "/" . preg_replace('/__file__/', $TFile['name'][$i], $savingdocmask); - $destfile=preg_replace('/__file__/', $TFile['name'][$i], $savingdocmask); + $destfull = $upload_dir."/".preg_replace('/__file__/', $TFile['name'][$i], $savingdocmask); + $destfile = preg_replace('/__file__/', $TFile['name'][$i], $savingdocmask); } // dol_sanitizeFileName the file name and lowercase extension $info = pathinfo($destfull); - $destfull = $info['dirname'].'/'.dol_sanitizeFileName($info['filename'].($info['extension']!='' ? ('.'.strtolower($info['extension'])) : '')); + $destfull = $info['dirname'].'/'.dol_sanitizeFileName($info['filename'].($info['extension'] != '' ? ('.'.strtolower($info['extension'])) : '')); $info = pathinfo($destfile); - $destfile = dol_sanitizeFileName($info['filename'].($info['extension']!='' ? ('.'.strtolower($info['extension'])) : '')); + $destfile = dol_sanitizeFileName($info['filename'].($info['extension'] != '' ? ('.'.strtolower($info['extension'])) : '')); // We apply dol_string_nohtmltag also to clean file names (this remove duplicate spaces) because // this function is also applied when we make try to download file (by the GETPOST(filename, 'alphanohtml') call). @@ -1845,15 +1845,15 @@ function dol_convert_file($fileinput, $ext = 'png', $fileoutput = '', $page = '' $ret = $image->setImageFormat($ext); if ($ret) { - if (empty($fileoutput)) $fileoutput=$fileinput.".".$ext; + if (empty($fileoutput)) $fileoutput = $fileinput.".".$ext; $count = $image->getNumberImages(); - if (! dol_is_file($fileoutput) || is_writeable($fileoutput)) + if (!dol_is_file($fileoutput) || is_writeable($fileoutput)) { try { $ret = $image->writeImages($fileoutput, true); } - catch(Exception $e) + catch (Exception $e) { dol_syslog($e->getMessage(), LOG_WARNING); } @@ -1896,20 +1896,20 @@ function dol_compress_file($inputfile, $outputfile, $mode = "gz", &$errorstring { global $conf; - $foundhandler=0; + $foundhandler = 0; try { dol_syslog("dol_compress_file mode=".$mode." inputfile=".$inputfile." outputfile=".$outputfile); $data = implode("", file(dol_osencode($inputfile))); - if ($mode == 'gz') { $foundhandler=1; $compressdata = gzencode($data, 9); } - elseif ($mode == 'bz') { $foundhandler=1; $compressdata = bzcompress($data, 9); } + if ($mode == 'gz') { $foundhandler = 1; $compressdata = gzencode($data, 9); } + elseif ($mode == 'bz') { $foundhandler = 1; $compressdata = bzcompress($data, 9); } elseif ($mode == 'zip') { - if (class_exists('ZipArchive') && ! empty($conf->global->MAIN_USE_ZIPARCHIVE_FOR_ZIP_COMPRESS)) + if (class_exists('ZipArchive') && !empty($conf->global->MAIN_USE_ZIPARCHIVE_FOR_ZIP_COMPRESS)) { - $foundhandler=1; + $foundhandler = 1; $rootPath = realpath($inputfile); @@ -1917,7 +1917,7 @@ function dol_compress_file($inputfile, $outputfile, $mode = "gz", &$errorstring $zip = new ZipArchive; if ($zip->open($outputfile, ZipArchive::CREATE) !== true) { - $errorstring="dol_compress_file failure - Failed to open file ".$outputfile."\n"; + $errorstring = "dol_compress_file failure - Failed to open file ".$outputfile."\n"; dol_syslog($errorstring, LOG_ERR); global $errormsg; @@ -1956,7 +1956,7 @@ function dol_compress_file($inputfile, $outputfile, $mode = "gz", &$errorstring if (defined('ODTPHP_PATHTOPCLZIP')) { - $foundhandler=1; + $foundhandler = 1; include_once ODTPHP_PATHTOPCLZIP.'/pclzip.lib.php'; $archive = new PclZip($outputfile); @@ -1965,7 +1965,7 @@ function dol_compress_file($inputfile, $outputfile, $mode = "gz", &$errorstring if ($result === 0) { global $errormsg; - $errormsg=$archive->errorInfo(true); + $errormsg = $archive->errorInfo(true); if ($archive->errorCode() == PCLZIP_ERR_WRITE_OPEN_FAIL) { @@ -2007,7 +2007,7 @@ function dol_compress_file($inputfile, $outputfile, $mode = "gz", &$errorstring { global $langs, $errormsg; $langs->load("errors"); - $errormsg=$langs->trans("ErrorFailedToWriteInDir"); + $errormsg = $langs->trans("ErrorFailedToWriteInDir"); $errorstring = "Failed to open file ".$outputfile; dol_syslog($errorstring, LOG_ERR); @@ -2087,22 +2087,22 @@ function dol_uncompress($inputfile, $outputdir) */ function dol_compress_dir($inputdir, $outputfile, $mode = "zip", $excludefiles = '', $rootdirinzip = '') { - $foundhandler=0; + $foundhandler = 0; dol_syslog("Try to zip dir ".$inputdir." into ".$outputfile." mode=".$mode); - if (! dol_is_dir(dirname($outputfile)) || ! is_writable(dirname($outputfile))) + if (!dol_is_dir(dirname($outputfile)) || !is_writable(dirname($outputfile))) { global $langs, $errormsg; $langs->load("errors"); - $errormsg=$langs->trans("ErrorFailedToWriteInDir", $outputfile); + $errormsg = $langs->trans("ErrorFailedToWriteInDir", $outputfile); return -3; } try { - if ($mode == 'gz') { $foundhandler=0; } - elseif ($mode == 'bz') { $foundhandler=0; } + if ($mode == 'gz') { $foundhandler = 0; } + elseif ($mode == 'bz') { $foundhandler = 0; } elseif ($mode == 'zip') { /*if (defined('ODTPHP_PATHTOPCLZIP')) @@ -2124,11 +2124,11 @@ function dol_compress_dir($inputdir, $outputfile, $mode = "zip", $excludefiles = // Initialize archive object $zip = new ZipArchive(); $result = $zip->open($outputfile, ZipArchive::CREATE | ZipArchive::OVERWRITE); - if (! $result) + if (!$result) { global $langs, $errormsg; $langs->load("errors"); - $errormsg=$langs->trans("ErrorFailedToWriteInFile", $outputfile); + $errormsg = $langs->trans("ErrorFailedToWriteInFile", $outputfile); return -4; } @@ -2148,7 +2148,7 @@ function dol_compress_dir($inputdir, $outputfile, $mode = "zip", $excludefiles = $filePath = $file->getRealPath(); $relativePath = ($rootdirinzip ? $rootdirinzip.'/' : '').substr($filePath, strlen($inputdir) + 1); - if (empty($excludefiles) || ! preg_match($excludefiles, $filePath)) + if (empty($excludefiles) || !preg_match($excludefiles, $filePath)) { // Add current file to archive $zip->addFile($filePath, $relativePath); @@ -2219,267 +2219,267 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, global $conf, $db, $user; global $dolibarr_main_data_root, $dolibarr_main_document_root_alt; - if (! is_object($fuser)) $fuser=$user; + if (!is_object($fuser)) $fuser = $user; if (empty($modulepart)) return 'ErrorBadParameter'; if (empty($entity)) { - if (empty($conf->multicompany->enabled)) $entity=1; - else $entity=0; + if (empty($conf->multicompany->enabled)) $entity = 1; + else $entity = 0; } // Fix modulepart - if ($modulepart == 'users') $modulepart='user'; + if ($modulepart == 'users') $modulepart = 'user'; dol_syslog('modulepart='.$modulepart.' original_file='.$original_file.' entity='.$entity); // We define $accessallowed and $sqlprotectagainstexternals - $accessallowed=0; - $sqlprotectagainstexternals=''; - $ret=array(); + $accessallowed = 0; + $sqlprotectagainstexternals = ''; + $ret = array(); // Find the subdirectory name as the reference. For exemple original_file='10/myfile.pdf' -> refname='10' - if (empty($refname)) $refname=basename(dirname($original_file)."/"); + if (empty($refname)) $refname = basename(dirname($original_file)."/"); // Define possible keys to use for permission check - $lire='lire'; $read='read'; $download='download'; + $lire = 'lire'; $read = 'read'; $download = 'download'; if ($mode == 'write') { - $lire='creer'; $read='write'; $download='upload'; + $lire = 'creer'; $read = 'write'; $download = 'upload'; } // Wrapping for miscellaneous medias files if ($modulepart == 'medias' && !empty($dolibarr_main_data_root)) { if (empty($entity) || empty($conf->medias->multidir_output[$entity])) return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); - $accessallowed=1; - $original_file=$conf->medias->multidir_output[$entity].'/'.$original_file; + $accessallowed = 1; + $original_file = $conf->medias->multidir_output[$entity].'/'.$original_file; } // Wrapping for *.log files, like when used with url http://.../document.php?modulepart=logs&file=dolibarr.log elseif ($modulepart == 'logs' && !empty($dolibarr_main_data_root)) { - $accessallowed=($user->admin && basename($original_file) == $original_file && preg_match('/^dolibarr.*\.log$/', basename($original_file))); - $original_file=$dolibarr_main_data_root.'/'.$original_file; + $accessallowed = ($user->admin && basename($original_file) == $original_file && preg_match('/^dolibarr.*\.log$/', basename($original_file))); + $original_file = $dolibarr_main_data_root.'/'.$original_file; } // Wrapping for *.log files, like when used with url http://.../document.php?modulepart=logs&file=dolibarr.log elseif ($modulepart == 'doctemplateswebsite' && !empty($dolibarr_main_data_root)) { - $accessallowed=($fuser->rights->website->write && preg_match('/\.jpg$/i', basename($original_file))); - $original_file=$dolibarr_main_data_root.'/doctemplates/websites/'.$original_file; + $accessallowed = ($fuser->rights->website->write && preg_match('/\.jpg$/i', basename($original_file))); + $original_file = $dolibarr_main_data_root.'/doctemplates/websites/'.$original_file; } // Wrapping for *.zip files, like when used with url http://.../document.php?modulepart=packages&file=module_myfile.zip elseif ($modulepart == 'packages' && !empty($dolibarr_main_data_root)) { // Dir for custom dirs - $tmp=explode(',', $dolibarr_main_document_root_alt); + $tmp = explode(',', $dolibarr_main_document_root_alt); $dirins = $tmp[0]; - $accessallowed=($user->admin && preg_match('/^module_.*\.zip$/', basename($original_file))); - $original_file=$dirins.'/'.$original_file; + $accessallowed = ($user->admin && preg_match('/^module_.*\.zip$/', basename($original_file))); + $original_file = $dirins.'/'.$original_file; } // Wrapping for some images elseif ($modulepart == 'mycompany' && !empty($conf->mycompany->dir_output)) { - $accessallowed=1; - $original_file=$conf->mycompany->dir_output.'/'.$original_file; + $accessallowed = 1; + $original_file = $conf->mycompany->dir_output.'/'.$original_file; } // Wrapping for users photos elseif ($modulepart == 'userphoto' && !empty($conf->user->dir_output)) { - $accessallowed=1; - $original_file=$conf->user->dir_output.'/'.$original_file; + $accessallowed = 1; + $original_file = $conf->user->dir_output.'/'.$original_file; } // Wrapping for members photos elseif ($modulepart == 'memberphoto' && !empty($conf->adherent->dir_output)) { - $accessallowed=1; - $original_file=$conf->adherent->dir_output.'/'.$original_file; + $accessallowed = 1; + $original_file = $conf->adherent->dir_output.'/'.$original_file; } // Wrapping pour les apercu factures elseif ($modulepart == 'apercufacture' && !empty($conf->facture->multidir_output[$entity])) { - if ($fuser->rights->facture->{$lire}) $accessallowed=1; - $original_file=$conf->facture->multidir_output[$entity].'/'.$original_file; + if ($fuser->rights->facture->{$lire}) $accessallowed = 1; + $original_file = $conf->facture->multidir_output[$entity].'/'.$original_file; } // Wrapping pour les apercu propal elseif ($modulepart == 'apercupropal' && !empty($conf->propal->multidir_output[$entity])) { - if ($fuser->rights->propale->{$lire}) $accessallowed=1; - $original_file=$conf->propal->multidir_output[$entity].'/'.$original_file; + if ($fuser->rights->propale->{$lire}) $accessallowed = 1; + $original_file = $conf->propal->multidir_output[$entity].'/'.$original_file; } // Wrapping pour les apercu commande elseif ($modulepart == 'apercucommande' && !empty($conf->commande->multidir_output[$entity])) { - if ($fuser->rights->commande->{$lire}) $accessallowed=1; - $original_file=$conf->commande->multidir_output[$entity].'/'.$original_file; + if ($fuser->rights->commande->{$lire}) $accessallowed = 1; + $original_file = $conf->commande->multidir_output[$entity].'/'.$original_file; } // Wrapping pour les apercu intervention elseif (($modulepart == 'apercufichinter' || $modulepart == 'apercuficheinter') && !empty($conf->ficheinter->dir_output)) { - if ($fuser->rights->ficheinter->{$lire}) $accessallowed=1; - $original_file=$conf->ficheinter->dir_output.'/'.$original_file; + if ($fuser->rights->ficheinter->{$lire}) $accessallowed = 1; + $original_file = $conf->ficheinter->dir_output.'/'.$original_file; } // Wrapping pour les apercu conat elseif (($modulepart == 'apercucontract') && !empty($conf->contrat->dir_output)) { - if ($fuser->rights->contrat->{$lire}) $accessallowed=1; - $original_file=$conf->contrat->dir_output.'/'.$original_file; + if ($fuser->rights->contrat->{$lire}) $accessallowed = 1; + $original_file = $conf->contrat->dir_output.'/'.$original_file; } // Wrapping pour les apercu supplier proposal elseif (($modulepart == 'apercusupplier_proposal' || $modulepart == 'apercusupplier_proposal') && !empty($conf->supplier_proposal->dir_output)) { - if ($fuser->rights->supplier_proposal->{$lire}) $accessallowed=1; - $original_file=$conf->supplier_proposal->dir_output.'/'.$original_file; + if ($fuser->rights->supplier_proposal->{$lire}) $accessallowed = 1; + $original_file = $conf->supplier_proposal->dir_output.'/'.$original_file; } // Wrapping pour les apercu supplier order elseif (($modulepart == 'apercusupplier_order' || $modulepart == 'apercusupplier_order') && !empty($conf->fournisseur->commande->dir_output)) { - if ($fuser->rights->fournisseur->commande->{$lire}) $accessallowed=1; - $original_file=$conf->fournisseur->commande->dir_output.'/'.$original_file; + if ($fuser->rights->fournisseur->commande->{$lire}) $accessallowed = 1; + $original_file = $conf->fournisseur->commande->dir_output.'/'.$original_file; } // Wrapping pour les apercu supplier invoice elseif (($modulepart == 'apercusupplier_invoice' || $modulepart == 'apercusupplier_invoice') && !empty($conf->fournisseur->facture->dir_output)) { - if ($fuser->rights->fournisseur->facture->{$lire}) $accessallowed=1; - $original_file=$conf->fournisseur->facture->dir_output.'/'.$original_file; + if ($fuser->rights->fournisseur->facture->{$lire}) $accessallowed = 1; + $original_file = $conf->fournisseur->facture->dir_output.'/'.$original_file; } // Wrapping pour les apercu supplier invoice elseif (($modulepart == 'apercuexpensereport') && !empty($conf->expensereport->dir_output)) { - if ($fuser->rights->expensereport->{$lire}) $accessallowed=1; - $original_file=$conf->expensereport->dir_output.'/'.$original_file; + if ($fuser->rights->expensereport->{$lire}) $accessallowed = 1; + $original_file = $conf->expensereport->dir_output.'/'.$original_file; } // Wrapping pour les images des stats propales elseif ($modulepart == 'propalstats' && !empty($conf->propal->multidir_temp[$entity])) { - if ($fuser->rights->propale->{$lire}) $accessallowed=1; - $original_file=$conf->propal->multidir_temp[$entity].'/'.$original_file; + if ($fuser->rights->propale->{$lire}) $accessallowed = 1; + $original_file = $conf->propal->multidir_temp[$entity].'/'.$original_file; } // Wrapping pour les images des stats commandes elseif ($modulepart == 'orderstats' && !empty($conf->commande->dir_temp)) { - if ($fuser->rights->commande->{$lire}) $accessallowed=1; - $original_file=$conf->commande->dir_temp.'/'.$original_file; + if ($fuser->rights->commande->{$lire}) $accessallowed = 1; + $original_file = $conf->commande->dir_temp.'/'.$original_file; } elseif ($modulepart == 'orderstatssupplier' && !empty($conf->fournisseur->dir_output)) { - if ($fuser->rights->fournisseur->commande->{$lire}) $accessallowed=1; - $original_file=$conf->fournisseur->commande->dir_temp.'/'.$original_file; + if ($fuser->rights->fournisseur->commande->{$lire}) $accessallowed = 1; + $original_file = $conf->fournisseur->commande->dir_temp.'/'.$original_file; } // Wrapping pour les images des stats factures elseif ($modulepart == 'billstats' && !empty($conf->facture->dir_temp)) { - if ($fuser->rights->facture->{$lire}) $accessallowed=1; - $original_file=$conf->facture->dir_temp.'/'.$original_file; + if ($fuser->rights->facture->{$lire}) $accessallowed = 1; + $original_file = $conf->facture->dir_temp.'/'.$original_file; } elseif ($modulepart == 'billstatssupplier' && !empty($conf->fournisseur->dir_output)) { - if ($fuser->rights->fournisseur->facture->{$lire}) $accessallowed=1; - $original_file=$conf->fournisseur->facture->dir_temp.'/'.$original_file; + if ($fuser->rights->fournisseur->facture->{$lire}) $accessallowed = 1; + $original_file = $conf->fournisseur->facture->dir_temp.'/'.$original_file; } // Wrapping pour les images des stats expeditions elseif ($modulepart == 'expeditionstats' && !empty($conf->expedition->dir_temp)) { - if ($fuser->rights->expedition->{$lire}) $accessallowed=1; - $original_file=$conf->expedition->dir_temp.'/'.$original_file; + if ($fuser->rights->expedition->{$lire}) $accessallowed = 1; + $original_file = $conf->expedition->dir_temp.'/'.$original_file; } // Wrapping pour les images des stats expeditions elseif ($modulepart == 'tripsexpensesstats' && !empty($conf->deplacement->dir_temp)) { - if ($fuser->rights->deplacement->{$lire}) $accessallowed=1; - $original_file=$conf->deplacement->dir_temp.'/'.$original_file; + if ($fuser->rights->deplacement->{$lire}) $accessallowed = 1; + $original_file = $conf->deplacement->dir_temp.'/'.$original_file; } // Wrapping pour les images des stats expeditions elseif ($modulepart == 'memberstats' && !empty($conf->adherent->dir_temp)) { - if ($fuser->rights->adherent->{$lire}) $accessallowed=1; - $original_file=$conf->adherent->dir_temp.'/'.$original_file; + if ($fuser->rights->adherent->{$lire}) $accessallowed = 1; + $original_file = $conf->adherent->dir_temp.'/'.$original_file; } // Wrapping pour les images des stats produits elseif (preg_match('/^productstats_/i', $modulepart) && !empty($conf->product->dir_temp)) { - if ($fuser->rights->produit->{$lire} || $fuser->rights->service->{$lire}) $accessallowed=1; - $original_file=(!empty($conf->product->multidir_temp[$entity])?$conf->product->multidir_temp[$entity]:$conf->service->multidir_temp[$entity]).'/'.$original_file; + if ($fuser->rights->produit->{$lire} || $fuser->rights->service->{$lire}) $accessallowed = 1; + $original_file = (!empty($conf->product->multidir_temp[$entity]) ? $conf->product->multidir_temp[$entity] : $conf->service->multidir_temp[$entity]).'/'.$original_file; } // Wrapping for taxes elseif ($modulepart == 'tax' && !empty($conf->tax->dir_output)) { - if ($fuser->rights->tax->charges->{$lire}) $accessallowed=1; - $original_file=$conf->tax->dir_output.'/'.$original_file; + if ($fuser->rights->tax->charges->{$lire}) $accessallowed = 1; + $original_file = $conf->tax->dir_output.'/'.$original_file; } // Wrapping for events elseif ($modulepart == 'actions' && !empty($conf->agenda->dir_output)) { - if ($fuser->rights->agenda->myactions->{$read}) $accessallowed=1; - $original_file=$conf->agenda->dir_output.'/'.$original_file; + if ($fuser->rights->agenda->myactions->{$read}) $accessallowed = 1; + $original_file = $conf->agenda->dir_output.'/'.$original_file; } // Wrapping for categories elseif ($modulepart == 'category' && !empty($conf->categorie->dir_output)) { if (empty($entity) || empty($conf->categorie->multidir_output[$entity])) return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); - if ($fuser->rights->categorie->{$lire}) $accessallowed=1; - $original_file=$conf->categorie->multidir_output[$entity].'/'.$original_file; + if ($fuser->rights->categorie->{$lire}) $accessallowed = 1; + $original_file = $conf->categorie->multidir_output[$entity].'/'.$original_file; } // Wrapping pour les prelevements elseif ($modulepart == 'prelevement' && !empty($conf->prelevement->dir_output)) { - if ($fuser->rights->prelevement->bons->{$lire} || preg_match('/^specimen/i', $original_file)) $accessallowed=1; - $original_file=$conf->prelevement->dir_output.'/'.$original_file; + if ($fuser->rights->prelevement->bons->{$lire} || preg_match('/^specimen/i', $original_file)) $accessallowed = 1; + $original_file = $conf->prelevement->dir_output.'/'.$original_file; } // Wrapping pour les graph energie elseif ($modulepart == 'graph_stock' && !empty($conf->stock->dir_temp)) { - $accessallowed=1; - $original_file=$conf->stock->dir_temp.'/'.$original_file; + $accessallowed = 1; + $original_file = $conf->stock->dir_temp.'/'.$original_file; } // Wrapping pour les graph fournisseurs elseif ($modulepart == 'graph_fourn' && !empty($conf->fournisseur->dir_temp)) { - $accessallowed=1; - $original_file=$conf->fournisseur->dir_temp.'/'.$original_file; + $accessallowed = 1; + $original_file = $conf->fournisseur->dir_temp.'/'.$original_file; } // Wrapping pour les graph des produits elseif ($modulepart == 'graph_product' && !empty($conf->product->dir_temp)) { - $accessallowed=1; - $original_file=$conf->product->multidir_temp[$entity].'/'.$original_file; + $accessallowed = 1; + $original_file = $conf->product->multidir_temp[$entity].'/'.$original_file; } // Wrapping pour les code barre elseif ($modulepart == 'barcode') { - $accessallowed=1; + $accessallowed = 1; // If viewimage is called for barcode, we try to output an image on the fly, with no build of file on disk. //$original_file=$conf->barcode->dir_temp.'/'.$original_file; - $original_file=''; + $original_file = ''; } // Wrapping pour les icones de background des mailings elseif ($modulepart == 'iconmailing' && !empty($conf->mailing->dir_temp)) { - $accessallowed=1; - $original_file=$conf->mailing->dir_temp.'/'.$original_file; + $accessallowed = 1; + $original_file = $conf->mailing->dir_temp.'/'.$original_file; } // Wrapping pour le scanner elseif ($modulepart == 'scanner_user_temp' && !empty($conf->scanner->dir_temp)) { - $accessallowed=1; - $original_file=$conf->scanner->dir_temp.'/'.$fuser->id.'/'.$original_file; + $accessallowed = 1; + $original_file = $conf->scanner->dir_temp.'/'.$fuser->id.'/'.$original_file; } // Wrapping pour les images fckeditor elseif ($modulepart == 'fckeditor' && !empty($conf->fckeditor->dir_output)) { - $accessallowed=1; - $original_file=$conf->fckeditor->dir_output.'/'.$original_file; + $accessallowed = 1; + $original_file = $conf->fckeditor->dir_output.'/'.$original_file; } // Wrapping for users elseif ($modulepart == 'user' && !empty($conf->user->dir_output)) { - $canreaduser=(! empty($fuser->admin) || $fuser->rights->user->user->{$lire}); - if ($fuser->id == (int) $refname) { $canreaduser=1; } // A user can always read its own card + $canreaduser = (!empty($fuser->admin) || $fuser->rights->user->user->{$lire}); + if ($fuser->id == (int) $refname) { $canreaduser = 1; } // A user can always read its own card if ($canreaduser || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->user->dir_output.'/'.$original_file; + $original_file = $conf->user->dir_output.'/'.$original_file; } // Wrapping for third parties @@ -2510,9 +2510,9 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, { if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->facture->multidir_output[$entity].'/'.$original_file; + $original_file = $conf->facture->multidir_output[$entity].'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."facture WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; } // Wrapping for mass actions @@ -2520,81 +2520,81 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, { if ($fuser->rights->propal->{$lire} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->propal->multidir_output[$entity].'/temp/massgeneration/'.$user->id.'/'.$original_file; + $original_file = $conf->propal->multidir_output[$entity].'/temp/massgeneration/'.$user->id.'/'.$original_file; } elseif ($modulepart == 'massfilesarea_orders') { if ($fuser->rights->commande->{$lire} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->commande->multidir_output[$entity].'/temp/massgeneration/'.$user->id.'/'.$original_file; + $original_file = $conf->commande->multidir_output[$entity].'/temp/massgeneration/'.$user->id.'/'.$original_file; } elseif ($modulepart == 'massfilesarea_sendings') { if ($fuser->rights->expedition->{$lire} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->expedition->dir_output.'/sending/temp/massgeneration/'.$user->id.'/'.$original_file; + $original_file = $conf->expedition->dir_output.'/sending/temp/massgeneration/'.$user->id.'/'.$original_file; } elseif ($modulepart == 'massfilesarea_invoices') { if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->facture->multidir_output[$entity].'/temp/massgeneration/'.$user->id.'/'.$original_file; + $original_file = $conf->facture->multidir_output[$entity].'/temp/massgeneration/'.$user->id.'/'.$original_file; } elseif ($modulepart == 'massfilesarea_expensereport') { if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->expensereport->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; + $original_file = $conf->expensereport->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; } elseif ($modulepart == 'massfilesarea_interventions') { if ($fuser->rights->ficheinter->{$lire} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->ficheinter->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; + $original_file = $conf->ficheinter->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; } elseif ($modulepart == 'massfilesarea_supplier_proposal' && !empty($conf->supplier_proposal->dir_output)) { if ($fuser->rights->supplier_proposal->{$lire} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->supplier_proposal->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; + $original_file = $conf->supplier_proposal->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; } elseif ($modulepart == 'massfilesarea_supplier_order') { if ($fuser->rights->fournisseur->commande->{$lire} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->fournisseur->commande->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; + $original_file = $conf->fournisseur->commande->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; } elseif ($modulepart == 'massfilesarea_supplier_invoice') { if ($fuser->rights->fournisseur->facture->{$lire} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->fournisseur->facture->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; + $original_file = $conf->fournisseur->facture->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; } elseif ($modulepart == 'massfilesarea_contract' && !empty($conf->contrat->dir_output)) { if ($fuser->rights->contrat->{$lire} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->contrat->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; + $original_file = $conf->contrat->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; } // Wrapping for interventions @@ -2634,9 +2634,9 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, { if ($fuser->rights->commande->{$lire} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->commande->multidir_output[$entity].'/'.$original_file; + $original_file = $conf->commande->multidir_output[$entity].'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."commande WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; } @@ -2676,9 +2676,9 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, { if ($fuser->rights->fournisseur->facture->{$lire} || preg_match('/^specimen/i', $original_file)) { - $accessallowed=1; + $accessallowed = 1; } - $original_file=$conf->fournisseur->facture->dir_output.'/'.$original_file; + $original_file = $conf->fournisseur->facture->dir_output.'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."facture_fourn WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; } // Wrapping pour les rapport de paiements diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 4d105e0074e..98d636e97dd 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -2627,7 +2627,7 @@ function price2fec($amount) global $conf; // Clean parameters - if (empty($amount)) $amount=0; // To have a numeric value if amount not defined or = '' + if (empty($amount)) $amount = 0; // To have a numeric value if amount not defined or = '' $amount = (is_numeric($amount) ? $amount : 0); // Check if amount is numeric, for example, an error occured when amount value = o (letter) instead 0 (number) // Output decimal number by default diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index a5ba08bb139..4be26bc4c50 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -2157,7 +2157,7 @@ function pdf_getLinkedObjects($object, $outputlangs) elseif ($objecttype == 'fichinter') { $outputlangs->load('interventions'); - foreach($objects as $elementobject) + foreach ($objects as $elementobject) { $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("InterRef"); $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref); diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index 26e97499482..6542b774208 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -34,9 +34,9 @@ */ function dol_getwebuser($mode) { - $t='?'; - if ($mode=='user') $t=getenv('APACHE_RUN_USER'); // $_ENV['APACHE_RUN_USER'] is empty - if ($mode=='group') $t=getenv('APACHE_RUN_GROUP'); + $t = '?'; + if ($mode == 'user') $t = getenv('APACHE_RUN_USER'); // $_ENV['APACHE_RUN_USER'] is empty + if ($mode == 'group') $t = getenv('APACHE_RUN_GROUP'); return $t; } @@ -52,11 +52,11 @@ function dol_getwebuser($mode) */ function checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $authmode, $context = '') { - global $conf,$langs; + global $conf, $langs; //global $dolauthmode; // To return authentication finally used // Check parameters - if ($entitytotest == '') $entitytotest=1; + if ($entitytotest == '') $entitytotest = 1; dol_syslog("checkLoginPassEntity usertotest=".$usertotest." entitytotest=".$entitytotest." authmode=".join(',', $authmode)); $login = ''; @@ -64,42 +64,42 @@ function checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $auth // Validation of login/pass/entity with standard modules if (empty($login)) { - $test=true; - foreach($authmode as $mode) + $test = true; + foreach ($authmode as $mode) { - if ($test && $mode && ! $login) + if ($test && $mode && !$login) { // Validation of login/pass/entity for mode $mode - $mode=trim($mode); - $authfile='functions_'.$mode.'.php'; - $fullauthfile=''; + $mode = trim($mode); + $authfile = 'functions_'.$mode.'.php'; + $fullauthfile = ''; - $dirlogin=array_merge(array("/core/login"), (array) $conf->modules_parts['login']); - foreach($dirlogin as $reldir) + $dirlogin = array_merge(array("/core/login"), (array) $conf->modules_parts['login']); + foreach ($dirlogin as $reldir) { - $dir=dol_buildpath($reldir, 0); - $newdir=dol_osencode($dir); + $dir = dol_buildpath($reldir, 0); + $newdir = dol_osencode($dir); // Check if file found (do not use dol_is_file to avoid loading files.lib.php) - $tmpnewauthfile = $newdir.(preg_match('/\/$/', $newdir)?'':'/').$authfile; - if (is_file($tmpnewauthfile)) $fullauthfile=$tmpnewauthfile; + $tmpnewauthfile = $newdir.(preg_match('/\/$/', $newdir) ? '' : '/').$authfile; + if (is_file($tmpnewauthfile)) $fullauthfile = $tmpnewauthfile; } - $result=false; - if ($fullauthfile) $result=include_once $fullauthfile; + $result = false; + if ($fullauthfile) $result = include_once $fullauthfile; if ($fullauthfile && $result) { // Call function to check user/password - $function='check_user_password_'.$mode; - $login=call_user_func($function, $usertotest, $passwordtotest, $entitytotest, $context); + $function = 'check_user_password_'.$mode; + $login = call_user_func($function, $usertotest, $passwordtotest, $entitytotest, $context); if ($login) // Login is successfull { - $test=false; // To stop once at first login success - $conf->authmode=$mode; // This properties is defined only when logged to say what mode was successfully used - $dol_tz=GETPOST('tz'); - $dol_dst=GETPOST('dst'); - $dol_screenwidth=GETPOST('screenwidth'); - $dol_screenheight=GETPOST('screenheight'); + $test = false; // To stop once at first login success + $conf->authmode = $mode; // This properties is defined only when logged to say what mode was successfully used + $dol_tz = GETPOST('tz'); + $dol_dst = GETPOST('dst'); + $dol_screenwidth = GETPOST('screenwidth'); + $dol_screenheight = GETPOST('screenheight'); } } else @@ -109,7 +109,7 @@ function checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $auth // Load translation files required by the page $langs->loadLangs(array('other', 'main', 'errors')); - $_SESSION["dol_loginmesg"]=$langs->trans("ErrorFailedToLoadLoginFileForMode", $mode); + $_SESSION["dol_loginmesg"] = $langs->trans("ErrorFailedToLoadLoginFileForMode", $mode); } } } @@ -119,7 +119,7 @@ function checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $auth } -if (! function_exists('dol_loginfunction')) +if (!function_exists('dol_loginfunction')) { /** * Show Dolibarr default login page. @@ -135,22 +135,22 @@ if (! function_exists('dol_loginfunction')) global $dolibarr_main_demo, $db; global $hookmanager; - $langs->loadLangs(array("main","other","help","admin")); + $langs->loadLangs(array("main", "other", "help", "admin")); // Instantiate hooks of thirdparty module only if not already define $hookmanager->initHooks(array('mainloginpage')); - $main_authentication=$conf->file->main_authentication; + $main_authentication = $conf->file->main_authentication; - $session_name=session_name(); // Get current session name + $session_name = session_name(); // Get current session name $dol_url_root = DOL_URL_ROOT; // Title - $appli=constant('DOL_APPLICATION_TITLE'); - $title=$appli.' '.constant('DOL_VERSION'); - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$conf->global->MAIN_APPLICATION_TITLE; - $titletruedolibarrversion=constant('DOL_VERSION'); // $title used by login template after the @ to inform of true Dolibarr version + $appli = constant('DOL_APPLICATION_TITLE'); + $title = $appli.' '.constant('DOL_VERSION'); + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $title = $conf->global->MAIN_APPLICATION_TITLE; + $titletruedolibarrversion = constant('DOL_VERSION'); // $title used by login template after the @ to inform of true Dolibarr version // Note: $conf->css looks like '/theme/eldy/style.css.php' /* @@ -171,13 +171,13 @@ if (! function_exists('dol_loginfunction')) */ // Select templates dir - if (! empty($conf->modules_parts['tpl'])) // Using this feature slow down application + if (!empty($conf->modules_parts['tpl'])) // Using this feature slow down application { - $dirtpls=array_merge($conf->modules_parts['tpl'], array('/core/tpl/')); - foreach($dirtpls as $reldir) + $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl/')); + foreach ($dirtpls as $reldir) { - $tmp=dol_buildpath($reldir.'login.tpl.php'); - if (file_exists($tmp)) { $template_dir=preg_replace('/login\.tpl\.php$/', '', $tmp); break; } + $tmp = dol_buildpath($reldir.'login.tpl.php'); + if (file_exists($tmp)) { $template_dir = preg_replace('/login\.tpl\.php$/', '', $tmp); break; } } } else @@ -186,116 +186,116 @@ if (! function_exists('dol_loginfunction')) } // Set cookie for timeout management - $prefix=dol_getprefix(''); - $sessiontimeout='DOLSESSTIMEOUT_'.$prefix; - if (! empty($conf->global->MAIN_SESSION_TIMEOUT)) setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", null, false, true); + $prefix = dol_getprefix(''); + $sessiontimeout = 'DOLSESSTIMEOUT_'.$prefix; + if (!empty($conf->global->MAIN_SESSION_TIMEOUT)) setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", null, false, true); - if (GETPOST('urlfrom', 'alpha')) $_SESSION["urlfrom"]=GETPOST('urlfrom', 'alpha'); + if (GETPOST('urlfrom', 'alpha')) $_SESSION["urlfrom"] = GETPOST('urlfrom', 'alpha'); else unset($_SESSION["urlfrom"]); - if (! GETPOST("username", 'alpha')) $focus_element='username'; - else $focus_element='password'; + if (!GETPOST("username", 'alpha')) $focus_element = 'username'; + else $focus_element = 'password'; - $demologin=''; - $demopassword=''; - if (! empty($dolibarr_main_demo)) + $demologin = ''; + $demopassword = ''; + if (!empty($dolibarr_main_demo)) { - $tab=explode(',', $dolibarr_main_demo); - $demologin=$tab[0]; - $demopassword=$tab[1]; + $tab = explode(',', $dolibarr_main_demo); + $demologin = $tab[0]; + $demopassword = $tab[1]; } // Execute hook getLoginPageOptions (for table) - $parameters=array('entity' => GETPOST('entity', 'int')); - $reshook = $hookmanager->executeHooks('getLoginPageOptions', $parameters); // Note that $action and $object may have been modified by some hooks. + $parameters = array('entity' => GETPOST('entity', 'int')); + $reshook = $hookmanager->executeHooks('getLoginPageOptions', $parameters); // Note that $action and $object may have been modified by some hooks. $morelogincontent = $hookmanager->resPrint; // Execute hook getLoginPageExtraOptions (eg for js) - $parameters=array('entity' => GETPOST('entity', 'int')); - $reshook = $hookmanager->executeHooks('getLoginPageExtraOptions', $parameters); // Note that $action and $object may have been modified by some hooks. + $parameters = array('entity' => GETPOST('entity', 'int')); + $reshook = $hookmanager->executeHooks('getLoginPageExtraOptions', $parameters); // Note that $action and $object may have been modified by some hooks. $moreloginextracontent = $hookmanager->resPrint; // Login - $login = (! empty($hookmanager->resArray['username']) ? $hookmanager->resArray['username'] : (GETPOST("username", "alpha") ? GETPOST("username", "alpha") : $demologin)); + $login = (!empty($hookmanager->resArray['username']) ? $hookmanager->resArray['username'] : (GETPOST("username", "alpha") ? GETPOST("username", "alpha") : $demologin)); $password = $demopassword; // Show logo (search in order: small company logo, large company logo, theme logo, common logo) - $width=0; - $urllogo=DOL_URL_ROOT.'/theme/login_logo.png'; + $width = 0; + $urllogo = DOL_URL_ROOT.'/theme/login_logo.png'; - if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) + if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) { - $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_small); + $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_small); } - elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) + elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) { - $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/'.$mysoc->logo); - $width=128; + $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/'.$mysoc->logo); + $width = 128; } elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/dolibarr_logo.png')) { - $urllogo=DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/dolibarr_logo.png'; + $urllogo = DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/dolibarr_logo.png'; } elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.png')) { - $urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo.png'; + $urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.png'; } // Security graphical code - $captcha=0; - $captcha_refresh=''; - if (function_exists("imagecreatefrompng") && ! empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) + $captcha = 0; + $captcha_refresh = ''; + if (function_exists("imagecreatefrompng") && !empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) { - $captcha=1; - $captcha_refresh=img_picto($langs->trans("Refresh"), 'refresh', 'id="captcha_refresh_img"'); + $captcha = 1; + $captcha_refresh = img_picto($langs->trans("Refresh"), 'refresh', 'id="captcha_refresh_img"'); } // Extra link - $forgetpasslink=0; - $helpcenterlink=0; + $forgetpasslink = 0; + $helpcenterlink = 0; if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK) || empty($conf->global->MAIN_HELPCENTER_DISABLELINK)) { if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK)) { - $forgetpasslink=1; + $forgetpasslink = 1; } if (empty($conf->global->MAIN_HELPCENTER_DISABLELINK)) { - $helpcenterlink=1; + $helpcenterlink = 1; } } // Home message - $main_home=''; - if (! empty($conf->global->MAIN_HOME)) + $main_home = ''; + if (!empty($conf->global->MAIN_HOME)) { - $substitutionarray=getCommonSubstitutionArray($langs); + $substitutionarray = getCommonSubstitutionArray($langs); complete_substitutions_array($substitutionarray, $langs); $texttoshow = make_substitutions($conf->global->MAIN_HOME, $substitutionarray, $langs); - $main_home=dol_htmlcleanlastbr($texttoshow); + $main_home = dol_htmlcleanlastbr($texttoshow); } // Google AD - $main_google_ad_client = ((! empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && ! empty($conf->global->MAIN_GOOGLE_AD_SLOT))?1:0); + $main_google_ad_client = ((!empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && !empty($conf->global->MAIN_GOOGLE_AD_SLOT)) ? 1 : 0); // Set jquery theme - $dol_loginmesg = (! empty($_SESSION["dol_loginmesg"])?$_SESSION["dol_loginmesg"]:''); + $dol_loginmesg = (!empty($_SESSION["dol_loginmesg"]) ? $_SESSION["dol_loginmesg"] : ''); $favicon = DOL_URL_ROOT.'/theme/dolibarr_logo_256x256.png'; - if (! empty($mysoc->logo_squarred_mini)) $favicon = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_mini); - if (! empty($conf->global->MAIN_FAVICON_URL)) $favicon=$conf->global->MAIN_FAVICON_URL; + if (!empty($mysoc->logo_squarred_mini)) $favicon = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_mini); + if (!empty($conf->global->MAIN_FAVICON_URL)) $favicon = $conf->global->MAIN_FAVICON_URL; $jquerytheme = 'base'; - if (! empty($conf->global->MAIN_USE_JQUERY_THEME)) $jquerytheme = $conf->global->MAIN_USE_JQUERY_THEME; + if (!empty($conf->global->MAIN_USE_JQUERY_THEME)) $jquerytheme = $conf->global->MAIN_USE_JQUERY_THEME; // Set dol_hide_topmenu, dol_hide_leftmenu, dol_optimize_smallscreen, dol_no_mouse_hover - $dol_hide_topmenu=GETPOST('dol_hide_topmenu', 'int'); - $dol_hide_leftmenu=GETPOST('dol_hide_leftmenu', 'int'); - $dol_optimize_smallscreen=GETPOST('dol_optimize_smallscreen', 'int'); - $dol_no_mouse_hover=GETPOST('dol_no_mouse_hover', 'int'); - $dol_use_jmobile=GETPOST('dol_use_jmobile', 'int'); + $dol_hide_topmenu = GETPOST('dol_hide_topmenu', 'int'); + $dol_hide_leftmenu = GETPOST('dol_hide_leftmenu', 'int'); + $dol_optimize_smallscreen = GETPOST('dol_optimize_smallscreen', 'int'); + $dol_no_mouse_hover = GETPOST('dol_no_mouse_hover', 'int'); + $dol_use_jmobile = GETPOST('dol_use_jmobile', 'int'); // Include login page template include $template_dir.'login.tpl.php'; @@ -316,20 +316,20 @@ if (! function_exists('dol_loginfunction')) function makesalt($type = CRYPT_SALT_LENGTH) { dol_syslog("makesalt type=".$type); - switch($type) + switch ($type) { case 12: // 8 + 4 - $saltlen=8; $saltprefix='$1$'; $saltsuffix='$'; break; + $saltlen = 8; $saltprefix = '$1$'; $saltsuffix = '$'; break; case 8: // 8 (Pour compatibilite, ne devrait pas etre utilise) - $saltlen=8; $saltprefix='$1$'; $saltsuffix='$'; break; + $saltlen = 8; $saltprefix = '$1$'; $saltsuffix = '$'; break; case 2: // 2 default: // by default, fall back on Standard DES (should work everywhere) - $saltlen=2; $saltprefix=''; $saltsuffix=''; break; + $saltlen = 2; $saltprefix = ''; $saltsuffix = ''; break; } - $salt=''; - while(dol_strlen($salt) < $saltlen) $salt.=chr(mt_rand(64, 126)); + $salt = ''; + while (dol_strlen($salt) < $saltlen) $salt .= chr(mt_rand(64, 126)); - $result=$saltprefix.$salt.$saltsuffix; + $result = $saltprefix.$salt.$saltsuffix; dol_syslog("makesalt return=".$result); return $result; } @@ -344,35 +344,35 @@ function encodedecode_dbpassconf($level = 0) { dol_syslog("encodedecode_dbpassconf level=".$level, LOG_DEBUG); $config = ''; - $passwd=''; - $passwd_crypted=''; + $passwd = ''; + $passwd_crypted = ''; if ($fp = fopen(DOL_DOCUMENT_ROOT.'/conf/conf.php', 'r')) { - while(!feof($fp)) + while (!feof($fp)) { $buffer = fgets($fp, 4096); - $lineofpass=0; + $lineofpass = 0; if (preg_match('/^[^#]*dolibarr_main_db_encrypted_pass[\s]*=[\s]*(.*)/i', $buffer, $reg)) // Old way to save crypted value { - $val = trim($reg[1]); // This also remove CR/LF - $val=preg_replace('/^["\']/', '', $val); - $val=preg_replace('/["\'][\s;]*$/', '', $val); - if (! empty($val)) + $val = trim($reg[1]); // This also remove CR/LF + $val = preg_replace('/^["\']/', '', $val); + $val = preg_replace('/["\'][\s;]*$/', '', $val); + if (!empty($val)) { $passwd_crypted = $val; $val = dol_decode($val); $passwd = $val; - $lineofpass=1; + $lineofpass = 1; } } elseif (preg_match('/^[^#]*dolibarr_main_db_pass[\s]*=[\s]*(.*)/i', $buffer, $reg)) { - $val = trim($reg[1]); // This also remove CR/LF - $val=preg_replace('/^["\']/', '', $val); - $val=preg_replace('/["\'][\s;]*$/', '', $val); + $val = trim($reg[1]); // This also remove CR/LF + $val = preg_replace('/^["\']/', '', $val); + $val = preg_replace('/["\'][\s;]*$/', '', $val); if (preg_match('/crypted:/i', $buffer)) { $val = preg_replace('/crypted:/i', '', $val); @@ -386,7 +386,7 @@ function encodedecode_dbpassconf($level = 0) $val = dol_encode($val); $passwd_crypted = $val; } - $lineofpass=1; + $lineofpass = 1; } // Output line @@ -413,7 +413,7 @@ function encodedecode_dbpassconf($level = 0) fclose($fp); // Write new conf file - $file=DOL_DOCUMENT_ROOT.'/conf/conf.php'; + $file = DOL_DOCUMENT_ROOT.'/conf/conf.php'; if ($fp = @fopen($file, 'w')) { fputs($fp, $config); @@ -451,17 +451,17 @@ function encodedecode_dbpassconf($level = 0) */ function getRandomPassword($generic = false, $replaceambiguouschars = null, $length = 32) { - global $db,$conf,$langs,$user; + global $db, $conf, $langs, $user; - $generated_password=''; + $generated_password = ''; if ($generic) { $lowercase = "qwertyuiopasdfghjklzxcvbnm"; $uppercase = "ASDFGHJKLZXCVBNMQWERTYUIOP"; $numbers = "1234567890"; $randomCode = ""; - $nbofchar = round($length/3); - $nbofcharlast = ($length - 2*$nbofchar); + $nbofchar = round($length / 3); + $nbofcharlast = ($length - 2 * $nbofchar); //var_dump($nbofchar.'-'.$nbofcharlast); if (function_exists('random_int')) // Cryptographic random { @@ -478,7 +478,7 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len $randomCode .= $numbers{random_int(0, $max)}; } - $generated_password=str_shuffle($randomCode); + $generated_password = str_shuffle($randomCode); } else // Old platform, non cryptographic random { @@ -495,17 +495,17 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len $randomCode .= $numbers{mt_rand(0, $max)}; } - $generated_password=str_shuffle($randomCode); + $generated_password = str_shuffle($randomCode); } } - elseif (! empty($conf->global->USER_PASSWORD_GENERATED)) + elseif (!empty($conf->global->USER_PASSWORD_GENERATED)) { - $nomclass="modGeneratePass".ucfirst($conf->global->USER_PASSWORD_GENERATED); - $nomfichier=$nomclass.".class.php"; + $nomclass = "modGeneratePass".ucfirst($conf->global->USER_PASSWORD_GENERATED); + $nomfichier = $nomclass.".class.php"; //print DOL_DOCUMENT_ROOT."/core/modules/security/generate/".$nomclass; require_once DOL_DOCUMENT_ROOT."/core/modules/security/generate/".$nomfichier; - $genhandler=new $nomclass($db, $conf, $langs, $user); - $generated_password=$genhandler->getNewGeneratedPassword(); + $genhandler = new $nomclass($db, $conf, $langs, $user); + $generated_password = $genhandler->getNewGeneratedPassword(); unset($genhandler); } @@ -516,11 +516,11 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len $max = strlen($numbers) - 1; if (function_exists('random_int')) // Cryptographic random { - $generated_password=str_replace($replaceambiguouschars, $numbers{random_int(0, $max)}, $generated_password); + $generated_password = str_replace($replaceambiguouschars, $numbers{random_int(0, $max)}, $generated_password); } else { - $generated_password=str_replace($replaceambiguouschars, $numbers{mt_rand(0, $max)}, $generated_password); + $generated_password = str_replace($replaceambiguouschars, $numbers{mt_rand(0, $max)}, $generated_password); } } diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index e8a09515d91..aabc538db41 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -128,7 +128,7 @@ class pdf_einstein extends ModelePDFCommandes */ public function __construct($db) { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; // Translations $langs->loadLangs(array("main", "bills", "products")); @@ -136,70 +136,70 @@ class pdf_einstein extends ModelePDFCommandes $this->db = $db; $this->name = "einstein"; $this->description = $langs->trans('PDFEinsteinDescription'); - $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template + $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template // Dimension page $this->type = 'pdf'; - $formatarray=pdf_getFormat(); + $formatarray = pdf_getFormat(); $this->page_largeur = $formatarray['width']; $this->page_hauteur = $formatarray['height']; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; - $this->option_logo = 1; // Display logo - $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION - $this->option_modereg = 1; // Display payment mode - $this->option_condreg = 1; // Display payment terms - $this->option_codeproduitservice = 1; // Display product-service code - $this->option_multilang = 1; // Available in several languages - $this->option_escompte = 0; // Displays if there has been a discount - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 1; // Support add of a watermark on drafts + $this->option_logo = 1; // Display logo + $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION + $this->option_modereg = 1; // Display payment mode + $this->option_condreg = 1; // Display payment terms + $this->option_codeproduitservice = 1; // Display product-service code + $this->option_multilang = 1; // Available in several languages + $this->option_escompte = 0; // Displays if there has been a discount + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 1; // Support add of a watermark on drafts // Get source company - $this->emetteur=$mysoc; - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default, if was not defined + $this->emetteur = $mysoc; + if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined // Define position of columns - $this->posxdesc=$this->marge_gauche+1; - if($conf->global->PRODUCT_USE_UNITS) + $this->posxdesc = $this->marge_gauche + 1; + if ($conf->global->PRODUCT_USE_UNITS) { - $this->posxtva=101; - $this->posxup=118; - $this->posxqty=135; - $this->posxunit=151; + $this->posxtva = 101; + $this->posxup = 118; + $this->posxqty = 135; + $this->posxunit = 151; } else { - $this->posxtva=110; - $this->posxup=126; - $this->posxqty=145; - $this->posxunit=162; + $this->posxtva = 110; + $this->posxup = 126; + $this->posxqty = 145; + $this->posxunit = 162; } - $this->posxdiscount=162; - $this->postotalht=174; - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup; - $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images + $this->posxdiscount = 162; + $this->postotalht = 174; + if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva = $this->posxup; + $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images if ($this->page_largeur < 210) // To work with US executive format { - $this->posxpicture-=20; - $this->posxtva-=20; - $this->posxup-=20; - $this->posxqty-=20; - $this->posxunit-=20; - $this->posxdiscount-=20; - $this->postotalht-=20; + $this->posxpicture -= 20; + $this->posxtva -= 20; + $this->posxup -= 20; + $this->posxqty -= 20; + $this->posxunit -= 20; + $this->posxdiscount -= 20; + $this->postotalht -= 20; } - $this->tva=array(); - $this->localtax1=array(); - $this->localtax2=array(); - $this->atleastoneratenotnull=0; - $this->atleastonediscount=0; + $this->tva = array(); + $this->localtax1 = array(); + $this->localtax2 = array(); + $this->atleastoneratenotnull = 0; + $this->atleastonediscount = 0; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -219,9 +219,9 @@ class pdf_einstein extends ModelePDFCommandes // phpcs:enable global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines; - if (! is_object($outputlangs)) $outputlangs=$langs; + if (!is_object($outputlangs)) $outputlangs = $langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; // Load translation files required by the page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries")); @@ -238,20 +238,20 @@ class pdf_einstein extends ModelePDFCommandes if ($object->specimen) { $dir = $conf->commande->multidir_output[$conf->entity]; - $file = $dir . "/SPECIMEN.pdf"; + $file = $dir."/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); - $dir = $conf->commande->multidir_output[$object->entity] . "/" . $objectref; - $file = $dir . "/" . $objectref . ".pdf"; + $dir = $conf->commande->multidir_output[$object->entity]."/".$objectref; + $file = $dir."/".$objectref.".pdf"; } - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } @@ -259,25 +259,25 @@ class pdf_einstein extends ModelePDFCommandes if (file_exists($dir)) { // Add pdfgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks // Create pdf instance - $pdf=pdf_getInstance($this->format); - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance + $pdf = pdf_getInstance($this->format); + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $pdf->SetAutoPageBreak(1, 0); - $heightforinfotot = 40; // Height reserved to output the info and total part - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; + $heightforinfotot = 40; // Height reserved to output the info and total part + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; if (class_exists('TCPDF')) { @@ -286,14 +286,14 @@ class pdf_einstein extends ModelePDFCommandes } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); } $pdf->Open(); - $pagenb=0; + $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); @@ -301,12 +301,12 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfOrderTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right // Set $this->atleastonediscount if you have at least one discount - for ($i = 0 ; $i < $nblines ; $i++) + for ($i = 0; $i < $nblines; $i++) { if ($object->lines[$i]->remise_percent) { @@ -316,27 +316,27 @@ class pdf_einstein extends ModelePDFCommandes if (empty($this->atleastonediscount)) { $delta = ($this->postotalht - $this->posxdiscount); - $this->posxpicture+=$delta; - $this->posxtva+=$delta; - $this->posxup+=$delta; - $this->posxqty+=$delta; - $this->posxunit+=$delta; - $this->posxdiscount+=$delta; + $this->posxpicture += $delta; + $this->posxtva += $delta; + $this->posxup += $delta; + $this->posxqty += $delta; + $this->posxunit += $delta; + $this->posxdiscount += $delta; // post of fields after are not modified, stay at same position } // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); - $tab_top = 90+$top_shift; - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10); + $tab_top = 90 + $top_shift; + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); // Incoterm if ($conf->incoterm->enabled) @@ -347,50 +347,50 @@ class pdf_einstein extends ModelePDFCommandes $tab_top -= 2; $pdf->SetFont('', '', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); $nexY = $pdf->GetY(); - $height_incoterms=$nexY-$tab_top; + $height_incoterms = $nexY - $tab_top; // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); - $tab_top = $nexY+6; + $tab_top = $nexY + 6; } } // Displays notes - $notetoshow=empty($object->note_public)?'':$object->note_public; - if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) + $notetoshow = empty($object->note_public) ? '' : $object->note_public; + if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) { // Get first sale rep if (is_object($object->thirdparty)) { - $salereparray=$object->thirdparty->getSalesRepresentatives($user); - $salerepobj=new User($this->db); + $salereparray = $object->thirdparty->getSalesRepresentatives($user); + $salerepobj = new User($this->db); $salerepobj->fetch($salereparray[0]['id']); - if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); + if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature); } } if ($notetoshow) { $tab_top -= 2; - $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); + $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object); complete_substitutions_array($substitutionarray, $outputlangs, $object); $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($notetoshow), 0, 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($notetoshow), 0, 1); $nexY = $pdf->GetY(); - $height_note=$nexY-$tab_top; + $height_note = $nexY - $tab_top; // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); - $tab_top = $nexY+6; + $tab_top = $nexY + 6; } $iniY = $tab_top + 7; @@ -398,156 +398,156 @@ class pdf_einstein extends ModelePDFCommandes $nexY = $tab_top + 7; // Loop on each lines - for ($i = 0 ; $i < $nblines ; $i++) + for ($i = 0; $i < $nblines; $i++) { $curY = $nexY; - $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0, 0, 0); $pdf->setTopMargin($tab_top_newpage); - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. - $pageposbefore=$pdf->getPage(); + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $pageposbefore = $pdf->getPage(); // Description of product line - $curX = $this->posxdesc-1; + $curX = $this->posxdesc - 1; - $showpricebeforepagebreak=1; + $showpricebeforepagebreak = 1; $pdf->startTransaction(); - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva-$curX, 3, $curX, $curY, $hideref, $hidedesc); - $pageposafter=$pdf->getPage(); + pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc); + $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { $pdf->rollbackTransaction(true); - $pageposafter=$pageposbefore; + $pageposafter = $pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva-$curX, 4, $curX, $curY, $hideref, $hidedesc); - $pageposafter=$pdf->getPage(); - $posyafter=$pdf->GetY(); - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc); + $pageposafter = $pdf->getPage(); + $posyafter = $pdf->GetY(); + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text { - if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page + if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page { $pdf->AddPage('', '', true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposafter+1); + $pdf->setPage($pageposafter + 1); } } else { // We found a page break - $showpricebeforepagebreak=0; + $showpricebeforepagebreak = 0; } } else // No pagebreak { $pdf->commitTransaction(); } - $posYAfterDescription=$pdf->GetY(); + $posYAfterDescription = $pdf->GetY(); $nexY = $pdf->GetY(); - $pageposafter=$pdf->getPage(); + $pageposafter = $pdf->getPage(); $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. // We suppose that a too long description is moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { $pdf->setPage($pageposafter); $curY = $tab_top_newpage; } - $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font + $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font // VAT Rate if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) { $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); - $pdf->SetXY($this->posxtva-5, $curY); - $pdf->MultiCell($this->posxup-$this->posxtva+4, 3, $vat_rate, 0, 'R'); + $pdf->SetXY($this->posxtva - 5, $curY); + $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0, 'R'); } // Unit price before discount $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxup, $curY); - $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0); + $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0, 'R', 0); // Quantity $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxqty, $curY); - $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R'); // Enough for 6 chars + $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); // Enough for 6 chars // Unit - if($conf->global->PRODUCT_USE_UNITS) + if ($conf->global->PRODUCT_USE_UNITS) { $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); $pdf->SetXY($this->posxunit, $curY); - $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L'); + $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L'); } // Discount on line $pdf->SetXY($this->posxdiscount, $curY); if ($object->lines[$i]->remise_percent) { - $pdf->SetXY($this->posxdiscount-2, $curY); + $pdf->SetXY($this->posxdiscount - 2, $curY); $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); - $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R'); + $pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0, 'R'); } // Total HT line $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->postotalht, $curY); - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0); // Collection of totals by value of vat in $this->vat["rate"] = total_tva - if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; - else $tvaligne=$object->lines[$i]->total_tva; + if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva; + else $tvaligne = $object->lines[$i]->total_tva; - $localtax1ligne=$object->lines[$i]->total_localtax1; - $localtax2ligne=$object->lines[$i]->total_localtax2; - $localtax1_rate=$object->lines[$i]->localtax1_tx; - $localtax2_rate=$object->lines[$i]->localtax2_tx; - $localtax1_type=$object->lines[$i]->localtax1_type; - $localtax2_type=$object->lines[$i]->localtax2_type; + $localtax1ligne = $object->lines[$i]->total_localtax1; + $localtax2ligne = $object->lines[$i]->total_localtax2; + $localtax1_rate = $object->lines[$i]->localtax1_tx; + $localtax2_rate = $object->lines[$i]->localtax2_tx; + $localtax1_type = $object->lines[$i]->localtax1_type; + $localtax2_type = $object->lines[$i]->localtax2_type; - if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; - if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; - if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; + if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100; + if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100; + if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100; - $vatrate=(string) $object->lines[$i]->tva_tx; + $vatrate = (string) $object->lines[$i]->tva_tx; // Retrieve type from database for backward compatibility with old records - if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined - && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax + if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined + && (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax { - $localtaxtmp_array=getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc); + $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc); $localtax1_type = $localtaxtmp_array[0]; $localtax2_type = $localtaxtmp_array[2]; } // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0) - $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; + $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; if ($localtax2_type && $localtax2ligne != 0) - $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; + $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; - if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; - if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; + if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*'; + if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0; $this->tva[$vatrate] += $tvaligne; // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) + if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { $pdf->setPage($pageposafter); - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); + $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); + $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1); $pdf->SetLineStyle(array('dash'=>0)); } - $nexY+=2; // Add space between lines + $nexY += 2; // Add space between lines // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) @@ -564,10 +564,10 @@ class pdf_einstein extends ModelePDFCommandes $this->_pagefoot($pdf, $object, $outputlangs, 1); $pagenb++; $pdf->setPage($pagenb); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { @@ -580,7 +580,7 @@ class pdf_einstein extends ModelePDFCommandes $this->_pagefoot($pdf, $object, $outputlangs, 1); // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } @@ -591,13 +591,13 @@ class pdf_einstein extends ModelePDFCommandes $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); else $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; // Affiche zone infos - $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); + $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); // Affiche zone totaux - $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); + $posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); // Affiche zone versements /* @@ -617,31 +617,31 @@ class pdf_einstein extends ModelePDFCommandes // Add pdfgeneration hook $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { $this->error = $hookmanager->error; $this->errors = $hookmanager->errors; } - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); $this->result = array('fullpath'=>$file); - return 1; // No error + return 1; // No error } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } else { - $this->error=$langs->transnoentities("ErrorConstantNotDefined", "COMMANDE_OUTPUTDIR"); + $this->error = $langs->transnoentities("ErrorConstantNotDefined", "COMMANDE_OUTPUTDIR"); return 0; } } @@ -688,10 +688,10 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetXY($this->marge_gauche, $posy); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); - $posy=$pdf->GetY()+4; + $posy = $pdf->GetY() + 4; } - $posxval=52; + $posxval = 52; // Show payments conditions if ($object->cond_reglement_code || $object->cond_reglement) @@ -703,11 +703,11 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); - $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc); - $lib_condition_paiement=str_replace('\n', "\n", $lib_condition_paiement); + $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc); + $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); $pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L'); - $posy=$pdf->GetY()+3; + $posy = $pdf->GetY() + 3; } // Check a payment mode is defined @@ -738,7 +738,7 @@ class pdf_einstein extends ModelePDFCommandes }*/ // Show planed date of delivery - if (! empty($object->date_livraison)) + if (!empty($object->date_livraison)) { $outputlangs->load("sendings"); $pdf->SetFont('', 'B', $default_font_size - 2); @@ -747,10 +747,10 @@ class pdf_einstein extends ModelePDFCommandes $pdf->MultiCell(80, 4, $titre, 0, 'L'); $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); - $dlp=dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true); + $dlp = dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true); $pdf->MultiCell(80, 4, $dlp, 0, 'L'); - $posy=$pdf->GetY()+1; + $posy = $pdf->GetY() + 1; } elseif ($object->availability_code || $object->availability) // Show availability conditions { @@ -761,11 +761,11 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); - $lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset(isset($object->availability)?$object->availability:''); - $lib_availability=str_replace('\n', "\n", $lib_availability); + $lib_availability = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != ('AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(isset($object->availability) ? $object->availability : ''); + $lib_availability = str_replace('\n', "\n", $lib_availability); $pdf->MultiCell(80, 4, $lib_availability, 0, 'L'); - $posy=$pdf->GetY()+1; + $posy = $pdf->GetY() + 1; } // Show payment mode @@ -779,17 +779,17 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); - $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement); + $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); - $posy=$pdf->GetY()+2; + $posy = $pdf->GetY() + 2; } // Show payment mode CHQ if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') { // Si mode reglement non force ou si force a CHQ - if (! empty($conf->global->FACTURE_CHQ_NUMBER)) + if (!empty($conf->global->FACTURE_CHQ_NUMBER)) { if ($conf->global->FACTURE_CHQ_NUMBER > 0) { @@ -799,14 +799,14 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', 'B', $default_font_size - 3); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0); - $posy=$pdf->GetY()+1; + $posy = $pdf->GetY() + 1; if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', '', $default_font_size - 3); $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0); - $posy=$pdf->GetY()+2; + $posy = $pdf->GetY() + 2; } } if ($conf->global->FACTURE_CHQ_NUMBER == -1) @@ -814,14 +814,14 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', 'B', $default_font_size - 3); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0); - $posy=$pdf->GetY()+1; + $posy = $pdf->GetY() + 1; if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', '', $default_font_size - 3); $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0); - $posy=$pdf->GetY()+2; + $posy = $pdf->GetY() + 2; } } } @@ -830,19 +830,19 @@ class pdf_einstein extends ModelePDFCommandes // If payment mode not forced or forced to VIR, show payment with BAN if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') { - if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER)) + if (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER)) { - $bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account); - if (! empty($object->fk_bank)) $bankid=$object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank + $bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account); + if (!empty($object->fk_bank)) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank $account = new Account($this->db); $account->fetch($bankid); - $curx=$this->marge_gauche; - $cury=$posy; + $curx = $this->marge_gauche; + $cury = $posy; - $posy=pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size); + $posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size); - $posy+=2; + $posy += 2; } } @@ -864,7 +864,7 @@ class pdf_einstein extends ModelePDFCommandes protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { // phpcs:enable - global $conf,$mysoc; + global $conf, $mysoc; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -876,32 +876,32 @@ class pdf_einstein extends ModelePDFCommandes $col1x = 120; $col2x = 170; if ($this->page_largeur < 210) // To work with US executive format { - $col2x-=20; + $col2x -= 20; } $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); - $useborder=0; + $useborder = 0; $index = 0; // Total HT $pdf->SetFillColor(255, 255, 255); $pdf->SetXY($col1x, $tab2_top + 0); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht); $pdf->SetXY($col2x, $tab2_top + 0); - $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1); // Show VAT by rates and total $pdf->SetFillColor(248, 248, 248); $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; - $this->atleastoneratenotnull=0; + $this->atleastoneratenotnull = 0; if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { - $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false); - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) + $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false); + if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) { // Nothing to do } @@ -910,27 +910,27 @@ class pdf_einstein extends ModelePDFCommandes //Local tax 1 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ - foreach($this->localtax1 as $localtax_type => $localtax_rate) + foreach ($this->localtax1 as $localtax_type => $localtax_rate) { - if (in_array((string) $localtax_type, array('1','3','5'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + if (in_array((string) $localtax_type, array('1', '3', '5'))) continue; + foreach ($localtax_rate as $tvakey => $tvaval) { - if ($tvakey!=0) // On affiche pas taux 0 + if ($tvakey != 0) // On affiche pas taux 0 { //$this->atleastoneratenotnull++; $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); @@ -941,27 +941,27 @@ class pdf_einstein extends ModelePDFCommandes //Local tax 2 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //{ - foreach($this->localtax2 as $localtax_type => $localtax_rate) + foreach ($this->localtax2 as $localtax_type => $localtax_rate) { - if (in_array((string) $localtax_type, array('1','3','5'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + if (in_array((string) $localtax_type, array('1', '3', '5'))) continue; + foreach ($localtax_rate as $tvakey => $tvaval) { - if ($tvakey!=0) // On affiche pas taux 0 + if ($tvakey != 0) // On affiche pas taux 0 { //$this->atleastoneratenotnull++; $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); @@ -970,7 +970,7 @@ class pdf_einstein extends ModelePDFCommandes } //} // VAT - foreach($this->tva as $tvakey => $tvaval) + foreach ($this->tva as $tvakey => $tvaval) { if ($tvakey != 0) // On affiche pas taux 0 { @@ -979,15 +979,15 @@ class pdf_einstein extends ModelePDFCommandes $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } - $totalvat =$outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; - $totalvat.=vatrate($tvakey, 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; + $totalvat .= vatrate($tvakey, 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); @@ -997,11 +997,11 @@ class pdf_einstein extends ModelePDFCommandes //Local tax 1 after VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ - foreach($this->localtax1 as $localtax_type => $localtax_rate) + foreach ($this->localtax1 as $localtax_type => $localtax_rate) { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; + if (in_array((string) $localtax_type, array('2', '4', '6'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + foreach ($localtax_rate as $tvakey => $tvaval) { if ($tvakey != 0) // On affiche pas taux 0 { @@ -1010,16 +1010,16 @@ class pdf_einstein extends ModelePDFCommandes $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } @@ -1029,11 +1029,11 @@ class pdf_einstein extends ModelePDFCommandes //Local tax 2 after VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //{ - foreach($this->localtax2 as $localtax_type => $localtax_rate) + foreach ($this->localtax2 as $localtax_type => $localtax_rate) { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; + if (in_array((string) $localtax_type, array('2', '4', '6'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + foreach ($localtax_rate as $tvakey => $tvaval) { if ($tvakey != 0) // On affiche pas taux 0 { @@ -1042,16 +1042,16 @@ class pdf_einstein extends ModelePDFCommandes $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); @@ -1065,7 +1065,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetTextColor(0, 0, 60); $pdf->SetFillColor(224, 224, 224); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1); @@ -1074,13 +1074,13 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetTextColor(0, 0, 0); - $creditnoteamount=0; - $depositsamount=0; + $creditnoteamount = 0; + $depositsamount = 0; //$creditnoteamount=$object->getSumCreditNotesUsed(); //$depositsamount=$object->getSumDepositsUsed(); //print "x".$creditnoteamount."-".$depositsamount;exit; $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); - if (! empty($object->paye)) $resteapayer=0; + if (!empty($object->paye)) $resteapayer = 0; if ($deja_regle > 0) { @@ -1088,7 +1088,7 @@ class pdf_einstein extends ModelePDFCommandes $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0); @@ -1096,7 +1096,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetTextColor(0, 0, 60); $pdf->SetFillColor(224, 224, 224); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1); @@ -1128,8 +1128,8 @@ class pdf_einstein extends ModelePDFCommandes global $conf; // Force to disable hidetop and hidebottom - $hidebottom=0; - if ($hidetop) $hidetop=-1; + $hidebottom = 0; + if ($hidetop) $hidetop = -1; $currency = !empty($currency) ? $currency : $conf->currency; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -1141,52 +1141,52 @@ class pdf_einstein extends ModelePDFCommandes if (empty($hidetop)) { $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; - if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); + if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); } $pdf->SetDrawColor(128, 128, 128); $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter if (empty($hidetop)) { - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line takes a position y in 2nd parameter and 4th parameter + $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line takes a position y in 2nd parameter and 4th parameter - $pdf->SetXY($this->posxdesc-1, $tab_top+1); + $pdf->SetXY($this->posxdesc - 1, $tab_top + 1); $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L'); } if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) { - $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); + $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxtva-3, $tab_top+1); - $pdf->MultiCell($this->posxup-$this->posxtva+3, 2, $outputlangs->transnoentities("VAT"), '', 'C'); + $pdf->SetXY($this->posxtva - 3, $tab_top + 1); + $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C'); } } - $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); + $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxup-1, $tab_top+1); - $pdf->MultiCell($this->posxqty-$this->posxup-1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C'); + $pdf->SetXY($this->posxup - 1, $tab_top + 1); + $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C'); } - $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); + $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxqty-1, $tab_top+1); - $pdf->MultiCell($this->posxunit-$this->posxqty-1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); + $pdf->SetXY($this->posxqty - 1, $tab_top + 1); + $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); } - if($conf->global->PRODUCT_USE_UNITS) { + if ($conf->global->PRODUCT_USE_UNITS) { $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxunit - 1, $tab_top + 1); @@ -1194,13 +1194,13 @@ class pdf_einstein extends ModelePDFCommandes } } - $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); + $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height); if (empty($hidetop)) { if ($this->atleastonediscount) { - $pdf->SetXY($this->posxdiscount-1, $tab_top+1); - $pdf->MultiCell($this->postotalht-$this->posxdiscount+1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C'); + $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1); + $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C'); } } @@ -1210,7 +1210,7 @@ class pdf_einstein extends ModelePDFCommandes } if (empty($hidetop)) { - $pdf->SetXY($this->postotalht-1, $tab_top+1); + $pdf->SetXY($this->postotalht - 1, $tab_top + 1); $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C'); } } @@ -1230,7 +1230,7 @@ class pdf_einstein extends ModelePDFCommandes protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "PdfOrderTitle") { // phpcs:enable - global $conf,$langs,$hookmanager; + global $conf, $langs, $hookmanager; // Load traductions files required by page $outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies")); @@ -1240,7 +1240,7 @@ class pdf_einstein extends ModelePDFCommandes pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); // Show Draft Watermark - if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) ) + if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK))) { pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK); } @@ -1248,8 +1248,8 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); - $posy=$this->marge_haute; - $posx=$this->page_largeur-$this->marge_droite-100; + $posy = $this->marge_haute; + $posx = $this->page_largeur - $this->marge_droite - 100; $pdf->SetXY($this->marge_gauche, $posy); @@ -1259,7 +1259,7 @@ class pdf_einstein extends ModelePDFCommandes if ($this->emetteur->logo) { $logodir = $conf->mycompany->dir_output; - if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity]; + if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity]; if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; @@ -1269,20 +1269,20 @@ class pdf_einstein extends ModelePDFCommandes } if (is_readable($logo)) { - $height=pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + $height = pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) } else { $pdf->SetTextColor(200, 0, 0); - $pdf->SetFont('', 'B', $default_font_size -2); + $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); } } else { - $text=$this->emetteur->name; + $text = $this->emetteur->name; $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } } @@ -1290,56 +1290,56 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $title=$outputlangs->transnoentities($titlekey); + $title = $outputlangs->transnoentities($titlekey); $pdf->MultiCell(100, 3, $title, '', 'R'); $pdf->SetFont('', 'B', $default_font_size); - $posy+=5; + $posy += 5; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R'); + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R'); - $posy+=1; + $posy += 1; $pdf->SetFont('', '', $default_font_size - 1); if ($object->ref_client) { - $posy+=5; + $posy += 5; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); } - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R'); - if (!empty($conf->global->DOC_SHOW_CUSTOMER_CODE) && ! empty($object->thirdparty->code_client)) + if (!empty($conf->global->DOC_SHOW_CUSTOMER_CODE) && !empty($object->thirdparty->code_client)) { - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); } // Get contact if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) { - $arrayidcontact=$object->getIdContact('internal', 'SALESREPFOLL'); + $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); if (count($arrayidcontact) > 0) { - $usertmp=new User($this->db); + $usertmp = new User($this->db); $usertmp->fetch($arrayidcontact[0]); - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); } } - $posy+=2; + $posy += 2; $top_shift = 0; // Show list of linked objects @@ -1353,28 +1353,28 @@ class pdf_einstein extends ModelePDFCommandes if ($showaddress) { // Sender properties - $carac_emetteur=''; + $carac_emetteur = ''; // Add internal contact of proposal if defined - $arrayidcontact=$object->getIdContact('internal', 'SALESREPFOLL'); + $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); if (count($arrayidcontact) > 0) { $object->fetch_user($arrayidcontact[0]); - $labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name")); - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name")); + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; } $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); // Show sender - $posy=42+$top_shift; - $posx=$this->marge_gauche; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; - $hautcadre=40; + $posy = 42 + $top_shift; + $posx = $this->marge_gauche; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80; + $hautcadre = 40; // Show sender frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx, $posy-5); + $pdf->SetXY($posx, $posy - 5); $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); @@ -1382,25 +1382,25 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetTextColor(0, 0, 60); // Show sender name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); - $posy=$pdf->getY(); + $posy = $pdf->getY(); // Show sender information - $pdf->SetXY($posx+2, $posy); + $pdf->SetXY($posx + 2, $posy); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); // If CUSTOMER contact defined on order, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external', 'CUSTOMER'); + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } //Recipient name @@ -1411,26 +1411,26 @@ class pdf_einstein extends ModelePDFCommandes $thirdparty = $object->thirdparty; } - $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); + $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact?$object->contact:''), $usecontact, 'target', $object); + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); // Show recipient - $widthrecbox=100; - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format - $posy=42+$top_shift; - $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; + $widthrecbox = 100; + if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format + $posy = 42 + $top_shift; + $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; // Show recipient frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx+2, $posy-5); + $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L'); $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); // Show recipient name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L'); @@ -1438,7 +1438,7 @@ class pdf_einstein extends ModelePDFCommandes // Show recipient information $pdf->SetFont('', '', $default_font_size - 1); - $pdf->SetXY($posx+2, $posy); + $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); } @@ -1461,7 +1461,7 @@ class pdf_einstein extends ModelePDFCommandes { // phpcs:enable global $conf; - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; return pdf_pagefoot($pdf, $outputlangs, 'ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); } } diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 03730936c0f..cd9f4c9d6a3 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -136,45 +136,45 @@ class pdf_eratosthene extends ModelePDFCommandes $this->db = $db; $this->name = "eratosthene"; $this->description = $langs->trans('PDFEratostheneDescription'); - $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template + $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template // Dimension page $this->type = 'pdf'; - $formatarray=pdf_getFormat(); + $formatarray = pdf_getFormat(); $this->page_largeur = $formatarray['width']; $this->page_hauteur = $formatarray['height']; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; - $this->option_logo = 1; // Display logo - $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION - $this->option_modereg = 1; // Display payment mode - $this->option_condreg = 1; // Display payment terms - $this->option_codeproduitservice = 1; // Display product-service code - $this->option_multilang = 1; // Available in several languages - $this->option_escompte = 0; // Displays if there has been a discount - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 1; // Support add of a watermark on drafts + $this->option_logo = 1; // Display logo + $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION + $this->option_modereg = 1; // Display payment mode + $this->option_condreg = 1; // Display payment terms + $this->option_codeproduitservice = 1; // Display product-service code + $this->option_multilang = 1; // Available in several languages + $this->option_escompte = 0; // Displays if there has been a discount + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 1; // Support add of a watermark on drafts // Get source company - $this->emetteur=$mysoc; - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default, if was not defined + $this->emetteur = $mysoc; + if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined // Define position of columns - $this->posxdesc=$this->marge_gauche+1; + $this->posxdesc = $this->marge_gauche + 1; $this->tabTitleHeight = 5; // default height - $this->tva=array(); - $this->localtax1=array(); - $this->localtax2=array(); - $this->atleastoneratenotnull=0; - $this->atleastonediscount=0; + $this->tva = array(); + $this->localtax1 = array(); + $this->localtax2 = array(); + $this->atleastoneratenotnull = 0; + $this->atleastonediscount = 0; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -194,14 +194,14 @@ class pdf_eratosthene extends ModelePDFCommandes // phpcs:enable global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines; - if (! is_object($outputlangs)) $outputlangs=$langs; + if (!is_object($outputlangs)) $outputlangs = $langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; // Load translation files required by the page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries")); - if (! empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { + if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { global $outputlangsbis; $outputlangsbis = new Translate('', $conf); $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); @@ -210,39 +210,39 @@ class pdf_eratosthene extends ModelePDFCommandes $nblines = count($object->lines); - $hidetop=0; - if(!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)){ - $hidetop=$conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE; + $hidetop = 0; + if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) { + $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE; } // Loop on each lines to detect if there is at least one image to show - $realpatharray=array(); + $realpatharray = array(); $this->atleastonephoto = false; - if (! empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE)) + if (!empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE)) { $objphoto = new Product($this->db); - for ($i = 0 ; $i < $nblines ; $i++) + for ($i = 0; $i < $nblines; $i++) { if (empty($object->lines[$i]->fk_product)) continue; $objphoto->fetch($object->lines[$i]->fk_product); //var_dump($objphoto->ref);exit; - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { - $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product') . $objphoto->id ."/photos/"; - $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product') . dol_sanitizeFileName($objphoto->ref).'/'; + $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; + $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; } else { - $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product') . dol_sanitizeFileName($objphoto->ref).'/'; // default - $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product') . $objphoto->id ."/photos/"; // alternative + $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; // default + $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative } $arephoto = false; foreach ($pdir as $midir) { - if (! $arephoto) + if (!$arephoto) { $dir = $conf->product->dir_output.'/'.$midir; @@ -287,20 +287,20 @@ class pdf_eratosthene extends ModelePDFCommandes if ($object->specimen) { $dir = $conf->commande->multidir_output[$conf->entity]; - $file = $dir . "/SPECIMEN.pdf"; + $file = $dir."/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); - $dir = $conf->commande->multidir_output[$object->entity] . "/" . $objectref; - $file = $dir . "/" . $objectref . ".pdf"; + $dir = $conf->commande->multidir_output[$object->entity]."/".$objectref; + $file = $dir."/".$objectref.".pdf"; } - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } @@ -334,14 +334,14 @@ class pdf_eratosthene extends ModelePDFCommandes } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); } $pdf->Open(); - $pagenb=0; + $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); @@ -364,16 +364,16 @@ class pdf_eratosthene extends ModelePDFCommandes // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); - $tab_top = 90+$top_shift; - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10); + $tab_top = 90 + $top_shift; + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); // Incoterm if ($conf->incoterm->enabled) @@ -384,39 +384,39 @@ class pdf_eratosthene extends ModelePDFCommandes $tab_top -= 2; $pdf->SetFont('', '', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); $nexY = $pdf->GetY(); - $height_incoterms=$nexY-$tab_top; + $height_incoterms = $nexY - $tab_top; // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); - $tab_top = $nexY+6; + $tab_top = $nexY + 6; } } // Displays notes - $notetoshow=empty($object->note_public)?'':$object->note_public; - if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) + $notetoshow = empty($object->note_public) ? '' : $object->note_public; + if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) { // Get first sale rep if (is_object($object->thirdparty)) { - $salereparray=$object->thirdparty->getSalesRepresentatives($user); - $salerepobj=new User($this->db); + $salereparray = $object->thirdparty->getSalesRepresentatives($user); + $salerepobj = new User($this->db); $salerepobj->fetch($salereparray[0]['id']); - if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); + if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature); } } $pagenb = $pdf->getPage(); if ($notetoshow) { - $tab_width = $this->page_largeur-$this->marge_gauche-$this->marge_droite; + $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite; $pageposbeforenote = $pagenb; - $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); + $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object); complete_substitutions_array($substitutionarray, $outputlangs, $object); $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow); @@ -544,85 +544,85 @@ class pdf_eratosthene extends ModelePDFCommandes $nexY = $tab_top + $this->tabTitleHeight + 2; // Loop on each lines - $pageposbeforeprintlines=$pdf->getPage(); + $pageposbeforeprintlines = $pdf->getPage(); $pagenb = $pageposbeforeprintlines; - for ($i = 0 ; $i < $nblines ; $i++) + for ($i = 0; $i < $nblines; $i++) { $curY = $nexY; - $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0, 0, 0); // Define size of image if we need it - $imglinesize=array(); - if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); + $imglinesize = array(); + if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]); $pdf->setTopMargin($tab_top_newpage); - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. - $pageposbefore=$pdf->getPage(); + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $pageposbefore = $pdf->getPage(); // Description of product line - $curX = $this->posxdesc-1; + $curX = $this->posxdesc - 1; - $showpricebeforepagebreak=1; - $posYAfterImage=0; - $posYAfterDescription=0; + $showpricebeforepagebreak = 1; + $posYAfterImage = 0; + $posYAfterDescription = 0; - if($this->getColumnStatus('photo')) + if ($this->getColumnStatus('photo')) { // We start with Photo of product line - if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page + if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // If photo too high, we moved completely on new page { $pdf->AddPage('', '', true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); - $pdf->setPage($pageposbefore+1); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); + $pdf->setPage($pageposbefore + 1); $curY = $tab_top_newpage; - $showpricebeforepagebreak=0; + $showpricebeforepagebreak = 0; } if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) { - $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi + $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi // $pdf->Image does not increase value return by getY, so we save it manually - $posYAfterImage=$curY+$imglinesize['height']; + $posYAfterImage = $curY + $imglinesize['height']; } } - if($this->getColumnStatus('desc')) + if ($this->getColumnStatus('desc')) { $pdf->startTransaction(); pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); - $pageposafter=$pdf->getPage(); + $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { $pdf->rollbackTransaction(true); - $pageposafter=$pageposbefore; + $pageposafter = $pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); - $pageposafter=$pdf->getPage(); - $posyafter=$pdf->GetY(); - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text + $pageposafter = $pdf->getPage(); + $posyafter = $pdf->GetY(); + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text { - if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page + if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page { $pdf->AddPage('', '', true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposafter+1); + $pdf->setPage($pageposafter + 1); } } else { // We found a page break - $showpricebeforepagebreak=0; + $showpricebeforepagebreak = 0; } } else // No pagebreak { $pdf->commitTransaction(); } - $posYAfterDescription=$pdf->GetY(); + $posYAfterDescription = $pdf->GetY(); } @@ -630,18 +630,18 @@ class pdf_eratosthene extends ModelePDFCommandes $nexY = max($pdf->GetY(), $posYAfterImage); - $pageposafter=$pdf->getPage(); + $pageposafter = $pdf->getPage(); $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. // We suppose that a too long description is moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { $pdf->setPage($pageposafter); $curY = $tab_top_newpage; } - $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font + $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font // VAT Rate if ($this->getColumnStatus('vat')) @@ -703,56 +703,56 @@ class pdf_eratosthene extends ModelePDFCommandes 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails ); - $reshook=$hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook + $reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook // Collection of totals by value of vat in $this->tva["rate"] = total_tva - if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; - else $tvaligne=$object->lines[$i]->total_tva; + if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva; + else $tvaligne = $object->lines[$i]->total_tva; - $localtax1ligne=$object->lines[$i]->total_localtax1; - $localtax2ligne=$object->lines[$i]->total_localtax2; - $localtax1_rate=$object->lines[$i]->localtax1_tx; - $localtax2_rate=$object->lines[$i]->localtax2_tx; - $localtax1_type=$object->lines[$i]->localtax1_type; - $localtax2_type=$object->lines[$i]->localtax2_type; + $localtax1ligne = $object->lines[$i]->total_localtax1; + $localtax2ligne = $object->lines[$i]->total_localtax2; + $localtax1_rate = $object->lines[$i]->localtax1_tx; + $localtax2_rate = $object->lines[$i]->localtax2_tx; + $localtax1_type = $object->lines[$i]->localtax1_type; + $localtax2_type = $object->lines[$i]->localtax2_type; - if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; - if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; - if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; + if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100; + if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100; + if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100; - $vatrate=(string) $object->lines[$i]->tva_tx; + $vatrate = (string) $object->lines[$i]->tva_tx; // Retrieve type from database for backward compatibility with old records - if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined - && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax + if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined + && (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax { - $localtaxtmp_array=getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc); + $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc); $localtax1_type = $localtaxtmp_array[0]; $localtax2_type = $localtaxtmp_array[2]; } // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0) - $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; + $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; if ($localtax2_type && $localtax2ligne != 0) - $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; + $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; - if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; - if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; + if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*'; + if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0; $this->tva[$vatrate] += $tvaligne; // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) + if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { $pdf->setPage($pageposafter); - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); + $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); + $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1); $pdf->SetLineStyle(array('dash'=>0)); } - $nexY+=2; // Add space between lines + $nexY += 2; // Add space between lines // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) @@ -822,31 +822,31 @@ class pdf_eratosthene extends ModelePDFCommandes // Add pdfgeneration hook $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { $this->error = $hookmanager->error; $this->errors = $hookmanager->errors; } - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); $this->result = array('fullpath'=>$file); - return 1; // No error + return 1; // No error } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } else { - $this->error=$langs->transnoentities("ErrorConstantNotDefined", "COMMANDE_OUTPUTDIR"); + $this->error = $langs->transnoentities("ErrorConstantNotDefined", "COMMANDE_OUTPUTDIR"); return 0; } } @@ -1080,7 +1080,7 @@ class pdf_eratosthene extends ModelePDFCommandes $index = 0; $outputlangsbis = null; - if (! empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { + if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { $outputlangsbis = new Translate('', $conf); $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal")); @@ -1112,27 +1112,27 @@ class pdf_eratosthene extends ModelePDFCommandes //Local tax 1 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ - foreach($this->localtax1 as $localtax_type => $localtax_rate) + foreach ($this->localtax1 as $localtax_type => $localtax_rate) { - if (in_array((string) $localtax_type, array('1','3','5'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + if (in_array((string) $localtax_type, array('1', '3', '5'))) continue; + foreach ($localtax_rate as $tvakey => $tvaval) { - if ($tvakey!=0) // On affiche pas taux 0 + if ($tvakey != 0) // On affiche pas taux 0 { //$this->atleastoneratenotnull++; $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : ''); - $totalvat.=' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat .= ' '; + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); @@ -1143,28 +1143,28 @@ class pdf_eratosthene extends ModelePDFCommandes //Local tax 2 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //{ - foreach($this->localtax2 as $localtax_type => $localtax_rate) + foreach ($this->localtax2 as $localtax_type => $localtax_rate) { - if (in_array((string) $localtax_type, array('1','3','5'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + if (in_array((string) $localtax_type, array('1', '3', '5'))) continue; + foreach ($localtax_rate as $tvakey => $tvaval) { - if ($tvakey!=0) // On affiche pas taux 0 + if ($tvakey != 0) // On affiche pas taux 0 { //$this->atleastoneratenotnull++; $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : ''); - $totalvat.=' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat .= ' '; + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); @@ -1189,7 +1189,7 @@ class pdf_eratosthene extends ModelePDFCommandes $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : ''); - $totalvat.=' '; + $totalvat .= ' '; $totalvat .= vatrate($tvakey, 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); @@ -1201,11 +1201,11 @@ class pdf_eratosthene extends ModelePDFCommandes //Local tax 1 after VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ - foreach($this->localtax1 as $localtax_type => $localtax_rate) + foreach ($this->localtax1 as $localtax_type => $localtax_rate) { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; + if (in_array((string) $localtax_type, array('2', '4', '6'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + foreach ($localtax_rate as $tvakey => $tvaval) { if ($tvakey != 0) // On affiche pas taux 0 { @@ -1214,17 +1214,17 @@ class pdf_eratosthene extends ModelePDFCommandes $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : ''); - $totalvat.=' '; + $totalvat .= ' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } @@ -1234,11 +1234,11 @@ class pdf_eratosthene extends ModelePDFCommandes //Local tax 2 after VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //{ - foreach($this->localtax2 as $localtax_type => $localtax_rate) + foreach ($this->localtax2 as $localtax_type => $localtax_rate) { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; + if (in_array((string) $localtax_type, array('2', '4', '6'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + foreach ($localtax_rate as $tvakey => $tvaval) { if ($tvakey != 0) // On affiche pas taux 0 { @@ -1247,17 +1247,17 @@ class pdf_eratosthene extends ModelePDFCommandes $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : ''); - $totalvat.=' '; + $totalvat .= ' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); @@ -1347,12 +1347,12 @@ class pdf_eratosthene extends ModelePDFCommandes if (empty($hidetop)) { $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; - if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); + if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { + $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); } } @@ -1360,13 +1360,13 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); - if (empty($hidetop)){ - $pdf->line($this->marge_gauche, $tab_top+$this->tabTitleHeight, $this->page_largeur-$this->marge_droite, $tab_top+$this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter + if (empty($hidetop)) { + $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter } } @@ -1385,7 +1385,7 @@ class pdf_eratosthene extends ModelePDFCommandes protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "PdfOrderTitle") { // phpcs:enable - global $conf,$langs,$hookmanager; + global $conf, $langs, $hookmanager; // Load traductions files required by page $outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies")); @@ -1403,8 +1403,8 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); - $posy=$this->marge_haute; - $posx=$this->page_largeur-$this->marge_droite-100; + $posy = $this->marge_haute; + $posx = $this->page_largeur - $this->marge_droite - 100; $pdf->SetXY($this->marge_gauche, $posy); @@ -1414,7 +1414,7 @@ class pdf_eratosthene extends ModelePDFCommandes if ($this->emetteur->logo) { $logodir = $conf->mycompany->dir_output; - if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity]; + if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity]; if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; @@ -1424,20 +1424,20 @@ class pdf_eratosthene extends ModelePDFCommandes } if (is_readable($logo)) { - $height=pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + $height = pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) } else { $pdf->SetTextColor(200, 0, 0); - $pdf->SetFont('', 'B', $default_font_size -2); + $pdf->SetFont('', 'B', $default_font_size - 2); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); } } else { - $text=$this->emetteur->name; + $text = $this->emetteur->name; $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } } @@ -1471,12 +1471,12 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R'); - if (!empty($conf->global->DOC_SHOW_CUSTOMER_CODE) && ! empty($object->thirdparty->code_client)) + if (!empty($conf->global->DOC_SHOW_CUSTOMER_CODE) && !empty($object->thirdparty->code_client)) { - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); } // Get contact diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 5b4199e2c57..52e41ea2589 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -168,7 +168,7 @@ class pdf_espadon extends ModelePdfExpedition // Load traductions files required by page $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch")); - if (! empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { + if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { global $outputlangsbis; $outputlangsbis = new Translate('', $conf); $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); @@ -178,22 +178,22 @@ class pdf_espadon extends ModelePdfExpedition $nblines = count($object->lines); // Loop on each lines to detect if there is at least one image to show - $realpatharray=array(); - if (! empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE)) + $realpatharray = array(); + if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE)) { $objphoto = new Product($this->db); - for ($i = 0 ; $i < $nblines ; $i++) + for ($i = 0; $i < $nblines; $i++) { if (empty($object->lines[$i]->fk_product)) continue; $objphoto = new Product($this->db); $objphoto->fetch($object->lines[$i]->fk_product); - $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product') . $object->lines[$i]->fk_product ."/photos/"; + $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/"; $dir = $conf->product->dir_output.'/'.$pdir; - $realpath=''; + $realpath = ''; foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) { @@ -250,25 +250,25 @@ class pdf_espadon extends ModelePdfExpedition if (file_exists($dir)) { // Add pdfgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks // Set nblines with the new facture lines content after hook $nblines = count($object->lines); - $pdf=pdf_getInstance($this->format); + $pdf = pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); - $heightforinfotot = 8; // Height reserved to output the info and total part - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; + $heightforinfotot = 8; // Height reserved to output the info and total part + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; $pdf->SetAutoPageBreak(1, 0); if (class_exists('TCPDF')) @@ -323,51 +323,51 @@ class pdf_espadon extends ModelePdfExpedition $tab_top = 88; $pdf->SetFont('', '', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); $nexY = $pdf->GetY(); - $height_incoterms=$nexY-$tab_top; + $height_incoterms = $nexY - $tab_top; // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); - $tab_top = $nexY+6; + $tab_top = $nexY + 6; $height_incoterms += 4; } } - if (! empty($object->note_public) || ! empty($object->tracking_number)) + if (!empty($object->note_public) || !empty($object->tracking_number)) { $tab_top = 88 + $height_incoterms; $tab_top_alt = $tab_top; $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top-1, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, 0, 1, false, true, 'L'); + $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, 0, 1, false, true, 'L'); $tab_top_alt = $pdf->GetY(); //$tab_top_alt += 1; // Tracking number - if (! empty($object->tracking_number)) + if (!empty($object->tracking_number)) { $object->getUrlTrackingStatus($object->tracking_number); - if (! empty($object->tracking_url)) + if (!empty($object->tracking_url)) { if ($object->shipping_method_id > 0) { // Get code using getLabelFromKey - $code=$outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); - $label=''; - if ($object->tracking_url != $object->tracking_number) $label.=$outputlangs->trans("LinkToTrackYourPackage")."
"; - $label.=$outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code)); + $code = $outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); + $label = ''; + if ($object->tracking_url != $object->tracking_number) $label .= $outputlangs->trans("LinkToTrackYourPackage")."
"; + $label .= $outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code)); //var_dump($object->tracking_url != $object->tracking_number);exit; if ($object->tracking_url != $object->tracking_number) { - $label.=" : "; - $label.=$object->tracking_url; + $label .= " : "; + $label .= $object->tracking_url; } $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top_alt, $label, 0, 1, false, true, 'L'); + $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1, false, true, 'L'); $tab_top_alt = $pdf->GetY(); } @@ -375,25 +375,25 @@ class pdf_espadon extends ModelePdfExpedition } // Notes - if (! empty($object->note_public)) + if (!empty($object->note_public)) { - $pdf->SetFont('', '', $default_font_size - 1); // In loop to manage multi-page - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1); + $pdf->SetFont('', '', $default_font_size - 1); // In loop to manage multi-page + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1); } $nexY = $pdf->GetY(); - $height_note=$nexY-$tab_top; + $height_note = $nexY - $tab_top; // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); $tab_height = $tab_height - $height_note; - $tab_top = $nexY+6; + $tab_top = $nexY + 6; } else { - $height_note=0; + $height_note = 0; } @@ -414,90 +414,90 @@ class pdf_espadon extends ModelePdfExpedition for ($i = 0; $i < $nblines; $i++) { $curY = $nexY; - $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0, 0, 0); // Define size of image if we need it - $imglinesize=array(); - if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); + $imglinesize = array(); + if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]); $pdf->setTopMargin($tab_top_newpage); - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. - $pageposbefore=$pdf->getPage(); + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $pageposbefore = $pdf->getPage(); - $showpricebeforepagebreak=1; - $posYAfterImage=0; - $posYAfterDescription=0; + $showpricebeforepagebreak = 1; + $posYAfterImage = 0; + $posYAfterDescription = 0; - if($this->getColumnStatus('photo')) + if ($this->getColumnStatus('photo')) { // We start with Photo of product line - if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot))) // If photo too high, we moved completely on new page + if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) // If photo too high, we moved completely on new page { $pdf->AddPage('', '', true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposbefore+1); + $pdf->setPage($pageposbefore + 1); $curY = $tab_top_newpage; - $showpricebeforepagebreak=0; + $showpricebeforepagebreak = 0; } if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) { - $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi + $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi // $pdf->Image does not increase value return by getY, so we save it manually - $posYAfterImage=$curY+$imglinesize['height']; + $posYAfterImage = $curY + $imglinesize['height']; } } // Description of product line - if($this->getColumnStatus('desc')) + if ($this->getColumnStatus('desc')) { $pdf->startTransaction(); pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); - $pageposafter=$pdf->getPage(); + $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { $pdf->rollbackTransaction(true); - $pageposafter=$pageposbefore; + $pageposafter = $pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); - $pageposafter=$pdf->getPage(); - $posyafter=$pdf->GetY(); + $pageposafter = $pdf->getPage(); + $posyafter = $pdf->GetY(); //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot))) // There is no space left for total+free text + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) // There is no space left for total+free text { - if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page + if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page { $pdf->AddPage('', '', true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposafter+1); + $pdf->setPage($pageposafter + 1); } } else { // We found a page break - $showpricebeforepagebreak=0; + $showpricebeforepagebreak = 0; } } else // No pagebreak { $pdf->commitTransaction(); } - $posYAfterDescription=$pdf->GetY(); + $posYAfterDescription = $pdf->GetY(); } $nexY = $pdf->GetY(); - $pageposafter=$pdf->getPage(); + $pageposafter = $pdf->getPage(); $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. // We suppose that a too long description or photo were moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { @@ -509,25 +509,25 @@ class pdf_espadon extends ModelePdfExpedition $pdf->setPage($pageposafter); $curY = $tab_top_newpage; } - $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font + $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font // weight - $weighttxt=''; + $weighttxt = ''; if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) { - $weighttxt=round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->weight_units); + $weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->weight_units); } - $voltxt=''; + $voltxt = ''; if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) { - $voltxt=round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "volume", $object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0); + $voltxt = round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "volume", $object->lines[$i]->volume_units ? $object->lines[$i]->volume_units : 0); } if ($this->getColumnStatus('weight')) { - $this->printStdColumnContent($pdf, $curY, 'weight', $weighttxt.(($weighttxt && $voltxt)?'
':'').$voltxt, array('html'=>1)); + $this->printStdColumnContent($pdf, $curY, 'weight', $weighttxt.(($weighttxt && $voltxt) ? '
' : '').$voltxt, array('html'=>1)); $nexY = max($pdf->GetY(), $nexY); } @@ -551,16 +551,16 @@ class pdf_espadon extends ModelePdfExpedition - $nexY+=3; - if ($weighttxt && $voltxt) $nexY+=2; + $nexY += 3; + if ($weighttxt && $voltxt) $nexY += 2; // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) + if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { $pdf->setPage($pageposafter); - $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80,80,80))); + $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY-1, $this->page_largeur - $this->marge_droite, $nexY-1); + $pdf->line($this->marge_gauche, $nexY - 1, $this->page_largeur - $this->marge_droite, $nexY - 1); $pdf->SetLineStyle(array('dash'=>0)); } @@ -579,10 +579,10 @@ class pdf_espadon extends ModelePdfExpedition $this->_pagefoot($pdf, $object, $outputlangs, 1); $pagenb++; $pdf->setPage($pagenb); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { @@ -605,16 +605,16 @@ class pdf_espadon extends ModelePdfExpedition if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } // Display total area - $posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs); + $posy = $this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs); // Pagefoot $this->_pagefoot($pdf, $object, $outputlangs); @@ -681,7 +681,7 @@ class pdf_espadon extends ModelePdfExpedition $pdf->SetFont('', 'B', $default_font_size - 1); // Total table - $col1x = $this->posxweightvol-50; $col2x = $this->posxweightvol; + $col1x = $this->posxweightvol - 50; $col2x = $this->posxweightvol; /*if ($this->page_largeur < 210) // To work with US executive format { $col2x-=20; @@ -788,8 +788,8 @@ class pdf_espadon extends ModelePdfExpedition if (empty($hidetop)) { //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; - if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); + if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { + $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); } } @@ -797,13 +797,13 @@ class pdf_espadon extends ModelePdfExpedition $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); - if (empty($hidetop)){ - $pdf->line($this->marge_gauche, $tab_top+$this->tabTitleHeight, $this->page_largeur-$this->marge_droite, $tab_top+$this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter + if (empty($hidetop)) { + $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter } } @@ -839,19 +839,19 @@ class pdf_espadon extends ModelePdfExpedition $w = 110; - $posy=$this->marge_haute; - $posx=$this->page_largeur-$this->marge_droite-$w; + $posy = $this->marge_haute; + $posx = $this->page_largeur - $this->marge_droite - $w; $pdf->SetXY($this->marge_gauche, $posy); // Logo - $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; + $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; if ($this->emetteur->logo) { if (is_readable($logo)) { - $height=pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + $height = pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) } else { @@ -863,21 +863,21 @@ class pdf_espadon extends ModelePdfExpedition } else { - $text=$this->emetteur->name; + $text = $this->emetteur->name; $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } // Show barcode - if (! empty($conf->barcode->enabled)) + if (!empty($conf->barcode->enabled)) { - $posx=105; + $posx = 105; } else { - $posx=$this->marge_gauche+3; + $posx = $this->marge_gauche + 3; } //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30); - if (! empty($conf->barcode->enabled)) + if (!empty($conf->barcode->enabled)) { // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); @@ -893,67 +893,67 @@ class pdf_espadon extends ModelePdfExpedition } - $posx=$this->page_largeur - $w - $this->marge_droite; - $posy=$this->marge_haute; + $posx = $this->page_largeur - $w - $this->marge_droite; + $posy = $this->marge_haute; $pdf->SetFont('', 'B', $default_font_size + 2); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $title=$outputlangs->transnoentities("SendingSheet"); + $title = $outputlangs->transnoentities("SendingSheet"); $pdf->MultiCell($w, 4, $title, '', 'R'); $pdf->SetFont('', '', $default_font_size + 1); - $posy+=5; + $posy += 5; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefSending") ." : ".$object->ref, '', 'R'); + $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefSending")." : ".$object->ref, '', 'R'); // Date planned delivery - if (! empty($object->date_delivery)) + if (!empty($object->date_delivery)) { - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R'); } - if (! empty($object->thirdparty->code_client)) + if (!empty($object->thirdparty->code_client)) { - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); } $pdf->SetFont('', '', $default_font_size + 3); - $Yoff=25; + $Yoff = 25; // Add list of linked orders - $origin = $object->origin; - $origin_id = $object->origin_id; + $origin = $object->origin; + $origin_id = $object->origin_id; // TODO move to external function - if (! empty($conf->$origin->enabled)) // commonly $origin='commande' + if (!empty($conf->$origin->enabled)) // commonly $origin='commande' { $outputlangs->load('orders'); $classname = ucfirst($origin); $linkedobject = new $classname($this->db); - $result=$linkedobject->fetch($origin_id); + $result = $linkedobject->fetch($origin_id); if ($result >= 0) { //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects $pdf->SetFont('', '', $default_font_size - 2); - $text=$linkedobject->ref; - if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')'; - $Yoff = $Yoff+8; + $text = $linkedobject->ref; + if ($linkedobject->ref_client) $text .= ' ('.$linkedobject->ref_client.')'; + $Yoff = $Yoff + 8; $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff); - $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R'); - $Yoff = $Yoff+3; + $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), 0, 'R'); + $Yoff = $Yoff + 3; $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff); $pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date, "day", false, $outputlangs, true), 0, 'R'); } @@ -994,24 +994,24 @@ class pdf_espadon extends ModelePdfExpedition $pdf->SetFillColor(255, 255, 255); // Show sender name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); - $pdf->MultiCell($widthrecbox-2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); - $posy=$pdf->getY(); + $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); + $posy = $pdf->getY(); // Show sender information - $pdf->SetXY($posx+2, $posy); + $pdf->SetXY($posx + 2, $posy); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->MultiCell($widthrecbox-2, 4, $carac_emetteur, 0, 'L'); + $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L'); // If SHIPPING contact defined, we use it - $usecontact=false; - $arrayidcontact=$object->$origin->getIdContact('external', 'SHIPPING'); + $usecontact = false; + $arrayidcontact = $object->$origin->getIdContact('external', 'SHIPPING'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } //Recipient name @@ -1022,26 +1022,26 @@ class pdf_espadon extends ModelePdfExpedition $thirdparty = $object->thirdparty; } - $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); + $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact)?$object->contact:null), $usecontact, 'targetwithdetails', $object); + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), $usecontact, 'targetwithdetails', $object); // Show recipient - $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format - $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; - $posx=$this->page_largeur - $this->marge_droite - $widthrecbox; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; + $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; + if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format + $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; + $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; // Show recipient frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx+2, $posy-5); + $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient").":", 0, 'L'); $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); // Show recipient name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L'); @@ -1049,7 +1049,7 @@ class pdf_espadon extends ModelePdfExpedition // Show recipient information $pdf->SetFont('', '', $default_font_size - 1); - $pdf->SetXY($posx+2, $posy); + $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); } diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 3936dccae95..71295335460 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -135,41 +135,41 @@ class pdf_standard extends ModeleExpenseReport // Page size for A4 format $this->type = 'pdf'; - $formatarray=pdf_getFormat(); + $formatarray = pdf_getFormat(); $this->page_largeur = $formatarray['width']; $this->page_hauteur = $formatarray['height']; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION - $this->option_modereg = 1; // Affiche mode reglement - $this->option_condreg = 1; // Affiche conditions reglement - $this->option_codeproduitservice = 1; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 1; // Support add of a watermark on drafts + $this->option_logo = 1; // Affiche logo + $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION + $this->option_modereg = 1; // Affiche mode reglement + $this->option_condreg = 1; // Affiche conditions reglement + $this->option_codeproduitservice = 1; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 1; // Support add of a watermark on drafts // Get source company - $this->emetteur=$mysoc; + $this->emetteur = $mysoc; - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default, if was not defined + if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined // Define position of columns - $this->posxpiece=$this->marge_gauche+1; - $this->posxcomment=$this->marge_gauche+10; + $this->posxpiece = $this->marge_gauche + 1; + $this->posxcomment = $this->marge_gauche + 10; //$this->posxdate=88; //$this->posxtype=107; //$this->posxprojet=120; - $this->posxtva=130; - $this->posxup=145; - $this->posxqty=168; - $this->postotalttc=178; + $this->posxtva = 130; + $this->posxup = 145; + $this->posxqty = 168; + $this->postotalttc = 178; // if (empty($conf->projet->enabled)) { // $this->posxtva-=20; // $this->posxup-=20; @@ -287,40 +287,40 @@ class pdf_standard extends ModeleExpenseReport $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Trips")); - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); $tab_top = 95; - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?65:10); + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 65 : 10); $tab_height = 130; $tab_height_newpage = 150; // Show notes - $notetoshow=empty($object->note_public)?'':$object->note_public; - if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) + $notetoshow = empty($object->note_public) ? '' : $object->note_public; + if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) { // Get first sale rep if (is_object($object->thirdparty)) { - $salereparray=$object->thirdparty->getSalesRepresentatives($user); - $salerepobj=new User($this->db); + $salereparray = $object->thirdparty->getSalesRepresentatives($user); + $salerepobj = new User($this->db); $salerepobj->fetch($salereparray[0]['id']); - if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); + if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature); } } if ($notetoshow) { - $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); + $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object); complete_substitutions_array($substitutionarray, $outputlangs, $object); $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow); @@ -328,20 +328,20 @@ class pdf_standard extends ModeleExpenseReport $tab_top = 95; $pdf->SetFont('', '', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxpiece-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); + $pdf->writeHTMLCell(190, 3, $this->posxpiece - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); $nexY = $pdf->GetY(); - $height_note=$nexY-$tab_top; + $height_note = $nexY - $tab_top; // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); $tab_height = $tab_height - $height_note; - $tab_top = $nexY+6; + $tab_top = $nexY + 6; } else { - $height_note=0; + $height_note = 0; } $iniY = $tab_top + 7; @@ -349,41 +349,41 @@ class pdf_standard extends ModeleExpenseReport $nexY = $tab_top + 7; // Loop on each lines - for ($i = 0 ; $i < $nblines ; $i++) { - $pdf->SetFont('', '', $default_font_size - 2); // Into loop to work with multipage + for ($i = 0; $i < $nblines; $i++) { + $pdf->SetFont('', '', $default_font_size - 2); // Into loop to work with multipage $pdf->SetTextColor(0, 0, 0); $pdf->setTopMargin($tab_top_newpage); - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pageposbefore = $pdf->getPage(); $curY = $nexY; $pdf->startTransaction(); $this->printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails); - $pageposafter=$pdf->getPage(); + $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) { // There is a pagebreak $pdf->rollbackTransaction(true); $pageposafter = $pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. $this->printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails); $pageposafter = $pdf->getPage(); $posyafter = $pdf->GetY(); //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) { + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text - if ($i == ($nblines-1)) { + if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page $pdf->AddPage('', '', true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposafter+1); + $pdf->setPage($pageposafter + 1); } } else { // We found a page break - $showpricebeforepagebreak=0; + $showpricebeforepagebreak = 0; } } else // No pagebreak @@ -413,7 +413,7 @@ class pdf_standard extends ModeleExpenseReport // } //$nexY+=$nblineFollowComment*($pdf->getFontSize()*1.3); // Add space between lines - $nexY += ($pdf->getFontSize()*1.3); // Add space between lines + $nexY += ($pdf->getFontSize() * 1.3); // Add space between lines // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) @@ -509,31 +509,31 @@ class pdf_standard extends ModeleExpenseReport // Add pdfgeneration hook $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { $this->error = $hookmanager->error; $this->errors = $hookmanager->errors; } - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); $this->result = array('fullpath'=>$file); - return 1; // No error + return 1; // No error } else { - $this->error=$langs->trans("ErrorCanNotCreateDir", $dir); + $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); return 0; } } else { - $this->error=$langs->trans("ErrorConstantNotDefined", "EXPENSEREPORT_OUTPUTDIR"); + $this->error = $langs->trans("ErrorConstantNotDefined", "EXPENSEREPORT_OUTPUTDIR"); return 0; } } @@ -592,30 +592,30 @@ class pdf_standard extends ModeleExpenseReport if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { $vat_rate = pdf_getlinevatrate($object, $linenumber, $outputlangs, $hidedetails); $pdf->SetXY($this->posxtva, $curY); - $pdf->MultiCell($this->posxup-$this->posxtva-0.8, 4, $vat_rate, 0, 'R'); + $pdf->MultiCell($this->posxup - $this->posxtva - 0.8, 4, $vat_rate, 0, 'R'); } // Unit price $pdf->SetXY($this->posxup, $curY); - $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 4, price($object->lines[$linenumber]->value_unit), 0, 'R'); + $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 4, price($object->lines[$linenumber]->value_unit), 0, 'R'); // Quantity $pdf->SetXY($this->posxqty, $curY); - $pdf->MultiCell($this->postotalttc-$this->posxqty-0.8, 4, $object->lines[$linenumber]->qty, 0, 'R'); + $pdf->MultiCell($this->postotalttc - $this->posxqty - 0.8, 4, $object->lines[$linenumber]->qty, 0, 'R'); // Total with all taxes - $pdf->SetXY($this->postotalttc-1, $curY); - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalttc, 4, price($object->lines[$linenumber]->total_ttc), 0, 'R'); + $pdf->SetXY($this->postotalttc - 1, $curY); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc, 4, price($object->lines[$linenumber]->total_ttc), 0, 'R'); // Comments $pdf->SetXY($this->posxcomment, $curY); - $comment = $outputlangs->trans("Date").':'. dol_print_date($object->lines[$linenumber]->date, "day", false, $outputlangs).' '; - $comment .= $outputlangs->trans("Type").':'. $expensereporttypecodetoshow.'
'; - if (! empty($object->lines[$linenumber]->projet_ref)) { - $comment .= $outputlangs->trans("Project").':'. $object->lines[$linenumber]->projet_ref.'
'; + $comment = $outputlangs->trans("Date").':'.dol_print_date($object->lines[$linenumber]->date, "day", false, $outputlangs).' '; + $comment .= $outputlangs->trans("Type").':'.$expensereporttypecodetoshow.'
'; + if (!empty($object->lines[$linenumber]->projet_ref)) { + $comment .= $outputlangs->trans("Project").':'.$object->lines[$linenumber]->projet_ref.'
'; } $comment .= $object->lines[$linenumber]->comments; - $pdf->writeHTMLCell($this->posxtva-$this->posxcomment-0.8, 4, $this->posxcomment-1, $curY, $comment, 0, 1); + $pdf->writeHTMLCell($this->posxtva - $this->posxcomment - 0.8, 4, $this->posxcomment - 1, $curY, $comment, 0, 1); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore @@ -751,96 +751,96 @@ class pdf_standard extends ModeleExpenseReport // Show sender information if (empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); - $pdf->SetXY($posx+2, $posy+8); + $pdf->SetXY($posx + 2, $posy + 8); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); } else { - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset(dolGetFirstLastname($receiver->firstname, $receiver->lastname)), 0, 'L'); - $pdf->SetXY($posx+2, $posy+8); + $pdf->SetXY($posx + 2, $posy + 8); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(80, 4, $expense_receiver, 0, 'L'); } // Show recipient - $posy=50; - $posx=100; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; + $posy = 50; + $posx = 100; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; // Show recipient frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', 'B', 8); - $pdf->SetXY($posx, $posy-5); + $pdf->SetXY($posx, $posy - 5); $pdf->MultiCell(80, 5, $outputlangs->transnoentities("TripNDF")." :", 0, 'L'); $pdf->rect($posx, $posy, $this->page_largeur - $this->marge_gauche - $posx, $hautcadre); // Informations for trip (dates and users workflow) if ($object->fk_user_author > 0) { - $userfee=new User($this->db); + $userfee = new User($this->db); $userfee->fetch($object->fk_user_author); - $posy+=3; - $pdf->SetXY($posx+2, $posy); + $posy += 3; + $pdf->SetXY($posx + 2, $posy); $pdf->SetFont('', '', 10); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("AUTHOR")." : ".dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L'); - $posy+=5; - $pdf->SetXY($posx+2, $posy); + $posy += 5; + $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("DateCreation")." : ".dol_print_date($object->date_create, "day", false, $outputlangs), 0, 'L'); } - if ($object->fk_statut==99) { + if ($object->fk_statut == 99) { if ($object->fk_user_refuse > 0) { - $userfee=new User($this->db); - $userfee->fetch($object->fk_user_refuse); $posy+=6; - $pdf->SetXY($posx+2, $posy); + $userfee = new User($this->db); + $userfee->fetch($object->fk_user_refuse); $posy += 6; + $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("REFUSEUR")." : ".dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L'); - $posy+=5; - $pdf->SetXY($posx+2, $posy); + $posy += 5; + $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("MOTIF_REFUS")." : ".$outputlangs->convToOutputCharset($object->detail_refuse), 0, 'L'); - $posy+=5; - $pdf->SetXY($posx+2, $posy); + $posy += 5; + $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("DATE_REFUS")." : ".dol_print_date($object->date_refuse, "day", false, $outputlangs), 0, 'L'); } } - elseif($object->fk_statut==4) + elseif ($object->fk_statut == 4) { if ($object->fk_user_cancel > 0) { - $userfee=new User($this->db); - $userfee->fetch($object->fk_user_cancel); $posy+=6; - $pdf->SetXY($posx+2, $posy); + $userfee = new User($this->db); + $userfee->fetch($object->fk_user_cancel); $posy += 6; + $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("CANCEL_USER")." : ".dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L'); - $posy+=5; - $pdf->SetXY($posx+2, $posy); + $posy += 5; + $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("MOTIF_CANCEL")." : ".$outputlangs->convToOutputCharset($object->detail_cancel), 0, 'L'); - $posy+=5; - $pdf->SetXY($posx+2, $posy); + $posy += 5; + $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("DATE_CANCEL")." : ".dol_print_date($object->date_cancel, "day", false, $outputlangs), 0, 'L'); } } else { if ($object->fk_user_approve > 0) { - $userfee=new User($this->db); - $userfee->fetch($object->fk_user_approve); $posy+=6; - $pdf->SetXY($posx+2, $posy); + $userfee = new User($this->db); + $userfee->fetch($object->fk_user_approve); $posy += 6; + $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("VALIDOR")." : ".dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L'); - $posy+=5; - $pdf->SetXY($posx+2, $posy); + $posy += 5; + $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("DateApprove")." : ".dol_print_date($object->date_approve, "day", false, $outputlangs), 0, 'L'); } } - if($object->fk_statut==6) { + if ($object->fk_statut == 6) { if ($object->fk_user_paid > 0) { - $userfee=new User($this->db); - $userfee->fetch($object->fk_user_paid); $posy+=6; - $pdf->SetXY($posx+2, $posy); + $userfee = new User($this->db); + $userfee->fetch($object->fk_user_paid); $posy += 6; + $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("AUTHORPAIEMENT")." : ".dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L'); - $posy+=5; - $pdf->SetXY($posx+2, $posy); + $posy += 5; + $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("DATE_PAIEMENT")." : ".dol_print_date($object->date_paiement, "day", false, $outputlangs), 0, 'L'); } } @@ -876,31 +876,31 @@ class pdf_standard extends ModeleExpenseReport $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 4), $tab_top -4); + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 4), $tab_top - 4); $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); $pdf->SetDrawColor(128, 128, 128); // Rect takes a length in 3rd parameter - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height); + $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height); // line prend une position y en 3eme param if (empty($hidetop)) { - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); + $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); } $pdf->SetFont('', '', 8); // Accountancy piece if (empty($hidetop)) { - $pdf->SetXY($this->posxpiece-1, $tab_top+1); - $pdf->MultiCell($this->posxcomment-$this->posxpiece-1, 1, '', '', 'R'); + $pdf->SetXY($this->posxpiece - 1, $tab_top + 1); + $pdf->MultiCell($this->posxcomment - $this->posxpiece - 1, 1, '', '', 'R'); } // Comments - $pdf->line($this->posxcomment-1, $tab_top, $this->posxcomment-1, $tab_top + $tab_height); + $pdf->line($this->posxcomment - 1, $tab_top, $this->posxcomment - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxcomment-1, $tab_top+1); - $pdf->MultiCell($this->posxdate-$this->posxcomment-1, 1, $outputlangs->transnoentities("Description"), '', 'L'); + $pdf->SetXY($this->posxcomment - 1, $tab_top + 1); + $pdf->MultiCell($this->posxdate - $this->posxcomment - 1, 1, $outputlangs->transnoentities("Description"), '', 'L'); } // Date @@ -931,32 +931,32 @@ class pdf_standard extends ModeleExpenseReport // VAT if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { - $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); + $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxtva-1, $tab_top+1); - $pdf->MultiCell($this->posxup-$this->posxtva - 1, 2, $outputlangs->transnoentities("VAT"), '', 'C'); + $pdf->SetXY($this->posxtva - 1, $tab_top + 1); + $pdf->MultiCell($this->posxup - $this->posxtva - 1, 2, $outputlangs->transnoentities("VAT"), '', 'C'); } } // Unit price - $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); + $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxup-1, $tab_top+1); - $pdf->MultiCell($this->posxqty-$this->posxup-1, 2, $outputlangs->transnoentities("PriceU"), '', 'C'); + $pdf->SetXY($this->posxup - 1, $tab_top + 1); + $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceU"), '', 'C'); } // Quantity - $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); + $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxqty-1, $tab_top+1); - $pdf->MultiCell($this->postotalttc-$this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); + $pdf->SetXY($this->posxqty - 1, $tab_top + 1); + $pdf->MultiCell($this->postotalttc - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); } // Total with all taxes $pdf->line($this->postotalttc, $tab_top, $this->postotalttc, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->postotalttc-1, $tab_top+1); - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalttc, 2, $outputlangs->transnoentities("TotalTTC"), '', 'R'); + $pdf->SetXY($this->postotalttc - 1, $tab_top + 1); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc, 2, $outputlangs->transnoentities("TotalTTC"), '', 'R'); } $pdf->SetTextColor(0, 0, 0); @@ -983,94 +983,94 @@ class pdf_standard extends ModeleExpenseReport $default_font_size = pdf_getPDFFontSize($outputlangs); - $title=$outputlangs->transnoentities("PaymentsAlreadyDone"); + $title = $outputlangs->transnoentities("PaymentsAlreadyDone"); $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($tab3_posx, $tab3_top - 4); $pdf->SetTextColor(0, 0, 0); $pdf->MultiCell(60, 3, $title, 0, 'L', 0); - $pdf->line($tab3_posx, $tab3_top, $tab3_posx+$tab3_width+2, $tab3_top); // Top border line of table title + $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width + 2, $tab3_top); // Top border line of table title - $pdf->SetXY($tab3_posx, $tab3_top+1); + $pdf->SetXY($tab3_posx, $tab3_top + 1); $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Date"), 0, 'L', 0); - $pdf->SetXY($tab3_posx+19, $tab3_top+1); // Old value 17 + $pdf->SetXY($tab3_posx + 19, $tab3_top + 1); // Old value 17 $pdf->MultiCell(15, 3, $outputlangs->transnoentities("Amount"), 0, 'C', 0); - $pdf->SetXY($tab3_posx+35, $tab3_top+1); + $pdf->SetXY($tab3_posx + 35, $tab3_top + 1); $pdf->MultiCell(30, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0); - if (! empty($conf->banque->enabled)) { - $pdf->SetXY($tab3_posx+65, $tab3_top+1); + if (!empty($conf->banque->enabled)) { + $pdf->SetXY($tab3_posx + 65, $tab3_top + 1); $pdf->MultiCell(25, 3, $outputlangs->transnoentities("BankAccount"), 0, 'L', 0); } - $pdf->line($tab3_posx, $tab3_top+$tab3_height, $tab3_posx+$tab3_width+2, $tab3_top+$tab3_height); // Bottom border line of table title + $pdf->line($tab3_posx, $tab3_top + $tab3_height, $tab3_posx + $tab3_width + 2, $tab3_top + $tab3_height); // Bottom border line of table title - $y=0; + $y = 0; // Loop on each payment // TODO create method on expensereport class to get payments // Payments already done (from payment on this expensereport) $sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount, p.fk_bank,"; - $sql.= "c.code as p_code, c.libelle as payment_type,"; - $sql.= "ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal"; - $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."payment_expensereport as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; - $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid'; - $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid'; - $sql.= " WHERE e.rowid = '".$object->id."'"; - $sql.= " AND p.fk_expensereport = e.rowid"; - $sql.= ' AND e.entity IN ('.getEntity('expensereport').')'; - $sql.= " ORDER BY dp"; + $sql .= "c.code as p_code, c.libelle as payment_type,"; + $sql .= "ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal"; + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."payment_expensereport as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; + $sql .= " WHERE e.rowid = '".$object->id."'"; + $sql .= " AND p.fk_expensereport = e.rowid"; + $sql .= ' AND e.entity IN ('.getEntity('expensereport').')'; + $sql .= " ORDER BY dp"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); $totalpaid = 0; - $i=0; + $i = 0; while ($i < $num) { - $y+=$tab3_height; + $y += $tab3_height; $row = $this->db->fetch_object($resql); - $pdf->SetXY($tab3_posx, $tab3_top+$y+1); + $pdf->SetXY($tab3_posx, $tab3_top + $y + 1); $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->dp), 'day', false, $outputlangs, true), 0, 'L', 0); - $pdf->SetXY($tab3_posx+17, $tab3_top+$y+1); + $pdf->SetXY($tab3_posx + 17, $tab3_top + $y + 1); $pdf->MultiCell(15, 3, price($sign * $row->amount, 0, $outputlangs), 0, 'R', 0); - $pdf->SetXY($tab3_posx+35, $tab3_top+$y+1); - $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->p_code); + $pdf->SetXY($tab3_posx + 35, $tab3_top + $y + 1); + $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort".$row->p_code); $pdf->MultiCell(40, 3, $oper, 0, 'L', 0); - if (! empty($conf->banque->enabled)) { - $pdf->SetXY($tab3_posx+65, $tab3_top+$y+1); + if (!empty($conf->banque->enabled)) { + $pdf->SetXY($tab3_posx + 65, $tab3_top + $y + 1); $pdf->MultiCell(30, 3, $row->baref, 0, 'L', 0); } - $pdf->line($tab3_posx, $tab3_top+$y+$tab3_height, $tab3_posx+$tab3_width+2, $tab3_top+$y+$tab3_height); // Bottom line border of table + $pdf->line($tab3_posx, $tab3_top + $y + $tab3_height, $tab3_posx + $tab3_width + 2, $tab3_top + $y + $tab3_height); // Bottom line border of table $totalpaid += $row->amount; $i++; } if ($num > 0 && $object->paid == 0) { - $y+=$tab3_height; + $y += $tab3_height; - $pdf->SetXY($tab3_posx+17, $tab3_top+$y); + $pdf->SetXY($tab3_posx + 17, $tab3_top + $y); $pdf->MultiCell(15, 3, price($totalpaid), 0, 'R', 0); - $pdf->SetXY($tab3_posx+35, $tab3_top+$y); + $pdf->SetXY($tab3_posx + 35, $tab3_top + $y); $pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv("AlreadyPaid"), 0, 'L', 0); - $y+=$tab3_height-2; - $pdf->SetXY($tab3_posx+17, $tab3_top+$y); + $y += $tab3_height - 2; + $pdf->SetXY($tab3_posx + 17, $tab3_top + $y); $pdf->MultiCell(15, 3, price($object->total_ttc), 0, 'R', 0); - $pdf->SetXY($tab3_posx+35, $tab3_top+$y); + $pdf->SetXY($tab3_posx + 35, $tab3_top + $y); $pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv("AmountExpected"), 0, 'L', 0); - $y+=$tab3_height-2; + $y += $tab3_height - 2; $remaintopay = $object->total_ttc - $totalpaid; - $pdf->SetXY($tab3_posx+17, $tab3_top+$y); + $pdf->SetXY($tab3_posx + 17, $tab3_top + $y); $pdf->MultiCell(15, 3, price($remaintopay), 0, 'R', 0); - $pdf->SetXY($tab3_posx+35, $tab3_top+$y); + $pdf->SetXY($tab3_posx + 35, $tab3_top + $y); $pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv("RemainderToPay"), 0, 'L', 0); } } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 50a4a4e6a0a..603ffbbd3d6 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1632,7 +1632,7 @@ class pdf_crabe extends ModelePDFFactures if ($this->emetteur->logo) { $logodir = $conf->mycompany->dir_output; - if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity]; + if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity]; if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index efe009bbafc..1c59a9839b3 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -147,48 +147,48 @@ class pdf_sponge extends ModelePDFFactures $this->db = $db; $this->name = "sponge"; $this->description = $langs->trans('PDFSpongeDescription'); - $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template + $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template // Dimension page $this->type = 'pdf'; - $formatarray=pdf_getFormat(); + $formatarray = pdf_getFormat(); $this->page_largeur = $formatarray['width']; $this->page_hauteur = $formatarray['height']; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; - $this->option_logo = 1; // Display logo - $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION - $this->option_modereg = 1; // Display payment mode - $this->option_condreg = 1; // Display payment terms - $this->option_codeproduitservice = 1; // Display product-service code - $this->option_multilang = 1; // Available in several languages - $this->option_escompte = 1; // Displays if there has been a discount - $this->option_credit_note = 1; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 1; // Support add of a watermark on drafts + $this->option_logo = 1; // Display logo + $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION + $this->option_modereg = 1; // Display payment mode + $this->option_condreg = 1; // Display payment terms + $this->option_codeproduitservice = 1; // Display product-service code + $this->option_multilang = 1; // Available in several languages + $this->option_escompte = 1; // Displays if there has been a discount + $this->option_credit_note = 1; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 1; // Support add of a watermark on drafts // Get source company - $this->emetteur=$mysoc; - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default, if was not defined + $this->emetteur = $mysoc; + if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined // Define position of columns - $this->posxdesc=$this->marge_gauche+1; // used for notes ans other stuff + $this->posxdesc = $this->marge_gauche + 1; // used for notes ans other stuff $this->tabTitleHeight = 5; // default height // Use new system for position of columns, view $this->defineColumnField() - $this->tva=array(); - $this->localtax1=array(); - $this->localtax2=array(); - $this->atleastoneratenotnull=0; - $this->atleastonediscount=0; - $this->situationinvoice=false; + $this->tva = array(); + $this->localtax1 = array(); + $this->localtax2 = array(); + $this->atleastoneratenotnull = 0; + $this->atleastonediscount = 0; + $this->situationinvoice = false; } @@ -211,14 +211,14 @@ class pdf_sponge extends ModelePDFFactures dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null')); - if (! is_object($outputlangs)) $outputlangs=$langs; + if (!is_object($outputlangs)) $outputlangs = $langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; // Load translation files required by the page $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies")); - if (! empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { + if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { global $outputlangsbis; $outputlangsbis = new Translate('', $conf); $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); @@ -227,39 +227,39 @@ class pdf_sponge extends ModelePDFFactures $nblines = count($object->lines); - $hidetop=0; - if(!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)){ - $hidetop=$conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE; + $hidetop = 0; + if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) { + $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE; } // Loop on each lines to detect if there is at least one image to show - $realpatharray=array(); + $realpatharray = array(); $this->atleastonephoto = false; - if (! empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE)) + if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE)) { $objphoto = new Product($this->db); - for ($i = 0 ; $i < $nblines ; $i++) + for ($i = 0; $i < $nblines; $i++) { if (empty($object->lines[$i]->fk_product)) continue; $objphoto->fetch($object->lines[$i]->fk_product); //var_dump($objphoto->ref);exit; - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { - $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product') . $objphoto->id ."/photos/"; - $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product') . dol_sanitizeFileName($objphoto->ref).'/'; + $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; + $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; } else { - $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product') . dol_sanitizeFileName($objphoto->ref).'/'; // default - $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product') . $objphoto->id ."/photos/"; // alternative + $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; // default + $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative } $arephoto = false; foreach ($pdir as $midir) { - if (! $arephoto) + if (!$arephoto) { $dir = $conf->product->dir_output.'/'.$midir; @@ -326,28 +326,28 @@ class pdf_sponge extends ModelePDFFactures if (file_exists($dir)) { // Add pdfgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks // Set nblines with the new facture lines content after hook $nblines = count($object->lines); $nbpayments = count($object->getListOfPayments()); // Create pdf instance - $pdf=pdf_getInstance($this->format); - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance + $pdf = pdf_getInstance($this->format); + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $pdf->SetAutoPageBreak(1, 0); - $heightforinfotot = 50+(4*$nbpayments); // Height reserved to output the info and total part and payment part - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page - $heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22); // Height reserved to output the footer (value include bottom margin) + $heightforinfotot = 50 + (4 * $nbpayments); // Height reserved to output the info and total part and payment part + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22); // Height reserved to output the footer (value include bottom margin) if (class_exists('TCPDF')) { @@ -357,14 +357,14 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); } $pdf->Open(); - $pagenb=0; + $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); @@ -372,9 +372,9 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfInvoiceTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right // Does we have at least one line with discount $this->atleastonediscount foreach ($object->lines as $line) { @@ -417,30 +417,30 @@ class pdf_sponge extends ModelePDFFactures $tab_top -= 2; $pdf->SetFont('', '', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); $nexY = max($pdf->GetY(), $nexY); - $height_incoterms=$nexY-$tab_top; + $height_incoterms = $nexY - $tab_top; // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); - $tab_top = $nexY+6; + $tab_top = $nexY + 6; $height_incoterms += 4; } } // Display notes - $notetoshow=empty($object->note_public)?'':$object->note_public; - if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) + $notetoshow = empty($object->note_public) ? '' : $object->note_public; + if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) { // Get first sale rep if (is_object($object->thirdparty)) { - $salereparray=$object->thirdparty->getSalesRepresentatives($user); - $salerepobj=new User($this->db); + $salereparray = $object->thirdparty->getSalesRepresentatives($user); + $salerepobj = new User($this->db); $salerepobj->fetch($salereparray[0]['id']); - if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); + if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature); } } @@ -577,44 +577,44 @@ class pdf_sponge extends ModelePDFFactures $nexY = $tab_top + $this->tabTitleHeight + 2; // Loop on each lines - $pageposbeforeprintlines=$pdf->getPage(); + $pageposbeforeprintlines = $pdf->getPage(); $pagenb = $pageposbeforeprintlines; for ($i = 0; $i < $nblines; $i++) { $curY = $nexY; - $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0, 0, 0); // Define size of image if we need it - $imglinesize=array(); - if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); + $imglinesize = array(); + if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]); $pdf->setTopMargin($tab_top_newpage); - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. - $pageposbefore=$pdf->getPage(); + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $pageposbefore = $pdf->getPage(); - $showpricebeforepagebreak=1; - $posYAfterImage=0; - $posYAfterDescription=0; + $showpricebeforepagebreak = 1; + $posYAfterImage = 0; + $posYAfterDescription = 0; - if($this->getColumnStatus('photo')) + if ($this->getColumnStatus('photo')) { // We start with Photo of product line - if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page + if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // If photo too high, we moved completely on new page { $pdf->AddPage('', '', true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); - $pdf->setPage($pageposbefore+1); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); + $pdf->setPage($pageposbefore + 1); $curY = $tab_top_newpage; - $showpricebeforepagebreak=0; + $showpricebeforepagebreak = 0; } if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) { - $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi + $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi // $pdf->Image does not increase value return by getY, so we save it manually - $posYAfterImage=$curY+$imglinesize['height']; + $posYAfterImage = $curY + $imglinesize['height']; } } @@ -623,51 +623,51 @@ class pdf_sponge extends ModelePDFFactures { $pdf->startTransaction(); pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); - $pageposafter=$pdf->getPage(); + $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { $pdf->rollbackTransaction(true); - $pageposafter=$pageposbefore; + $pageposafter = $pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); - $pageposafter=$pdf->getPage(); - $posyafter=$pdf->GetY(); + $pageposafter = $pdf->getPage(); + $posyafter = $pdf->GetY(); //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text { - if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page + if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page { $pdf->AddPage('', '', true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); - $pdf->setPage($pageposafter+1); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); + $pdf->setPage($pageposafter + 1); } } else { // We found a page break - $showpricebeforepagebreak=0; + $showpricebeforepagebreak = 0; } } else // No pagebreak { $pdf->commitTransaction(); } - $posYAfterDescription=$pdf->GetY(); + $posYAfterDescription = $pdf->GetY(); } $nexY = $pdf->GetY(); - $pageposafter=$pdf->getPage(); + $pageposafter = $pdf->getPage(); $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. // We suppose that a too long description or photo were moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { $pdf->setPage($pageposafter); $curY = $tab_top_newpage; } - $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut + $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut // VAT Rate if ($this->getColumnStatus('vat')) @@ -749,56 +749,56 @@ class pdf_sponge extends ModelePDFFactures if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; else $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; } else { - if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne= $sign * $object->lines[$i]->multicurrency_total_tva; - else $tvaligne= $sign * $object->lines[$i]->total_tva; + if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva; + else $tvaligne = $sign * $object->lines[$i]->total_tva; } - $localtax1ligne=$object->lines[$i]->total_localtax1; - $localtax2ligne=$object->lines[$i]->total_localtax2; - $localtax1_rate=$object->lines[$i]->localtax1_tx; - $localtax2_rate=$object->lines[$i]->localtax2_tx; - $localtax1_type=$object->lines[$i]->localtax1_type; - $localtax2_type=$object->lines[$i]->localtax2_type; + $localtax1ligne = $object->lines[$i]->total_localtax1; + $localtax2ligne = $object->lines[$i]->total_localtax2; + $localtax1_rate = $object->lines[$i]->localtax1_tx; + $localtax2_rate = $object->lines[$i]->localtax2_tx; + $localtax1_type = $object->lines[$i]->localtax1_type; + $localtax2_type = $object->lines[$i]->localtax2_type; - if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; - if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; - if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; + if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100; + if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100; + if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100; - $vatrate=(string) $object->lines[$i]->tva_tx; + $vatrate = (string) $object->lines[$i]->tva_tx; // Retrieve type from database for backward compatibility with old records - if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined - && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax + if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined + && (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax { - $localtaxtmp_array=getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc); + $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc); $localtax1_type = $localtaxtmp_array[0]; $localtax2_type = $localtaxtmp_array[2]; } // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0) { - $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; + $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; } if ($localtax2_type && $localtax2ligne != 0) { - $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; + $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; } - if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; - if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; + if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*'; + if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0; $this->tva[$vatrate] += $tvaligne; $nexY = max($nexY, $posYAfterImage); // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { + if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { $pdf->setPage($pageposafter); - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); + $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); + $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1); $pdf->SetLineStyle(array('dash'=>0)); } - $nexY+=2; // Add space between lines + $nexY += 2; // Add space between lines // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) { @@ -813,11 +813,11 @@ class pdf_sponge extends ModelePDFFactures $this->_pagefoot($pdf, $object, $outputlangs, 1); $pagenb++; $pdf->setPage($pagenb); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) { + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == $pageposafter) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code); } @@ -828,7 +828,7 @@ class pdf_sponge extends ModelePDFFactures $this->_pagefoot($pdf, $object, $outputlangs, 1); // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } @@ -838,24 +838,24 @@ class pdf_sponge extends ModelePDFFactures if ($pagenb == $pageposbeforeprintlines) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } // Display infos area - $posy=$this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs); + $posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs); // Display total zone - $posy=$this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); + $posy = $this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); // Display payment area if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS)) { - $posy=$this->drawPaymentsTable($pdf, $object, $posy, $outputlangs); + $posy = $this->drawPaymentsTable($pdf, $object, $posy, $outputlangs); } // Pagefoot @@ -1236,15 +1236,15 @@ class pdf_sponge extends ModelePDFFactures $col1x = 120; $col2x = 170; if ($this->page_largeur < 210) // To work with US executive format { - $col2x-=20; + $col2x -= 20; } $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); - $useborder=0; + $useborder = 0; $index = 0; $outputlangsbis = null; - if (! empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { + if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { $outputlangsbis = new Translate('', $conf); $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal")); @@ -1252,18 +1252,18 @@ class pdf_sponge extends ModelePDFFactures // overall percentage of advancement $percent = 0; - $i=0; + $i = 0; foreach ($object->lines as $line) { - if(!class_exists('TSubtotal') || !TSubtotal::isModSubtotalLine($line)){ + if (!class_exists('TSubtotal') || !TSubtotal::isModSubtotalLine($line)) { $percent += $line->situation_percent; $i++; } } - if(!empty($i)){ - $avancementGlobal = $percent/$i; + if (!empty($i)) { + $avancementGlobal = $percent / $i; } - else{ + else { $avancementGlobal = 0; } @@ -1272,18 +1272,18 @@ class pdf_sponge extends ModelePDFFactures $total_a_payer = 0; $total_a_payer_ttc = 0; - foreach ($TPreviousIncoice as &$fac){ + foreach ($TPreviousIncoice as &$fac) { $total_a_payer += $fac->total_ht; $total_a_payer_ttc += $fac->total_ttc; } $total_a_payer += $object->total_ht; $total_a_payer_ttc += $object->total_ttc; - if(!empty($avancementGlobal)){ + if (!empty($avancementGlobal)) { $total_a_payer = $total_a_payer * 100 / $avancementGlobal; - $total_a_payer_ttc = $total_a_payer_ttc * 100 / $avancementGlobal; + $total_a_payer_ttc = $total_a_payer_ttc * 100 / $avancementGlobal; } - else{ + else { $total_a_payer = 0; $total_a_payer_ttc = 0; } @@ -1295,7 +1295,7 @@ class pdf_sponge extends ModelePDFFactures $posy = $pdf->GetY(); foreach ($TPreviousIncoice as &$fac) { - if($posy > $this->page_hauteur - 4 ) { + if ($posy > $this->page_hauteur - 4) { $this->_pagefoot($pdf, $object, $outputlangs, 1); $pdf->addPage(); $pdf->setY($this->marge_haute); @@ -1306,13 +1306,13 @@ class pdf_sponge extends ModelePDFFactures $index++; $pdf->SetFillColor(255, 255, 255); $pdf->SetXY($col1x, $posy); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $fac->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $fac->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1); $pdf->SetXY($col2x, $posy); $facSign = ''; - if ($i>1) { - $facSign = $fac->total_ht>=0?'+':''; + if ($i > 1) { + $facSign = $fac->total_ht >= 0 ? '+' : ''; } $displayAmount = ' '.$facSign.' '.price($fac->total_ht, 0, $outputlangs); @@ -1329,12 +1329,12 @@ class pdf_sponge extends ModelePDFFactures // Display current total $pdf->SetFillColor(255, 255, 255); $pdf->SetXY($col1x, $posy); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $object->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $object->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1); $pdf->SetXY($col2x, $posy); $facSign = ''; - if ($i>1) { - $facSign = $object->total_ht>=0?'+':''; // management of a particular customer case + if ($i > 1) { + $facSign = $object->total_ht >= 0 ? '+' : ''; // management of a particular customer case } if ($fac->type === facture::TYPE_CREDIT_NOTE) { @@ -1351,22 +1351,22 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetFont('', '', $default_font_size - 1); $pdf->SetFillColor(255, 255, 255); $pdf->SetXY($col1x, $posy); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("SituationTotalProgress", $avancementGlobal), 0, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("SituationTotalProgress", $avancementGlobal), 0, 'L', 1); $pdf->SetXY($col2x, $posy); - $pdf->MultiCell($largcol2, $tab2_hl, price($total_a_payer*$avancementGlobal/100, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_a_payer * $avancementGlobal / 100, 0, $outputlangs), 0, 'R', 1); $pdf->SetFont('', '', $default_font_size - 2); $posy += $tab2_hl; - if($posy > $this->page_hauteur - 4 ) { + if ($posy > $this->page_hauteur - 4) { $pdf->addPage(); $pdf->setY($this->marge_haute); $posy = $pdf->GetY(); } $tab2_top = $posy; - $index=0; + $index = 0; } $tab2_top += 3; @@ -1375,27 +1375,27 @@ class pdf_sponge extends ModelePDFFactures $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht); // Total remise - $total_line_remise=0; - foreach($object->lines as $i => $line) { - $total_line_remise+= pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, 2); // TODO: add this methode to core/lib/pdf.lib + $total_line_remise = 0; + foreach ($object->lines as $i => $line) { + $total_line_remise += pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, 2); // TODO: add this methode to core/lib/pdf.lib // Gestion remise sous forme de ligne négative - if($line->total_ht < 0) $total_line_remise += -$line->total_ht; + if ($line->total_ht < 0) $total_line_remise += -$line->total_ht; } - if($total_line_remise > 0) { - if (! empty($conf->global->MAIN_SHOW_AMOUNT_DISCOUNT)) { + if ($total_line_remise > 0) { + if (!empty($conf->global->MAIN_SHOW_AMOUNT_DISCOUNT)) { $pdf->SetFillColor(255, 255, 255); $pdf->SetXY($col1x, $tab2_top + $tab2_hl); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalDiscount").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalDiscount") : ''), 0, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalDiscount").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalDiscount") : ''), 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl); $pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise, 0, $outputlangs), 0, 'R', 1); $index++; } // Show total NET before discount - if (! empty($conf->global->MAIN_SHOW_AMOUNT_BEFORE_DISCOUNT)) { + if (!empty($conf->global->MAIN_SHOW_AMOUNT_BEFORE_DISCOUNT)) { $pdf->SetFillColor(255, 255, 255); $pdf->SetXY($col1x, $tab2_top + 0); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHTBeforeDiscount").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHTBeforeDiscount") : ''), 0, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHTBeforeDiscount").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHTBeforeDiscount") : ''), 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + 0); $pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise + $total_ht, 0, $outputlangs), 0, 'R', 1); @@ -1406,22 +1406,22 @@ class pdf_sponge extends ModelePDFFactures // Total HT $pdf->SetFillColor(255, 255, 255); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHT") : ''), 0, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHT") : ''), 0, 'L', 1); $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (! empty($object->remise)?$object->remise:0)), 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, $outputlangs), 0, 'R', 1); // Show VAT by rates and total $pdf->SetFillColor(248, 248, 248); $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; - $this->atleastoneratenotnull=0; + $this->atleastoneratenotnull = 0; if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { - $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false); - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) + $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false); + if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) { // Nothing to do } @@ -1432,30 +1432,30 @@ class pdf_sponge extends ModelePDFFactures //Local tax 1 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ - foreach($this->localtax1 as $localtax_type => $localtax_rate) + foreach ($this->localtax1 as $localtax_type => $localtax_rate) { if (in_array((string) $localtax_type, array('1', '3', '5'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + foreach ($localtax_rate as $tvakey => $tvaval) { - if ($tvakey!=0) // On affiche pas taux 0 + if ($tvakey != 0) // On affiche pas taux 0 { //$this->atleastoneratenotnull++; $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : ''); - $totalvat.=' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat .= ' '; + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); @@ -1466,29 +1466,29 @@ class pdf_sponge extends ModelePDFFactures //Local tax 2 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //{ - foreach($this->localtax2 as $localtax_type => $localtax_rate) + foreach ($this->localtax2 as $localtax_type => $localtax_rate) { - if (in_array((string) $localtax_type, array('1','3','5'))) continue; + if (in_array((string) $localtax_type, array('1', '3', '5'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + foreach ($localtax_rate as $tvakey => $tvaval) { - if ($tvakey!=0) // On affiche pas taux 0 + if ($tvakey != 0) // On affiche pas taux 0 { //$this->atleastoneratenotnull++; $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : ''); - $totalvat.=' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat .= ' '; + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); @@ -1501,12 +1501,12 @@ class pdf_sponge extends ModelePDFFactures // Situations totals migth be wrong on huge amounts if ($object->situation_cycle_ref && $object->situation_counter > 1) { $sum_pdf_tva = 0; - foreach($this->tva as $tvakey => $tvaval){ - $sum_pdf_tva+=$tvaval; // sum VAT amounts to compare to object + foreach ($this->tva as $tvakey => $tvaval) { + $sum_pdf_tva += $tvaval; // sum VAT amounts to compare to object } - if($sum_pdf_tva!=$object->total_tva) { // apply coef to recover the VAT object amount (the good one) - if(!empty($sum_pdf_tva)) + if ($sum_pdf_tva != $object->total_tva) { // apply coef to recover the VAT object amount (the good one) + if (!empty($sum_pdf_tva)) { $coef_fix_tva = $object->total_tva / $sum_pdf_tva; } @@ -1515,13 +1515,13 @@ class pdf_sponge extends ModelePDFFactures } - foreach($this->tva as $tvakey => $tvaval) { - $this->tva[$tvakey]=$tvaval * $coef_fix_tva; + foreach ($this->tva as $tvakey => $tvaval) { + $this->tva[$tvakey] = $tvaval * $coef_fix_tva; } } } - foreach($this->tva as $tvakey => $tvaval) + foreach ($this->tva as $tvakey => $tvaval) { if ($tvakey != 0) // On affiche pas taux 0 { @@ -1537,7 +1537,7 @@ class pdf_sponge extends ModelePDFFactures $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : ''); - $totalvat.=' '; + $totalvat .= ' '; $totalvat .= vatrate($tvakey, 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); @@ -1549,11 +1549,11 @@ class pdf_sponge extends ModelePDFFactures //Local tax 1 after VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ - foreach($this->localtax1 as $localtax_type => $localtax_rate) + foreach ($this->localtax1 as $localtax_type => $localtax_rate) { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; + if (in_array((string) $localtax_type, array('2', '4', '6'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + foreach ($localtax_rate as $tvakey => $tvaval) { if ($tvakey != 0) // On affiche pas taux 0 { @@ -1562,17 +1562,17 @@ class pdf_sponge extends ModelePDFFactures $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : ''); - $totalvat.=' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; + $totalvat .= ' '; + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } @@ -1582,11 +1582,11 @@ class pdf_sponge extends ModelePDFFactures //Local tax 2 after VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //{ - foreach($this->localtax2 as $localtax_type => $localtax_rate) + foreach ($this->localtax2 as $localtax_type => $localtax_rate) { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; + if (in_array((string) $localtax_type, array('2', '4', '6'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + foreach ($localtax_rate as $tvakey => $tvaval) { // retrieve global local tax if ($tvakey != 0) // On affiche pas taux 0 @@ -1596,17 +1596,17 @@ class pdf_sponge extends ModelePDFFactures $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : ''); - $totalvat.=' '; + $totalvat .= ' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); @@ -1652,31 +1652,31 @@ class pdf_sponge extends ModelePDFFactures // Retained warranty - if( !empty($object->situation_final) && ( $object->type == Facture::TYPE_SITUATION && (!empty($object->retained_warranty) ) ) ) + if (!empty($object->situation_final) && ($object->type == Facture::TYPE_SITUATION && (!empty($object->retained_warranty)))) { $displayWarranty = false; // Check if this situation invoice is 100% for real - if(!empty($object->situation_final)){ + if (!empty($object->situation_final)) { $displayWarranty = true; } - elseif(!empty($object->lines) && $object->status == Facture::STATUS_DRAFT ){ + elseif (!empty($object->lines) && $object->status == Facture::STATUS_DRAFT) { // $object->situation_final need validation to be done so this test is need for draft $displayWarranty = true; - foreach($object->lines as $i => $line){ - if($line->product_type < 2 && $line->situation_percent < 100){ + foreach ($object->lines as $i => $line) { + if ($line->product_type < 2 && $line->situation_percent < 100) { $displayWarranty = false; break; } } } - if($displayWarranty){ + if ($displayWarranty) { $pdf->SetTextColor(40, 40, 40); $pdf->SetFillColor(255, 255, 255); $retainedWarranty = $total_a_payer_ttc * $object->retained_warranty / 100; - $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty ; + $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty; // Billed - retained warranty $index++; @@ -1690,10 +1690,10 @@ class pdf_sponge extends ModelePDFFactures $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $retainedWarrantyToPayOn = $outputlangs->transnoentities("PDFEVOLRetainedWarranty") . ' ('.$object->retained_warranty.'%)'; - $retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit)?' '.$outputlangs->transnoentities("PDFEVOLtoPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')):''; + $retainedWarrantyToPayOn = $outputlangs->transnoentities("PDFEVOLRetainedWarranty").' ('.$object->retained_warranty.'%)'; + $retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit) ? ' '.$outputlangs->transnoentities("PDFEVOLtoPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')) : ''; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($retainedWarranty), $useborder, 'R', 1); } @@ -1714,7 +1714,7 @@ class pdf_sponge extends ModelePDFFactures // Already paid + Deposits $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Paid").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("Paid") : ''), 0, 'L', 0); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Paid").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("Paid") : ''), 0, 'L', 0); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle + $depositsamount, 0, $outputlangs), 0, 'R', 0); @@ -1806,12 +1806,12 @@ class pdf_sponge extends ModelePDFFactures if (empty($hidetop)) { $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; - if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); + if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { + $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); } } @@ -1819,13 +1819,13 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); - if (empty($hidetop)){ - $pdf->line($this->marge_gauche, $tab_top+$this->tabTitleHeight, $this->page_largeur-$this->marge_droite, $tab_top+$this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter + if (empty($hidetop)) { + $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter } } @@ -1861,8 +1861,8 @@ class pdf_sponge extends ModelePDFFactures $w = 110; - $posy=$this->marge_haute; - $posx=$this->page_largeur-$this->marge_droite-$w; + $posy = $this->marge_haute; + $posx = $this->page_largeur - $this->marge_droite - $w; $pdf->SetXY($this->marge_gauche, $posy); @@ -1872,7 +1872,7 @@ class pdf_sponge extends ModelePDFFactures if ($this->emetteur->logo) { $logodir = $conf->mycompany->dir_output; - if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity]; + if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity]; if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; @@ -1882,8 +1882,8 @@ class pdf_sponge extends ModelePDFFactures } if (is_readable($logo)) { - $height=pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + $height = pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) } else { diff --git a/htdocs/core/modules/facture/modules_facture.php b/htdocs/core/modules/facture/modules_facture.php index f27f086ec7d..56379a0c492 100644 --- a/htdocs/core/modules/facture/modules_facture.php +++ b/htdocs/core/modules/facture/modules_facture.php @@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Required because used in classes that inherit +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Required because used in classes that inherit /** @@ -40,7 +40,7 @@ abstract class ModelePDFFactures extends CommonDocGenerator /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; public $atleastonediscount = 0; public $atleastoneratenotnull = 0; @@ -59,11 +59,11 @@ abstract class ModelePDFFactures extends CommonDocGenerator // phpcs:enable global $conf; - $type='invoice'; - $liste=array(); + $type = 'invoice'; + $liste = array(); include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $liste=getListOfModels($db, $type, $maxfilenamelength); + $liste = getListOfModels($db, $type, $maxfilenamelength); return $liste; } @@ -77,7 +77,7 @@ abstract class ModeleNumRefFactures /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * Return if a module can be used or not diff --git a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php index fca1df1386d..1b6ddf143e0 100644 --- a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php @@ -118,7 +118,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder */ public function __construct($db) { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; // Translations $langs->loadLangs(array("main", "bills", "sendings", "companies")); @@ -129,45 +129,45 @@ class pdf_typhon extends ModelePDFDeliveryOrder // Page size for A4 format $this->type = 'pdf'; - $formatarray=pdf_getFormat(); + $formatarray = pdf_getFormat(); $this->page_largeur = $formatarray['width']; $this->page_hauteur = $formatarray['height']; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; - $this->option_logo = 1; // Display logo FAC_PDF_LOGO - $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION - $this->option_codeproduitservice = 1; // Display product-service code + $this->option_logo = 1; // Display logo FAC_PDF_LOGO + $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION + $this->option_codeproduitservice = 1; // Display product-service code // Get source company - $this->emetteur=$mysoc; - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default, if was not defined + $this->emetteur = $mysoc; + if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined // Define position of columns - $this->posxdesc=$this->marge_gauche+1; - $this->posxcomm=112; + $this->posxdesc = $this->marge_gauche + 1; + $this->posxcomm = 112; //$this->posxtva=112; //$this->posxup=126; - $this->posxqty=165; - $this->posxremainingqty=185; + $this->posxqty = 165; + $this->posxremainingqty = 185; //$this->posxdiscount=162; //$this->postotalht=174; if ($this->page_largeur < 210) // To work with US executive format { - $this->posxcomm-=20; + $this->posxcomm -= 20; //$this->posxtva-=20; //$this->posxup-=20; - $this->posxqty-=20; + $this->posxqty -= 20; //$this->posxdiscount-=20; //$this->postotalht-=20; } - $this->tva=array(); - $this->atleastoneratenotnull=0; - $this->atleastonediscount=0; + $this->tva = array(); + $this->atleastoneratenotnull = 0; + $this->atleastonediscount = 0; } @@ -186,11 +186,11 @@ class pdf_typhon extends ModelePDFDeliveryOrder public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$langs,$conf,$mysoc,$hookmanager; + global $user, $langs, $conf, $mysoc, $hookmanager; - if (! is_object($outputlangs)) $outputlangs=$langs; + if (!is_object($outputlangs)) $outputlangs = $langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; // Load translation files required by the page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "sendings", "deliveries")); @@ -203,20 +203,20 @@ class pdf_typhon extends ModelePDFDeliveryOrder if ($object->specimen) { $dir = $conf->expedition->dir_output."/receipt"; - $file = $dir . "/SPECIMEN.pdf"; + $file = $dir."/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); - $dir = $conf->expedition->dir_output."/receipt/" . $objectref; - $file = $dir . "/" . $objectref . ".pdf"; + $dir = $conf->expedition->dir_output."/receipt/".$objectref; + $file = $dir."/".$objectref.".pdf"; } - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } @@ -224,25 +224,25 @@ class pdf_typhon extends ModelePDFDeliveryOrder if (file_exists($dir)) { // Add pdfgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $nblines = count($object->lines); // Create pdf instance - $pdf=pdf_getInstance($this->format); - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance - $heightforinfotot = 30; // Height reserved to output the info and total part - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; + $pdf = pdf_getInstance($this->format); + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance + $heightforinfotot = 30; // Height reserved to output the info and total part + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; $pdf->SetAutoPageBreak(1, 0); if (class_exists('TCPDF')) @@ -252,14 +252,14 @@ class pdf_typhon extends ModelePDFDeliveryOrder } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); } // We get the shipment that is the origin of delivery receipt - $expedition=new Expedition($this->db); + $expedition = new Expedition($this->db); $result = $expedition->fetch($object->origin_id); // Now we get the order that is origin of shipment $commande = new Commande($this->db); @@ -267,12 +267,12 @@ class pdf_typhon extends ModelePDFDeliveryOrder { $commande->fetch($expedition->origin_id); } - $object->commande=$commande; // We set order of shipment onto delivery. + $object->commande = $commande; // We set order of shipment onto delivery. $object->commande->loadExpeditions(); $pdf->Open(); - $pagenb=0; + $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); @@ -280,9 +280,9 @@ class pdf_typhon extends ModelePDFDeliveryOrder $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("DeliveryOrder")); - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right /* // Positionne $this->atleastonediscount si on a au moins une remise @@ -306,15 +306,15 @@ class pdf_typhon extends ModelePDFDeliveryOrder // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); $tab_top = 90; - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); $tab_height = 130; $tab_height_newpage = 150; @@ -328,39 +328,39 @@ class pdf_typhon extends ModelePDFDeliveryOrder $tab_top = 88; $pdf->SetFont('', '', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); $nexY = $pdf->GetY(); - $height_incoterms=$nexY-$tab_top; + $height_incoterms = $nexY - $tab_top; // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); - $tab_top = $nexY+6; + $tab_top = $nexY + 6; $height_incoterms += 4; } } // Affiche notes - if (! empty($object->note_public)) + if (!empty($object->note_public)) { $tab_top = 88 + $height_incoterms; $pdf->SetFont('', '', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1); $nexY = $pdf->GetY(); - $height_note=$nexY-$tab_top; + $height_note = $nexY - $tab_top; // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); $tab_height = $tab_height - $height_note; - $tab_top = $nexY+6; + $tab_top = $nexY + 6; } else { - $height_note=0; + $height_note = 0; } $iniY = $tab_top + 11; @@ -368,46 +368,46 @@ class pdf_typhon extends ModelePDFDeliveryOrder $nexY = $tab_top + 11; // Loop on each lines - for ($i = 0 ; $i < $nblines ; $i++) + for ($i = 0; $i < $nblines; $i++) { $curY = $nexY; - $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0, 0, 0); $pdf->setTopMargin($tab_top_newpage); - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. - $pageposbefore=$pdf->getPage(); + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $pageposbefore = $pdf->getPage(); // Description of product line - $curX = $this->posxdesc-1; + $curX = $this->posxdesc - 1; - $showpricebeforepagebreak=1; + $showpricebeforepagebreak = 1; $pdf->startTransaction(); - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxcomm-$curX, 3, $curX, $curY, $hideref, $hidedesc); - $pageposafter=$pdf->getPage(); + pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxcomm - $curX, 3, $curX, $curY, $hideref, $hidedesc); + $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { $pdf->rollbackTransaction(true); - $pageposafter=$pageposbefore; + $pageposafter = $pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxcomm-$curX, 4, $curX, $curY, $hideref, $hidedesc); - $posyafter=$pdf->GetY(); - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxcomm - $curX, 4, $curX, $curY, $hideref, $hidedesc); + $posyafter = $pdf->GetY(); + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text { - if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page + if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page { $pdf->AddPage('', '', true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposafter+1); + $pdf->setPage($pageposafter + 1); } } else { // We found a page break - $showpricebeforepagebreak=0; + $showpricebeforepagebreak = 0; } } else // No pagebreak @@ -416,17 +416,17 @@ class pdf_typhon extends ModelePDFDeliveryOrder } $nexY = $pdf->GetY(); - $pageposafter=$pdf->getPage(); + $pageposafter = $pdf->getPage(); $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. // We suppose that a too long description is moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { $pdf->setPage($pageposafter); $curY = $tab_top_newpage; } - $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut + $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut /* // TVA @@ -445,7 +445,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder // Remaining to ship $pdf->SetXY($this->posxremainingqty, $curY); $qtyRemaining = $object->lines[$i]->qty_asked - $object->commande->expeditions[$object->lines[$i]->fk_origin_line]; - $pdf->MultiCell($this->page_largeur-$this->marge_droite - $this->posxremainingqty, 3, $qtyRemaining, 0, 'R'); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxremainingqty, 3, $qtyRemaining, 0, 'R'); /* // Remise sur ligne $pdf->SetXY($this->posxdiscount, $curY); @@ -467,16 +467,16 @@ class pdf_typhon extends ModelePDFDeliveryOrder */ // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) + if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { $pdf->setPage($pageposafter); - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); + $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); + $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1); $pdf->SetLineStyle(array('dash'=>0)); } - $nexY+=2; // Add space between lines + $nexY += 2; // Add space between lines // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) @@ -493,10 +493,10 @@ class pdf_typhon extends ModelePDFDeliveryOrder $this->_pagefoot($pdf, $object, $outputlangs, 1); $pagenb++; $pdf->setPage($pagenb); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { @@ -509,7 +509,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder $this->_pagefoot($pdf, $object, $outputlangs, 1); // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } @@ -519,12 +519,12 @@ class pdf_typhon extends ModelePDFDeliveryOrder if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } // Affiche zone infos @@ -601,36 +601,36 @@ class pdf_typhon extends ModelePDFDeliveryOrder $pdf->Output($file, 'F'); // Add pdfgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { $this->error = $hookmanager->error; $this->errors = $hookmanager->errors; } - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); $this->result = array('fullpath'=>$file); - return 1; // No error + return 1; // No error } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } - $this->error=$langs->transnoentities("ErrorConstantNotDefined", "LIVRAISON_OUTPUTDIR"); + $this->error = $langs->transnoentities("ErrorConstantNotDefined", "LIVRAISON_OUTPUTDIR"); return 0; } @@ -648,19 +648,19 @@ class pdf_typhon extends ModelePDFDeliveryOrder protected function _tableau_info(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable - global $conf,$mysoc; + global $conf, $mysoc; $default_font_size = pdf_getPDFFontSize($outputlangs); $pdf->SetFont('', '', $default_font_size); $pdf->SetXY($this->marge_gauche, $posy); - $larg_sign = ($this->page_largeur-$this->marge_gauche-$this->marge_droite)/3; + $larg_sign = ($this->page_largeur - $this->marge_gauche - $this->marge_droite) / 3; $pdf->Rect($this->marge_gauche, $posy + 1, $larg_sign, 25); $pdf->SetXY($this->marge_gauche + 2, $posy + 2); $pdf->MultiCell($larg_sign, 2, $outputlangs->trans("For").' '.$outputlangs->convToOutputCharset($mysoc->name).":", '', 'L'); - $pdf->Rect(2*$larg_sign+$this->marge_gauche, $posy + 1, $larg_sign, 25); - $pdf->SetXY(2*$larg_sign+$this->marge_gauche + 2, $posy + 2); + $pdf->Rect(2 * $larg_sign + $this->marge_gauche, $posy + 1, $larg_sign, 25); + $pdf->SetXY(2 * $larg_sign + $this->marge_gauche + 2, $posy + 2); $pdf->MultiCell($larg_sign, 2, $outputlangs->trans("ForCustomer").':', '', 'L'); } @@ -679,11 +679,11 @@ class pdf_typhon extends ModelePDFDeliveryOrder */ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) { - global $conf,$mysoc; + global $conf, $mysoc; // Force to disable hidetop and hidebottom - $hidebottom=0; - if ($hidetop) $hidetop=-1; + $hidebottom = 0; + if ($hidetop) $hidetop = -1; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -692,11 +692,11 @@ class pdf_typhon extends ModelePDFDeliveryOrder $pdf->SetFont('', '', $default_font_size - 2); // Output Rec - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter if (empty($hidetop)) { - $pdf->line($this->marge_gauche, $tab_top+10, $this->page_largeur-$this->marge_droite, $tab_top+10); + $pdf->line($this->marge_gauche, $tab_top + 10, $this->page_largeur - $this->marge_droite, $tab_top + 10); } $pdf->SetDrawColor(128, 128, 128); @@ -704,29 +704,29 @@ class pdf_typhon extends ModelePDFDeliveryOrder if (empty($hidetop)) { - $pdf->SetXY($this->posxdesc-1, $tab_top+1); + $pdf->SetXY($this->posxdesc - 1, $tab_top + 1); $pdf->MultiCell($this->posxcomm - $this->posxdesc, 2, $outputlangs->transnoentities("Designation"), '', 'L'); } // Modif SEB pour avoir une col en plus pour les commentaires clients $pdf->line($this->posxcomm, $tab_top, $this->posxcomm, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxcomm, $tab_top+1); + $pdf->SetXY($this->posxcomm, $tab_top + 1); $pdf->MultiCell($this->posxqty - $this->posxcomm, 2, $outputlangs->transnoentities("Comments"), '', 'L'); } // Qty $pdf->line($this->posxqty, $tab_top, $this->posxqty, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxqty, $tab_top+1); + $pdf->SetXY($this->posxqty, $tab_top + 1); $pdf->MultiCell($this->posxremainingqty - $this->posxqty, 2, $outputlangs->transnoentities("QtyShippedShort"), '', 'R'); } // Remain to ship $pdf->line($this->posxremainingqty, $tab_top, $this->posxremainingqty, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxremainingqty, $tab_top+1); - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxremainingqty, 2, $outputlangs->transnoentities("KeepToShipShort"), '', 'R'); + $pdf->SetXY($this->posxremainingqty, $tab_top + 1); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxremainingqty, 2, $outputlangs->transnoentities("KeepToShipShort"), '', 'R'); } } @@ -742,14 +742,14 @@ class pdf_typhon extends ModelePDFDeliveryOrder */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { - global $conf,$langs,$hookmanager; + global $conf, $langs, $hookmanager; $default_font_size = pdf_getPDFFontSize($outputlangs); pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); // Show Draft Watermark - if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) ) + if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK))) { pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK); } @@ -757,19 +757,19 @@ class pdf_typhon extends ModelePDFDeliveryOrder $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); - $posy=$this->marge_haute; - $posx=$this->page_largeur-$this->marge_droite-100; + $posy = $this->marge_haute; + $posx = $this->page_largeur - $this->marge_droite - 100; $pdf->SetXY($this->marge_gauche, $posy); // Logo - $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; + $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; if ($this->emetteur->logo) { if (is_readable($logo)) { - $height=pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + $height = pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) } else { @@ -788,12 +788,12 @@ class pdf_typhon extends ModelePDFDeliveryOrder $pdf->SetFont('', '', $default_font_size + 2); - $posy+=5; + $posy += 5; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); if ($object->date_valid) { - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date_delivery, "%d %b %Y", false, $outputlangs, true), '', 'R'); + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date_delivery, "%d %b %Y", false, $outputlangs, true), '', 'R'); } else { @@ -804,15 +804,15 @@ class pdf_typhon extends ModelePDFDeliveryOrder if ($object->thirdparty->code_client) { - $posy+=5; + $posy += 5; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); } $pdf->SetTextColor(0, 0, 60); - $posy+=2; + $posy += 2; // Show list of linked objects $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); @@ -823,15 +823,15 @@ class pdf_typhon extends ModelePDFDeliveryOrder $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); // Show sender - $posy=42; - $posx=$this->marge_gauche; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; - $hautcadre=40; + $posy = 42; + $posx = $this->marge_gauche; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80; + $hautcadre = 40; // Show sender frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx, $posy-5); + $pdf->SetXY($posx, $posy - 5); $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); @@ -839,32 +839,32 @@ class pdf_typhon extends ModelePDFDeliveryOrder $pdf->SetTextColor(0, 0, 60); // Show sender name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); - $posy=$pdf->getY(); + $posy = $pdf->getY(); // Show sender information - $pdf->SetXY($posx+2, $posy); + $pdf->SetXY($posx + 2, $posy); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); // Client destinataire - $posy=42; - $posx=102; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; + $posy = 42; + $posx = 102; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx, $posy-5); + $pdf->SetXY($posx, $posy - 5); $pdf->MultiCell(80, 5, $outputlangs->transnoentities("DeliveryAddress").":", 0, 'L'); // If SHIPPING contact defined on order, we use it - $usecontact=false; - $arrayidcontact=$object->commande->getIdContact('external', 'SHIPPING'); + $usecontact = false; + $arrayidcontact = $object->commande->getIdContact('external', 'SHIPPING'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } //Recipient name @@ -875,26 +875,26 @@ class pdf_typhon extends ModelePDFDeliveryOrder $thirdparty = $object->thirdparty; } - $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); + $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact?$object->contact:''), $usecontact, 'target', $object); + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); // Show recipient - $widthrecbox=100; - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format - $posy=42; - $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; + $widthrecbox = 100; + if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format + $posy = 42; + $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; // Show recipient frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx+2, $posy-5); + $pdf->SetXY($posx + 2, $posy - 5); //$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L'); $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); // Show recipient name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L'); @@ -902,7 +902,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder // Show recipient information $pdf->SetFont('', '', $default_font_size - 1); - $pdf->SetXY($posx+2, $posy); + $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); } @@ -922,7 +922,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; return pdf_pagefoot($pdf, $outputlangs, 'DELIVERY_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); } } diff --git a/htdocs/core/modules/modCashDesk.class.php b/htdocs/core/modules/modCashDesk.class.php index afb5185fb51..9bff4afdaf8 100644 --- a/htdocs/core/modules/modCashDesk.class.php +++ b/htdocs/core/modules/modCashDesk.class.php @@ -22,7 +22,7 @@ * \ingroup pos * \brief File to enable/disable module Point Of Sales */ -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; /** @@ -64,13 +64,13 @@ class modCashDesk extends DolibarrModules $this->config_page_url = array("cashdesk.php@cashdesk"); // Dependencies - $this->hidden = false; // A condition to hide module - $this->depends = array('always'=>"modBanque", 'always'=>"modFacture", 'always'=>"modProduct", 'FR'=>'modBlockedLog'); // List of modules id that must be enabled if this module is enabled - $this->requiredby = array(); // List of modules id to disable if this one is disabled - $this->phpmin = array(5,4); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(2,4); // Minimum version of Dolibarr required by module + $this->hidden = false; // A condition to hide module + $this->depends = array('always'=>"modBanque", 'always'=>"modFacture", 'always'=>"modProduct", 'FR'=>'modBlockedLog'); // List of modules id that must be enabled if this module is enabled + $this->requiredby = array(); // List of modules id to disable if this one is disabled + $this->phpmin = array(5, 4); // Minimum version of PHP required by module + $this->need_dolibarr_version = array(2, 4); // Minimum version of Dolibarr required by module $this->langfiles = array("cashdesk"); - $this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text') + $this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text') //$this->warnings_activation_ext = array('FR'=>'WarningInstallationMayBecomeNotCompliantWithLaw'); // Warning to show when we activate an external module. array('always'='text') or array('FR'='text') // Constants @@ -81,7 +81,7 @@ class modCashDesk extends DolibarrModules // Permissions $this->rights = array(); - $r=0; + $r = 0; $r++; $this->rights[$r][0] = 50101; @@ -91,21 +91,21 @@ class modCashDesk extends DolibarrModules $this->rights[$r][4] = 'run'; // Main menu entries - $this->menus = array(); // List of menus to add - $r=0; + $this->menus = array(); // List of menus to add + $r = 0; // This is to declare the Top Menu entry: - $this->menu[$r]=array( 'fk_menu'=>0, // Put 0 if this is a top menu - 'type'=>'top', // This is a Top menu entry + $this->menu[$r] = array('fk_menu'=>0, // Put 0 if this is a top menu + 'type'=>'top', // This is a Top menu entry 'titre'=>'PointOfSaleShort', 'mainmenu'=>'cashdesk', 'url'=>'/cashdesk/index.php?user=__USER_LOGIN__', - 'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'position'=>900, 'enabled'=>'$conf->cashdesk->enabled', - 'perms'=>'$user->rights->cashdesk->run', // Use 'perms'=>'1' if you want your menu with no permission rules + 'perms'=>'$user->rights->cashdesk->run', // Use 'perms'=>'1' if you want your menu with no permission rules 'target'=>'pointofsale', - 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both + 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both $r++; diff --git a/htdocs/core/modules/modMrp.class.php b/htdocs/core/modules/modMrp.class.php index a5d58bd8333..1ca8e380aa4 100644 --- a/htdocs/core/modules/modMrp.class.php +++ b/htdocs/core/modules/modMrp.class.php @@ -26,7 +26,7 @@ * \ingroup mrp * \brief Description and activation file for module Mrp */ -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; /** * Description and activation class for module Mrp @@ -40,7 +40,7 @@ class modMrp extends DolibarrModules */ public function __construct($db) { - global $langs,$conf; + global $langs, $conf; $this->db = $db; // Id for module (must be unique). @@ -71,7 +71,7 @@ class modMrp extends DolibarrModules // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' - $this->picto='mrp'; + $this->picto = 'mrp'; // Define some features supported by module (triggers, login, substitutions, menus, css, etc...) $this->module_parts = array( // Set this to 1 if module has its own trigger directory (core/triggers) @@ -119,13 +119,13 @@ class modMrp extends DolibarrModules $this->hidden = false; // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...) $this->depends = array('modBom'); - $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) - $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) + $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) + $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) $this->langfiles = array("mrp"); - $this->phpmin = array(5,5); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(8,0); // Minimum version of Dolibarr required by module - $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) - $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->phpmin = array(5, 5); // Minimum version of PHP required by module + $this->need_dolibarr_version = array(8, 0); // Minimum version of Dolibarr required by module + $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) //$this->automatic_activation = array('FR'=>'MrpWasAutomaticallyActivatedBecauseOfYourCountryChoice'); //$this->always_enabled = true; // If true, can't be disabled @@ -146,9 +146,9 @@ class modMrp extends DolibarrModules 'fr_FR:ParentCompany'=>'Maison mère ou revendeur' )*/ - if (! isset($conf->mrp) || ! isset($conf->mrp->enabled)) { - $conf->mrp=new stdClass(); - $conf->mrp->enabled=0; + if (!isset($conf->mrp) || !isset($conf->mrp->enabled)) { + $conf->mrp = new stdClass(); + $conf->mrp->enabled = 0; } // Array to add new pages in new tabs @@ -180,7 +180,7 @@ class modMrp extends DolibarrModules // 'user' to add a tab in user view // Dictionaries - $this->dictionaries=array(); + $this->dictionaries = array(); /* Example: $this->dictionaries=array( 'langs'=>'mylangfile@mrp', @@ -236,35 +236,35 @@ class modMrp extends DolibarrModules // Permissions provided by this module $this->rights = array(); - $r=0; + $r = 0; // Add here entries to declare new permissions /* BEGIN MODULEBUILDER PERMISSIONS */ - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) - $this->rights[$r][1] = 'Read Manufacturing Order'; // Permission label - $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Read Manufacturing Order'; // Permission label + $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) $r++; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) - $this->rights[$r][1] = 'Create/Update Manufacturing Order'; // Permission label - $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Create/Update Manufacturing Order'; // Permission label + $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) $r++; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) - $this->rights[$r][1] = 'Delete Manufacturing Order'; // Permission label - $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Delete Manufacturing Order'; // Permission label + $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2) $r++; /* END MODULEBUILDER PERMISSIONS */ // Main menu entries to add $this->menu = array(); - $r=0; + $r = 0; // Add here entries to declare new menus /* BEGIN MODULEBUILDER TOPMENU */ /* END MODULEBUILDER LEFTMENU MO */ // Exports profiles provided by this module - $r=1; + $r = 1; /* BEGIN MODULEBUILDER EXPORT MO */ /* $langs->load("mrp"); @@ -284,7 +284,7 @@ class modMrp extends DolibarrModules /* END MODULEBUILDER EXPORT MO */ // Imports profiles provided by this module - $r=1; + $r = 1; /* BEGIN MODULEBUILDER IMPORT MO */ /* $langs->load("mrp"); @@ -316,7 +316,7 @@ class modMrp extends DolibarrModules { global $conf, $langs; - $result=$this->_load_tables('/mrp/sql/'); + $result = $this->_load_tables('/mrp/sql/'); if ($result < 0) return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default') // Create extrafields during init @@ -334,19 +334,19 @@ class modMrp extends DolibarrModules $sql = array(); // ODT template - $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/mrps/template_mo.odt'; - $dirodt=DOL_DATA_ROOT.'/doctemplates/mrps'; - $dest=$dirodt.'/template_mo.odt'; + $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/mrps/template_mo.odt'; + $dirodt = DOL_DATA_ROOT.'/doctemplates/mrps'; + $dest = $dirodt.'/template_mo.odt'; - if (file_exists($src) && ! file_exists($dest)) + if (file_exists($src) && !file_exists($dest)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; dol_mkdir($dirodt); - $result=dol_copy($src, $dest, 0, 0); + $result = dol_copy($src, $dest, 0, 0); if ($result < 0) { $langs->load("errors"); - $this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest); + $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest); return 0; } } diff --git a/htdocs/core/modules/modTakePos.class.php b/htdocs/core/modules/modTakePos.class.php index 515f18cf690..804ce8152ab 100644 --- a/htdocs/core/modules/modTakePos.class.php +++ b/htdocs/core/modules/modTakePos.class.php @@ -24,7 +24,7 @@ * \ingroup takepos * \brief Description and activation file for module TakePos */ -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; /** @@ -39,7 +39,7 @@ class modTakePos extends DolibarrModules */ public function __construct($db) { - global $langs,$conf; + global $langs, $conf; $this->db = $db; @@ -71,21 +71,21 @@ class modTakePos extends DolibarrModules // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' - $this->picto='list'; + $this->picto = 'list'; // Defined all module parts (triggers, login, substitutions, menus, css, etc...) // for default path (eg: /takepos/core/xxxxx) (0=disable, 1=enable) // for specific path of parts (eg: /takepos/core/modules/barcode) // for specific css file (eg: /takepos/css/takepos.css.php) $this->module_parts = array( - 'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers) - 'login' => 0, // Set this to 1 if module has its own login method file (core/login) - 'substitutions' => 1, // Set this to 1 if module has its own substitution function file (core/substitutions) - 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus) - 'theme' => 0, // Set this to 1 if module has its own theme directory (theme) - 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) - 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) - 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) + 'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers) + 'login' => 0, // Set this to 1 if module has its own login method file (core/login) + 'substitutions' => 1, // Set this to 1 if module has its own substitution function file (core/substitutions) + 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus) + 'theme' => 0, // Set this to 1 if module has its own theme directory (theme) + 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) + 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) + 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) 'hooks' => array() // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all' ); @@ -97,15 +97,15 @@ class modTakePos extends DolibarrModules $this->config_page_url = array("setup.php@takepos"); // Dependencies - $this->hidden = false; // A condition to hide module - $this->depends = array('always1'=>"modBanque", 'always2'=>"modFacture", 'always3'=>"modProduct", 'always4'=>'modCategorie', 'FR1'=>'modBlockedLog'); // List of module class names as string that must be enabled if this module is enabled - $this->requiredby = array(); // List of module ids to disable if this one is disabled - $this->conflictwith = array(); // List of module class names as string this module is in conflict with + $this->hidden = false; // A condition to hide module + $this->depends = array('always1'=>"modBanque", 'always2'=>"modFacture", 'always3'=>"modProduct", 'always4'=>'modCategorie', 'FR1'=>'modBlockedLog'); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array(); // List of module class names as string this module is in conflict with $this->langfiles = array("cashdesk"); - $this->phpmin = array(5,4); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(4,0); // Minimum version of Dolibarr required by module - $this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text') - $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->phpmin = array(5, 4); // Minimum version of PHP required by module + $this->need_dolibarr_version = array(4, 0); // Minimum version of Dolibarr required by module + $this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text') + $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) //$this->automatic_activation = array('FR'=>'TakePosWasAutomaticallyActivatedBecauseOfYourCountryChoice'); //$this->always_enabled = true; // If true, can't be disabled @@ -119,10 +119,10 @@ class modTakePos extends DolibarrModules ); - if (! isset($conf->takepos) || ! isset($conf->takepos->enabled)) + if (!isset($conf->takepos) || !isset($conf->takepos->enabled)) { - $conf->takepos=new stdClass(); - $conf->takepos->enabled=0; + $conf->takepos = new stdClass(); + $conf->takepos->enabled = 0; } @@ -156,7 +156,7 @@ class modTakePos extends DolibarrModules // Dictionaries - $this->dictionaries=array(); + $this->dictionaries = array(); /* Example: $this->dictionaries=array( 'langs'=>'mylangfile@takepos', @@ -193,9 +193,9 @@ class modTakePos extends DolibarrModules // Permissions - $this->rights = array(); // Permission array used by this module + $this->rights = array(); // Permission array used by this module - $r=0; + $r = 0; $r++; $this->rights[$r][0] = 50151; @@ -206,24 +206,24 @@ class modTakePos extends DolibarrModules // Main menu entries - $this->menu = array(); // List of menus to add - $r=0; + $this->menu = array(); // List of menus to add + $r = 0; // Add here entries to declare new menus /* BEGIN MODULEBUILDER TOPMENU */ - $this->menu[$r++]=array('fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'top', // This is a Top menu entry + $this->menu[$r++] = array('fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'top', // This is a Top menu entry 'titre'=>'PointOfSaleShort', 'mainmenu'=>'takepos', 'leftmenu'=>'', 'url'=>'/takepos/takepos.php', - 'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>1000+$r, - 'enabled'=>'$conf->takepos->enabled', // Define condition to show or hide menu entry. Use '$conf->takepos->enabled' if entry must be visible if module is enabled. - 'perms'=>'$user->rights->takepos->run', // Use 'perms'=>'$user->rights->takepos->level1->level2' if you want your menu with a permission rules + 'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1000 + $r, + 'enabled'=>'$conf->takepos->enabled', // Define condition to show or hide menu entry. Use '$conf->takepos->enabled' if entry must be visible if module is enabled. + 'perms'=>'$user->rights->takepos->run', // Use 'perms'=>'$user->rights->takepos->level1->level2' if you want your menu with a permission rules 'target'=>'takepos', - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both /* END MODULEBUILDER TOPMENU */ diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index d8790c54eee..a14c087dbf7 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -135,45 +135,45 @@ class pdf_cyan extends ModelePDFPropales $this->db = $db; $this->name = "cyan"; $this->description = $langs->trans('DocModelCyanDescription'); - $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template + $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template // Dimension page $this->type = 'pdf'; - $formatarray=pdf_getFormat(); + $formatarray = pdf_getFormat(); $this->page_largeur = $formatarray['width']; $this->page_hauteur = $formatarray['height']; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; - $this->option_logo = 1; // Display logo - $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION - $this->option_modereg = 1; // Display payment mode - $this->option_condreg = 1; // Display payment terms - $this->option_codeproduitservice = 1; // Display product-service code - $this->option_multilang = 1; // Available in several languages - $this->option_escompte = 0; // Displays if there has been a discount - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 1; // Support add of a watermark on drafts + $this->option_logo = 1; // Display logo + $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION + $this->option_modereg = 1; // Display payment mode + $this->option_condreg = 1; // Display payment terms + $this->option_codeproduitservice = 1; // Display product-service code + $this->option_multilang = 1; // Available in several languages + $this->option_escompte = 0; // Displays if there has been a discount + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 1; // Support add of a watermark on drafts // Get source company - $this->emetteur=$mysoc; - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default, if was not defined + $this->emetteur = $mysoc; + if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined // Define position of columns - $this->posxdesc=$this->marge_gauche+1; + $this->posxdesc = $this->marge_gauche + 1; $this->tabTitleHeight = 5; // default height - $this->tva=array(); - $this->localtax1=array(); - $this->localtax2=array(); - $this->atleastoneratenotnull=0; - $this->atleastonediscount=0; + $this->tva = array(); + $this->localtax1 = array(); + $this->localtax2 = array(); + $this->atleastoneratenotnull = 0; + $this->atleastonediscount = 0; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -191,16 +191,16 @@ class pdf_cyan extends ModelePDFPropales public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblines; + global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines; - if (! is_object($outputlangs)) $outputlangs=$langs; + if (!is_object($outputlangs)) $outputlangs = $langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "propal")); - if (! empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { + if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { global $outputlangsbis; $outputlangsbis = new Translate('', $conf); $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); @@ -209,39 +209,39 @@ class pdf_cyan extends ModelePDFPropales $nblines = count($object->lines); - $hidetop=0; - if(!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)){ - $hidetop=$conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE; + $hidetop = 0; + if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) { + $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE; } // Loop on each lines to detect if there is at least one image to show - $realpatharray=array(); + $realpatharray = array(); $this->atleastonephoto = false; - if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE)) + if (!empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE)) { $objphoto = new Product($this->db); - for ($i = 0 ; $i < $nblines ; $i++) + for ($i = 0; $i < $nblines; $i++) { if (empty($object->lines[$i]->fk_product)) continue; $objphoto->fetch($object->lines[$i]->fk_product); //var_dump($objphoto->ref);exit; - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { - $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product') . $objphoto->id ."/photos/"; - $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product') . dol_sanitizeFileName($objphoto->ref).'/'; + $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; + $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; } else { - $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product') . dol_sanitizeFileName($objphoto->ref).'/'; // default - $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product') . $objphoto->id ."/photos/"; // alternative + $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; // default + $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative } $arephoto = false; foreach ($pdir as $midir) { - if (! $arephoto) + if (!$arephoto) { if ($conf->product->entity != $objphoto->entity) { $dir = $conf->product->multidir_output[$objphoto->entity].'/'.$midir; //Check repertories of current entities @@ -333,14 +333,14 @@ class pdf_cyan extends ModelePDFPropales } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); } $pdf->Open(); - $pagenb=0; + $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); @@ -393,38 +393,38 @@ class pdf_cyan extends ModelePDFPropales $tab_top -= 2; $pdf->SetFont('', '', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); $nexY = $pdf->GetY(); - $height_incoterms=$nexY-$tab_top; + $height_incoterms = $nexY - $tab_top; // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); - $tab_top = $nexY+6; + $tab_top = $nexY + 6; } } // Affiche notes - $notetoshow=empty($object->note_public)?'':$object->note_public; - if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) + $notetoshow = empty($object->note_public) ? '' : $object->note_public; + if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) { // Get first sale rep if (is_object($object->thirdparty)) { - $salereparray=$object->thirdparty->getSalesRepresentatives($user); - $salerepobj=new User($this->db); + $salereparray = $object->thirdparty->getSalesRepresentatives($user); + $salerepobj = new User($this->db); $salerepobj->fetch($salereparray[0]['id']); - if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); + if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature); } } - if (! empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0) + if (!empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0) { - $tmpuser=new User($this->db); + $tmpuser = new User($this->db); $tmpuser->fetch($object->user_author_id); $notetoshow .= $langs->trans("CaseFollowedBy").' '.$tmpuser->getFullName($langs); - if ($tmpuser->email) $notetoshow.=', Mail: '.$tmpuser->email; - if ($tmpuser->office_phone) $notetoshow.=', Tel: '.$tmpuser->office_phone; + if ($tmpuser->email) $notetoshow .= ', Mail: '.$tmpuser->email; + if ($tmpuser->office_phone) $notetoshow .= ', Tel: '.$tmpuser->office_phone; } $tab_height = $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter; @@ -561,102 +561,102 @@ class pdf_cyan extends ModelePDFPropales $nexY = $tab_top + $this->tabTitleHeight + 2; // Loop on each lines - $pageposbeforeprintlines=$pdf->getPage(); + $pageposbeforeprintlines = $pdf->getPage(); $pagenb = $pageposbeforeprintlines; for ($i = 0; $i < $nblines; $i++) { $curY = $nexY; - $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0, 0, 0); // Define size of image if we need it - $imglinesize=array(); - if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); + $imglinesize = array(); + if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]); $pdf->setTopMargin($tab_top_newpage); - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. - $pageposbefore=$pdf->getPage(); + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $pageposbefore = $pdf->getPage(); - $showpricebeforepagebreak=1; - $posYAfterImage=0; - $posYAfterDescription=0; + $showpricebeforepagebreak = 1; + $posYAfterImage = 0; + $posYAfterDescription = 0; - if($this->getColumnStatus('photo')) + if ($this->getColumnStatus('photo')) { // We start with Photo of product line - if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot))) // If photo too high, we moved completely on new page + if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) // If photo too high, we moved completely on new page { $pdf->AddPage('', '', true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposbefore+1); + $pdf->setPage($pageposbefore + 1); $curY = $tab_top_newpage; - $showpricebeforepagebreak=0; + $showpricebeforepagebreak = 0; } if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) { - $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi + $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi // $pdf->Image does not increase value return by getY, so we save it manually - $posYAfterImage=$curY+$imglinesize['height']; + $posYAfterImage = $curY + $imglinesize['height']; } } // Description of product line - if($this->getColumnStatus('desc')) + if ($this->getColumnStatus('desc')) { $pdf->startTransaction(); pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); - $pageposafter=$pdf->getPage(); + $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { $pdf->rollbackTransaction(true); - $pageposafter=$pageposbefore; + $pageposafter = $pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); - $pageposafter=$pdf->getPage(); - $posyafter=$pdf->GetY(); + $pageposafter = $pdf->getPage(); + $posyafter = $pdf->GetY(); //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot))) // There is no space left for total+free text + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) // There is no space left for total+free text { - if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page + if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page { $pdf->AddPage('', '', true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposafter+1); + $pdf->setPage($pageposafter + 1); } } else { // We found a page break - $showpricebeforepagebreak=0; + $showpricebeforepagebreak = 0; } } else // No pagebreak { $pdf->commitTransaction(); } - $posYAfterDescription=$pdf->GetY(); + $posYAfterDescription = $pdf->GetY(); } $nexY = $pdf->GetY(); - $pageposafter=$pdf->getPage(); + $pageposafter = $pdf->getPage(); $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. // We suppose that a too long description or photo were moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { $pdf->setPage($pageposafter); $curY = $tab_top_newpage; } - $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut + $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut // VAT Rate if ($this->getColumnStatus('vat')) @@ -718,59 +718,59 @@ class pdf_cyan extends ModelePDFPropales 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails ); - $reshook=$hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook + $reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva - if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; - else $tvaligne=$object->lines[$i]->total_tva; + if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva; + else $tvaligne = $object->lines[$i]->total_tva; - $localtax1ligne=$object->lines[$i]->total_localtax1; - $localtax2ligne=$object->lines[$i]->total_localtax2; - $localtax1_rate=$object->lines[$i]->localtax1_tx; - $localtax2_rate=$object->lines[$i]->localtax2_tx; - $localtax1_type=$object->lines[$i]->localtax1_type; - $localtax2_type=$object->lines[$i]->localtax2_type; + $localtax1ligne = $object->lines[$i]->total_localtax1; + $localtax2ligne = $object->lines[$i]->total_localtax2; + $localtax1_rate = $object->lines[$i]->localtax1_tx; + $localtax2_rate = $object->lines[$i]->localtax2_tx; + $localtax1_type = $object->lines[$i]->localtax1_type; + $localtax2_type = $object->lines[$i]->localtax2_type; - if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; - if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; - if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; + if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100; + if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100; + if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100; - $vatrate=(string) $object->lines[$i]->tva_tx; + $vatrate = (string) $object->lines[$i]->tva_tx; // Retrieve type from database for backward compatibility with old records - if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined - && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax + if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined + && (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax { - $localtaxtmp_array=getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc); + $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc); $localtax1_type = $localtaxtmp_array[0]; $localtax2_type = $localtaxtmp_array[2]; } // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0) - $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; + $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; if ($localtax2_type && $localtax2ligne != 0) - $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; + $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; - if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; - if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; + if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*'; + if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0; $this->tva[$vatrate] += $tvaligne; - if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage; + if ($posYAfterImage > $posYAfterDescription) $nexY = $posYAfterImage; // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) + if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { $pdf->setPage($pageposafter); - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); + $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); + $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1); $pdf->SetLineStyle(array('dash'=>0)); } - $nexY+=2; // Add space between lines + $nexY += 2; // Add space between lines // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) @@ -867,41 +867,41 @@ class pdf_cyan extends ModelePDFPropales $product = new Product($this->db); $product->fetch($line->fk_product); - if ($product->entity!=$conf->entity) { - $entity_product_file=$product->entity; + if ($product->entity != $conf->entity) { + $entity_product_file = $product->entity; } else { - $entity_product_file=$conf->entity; + $entity_product_file = $conf->entity; } // If PDF is selected and file is not empty if (count($filetomerge->lines) > 0) { foreach ($filetomerge->lines as $linefile) { - if (! empty($linefile->id) && ! empty($linefile->file_name)) { - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) + if (!empty($linefile->id) && !empty($linefile->file_name)) { + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { - if (! empty($conf->product->enabled)) { - $filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . get_exdir($product->id, 2, 0, 0, $product, 'product') . $product->id ."/photos"; - } elseif (! empty($conf->service->enabled)) { - $filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . get_exdir($product->id, 2, 0, 0, $product, 'product') . $product->id ."/photos"; + if (!empty($conf->product->enabled)) { + $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].'/'.get_exdir($product->id, 2, 0, 0, $product, 'product').$product->id."/photos"; + } elseif (!empty($conf->service->enabled)) { + $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].'/'.get_exdir($product->id, 2, 0, 0, $product, 'product').$product->id."/photos"; } } else { - if (! empty($conf->product->enabled)) { - $filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . get_exdir(0, 0, 0, 0, $product, 'product') . dol_sanitizeFileName($product->ref); - } elseif (! empty($conf->service->enabled)) { - $filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . get_exdir(0, 0, 0, 0, $product, 'product') . dol_sanitizeFileName($product->ref); + if (!empty($conf->product->enabled)) { + $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].'/'.get_exdir(0, 0, 0, 0, $product, 'product').dol_sanitizeFileName($product->ref); + } elseif (!empty($conf->service->enabled)) { + $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].'/'.get_exdir(0, 0, 0, 0, $product, 'product').dol_sanitizeFileName($product->ref); } } - dol_syslog(get_class($this) . ':: upload_dir=' . $filetomerge_dir, LOG_DEBUG); + dol_syslog(get_class($this).':: upload_dir='.$filetomerge_dir, LOG_DEBUG); - $infile = $filetomerge_dir . '/' . $linefile->file_name; + $infile = $filetomerge_dir.'/'.$linefile->file_name; if (file_exists($infile) && is_readable($infile)) { $pagecount = $pdf->setSourceFile($infile); - for($i = 1; $i <= $pagecount; $i ++) { + for ($i = 1; $i <= $pagecount; $i++) { $tplIdx = $pdf->importPage($i); - if ($tplIdx!==false) { + if ($tplIdx !== false) { $s = $pdf->getTemplatesize($tplIdx); $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L'); $pdf->useTemplate($tplIdx); @@ -923,31 +923,31 @@ class pdf_cyan extends ModelePDFPropales //Add pdfgeneration hook $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { $this->error = $hookmanager->error; $this->errors = $hookmanager->errors; } - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); $this->result = array('fullpath'=>$file); - return 1; // No error + return 1; // No error } else { - $this->error=$langs->trans("ErrorCanNotCreateDir", $dir); + $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); return 0; } } else { - $this->error=$langs->trans("ErrorConstantNotDefined", "PROP_OUTPUTDIR"); + $this->error = $langs->trans("ErrorConstantNotDefined", "PROP_OUTPUTDIR"); return 0; } } @@ -1176,7 +1176,7 @@ class pdf_cyan extends ModelePDFPropales $index = 0; $outputlangsbis = null; - if (! empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { + if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { $outputlangsbis = new Translate('', $conf); $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal")); @@ -1209,29 +1209,29 @@ class pdf_cyan extends ModelePDFPropales //Local tax 1 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ - foreach($this->localtax1 as $localtax_type => $localtax_rate) + foreach ($this->localtax1 as $localtax_type => $localtax_rate) { - if (in_array((string) $localtax_type, array('1','3','5'))) continue; + if (in_array((string) $localtax_type, array('1', '3', '5'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + foreach ($localtax_rate as $tvakey => $tvaval) { - if ($tvakey!=0) // On affiche pas taux 0 + if ($tvakey != 0) // On affiche pas taux 0 { //$this->atleastoneratenotnull++; $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : ''); - $totalvat.=' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat .= ' '; + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); @@ -1242,13 +1242,13 @@ class pdf_cyan extends ModelePDFPropales //Local tax 2 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //{ - foreach($this->localtax2 as $localtax_type => $localtax_rate) + foreach ($this->localtax2 as $localtax_type => $localtax_rate) { - if (in_array((string) $localtax_type, array('1','3','5'))) continue; + if (in_array((string) $localtax_type, array('1', '3', '5'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + foreach ($localtax_rate as $tvakey => $tvaval) { - if ($tvakey!=0) // On affiche pas taux 0 + if ($tvakey != 0) // On affiche pas taux 0 { //$this->atleastoneratenotnull++; @@ -1257,16 +1257,16 @@ class pdf_cyan extends ModelePDFPropales $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : ''); - $totalvat.=' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat .= ' '; + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); @@ -1291,7 +1291,7 @@ class pdf_cyan extends ModelePDFPropales $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : ''); - $totalvat.=' '; + $totalvat .= ' '; $totalvat .= vatrate($tvakey, 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); @@ -1303,11 +1303,11 @@ class pdf_cyan extends ModelePDFPropales //Local tax 1 after VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ - foreach($this->localtax1 as $localtax_type => $localtax_rate) + foreach ($this->localtax1 as $localtax_type => $localtax_rate) { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; + if (in_array((string) $localtax_type, array('2', '4', '6'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + foreach ($localtax_rate as $tvakey => $tvaval) { if ($tvakey != 0) // On affiche pas taux 0 { @@ -1316,17 +1316,17 @@ class pdf_cyan extends ModelePDFPropales $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : ''); - $totalvat.=' '; + $totalvat .= ' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } @@ -1336,11 +1336,11 @@ class pdf_cyan extends ModelePDFPropales //Local tax 2 after VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //{ - foreach($this->localtax2 as $localtax_type => $localtax_rate) + foreach ($this->localtax2 as $localtax_type => $localtax_rate) { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; + if (in_array((string) $localtax_type, array('2', '4', '6'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + foreach ($localtax_rate as $tvakey => $tvaval) { // retrieve global local tax if ($tvakey != 0) // On affiche pas taux 0 @@ -1350,17 +1350,17 @@ class pdf_cyan extends ModelePDFPropales $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : ''); - $totalvat.= ' '; + $totalvat .= ' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); @@ -1464,12 +1464,12 @@ class pdf_cyan extends ModelePDFPropales if (empty($hidetop)) { $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; - if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); + if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { + $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); } } @@ -1477,12 +1477,12 @@ class pdf_cyan extends ModelePDFPropales $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); - if (empty($hidetop)){ - $pdf->line($this->marge_gauche, $tab_top+$this->tabTitleHeight, $this->page_largeur-$this->marge_droite, $tab_top+$this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter + if (empty($hidetop)) { + $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter } } @@ -1516,8 +1516,8 @@ class pdf_cyan extends ModelePDFPropales $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); - $posy=$this->marge_haute; - $posx=$this->page_largeur-$this->marge_droite-100; + $posy = $this->marge_haute; + $posx = $this->page_largeur - $this->marge_droite - 100; $pdf->SetXY($this->marge_gauche, $posy); @@ -1527,7 +1527,7 @@ class pdf_cyan extends ModelePDFPropales if ($this->emetteur->logo) { $logodir = $conf->mycompany->dir_output; - if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity]; + if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity]; if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; @@ -1537,8 +1537,8 @@ class pdf_cyan extends ModelePDFPropales } if (is_readable($logo)) { - $height=pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + $height = pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) } else { diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 2fbeb7ccdca..2a2916cf253 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -183,16 +183,16 @@ class pdf_cornas extends ModelePDFSuppliersOrders public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$langs,$conf,$hookmanager,$mysoc,$nblines; + global $user, $langs, $conf, $hookmanager, $mysoc, $nblines; - if (! is_object($outputlangs)) $outputlangs=$langs; + if (!is_object($outputlangs)) $outputlangs = $langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; // Load translation files required by the page $outputlangs->loadLangs(array("main", "orders", "companies", "bills", "dict", "products")); - if (! empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { + if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { global $outputlangsbis; $outputlangsbis = new Translate('', $conf); $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); @@ -201,46 +201,46 @@ class pdf_cornas extends ModelePDFSuppliersOrders $nblines = count($object->lines); - $hidetop=0; - if(!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)){ - $hidetop=$conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE; + $hidetop = 0; + if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) { + $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE; } // Loop on each lines to detect if there is at least one image to show - $realpatharray=array(); - if (! empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE)) + $realpatharray = array(); + if (!empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE)) { - for ($i = 0 ; $i < $nblines ; $i++) + for ($i = 0; $i < $nblines; $i++) { if (empty($object->lines[$i]->fk_product)) continue; $objphoto = new Product($this->db); $objphoto->fetch($object->lines[$i]->fk_product); - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { - $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product') . $object->lines[$i]->fk_product ."/photos/"; + $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/"; $dir = $conf->product->dir_output.'/'.$pdir; } else { - $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product') . dol_sanitizeFileName($objphoto->ref).'/'; + $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; $dir = $conf->product->dir_output.'/'.$pdir; } - $realpath=''; + $realpath = ''; foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) { - $filename=$obj['photo']; + $filename = $obj['photo']; //if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette']; $realpath = $dir.$filename; break; } - if ($realpath) $realpatharray[$i]=$realpath; + if ($realpath) $realpatharray[$i] = $realpath; } } - if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva; + if (count($realpatharray) == 0) $this->posxpicture = $this->posxtva; if ($conf->fournisseur->commande->dir_output) { @@ -279,24 +279,24 @@ class pdf_cornas extends ModelePDFSuppliersOrders if (file_exists($dir)) { // Add pdfgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $nblines = count($object->lines); - $pdf=pdf_getInstance($this->format); - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance - $heightforinfotot = 50; // Height reserved to output the info and total part - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; + $pdf = pdf_getInstance($this->format); + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance + $heightforinfotot = 50; // Height reserved to output the info and total part + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; $pdf->SetAutoPageBreak(1, 0); if (class_exists('TCPDF')) @@ -354,28 +354,28 @@ class pdf_cornas extends ModelePDFSuppliersOrders $tab_top -= 2; $pdf->SetFont('', '', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); $nexY = $pdf->GetY(); - $height_incoterms=$nexY-$tab_top; + $height_incoterms = $nexY - $tab_top; // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); - $tab_top = $nexY+6; + $tab_top = $nexY + 6; } } // Affiche notes - $notetoshow=empty($object->note_public)?'':$object->note_public; + $notetoshow = empty($object->note_public) ? '' : $object->note_public; $pagenb = $pdf->getPage(); if ($notetoshow) { - $tab_width = $this->page_largeur-$this->marge_gauche-$this->marge_droite; + $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite; $pageposbeforenote = $pagenb; - $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); + $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object); complete_substitutions_array($substitutionarray, $outputlangs, $object); $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow); @@ -497,98 +497,98 @@ class pdf_cornas extends ModelePDFSuppliersOrders $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref); // Loop on each lines - $pageposbeforeprintlines=$pdf->getPage(); + $pageposbeforeprintlines = $pdf->getPage(); $pagenb = $pageposbeforeprintlines; - for ($i = 0 ; $i < $nblines ; $i++) + for ($i = 0; $i < $nblines; $i++) { $curY = $nexY; - $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0, 0, 0); // Define size of image if we need it - $imglinesize=array(); - if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); + $imglinesize = array(); + if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]); $pdf->setTopMargin($tab_top_newpage); - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. - $pageposbefore=$pdf->getPage(); + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $pageposbefore = $pdf->getPage(); - $showpricebeforepagebreak=1; - $posYAfterImage=0; - $posYAfterDescription=0; + $showpricebeforepagebreak = 1; + $posYAfterImage = 0; + $posYAfterDescription = 0; // We start with Photo of product line - if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page + if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // If photo too high, we moved completely on new page { $pdf->AddPage('', '', true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposbefore+1); + $pdf->setPage($pageposbefore + 1); $curY = $tab_top_newpage; - $showpricebeforepagebreak=0; + $showpricebeforepagebreak = 0; } if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) { - $curX = $this->posxpicture-1; - $pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi + $curX = $this->posxpicture - 1; + $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi // $pdf->Image does not increase value return by getY, so we save it manually - $posYAfterImage=$curY+$imglinesize['height']; + $posYAfterImage = $curY + $imglinesize['height']; } // Description of product line - $curX = $this->posxdesc-1; - $showpricebeforepagebreak=1; + $curX = $this->posxdesc - 1; + $showpricebeforepagebreak = 1; - if($this->getColumnStatus('desc')) + if ($this->getColumnStatus('desc')) { $pdf->startTransaction(); pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); - $pageposafter=$pdf->getPage(); + $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { $pdf->rollbackTransaction(true); - $pageposafter=$pageposbefore; + $pageposafter = $pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); - $pageposafter=$pdf->getPage(); - $posyafter=$pdf->GetY(); - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text + $pageposafter = $pdf->getPage(); + $posyafter = $pdf->GetY(); + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text { - if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page + if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page { $pdf->AddPage('', '', true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposafter+1); + $pdf->setPage($pageposafter + 1); } } else { // We found a page break - $showpricebeforepagebreak=0; + $showpricebeforepagebreak = 0; } } else // No pagebreak { $pdf->commitTransaction(); } - $posYAfterDescription=$pdf->GetY(); + $posYAfterDescription = $pdf->GetY(); } $nexY = $pdf->GetY(); - $pageposafter=$pdf->getPage(); + $pageposafter = $pdf->getPage(); $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. // We suppose that a too long description is moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { $pdf->setPage($pageposafter); $curY = $tab_top_newpage; } - $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut + $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut // VAT Rate if ($this->getColumnStatus('vat')) @@ -641,7 +641,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders } - $parameters=array( + $parameters = array( 'object' => $object, 'i' => $i, 'pdf' =>& $pdf, @@ -650,58 +650,58 @@ class pdf_cornas extends ModelePDFSuppliersOrders 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails ); - $reshook=$hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook + $reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva - if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; - else $tvaligne=$object->lines[$i]->total_tva; + if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva; + else $tvaligne = $object->lines[$i]->total_tva; - $localtax1ligne=$object->lines[$i]->total_localtax1; - $localtax2ligne=$object->lines[$i]->total_localtax2; - $localtax1_rate=$object->lines[$i]->localtax1_tx; - $localtax2_rate=$object->lines[$i]->localtax2_tx; - $localtax1_type=$object->lines[$i]->localtax1_type; - $localtax2_type=$object->lines[$i]->localtax2_type; + $localtax1ligne = $object->lines[$i]->total_localtax1; + $localtax2ligne = $object->lines[$i]->total_localtax2; + $localtax1_rate = $object->lines[$i]->localtax1_tx; + $localtax2_rate = $object->lines[$i]->localtax2_tx; + $localtax1_type = $object->lines[$i]->localtax1_type; + $localtax2_type = $object->lines[$i]->localtax2_type; - if (! empty($object->remise_percent)) $tvaligne-=($tvaligne*$object->remise_percent)/100; - if (! empty($object->remise_percent)) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; - if (! empty($object->remise_percent)) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; + if (!empty($object->remise_percent)) $tvaligne -= ($tvaligne * $object->remise_percent) / 100; + if (!empty($object->remise_percent)) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100; + if (!empty($object->remise_percent)) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100; - $vatrate=(string) $object->lines[$i]->tva_tx; + $vatrate = (string) $object->lines[$i]->tva_tx; // Retrieve type from database for backward compatibility with old records - if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined - && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax + if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined + && (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax { - $localtaxtmp_array=getLocalTaxesFromRate($vatrate, 0, $mysoc, $object->thirdparty); + $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $mysoc, $object->thirdparty); $localtax1_type = $localtaxtmp_array[0]; $localtax2_type = $localtaxtmp_array[2]; } // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0) - $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; + $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; if ($localtax2_type && $localtax2ligne != 0) - $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; + $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; - if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; - if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; + if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*'; + if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0; $this->tva[$vatrate] += $tvaligne; - if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage; + if ($posYAfterImage > $posYAfterDescription) $nexY = $posYAfterImage; // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) + if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { $pdf->setPage($pageposafter); - $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80,80,80))); + $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); + $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1); $pdf->SetLineStyle(array('dash'=>0)); } - $nexY+=2; // Add space between lines + $nexY += 2; // Add space between lines // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) @@ -774,31 +774,31 @@ class pdf_cornas extends ModelePDFSuppliersOrders // Add pdfgeneration hook $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { $this->error = $hookmanager->error; $this->errors = $hookmanager->errors; } - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); $this->result = array('fullpath'=>$file); - return 1; // No error + return 1; // No error } else { - $this->error=$langs->trans("ErrorCanNotCreateDir", $dir); + $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); return 0; } } else { - $this->error=$langs->trans("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR"); + $this->error = $langs->trans("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR"); return 0; } } @@ -858,11 +858,11 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); - $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement); - $lib_condition_paiement=str_replace('\n', "\n", $lib_condition_paiement); + $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement); + $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); $pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L'); - $posy=$pdf->GetY()+3; + $posy = $pdf->GetY() + 3; } // Show payment mode @@ -993,7 +993,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders //Local tax 1 foreach ($this->localtax1 as $localtax_type => $localtax_rate) { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; + if (in_array((string) $localtax_type, array('2', '4', '6'))) continue; foreach ($localtax_rate as $tvakey => $tvaval) { @@ -1004,15 +1004,15 @@ class pdf_cornas extends ModelePDFSuppliersOrders $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } - $totalvat =$outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); @@ -1133,12 +1133,12 @@ class pdf_cornas extends ModelePDFSuppliersOrders if (empty($hidetop)) { $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; - if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); + if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { + $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); } } @@ -1146,17 +1146,17 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter foreach ($this->cols as $colKey => $colDef) { - if(!$this->getColumnStatus($colKey)) continue; + if (!$this->getColumnStatus($colKey)) continue; // get title label - $colDef['title']['label'] = !empty($colDef['title']['label'])?$colDef['title']['label']:$outputlangs->transnoentities($colDef['title']['textkey']); + $colDef['title']['label'] = !empty($colDef['title']['label']) ? $colDef['title']['label'] : $outputlangs->transnoentities($colDef['title']['textkey']); // Add column separator - if(!empty($colDef['border-left'])){ + if (!empty($colDef['border-left'])) { $pdf->line($colDef['xStartPos'], $tab_top, $colDef['xStartPos'], $tab_top + $tab_height); } @@ -1164,13 +1164,13 @@ class pdf_cornas extends ModelePDFSuppliersOrders { $pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0]); - $textWidth = $colDef['width'] - $colDef['title']['padding'][3] -$colDef['title']['padding'][1]; + $textWidth = $colDef['width'] - $colDef['title']['padding'][3] - $colDef['title']['padding'][1]; $pdf->MultiCell($textWidth, 2, $colDef['title']['label'], '', $colDef['title']['align']); } } - if (empty($hidetop)){ - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line takes a position y in 2nd parameter and 4th parameter + if (empty($hidetop)) { + $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line takes a position y in 2nd parameter and 4th parameter } } @@ -1206,19 +1206,19 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); - $posx=$this->page_largeur-$this->marge_droite-100; - $posy=$this->marge_haute; + $posx = $this->page_largeur - $this->marge_droite - 100; + $posy = $this->marge_haute; $pdf->SetXY($this->marge_gauche, $posy); // Logo - $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; + $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; if ($this->emetteur->logo) { if (is_readable($logo)) { - $height=pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + $height = pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) } else { @@ -1230,91 +1230,91 @@ class pdf_cornas extends ModelePDFSuppliersOrders } else { - $text=$this->emetteur->name; + $text = $this->emetteur->name; $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } $pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $title=$outputlangs->transnoentities("SupplierOrder")." ".$outputlangs->convToOutputCharset($object->ref); + $title = $outputlangs->transnoentities("SupplierOrder")." ".$outputlangs->convToOutputCharset($object->ref); $pdf->MultiCell(100, 3, $title, '', 'R'); - $posy+=1; + $posy += 1; if ($object->ref_supplier) { - $posy+=4; + $posy += 4; $pdf->SetFont('', 'B', $default_font_size); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefSupplier")." : " . $outputlangs->convToOutputCharset($object->ref_supplier), '', 'R'); - $posy+=1; + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefSupplier")." : ".$outputlangs->convToOutputCharset($object->ref_supplier), '', 'R'); + $posy += 1; } - $pdf->SetFont('', '', $default_font_size -1); + $pdf->SetFont('', '', $default_font_size - 1); - if (! empty($conf->global->PDF_SHOW_PROJECT)) + if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); - if (! empty($object->project->ref)) + if (!empty($object->project->ref)) { - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $langs->load("projects"); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); } } - if (! empty($object->date_commande)) + if (!empty($object->date_commande)) { - $posy+=5; + $posy += 5; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date_commande, "day", false, $outputlangs, true), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date_commande, "day", false, $outputlangs, true), '', 'R'); } else { - $posy+=5; + $posy += 5; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(255, 0, 0); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderToProcess"), '', 'R'); } $pdf->SetTextColor(0, 0, 60); - $usehourmin='day'; - if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin='dayhour'; - if (! empty($object->date_livraison)) + $usehourmin = 'day'; + if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin = 'dayhour'; + if (!empty($object->date_livraison)) { - $posy+=4; - $pdf->SetXY($posx-90, $posy); - $pdf->MultiCell(190, 3, $outputlangs->transnoentities("DateDeliveryPlanned")." : " . dol_print_date($object->date_livraison, $usehourmin, false, $outputlangs, true), '', 'R'); + $posy += 4; + $pdf->SetXY($posx - 90, $posy); + $pdf->MultiCell(190, 3, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_livraison, $usehourmin, false, $outputlangs, true), '', 'R'); } if ($object->thirdparty->code_fournisseur) { - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); } // Get contact if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) { - $arrayidcontact=$object->getIdContact('internal', 'SALESREPFOLL'); + $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); if (count($arrayidcontact) > 0) { - $usertmp=new User($this->db); + $usertmp = new User($this->db); $usertmp->fetch($arrayidcontact[0]); - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R'); } } - $posy+=1; + $posy += 1; $pdf->SetTextColor(0, 0, 60); $top_shift = 0; @@ -1666,10 +1666,10 @@ class pdf_cornas extends ModelePDFSuppliersOrders uasort($this->cols, array($this, 'columnSort')); // Positionning - $curX = $this->page_largeur-$this->marge_droite; // start from right + $curX = $this->page_largeur - $this->marge_droite; // start from right // Array width - $arrayWidth = $this->page_largeur-$this->marge_droite-$this->marge_gauche; + $arrayWidth = $this->page_largeur - $this->marge_droite - $this->marge_gauche; // Count flexible column $totalDefinedColWidth = 0; @@ -1818,16 +1818,16 @@ class pdf_cornas extends ModelePDFSuppliersOrders { global $hookmanager; - $parameters=array( + $parameters = array( 'curY' =>& $curY, 'columnText' => $columnText, 'colKey' => $colKey ); - $reshook=$hookmanager->executeHooks('printStdColumnContent', $parameters, $this); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('printStdColumnContent', $parameters, $this); // Note that $action and $object may have been modified by hook if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (!$reshook) { - if(empty($columnText)) return; + if (empty($columnText)) return; $pdf->SetXY($this->getColumnContentXStart($colKey), $curY); // Set curent position $colDef = $this->cols[$colKey]; $pdf->MultiCell($this->getColumnContentWidth($colKey), 2, $columnText, '', $colDef['content']['align']); diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php index 2da47c09205..395e461e807 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -133,66 +133,66 @@ class pdf_muscadet extends ModelePDFSuppliersOrders // Page size for A4 format $this->type = 'pdf'; - $formatarray=pdf_getFormat(); + $formatarray = pdf_getFormat(); $this->page_largeur = $formatarray['width']; $this->page_hauteur = $formatarray['height']; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION - $this->option_modereg = 1; // Affiche mode reglement - $this->option_condreg = 1; // Affiche conditions reglement - $this->option_codeproduitservice = 1; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 1; // Support add of a watermark on drafts + $this->option_logo = 1; // Affiche logo + $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION + $this->option_modereg = 1; // Affiche mode reglement + $this->option_condreg = 1; // Affiche conditions reglement + $this->option_codeproduitservice = 1; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 1; // Support add of a watermark on drafts // Get source company - $this->emetteur=$mysoc; - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default, if was not defined + $this->emetteur = $mysoc; + if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined // Define position of columns - $this->posxdesc=$this->marge_gauche+1; - $this->posxdiscount=162; - $this->postotalht=174; + $this->posxdesc = $this->marge_gauche + 1; + $this->posxdiscount = 162; + $this->postotalht = 174; if ($conf->global->PRODUCT_USE_UNITS) { - $this->posxtva=95; - $this->posxup=114; - $this->posxqty=132; - $this->posxunit=147; + $this->posxtva = 95; + $this->posxup = 114; + $this->posxqty = 132; + $this->posxunit = 147; } else { - $this->posxtva=110; - $this->posxup=126; - $this->posxqty=145; - $this->posxunit=162; + $this->posxtva = 110; + $this->posxup = 126; + $this->posxqty = 145; + $this->posxunit = 162; } - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxup = $this->posxtva; // posxtva is picture position reference - $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images + if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxup = $this->posxtva; // posxtva is picture position reference + $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images if ($this->page_largeur < 210) // To work with US executive format { - $this->posxpicture-=20; - $this->posxtva-=20; - $this->posxup-=20; - $this->posxqty-=20; - $this->posxunit-=20; - $this->posxdiscount-=20; - $this->postotalht-=20; + $this->posxpicture -= 20; + $this->posxtva -= 20; + $this->posxup -= 20; + $this->posxqty -= 20; + $this->posxunit -= 20; + $this->posxdiscount -= 20; + $this->postotalht -= 20; } - $this->tva=array(); - $this->localtax1=array(); - $this->localtax2=array(); - $this->atleastoneratenotnull=0; - $this->atleastonediscount=0; + $this->tva = array(); + $this->localtax1 = array(); + $this->localtax2 = array(); + $this->atleastoneratenotnull = 0; + $this->atleastonediscount = 0; } @@ -211,11 +211,11 @@ class pdf_muscadet extends ModelePDFSuppliersOrders public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$langs,$conf,$hookmanager,$mysoc,$nblines; + global $user, $langs, $conf, $hookmanager, $mysoc, $nblines; - if (! is_object($outputlangs)) $outputlangs=$langs; + if (!is_object($outputlangs)) $outputlangs = $langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; // Load translation files required by the page $outputlangs->loadLangs(array("main", "orders", "companies", "bills", "dict", "products")); @@ -223,40 +223,40 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $nblines = count($object->lines); // Loop on each lines to detect if there is at least one image to show - $realpatharray=array(); - if (! empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE)) + $realpatharray = array(); + if (!empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE)) { - for ($i = 0 ; $i < $nblines ; $i++) + for ($i = 0; $i < $nblines; $i++) { if (empty($object->lines[$i]->fk_product)) continue; $objphoto = new Product($this->db); $objphoto->fetch($object->lines[$i]->fk_product); - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { - $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product') . $object->lines[$i]->fk_product ."/photos/"; + $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/"; $dir = $conf->product->dir_output.'/'.$pdir; } else { - $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product') . dol_sanitizeFileName($objphoto->ref).'/'; + $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; $dir = $conf->product->dir_output.'/'.$pdir; } - $realpath=''; + $realpath = ''; foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) { - $filename=$obj['photo']; + $filename = $obj['photo']; //if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette']; $realpath = $dir.$filename; break; } - if ($realpath) $realpatharray[$i]=$realpath; + if ($realpath) $realpatharray[$i] = $realpath; } } - if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva; + if (count($realpatharray) == 0) $this->posxpicture = $this->posxtva; if ($conf->fournisseur->commande->dir_output) { @@ -272,22 +272,22 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if ($object->specimen) { $dir = $conf->fournisseur->commande->dir_output; - $file = $dir . "/SPECIMEN.pdf"; + $file = $dir."/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); $objectrefsupplier = dol_sanitizeFileName($object->ref_supplier); - $dir = $conf->fournisseur->commande->dir_output . '/'. $objectref; - $file = $dir . "/" . $objectref . ".pdf"; - if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf"; + $dir = $conf->fournisseur->commande->dir_output.'/'.$objectref; + $file = $dir."/".$objectref.".pdf"; + if (!empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir."/".$objectref.($objectrefsupplier ? "_".$objectrefsupplier : "").".pdf"; } - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } @@ -295,24 +295,24 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if (file_exists($dir)) { // Add pdfgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $nblines = count($object->lines); - $pdf=pdf_getInstance($this->format); - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance - $heightforinfotot = 50; // Height reserved to output the info and total part - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; + $pdf = pdf_getInstance($this->format); + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance + $heightforinfotot = 50; // Height reserved to output the info and total part + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; $pdf->SetAutoPageBreak(1, 0); if (class_exists('TCPDF')) @@ -322,14 +322,14 @@ class pdf_muscadet extends ModelePDFSuppliersOrders } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); } $pdf->Open(); - $pagenb=0; + $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); @@ -337,12 +337,12 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right // Positionne $this->atleastonediscount si on a au moins une remise - for ($i = 0 ; $i < $nblines ; $i++) + for ($i = 0; $i < $nblines; $i++) { if ($object->lines[$i]->remise_percent) { @@ -352,26 +352,26 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if (empty($this->atleastonediscount)) { $delta = ($this->postotalht - $this->posxdiscount); - $this->posxpicture+=$delta; - $this->posxtva+=$delta; - $this->posxup+=$delta; - $this->posxqty+=$delta; - $this->posxunit+=$delta; - $this->posxdiscount+=$delta; + $this->posxpicture += $delta; + $this->posxtva += $delta; + $this->posxup += $delta; + $this->posxqty += $delta; + $this->posxunit += $delta; + $this->posxdiscount += $delta; // post of fields after are not modified, stay at same position } // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); - $tab_top = 90+$top_shift; - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10); + $tab_top = 90 + $top_shift; + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); // Incoterm if ($conf->incoterm->enabled) @@ -382,33 +382,33 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $tab_top -= 2; $pdf->SetFont('', '', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); $nexY = $pdf->GetY(); - $height_incoterms=$nexY-$tab_top; + $height_incoterms = $nexY - $tab_top; // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); - $tab_top = $nexY+6; + $tab_top = $nexY + 6; } } // Affiche notes - if (! empty($object->note_public)) + if (!empty($object->note_public)) { $tab_top -= 2; $pdf->SetFont('', '', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($object->note_public), 0, 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($object->note_public), 0, 1); $nexY = $pdf->GetY(); - $height_note=$nexY-$tab_top; + $height_note = $nexY - $tab_top; // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); - $tab_top = $nexY+6; + $tab_top = $nexY + 6; } $iniY = $tab_top + 7; @@ -416,81 +416,81 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $nexY = $tab_top + 7; // Loop on each lines - for ($i = 0 ; $i < $nblines ; $i++) + for ($i = 0; $i < $nblines; $i++) { $curY = $nexY; - $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0, 0, 0); // Define size of image if we need it - $imglinesize=array(); - if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); + $imglinesize = array(); + if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]); $pdf->setTopMargin($tab_top_newpage); - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. - $pageposbefore=$pdf->getPage(); + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $pageposbefore = $pdf->getPage(); - $showpricebeforepagebreak=1; - $posYAfterImage=0; - $posYAfterDescription=0; + $showpricebeforepagebreak = 1; + $posYAfterImage = 0; + $posYAfterDescription = 0; // We start with Photo of product line - if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page + if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // If photo too high, we moved completely on new page { $pdf->AddPage('', '', true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposbefore+1); + $pdf->setPage($pageposbefore + 1); $curY = $tab_top_newpage; - $showpricebeforepagebreak=0; + $showpricebeforepagebreak = 0; } if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) { - $curX = $this->posxpicture-1; - $pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi + $curX = $this->posxpicture - 1; + $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi // $pdf->Image does not increase value return by getY, so we save it manually - $posYAfterImage=$curY+$imglinesize['height']; + $posYAfterImage = $curY + $imglinesize['height']; } // Description of product line - $curX = $this->posxdesc-1; - $showpricebeforepagebreak=1; + $curX = $this->posxdesc - 1; + $showpricebeforepagebreak = 1; $pdf->startTransaction(); if ($posYAfterImage > 0) { - $descWidth = $this->posxpicture-$curX; + $descWidth = $this->posxpicture - $curX; } else { - $descWidth = $this->posxtva-$curX; + $descWidth = $this->posxtva - $curX; } pdf_writelinedesc($pdf, $object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1); - $pageposafter=$pdf->getPage(); + $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { $pdf->rollbackTransaction(true); - $pageposafter=$pageposbefore; + $pageposafter = $pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. pdf_writelinedesc($pdf, $object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1); - $posyafter=$pdf->GetY(); - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text + $posyafter = $pdf->GetY(); + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text { - if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page + if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page { $pdf->AddPage('', '', true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposafter+1); + $pdf->setPage($pageposafter + 1); } } else { // We found a page break - $showpricebeforepagebreak=0; + $showpricebeforepagebreak = 0; } } else // No pagebreak @@ -499,42 +499,42 @@ class pdf_muscadet extends ModelePDFSuppliersOrders } $nexY = $pdf->GetY(); - $pageposafter=$pdf->getPage(); + $pageposafter = $pdf->getPage(); $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. // We suppose that a too long description is moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { $pdf->setPage($pageposafter); $curY = $tab_top_newpage; } - $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut + $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut // VAT Rate if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxtva, $curY); - $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R'); + $pdf->MultiCell($this->posxup - $this->posxtva - 1, 3, $vat_rate, 0, 'R'); } // Unit price before discount $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxup, $curY); - $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0); + $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0, 'R', 0); // Quantity $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxqty, $curY); - $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R'); // Enough for 6 chars + $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); // Enough for 6 chars // Unit - if($conf->global->PRODUCT_USE_UNITS) + if ($conf->global->PRODUCT_USE_UNITS) { $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); $pdf->SetXY($this->posxunit, $curY); - $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L'); + $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L'); } // Discount on line @@ -542,63 +542,63 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if ($object->lines[$i]->remise_percent) { $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); - $pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 3, $remise_percent, 0, 'R'); + $pdf->MultiCell($this->postotalht - $this->posxdiscount - 1, 3, $remise_percent, 0, 'R'); } // Total HT line $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs); $pdf->SetXY($this->postotalht, $curY); - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0); // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva - if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; - else $tvaligne=$object->lines[$i]->total_tva; + if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva; + else $tvaligne = $object->lines[$i]->total_tva; - $localtax1ligne=$object->lines[$i]->total_localtax1; - $localtax2ligne=$object->lines[$i]->total_localtax2; - $localtax1_rate=$object->lines[$i]->localtax1_tx; - $localtax2_rate=$object->lines[$i]->localtax2_tx; - $localtax1_type=$object->lines[$i]->localtax1_type; - $localtax2_type=$object->lines[$i]->localtax2_type; + $localtax1ligne = $object->lines[$i]->total_localtax1; + $localtax2ligne = $object->lines[$i]->total_localtax2; + $localtax1_rate = $object->lines[$i]->localtax1_tx; + $localtax2_rate = $object->lines[$i]->localtax2_tx; + $localtax1_type = $object->lines[$i]->localtax1_type; + $localtax2_type = $object->lines[$i]->localtax2_type; - if (! empty($object->remise_percent)) $tvaligne-=($tvaligne*$object->remise_percent)/100; - if (! empty($object->remise_percent)) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; - if (! empty($object->remise_percent)) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; + if (!empty($object->remise_percent)) $tvaligne -= ($tvaligne * $object->remise_percent) / 100; + if (!empty($object->remise_percent)) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100; + if (!empty($object->remise_percent)) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100; - $vatrate=(string) $object->lines[$i]->tva_tx; + $vatrate = (string) $object->lines[$i]->tva_tx; // Retrieve type from database for backward compatibility with old records - if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined - && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax + if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined + && (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax { - $localtaxtmp_array=getLocalTaxesFromRate($vatrate, 0, $mysoc, $object->thirdparty); + $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $mysoc, $object->thirdparty); $localtax1_type = $localtaxtmp_array[0]; $localtax2_type = $localtaxtmp_array[2]; } // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0) - $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; + $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; if ($localtax2_type && $localtax2ligne != 0) - $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; + $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; - if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; - if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; + if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*'; + if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0; $this->tva[$vatrate] += $tvaligne; - if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage; + if ($posYAfterImage > $posYAfterDescription) $nexY = $posYAfterImage; // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) + if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { $pdf->setPage($pageposafter); - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); + $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); + $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1); $pdf->SetLineStyle(array('dash'=>0)); } - $nexY+=2; // Add space between lines + $nexY += 2; // Add space between lines // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) @@ -615,10 +615,10 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $this->_pagefoot($pdf, $object, $outputlangs, 1); $pagenb++; $pdf->setPage($pagenb); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { @@ -631,7 +631,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $this->_pagefoot($pdf, $object, $outputlangs, 1); // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } @@ -641,24 +641,24 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } // Affiche zone infos - $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); + $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); // Affiche zone totaux - $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); + $posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); // Affiche zone versements if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) { - $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); + $posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs); } // Pied de page @@ -671,31 +671,31 @@ class pdf_muscadet extends ModelePDFSuppliersOrders // Add pdfgeneration hook $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { $this->error = $hookmanager->error; $this->errors = $hookmanager->errors; } - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); $this->result = array('fullpath'=>$file); - return 1; // No error + return 1; // No error } else { - $this->error=$langs->trans("ErrorCanNotCreateDir", $dir); + $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); return 0; } } else { - $this->error=$langs->trans("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR"); + $this->error = $langs->trans("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR"); return 0; } } @@ -740,10 +740,10 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetXY($this->marge_gauche, $posy); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); - $posy=$pdf->GetY()+4; + $posy = $pdf->GetY() + 4; } - $posxval=52; + $posxval = 52; // Show payments conditions if (!empty($object->cond_reglement_code) || $object->cond_reglement) @@ -755,11 +755,11 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); - $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement); - $lib_condition_paiement=str_replace('\n', "\n", $lib_condition_paiement); + $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement); + $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); $pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L'); - $posy=$pdf->GetY()+3; + $posy = $pdf->GetY() + 3; } // Show payment mode @@ -772,10 +772,10 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); - $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement); + $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); - $posy=$pdf->GetY()+2; + $posy = $pdf->GetY() + 2; } @@ -797,7 +797,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { // phpcs:enable - global $conf,$mysoc; + global $conf, $mysoc; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -809,27 +809,27 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $col1x = 120; $col2x = 170; if ($this->page_largeur < 210) // To work with US executive format { - $col2x-=20; + $col2x -= 20; } $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); - $useborder=0; + $useborder = 0; $index = 0; // Total HT $pdf->SetFillColor(255, 255, 255); $pdf->SetXY($col1x, $tab2_top + 0); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht); $pdf->SetXY($col2x, $tab2_top + 0); - $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0)), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, 'R', 1); // Show VAT by rates and total $pdf->SetFillColor(248, 248, 248); - $this->atleastoneratenotnull=0; - foreach($this->tva as $tvakey => $tvaval) + $this->atleastoneratenotnull = 0; + foreach ($this->tva as $tvakey => $tvaval) { if ($tvakey > 0) // On affiche pas taux 0 { @@ -838,47 +838,47 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } - $totalvat =$outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; - $totalvat.=vatrate($tvakey, 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; + $totalvat .= vatrate($tvakey, 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); } } - if (! $this->atleastoneratenotnull) // If no vat at all + if (!$this->atleastoneratenotnull) // If no vat at all { $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1); // Total LocalTax1 - if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0) + if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION == 'localtax1on' && $object->total_localtax1 > 0) { $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code), 0, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code), 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1); } // Total LocalTax2 - if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0) + if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION == 'localtax2on' && $object->total_localtax2 > 0) { $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code), 0, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code), 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1); } @@ -888,11 +888,11 @@ class pdf_muscadet extends ModelePDFSuppliersOrders //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ //Local tax 1 - foreach($this->localtax1 as $localtax_type => $localtax_rate) + foreach ($this->localtax1 as $localtax_type => $localtax_rate) { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; + if (in_array((string) $localtax_type, array('2', '4', '6'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + foreach ($localtax_rate as $tvakey => $tvaval) { if ($tvakey != 0) // On affiche pas taux 0 { @@ -901,15 +901,15 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } - $totalvat =$outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); @@ -920,11 +920,11 @@ class pdf_muscadet extends ModelePDFSuppliersOrders //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //{ //Local tax 2 - foreach($this->localtax2 as $localtax_type => $localtax_rate) + foreach ($this->localtax2 as $localtax_type => $localtax_rate) { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; + if (in_array((string) $localtax_type, array('2', '4', '6'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + foreach ($localtax_rate as $tvakey => $tvaval) { if ($tvakey != 0) // On affiche pas taux 0 { @@ -933,15 +933,15 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } - $totalvat =$outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); @@ -955,7 +955,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetTextColor(0, 0, 60); $pdf->SetFillColor(224, 224, 224); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); @@ -963,13 +963,13 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetFont('', '', $default_font_size - 1); $pdf->SetTextColor(0, 0, 0); - $creditnoteamount=0; - $depositsamount=0; + $creditnoteamount = 0; + $depositsamount = 0; //$creditnoteamount=$object->getSumCreditNotesUsed(); //$depositsamount=$object->getSumDepositsUsed(); //print "x".$creditnoteamount."-".$depositsamount;exit; $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); - if (! empty($object->paye)) $resteapayer=0; + if (!empty($object->paye)) $resteapayer = 0; if ($deja_regle > 0) { @@ -977,7 +977,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0); @@ -985,7 +985,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetTextColor(0, 0, 60); $pdf->SetFillColor(224, 224, 224); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1); @@ -1017,8 +1017,8 @@ class pdf_muscadet extends ModelePDFSuppliersOrders global $conf; // Force to disable hidetop and hidebottom - $hidebottom=0; - if ($hidetop) $hidetop=-1; + $hidebottom = 0; + if ($hidetop) $hidetop = -1; $currency = !empty($currency) ? $currency : $conf->currency; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -1030,24 +1030,24 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if (empty($hidetop)) { $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; - if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); + if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); } $pdf->SetDrawColor(128, 128, 128); $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter if (empty($hidetop)) { - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line takes a position y in 2nd parameter and 4th parameter + $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line takes a position y in 2nd parameter and 4th parameter - $pdf->SetXY($this->posxdesc-1, $tab_top+1); + $pdf->SetXY($this->posxdesc - 1, $tab_top + 1); $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L'); } @@ -1056,26 +1056,26 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->line($this->posxtva, $tab_top, $this->posxtva, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxtva-3, $tab_top+1); - $pdf->MultiCell($this->posxup-$this->posxtva+3, 2, $outputlangs->transnoentities("VAT"), '', 'C'); + $pdf->SetXY($this->posxtva - 3, $tab_top + 1); + $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C'); } } $pdf->line($this->posxup, $tab_top, $this->posxup, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxup-1, $tab_top+1); - $pdf->MultiCell($this->posxqty-$this->posxup-1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C'); + $pdf->SetXY($this->posxup - 1, $tab_top + 1); + $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C'); } - $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); + $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxqty-1, $tab_top+1); - $pdf->MultiCell($this->posxunit-$this->posxqty-1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); + $pdf->SetXY($this->posxqty - 1, $tab_top + 1); + $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); } - if($conf->global->PRODUCT_USE_UNITS) { + if ($conf->global->PRODUCT_USE_UNITS) { $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxunit - 1, $tab_top + 1); @@ -1083,13 +1083,13 @@ class pdf_muscadet extends ModelePDFSuppliersOrders } } - $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); + $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height); if (empty($hidetop)) { if ($this->atleastonediscount) { - $pdf->SetXY($this->posxdiscount-1, $tab_top+1); - $pdf->MultiCell($this->postotalht-$this->posxdiscount+1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C'); + $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1); + $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C'); } } @@ -1099,7 +1099,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders } if (empty($hidetop)) { - $pdf->SetXY($this->postotalht-1, $tab_top+1); + $pdf->SetXY($this->postotalht - 1, $tab_top + 1); $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHTShort"), '', 'C'); } } @@ -1136,19 +1136,19 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); - $posx=$this->page_largeur-$this->marge_droite-100; - $posy=$this->marge_haute; + $posx = $this->page_largeur - $this->marge_droite - 100; + $posy = $this->marge_haute; $pdf->SetXY($this->marge_gauche, $posy); // Logo - $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; + $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; if ($this->emetteur->logo) { if (is_readable($logo)) { - $height=pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + $height = pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) } else { @@ -1160,91 +1160,91 @@ class pdf_muscadet extends ModelePDFSuppliersOrders } else { - $text=$this->emetteur->name; + $text = $this->emetteur->name; $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } $pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $title=$outputlangs->transnoentities("SupplierOrder")." ".$outputlangs->convToOutputCharset($object->ref); + $title = $outputlangs->transnoentities("SupplierOrder")." ".$outputlangs->convToOutputCharset($object->ref); $pdf->MultiCell(100, 3, $title, '', 'R'); - $posy+=1; + $posy += 1; if ($object->ref_supplier) { - $posy+=4; + $posy += 4; $pdf->SetFont('', 'B', $default_font_size); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefSupplier")." : " . $outputlangs->convToOutputCharset($object->ref_supplier), '', 'R'); - $posy+=1; + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefSupplier")." : ".$outputlangs->convToOutputCharset($object->ref_supplier), '', 'R'); + $posy += 1; } - $pdf->SetFont('', '', $default_font_size -1); + $pdf->SetFont('', '', $default_font_size - 1); - if (! empty($conf->global->PDF_SHOW_PROJECT)) + if (!empty($conf->global->PDF_SHOW_PROJECT)) { $object->fetch_projet(); - if (! empty($object->project->ref)) + if (!empty($object->project->ref)) { - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $langs->load("projects"); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R'); } } - if (! empty($object->date_commande)) + if (!empty($object->date_commande)) { - $posy+=5; + $posy += 5; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date_commande, "day", false, $outputlangs, true), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date_commande, "day", false, $outputlangs, true), '', 'R'); } else { - $posy+=5; + $posy += 5; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(255, 0, 0); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderToProcess"), '', 'R'); } $pdf->SetTextColor(0, 0, 60); - $usehourmin='day'; - if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin='dayhour'; - if (! empty($object->date_livraison)) + $usehourmin = 'day'; + if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin = 'dayhour'; + if (!empty($object->date_livraison)) { - $posy+=4; - $pdf->SetXY($posx-90, $posy); - $pdf->MultiCell(190, 3, $outputlangs->transnoentities("DateDeliveryPlanned")." : " . dol_print_date($object->date_livraison, $usehourmin, false, $outputlangs, true), '', 'R'); + $posy += 4; + $pdf->SetXY($posx - 90, $posy); + $pdf->MultiCell(190, 3, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_livraison, $usehourmin, false, $outputlangs, true), '', 'R'); } if ($object->thirdparty->code_fournisseur) { - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); } // Get contact if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) { - $arrayidcontact=$object->getIdContact('internal', 'SALESREPFOLL'); + $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); if (count($arrayidcontact) > 0) { - $usertmp=new User($this->db); + $usertmp = new User($this->db); $usertmp->fetch($arrayidcontact[0]); - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R'); } } - $posy+=1; + $posy += 1; $pdf->SetTextColor(0, 0, 60); $top_shift = 0; @@ -1259,27 +1259,27 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if ($showaddress) { // Sender properties - $carac_emetteur=''; + $carac_emetteur = ''; // Add internal contact of proposal if defined - $arrayidcontact=$object->getIdContact('internal', 'SALESREPFOLL'); + $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); if (count($arrayidcontact) > 0) { $object->fetch_user($arrayidcontact[0]); - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; } $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); // Show sender - $posy=42+$top_shift; - $posx=$this->marge_gauche; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; - $hautcadre=40; + $posy = 42 + $top_shift; + $posx = $this->marge_gauche; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80; + $hautcadre = 40; // Show sender frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx, $posy-5); + $pdf->SetXY($posx, $posy - 5); $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); @@ -1287,24 +1287,24 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetTextColor(0, 0, 60); // Show sender name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); - $posy=$pdf->getY(); + $posy = $pdf->getY(); // Show sender information - $pdf->SetXY($posx+2, $posy); + $pdf->SetXY($posx + 2, $posy); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); // If CUSTOMER contact defined on order, we use it. Note: Even if this is a supplier object, the code for external contat that follow order is 'CUSTOMER' - $usecontact=false; + $usecontact = false; $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } //Recipient name @@ -1315,26 +1315,26 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $thirdparty = $object->thirdparty; } - $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); + $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact?$object->contact:''), $usecontact, 'target', $object); + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); // Show recipient - $widthrecbox=100; - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format - $posy=42+$top_shift; - $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; + $widthrecbox = 100; + if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format + $posy = 42 + $top_shift; + $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; // Show recipient frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx+2, $posy-5); + $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L'); $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); // Show recipient name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L'); @@ -1342,7 +1342,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders // Show recipient information $pdf->SetFont('', '', $default_font_size - 1); - $pdf->SetXY($posx+2, $posy); + $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); } @@ -1362,7 +1362,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); } } diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index 9979509f027..2a6112db9e2 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -130,47 +130,47 @@ class pdf_standard extends ModelePDFSuppliersPayments // Page size for A4 format $this->type = 'pdf'; - $formatarray=pdf_getFormat(); + $formatarray = pdf_getFormat(); $this->page_largeur = $formatarray['width']; $this->page_hauteur = $formatarray['height']; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; - $this->option_logo = 1; // Affiche logo - $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_logo = 1; // Affiche logo + $this->option_multilang = 1; // Dispo en plusieurs langues // Define column position - $this->posxdate=$this->marge_gauche+1; - $this->posxreffacturefourn=30; - $this->posxreffacture=65; - $this->posxtype=100; - $this->posxtotalht=80; - $this->posxtva=90; - $this->posxtotalttc=180; + $this->posxdate = $this->marge_gauche + 1; + $this->posxreffacturefourn = 30; + $this->posxreffacture = 65; + $this->posxtype = 100; + $this->posxtotalht = 80; + $this->posxtva = 90; + $this->posxtotalttc = 180; //if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup; if ($this->page_largeur < 210) // To work with US executive format { - $this->posxreffacturefourn-=20; - $this->posxreffacture-=20; - $this->posxtype-=20; - $this->posxtotalht-=20; - $this->posxtva-=20; - $this->posxtotalttc-=20; + $this->posxreffacturefourn -= 20; + $this->posxreffacture -= 20; + $this->posxtype -= 20; + $this->posxtotalht -= 20; + $this->posxtva -= 20; + $this->posxtotalttc -= 20; } - $this->tva=array(); - $this->localtax1=array(); - $this->localtax2=array(); - $this->atleastoneratenotnull=0; - $this->atleastonediscount=0; + $this->tva = array(); + $this->localtax1 = array(); + $this->localtax2 = array(); + $this->atleastoneratenotnull = 0; + $this->atleastonediscount = 0; // Recupere emetteur - $this->emetteur=$mysoc; - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined } @@ -191,9 +191,9 @@ class pdf_standard extends ModelePDFSuppliersPayments // phpcs:enable global $user, $langs, $conf, $mysoc, $hookmanager; - if (! is_object($outputlangs)) $outputlangs=$langs; + if (!is_object($outputlangs)) $outputlangs = $langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; // Load translation files required by the page $outputlangs->loadLangs(array("main", "suppliers", "companies", "bills", "dict", "products")); @@ -211,12 +211,12 @@ class pdf_standard extends ModelePDFSuppliersPayments $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf,'.MAIN_DB_PREFIX.'facture_fourn as f,'.MAIN_DB_PREFIX.'societe as s'; $sql .= ' WHERE pf.fk_facturefourn = f.rowid AND f.fk_soc = s.rowid'; $sql .= ' AND pf.fk_paiementfourn = '.$object->id; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql) > 0) { - while($objp = $this->db->fetch_object($resql)) { + while ($objp = $this->db->fetch_object($resql)) { $objp->type = $outputlangs->trans('SupplierInvoice'); $object->lines[] = $objp; } @@ -229,22 +229,22 @@ class pdf_standard extends ModelePDFSuppliersPayments if ($object->specimen) { $dir = $conf->fournisseur->payment->dir_output; - $file = $dir . "/SPECIMEN.pdf"; + $file = $dir."/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); $objectrefsupplier = dol_sanitizeFileName($object->ref_supplier); $dir = $conf->fournisseur->payment->dir_output.'/'.$objectref; - $file = $dir . "/" . $objectref . ".pdf"; - if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf"; + $file = $dir."/".$objectref.".pdf"; + if (!empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir."/".$objectref.($objectrefsupplier ? "_".$objectrefsupplier : "").".pdf"; } - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } @@ -252,24 +252,24 @@ class pdf_standard extends ModelePDFSuppliersPayments if (file_exists($dir)) { // Add pdfgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $nblines = count($object->lines); - $pdf=pdf_getInstance($this->format); - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance - $heightforinfotot = 50; // Height reserved to output the info and total part - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; + $pdf = pdf_getInstance($this->format); + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance + $heightforinfotot = 50; // Height reserved to output the info and total part + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; $pdf->SetAutoPageBreak(1, 0); if (class_exists('TCPDF')) @@ -279,14 +279,14 @@ class pdf_standard extends ModelePDFSuppliersPayments } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); } $pdf->Open(); - $pagenb=0; + $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); @@ -294,76 +294,76 @@ class pdf_standard extends ModelePDFSuppliersPayments $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); $tab_top = 90; - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); $tab_height = 130; $tab_height_newpage = 150; // Incoterm $height_incoterms = 0; - $height_note=0; + $height_note = 0; $iniY = $tab_top + 7; $curY = $tab_top + 7; $nexY = $tab_top + 7; // Loop on each lines - for ($i = 0 ; $i < $nblines ; $i++) + for ($i = 0; $i < $nblines; $i++) { $curY = $nexY; - $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0, 0, 0); $pdf->setTopMargin($tab_top_newpage); - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. - $pageposbefore=$pdf->getPage(); + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $pageposbefore = $pdf->getPage(); // Description of product line - $curX = $this->posxdate-1; - $showpricebeforepagebreak=1; + $curX = $this->posxdate - 1; + $showpricebeforepagebreak = 1; $pdf->startTransaction(); //pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,1); - $pdf->writeHTMLCell($this->posxtva-$curX, 4, $curX, $curY, $object->lines[$i]->datef, 0, 1, false, true, 'J', true); - $pageposafter=$pdf->getPage(); + $pdf->writeHTMLCell($this->posxtva - $curX, 4, $curX, $curY, $object->lines[$i]->datef, 0, 1, false, true, 'J', true); + $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { $pdf->rollbackTransaction(true); - $pageposafter=$pageposbefore; + $pageposafter = $pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. //pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,1); - $pdf->writeHTMLCell($this->posxtva-$curX, 4, $curX, $curY, $object->lines[$i]->datef, 0, 1, false, true, 'J', true); - $posyafter=$pdf->GetY(); - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text + $pdf->writeHTMLCell($this->posxtva - $curX, 4, $curX, $curY, $object->lines[$i]->datef, 0, 1, false, true, 'J', true); + $posyafter = $pdf->GetY(); + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text { - if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page + if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page { $pdf->AddPage('', '', true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposafter+1); + $pdf->setPage($pageposafter + 1); } } else { // We found a page break - $showpricebeforepagebreak=0; + $showpricebeforepagebreak = 0; } } else // No pagebreak @@ -372,54 +372,54 @@ class pdf_standard extends ModelePDFSuppliersPayments } $nexY = $pdf->GetY(); - $pageposafter=$pdf->getPage(); + $pageposafter = $pdf->getPage(); $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. // We suppose that a too long description is moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { $pdf->setPage($pageposafter); $curY = $tab_top_newpage; } - $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut + $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut // ref fourn $pdf->SetXY($this->posxreffacturefourn, $curY); - $pdf->MultiCell($this->posxreffacturefourn-$this->posxup-0.8, 3, $object->lines[$i]->ref_supplier, 0, 'L', 0); + $pdf->MultiCell($this->posxreffacturefourn - $this->posxup - 0.8, 3, $object->lines[$i]->ref_supplier, 0, 'L', 0); // ref facture fourn $pdf->SetXY($this->posxreffacture, $curY); - $pdf->MultiCell($this->posxreffacture-$this->posxup-0.8, 3, $object->lines[$i]->ref, 0, 'L', 0); + $pdf->MultiCell($this->posxreffacture - $this->posxup - 0.8, 3, $object->lines[$i]->ref, 0, 'L', 0); // type $pdf->SetXY($this->posxtype, $curY); - $pdf->MultiCell($this->posxtype-$this->posxup-0.8, 3, $object->lines[$i]->type, 0, 'L', 0); + $pdf->MultiCell($this->posxtype - $this->posxup - 0.8, 3, $object->lines[$i]->type, 0, 'L', 0); // Total ht $pdf->SetXY($this->posxtotalht, $curY); - $pdf->MultiCell($this->posxtotalht-$this->posxup-0.8, 3, price($object->lines[$i]->total_ht), 0, 'R', 0); + $pdf->MultiCell($this->posxtotalht - $this->posxup - 0.8, 3, price($object->lines[$i]->total_ht), 0, 'R', 0); // Total tva $pdf->SetXY($this->posxtva, $curY); - $pdf->MultiCell($this->posxtva-$this->posxup-0.8, 3, price($object->lines[$i]->total_tva), 0, 'R', 0); + $pdf->MultiCell($this->posxtva - $this->posxup - 0.8, 3, price($object->lines[$i]->total_tva), 0, 'R', 0); // Total TTC line $pdf->SetXY($this->posxtotalttc, $curY); - $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxtotalttc, 3, price($object->lines[$i]->total_ttc), 0, 'R', 0); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalttc, 3, price($object->lines[$i]->total_ttc), 0, 'R', 0); // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) + if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { $pdf->setPage($pageposafter); - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); + $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); + $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1); $pdf->SetLineStyle(array('dash'=>0)); } - $nexY+=2; // Add space between lines + $nexY += 2; // Add space between lines // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) @@ -436,10 +436,10 @@ class pdf_standard extends ModelePDFSuppliersPayments $this->_pagefoot($pdf, $object, $outputlangs, 1); $pagenb++; $pdf->setPage($pagenb); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { @@ -452,7 +452,7 @@ class pdf_standard extends ModelePDFSuppliersPayments $this->_pagefoot($pdf, $object, $outputlangs, 1); // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } @@ -462,16 +462,16 @@ class pdf_standard extends ModelePDFSuppliersPayments if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } // Affiche zone cheèque - $posy=$this->_tableau_cheque($pdf, $object, $bottomlasttab, $outputlangs); + $posy = $this->_tableau_cheque($pdf, $object, $bottomlasttab, $outputlangs); // Affiche zone totaux //$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); @@ -486,31 +486,31 @@ class pdf_standard extends ModelePDFSuppliersPayments // Add pdfgeneration hook $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { $this->error = $hookmanager->error; $this->errors = $hookmanager->errors; } - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); $this->result = array('fullpath'=>$file); - return 1; // No error + return 1; // No error } else { - $this->error=$langs->trans("ErrorCanNotCreateDir", $dir); + $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); return 0; } } else { - $this->error=$langs->trans("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR"); + $this->error = $langs->trans("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR"); return 0; } } @@ -529,7 +529,7 @@ class pdf_standard extends ModelePDFSuppliersPayments protected function _tableau_cheque(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable - global $conf,$mysoc; + global $conf, $mysoc; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -561,7 +561,7 @@ class pdf_standard extends ModelePDFSuppliersPayments $pdf->MultiCell(150, 4, $object->thirdparty->nom, 0, 'L', 1); $pdf->SetXY($this->page_largeur - $this->marge_droite - 30, $posy); - $pdf->MultiCell(35, 4, str_pad(price($object->montant). ' '.$currency, 18, '*', STR_PAD_LEFT), 0, 'R', 1); + $pdf->MultiCell(35, 4, str_pad(price($object->montant).' '.$currency, 18, '*', STR_PAD_LEFT), 0, 'R', 1); $posy += 10; @@ -591,11 +591,11 @@ class pdf_standard extends ModelePDFSuppliersPayments */ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') { - global $conf,$mysoc; + global $conf, $mysoc; // Force to disable hidetop and hidebottom - $hidebottom=0; - if ($hidetop) $hidetop=-1; + $hidebottom = 0; + if ($hidetop) $hidetop = -1; $currency = !empty($currency) ? $currency : $conf->currency; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -605,7 +605,7 @@ class pdf_standard extends ModelePDFSuppliersPayments $pdf->SetFont('', '', $default_font_size - 2); $titre = strtoupper($mysoc->town).', le '.date("d").' '.$outputlangs->transnoentitiesnoconv(date("F")).' '.date("Y"); - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3) - 60, $tab_top-6); + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3) - 60, $tab_top - 6); $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); @@ -645,19 +645,19 @@ class pdf_standard extends ModelePDFSuppliersPayments $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); - $posy=$this->marge_haute; - $posx=$this->page_largeur-$this->marge_droite-100; + $posy = $this->marge_haute; + $posx = $this->page_largeur - $this->marge_droite - 100; $pdf->SetXY($this->marge_gauche, $posy); // Logo - $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; + $logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo; if ($mysoc->logo) { if (is_readable($logo)) { - $height=pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + $height = pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) } else { @@ -669,7 +669,7 @@ class pdf_standard extends ModelePDFSuppliersPayments } else { - $text=$this->emetteur->name; + $text = $this->emetteur->name; $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } /* @@ -739,15 +739,15 @@ class pdf_standard extends ModelePDFSuppliersPayments $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); // Show payer - $posy=42; - $posx=$this->marge_gauche; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; - $hautcadre=40; + $posy = 42; + $posx = $this->marge_gauche; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80; + $hautcadre = 40; // Show sender frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx, $posy-5); + $pdf->SetXY($posx, $posy - 5); $pdf->MultiCell(66, 5, $outputlangs->transnoentities("PayedBy").":", 0, 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); @@ -755,39 +755,39 @@ class pdf_standard extends ModelePDFSuppliersPayments $pdf->SetTextColor(0, 0, 60); // Show sender name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); - $posy=$pdf->getY(); + $posy = $pdf->getY(); // Show sender information - $pdf->SetXY($posx+2, $posy); + $pdf->SetXY($posx + 2, $posy); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); // Payed $thirdparty = $object->thirdparty; - $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); + $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client=pdf_build_address($outputlangs, $this->emetteur, $mysoc, ((!empty($object->contact))?$object->contact:null), $usecontact, 'target', $object); + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $mysoc, ((!empty($object->contact)) ? $object->contact : null), $usecontact, 'target', $object); // Show recipient - $widthrecbox=90; - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format - $posy=42; - $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; + $widthrecbox = 90; + if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format + $posy = 42; + $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; // Show recipient frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx+2, $posy-5); + $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("PayedTo").":", 0, 'L'); $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); // Show recipient name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L'); @@ -795,7 +795,7 @@ class pdf_standard extends ModelePDFSuppliersPayments // Show recipient information $pdf->SetFont('', '', $default_font_size - 1); - $pdf->SetXY($posx+2, $posy); + $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); } } @@ -813,7 +813,7 @@ class pdf_standard extends ModelePDFSuppliersPayments protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); } } diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index cb73468f6fd..db5c5501d53 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -130,66 +130,66 @@ class pdf_aurore extends ModelePDFSupplierProposal // Page size for A4 format $this->type = 'pdf'; - $formatarray=pdf_getFormat(); + $formatarray = pdf_getFormat(); $this->page_largeur = $formatarray['width']; $this->page_hauteur = $formatarray['height']; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION - $this->option_modereg = 1; // Affiche mode reglement - $this->option_condreg = 1; // Affiche conditions reglement - $this->option_codeproduitservice = 1; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 1; // Affiche si il y a eu escompte - $this->option_credit_note = 1; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 1; //Support add of a watermark on drafts + $this->option_logo = 1; // Affiche logo + $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION + $this->option_modereg = 1; // Affiche mode reglement + $this->option_condreg = 1; // Affiche conditions reglement + $this->option_codeproduitservice = 1; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 1; // Affiche si il y a eu escompte + $this->option_credit_note = 1; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 1; //Support add of a watermark on drafts // Get source company - $this->emetteur=$mysoc; - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default, if was not defined + $this->emetteur = $mysoc; + if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined // Define position of columns - $this->posxdesc=$this->marge_gauche+1; - $this->posxdiscount=162; - $this->postotalht=174; + $this->posxdesc = $this->marge_gauche + 1; + $this->posxdiscount = 162; + $this->postotalht = 174; if ($conf->global->PRODUCT_USE_UNITS) { - $this->posxtva=101; - $this->posxup=118; - $this->posxqty=135; - $this->posxunit=151; + $this->posxtva = 101; + $this->posxup = 118; + $this->posxqty = 135; + $this->posxunit = 151; } else { - $this->posxtva=102; - $this->posxup=126; - $this->posxqty=145; - $this->posxunit=162; + $this->posxtva = 102; + $this->posxup = 126; + $this->posxqty = 145; + $this->posxunit = 162; } - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxup=$this->posxtva; - $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images + if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxup = $this->posxtva; + $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images if ($this->page_largeur < 210) // To work with US executive format { - $this->posxpicture-=20; - $this->posxtva-=20; - $this->posxup-=20; - $this->posxqty-=20; - $this->posxunit-=20; - $this->posxdiscount-=20; - $this->postotalht-=20; + $this->posxpicture -= 20; + $this->posxtva -= 20; + $this->posxup -= 20; + $this->posxqty -= 20; + $this->posxunit -= 20; + $this->posxdiscount -= 20; + $this->postotalht -= 20; } - $this->tva=array(); - $this->localtax1=array(); - $this->localtax2=array(); - $this->atleastoneratenotnull=0; - $this->atleastonediscount=0; + $this->tva = array(); + $this->localtax1 = array(); + $this->localtax2 = array(); + $this->atleastoneratenotnull = 0; + $this->atleastonediscount = 0; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -207,11 +207,11 @@ class pdf_aurore extends ModelePDFSupplierProposal public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblines; + global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines; - if (! is_object($outputlangs)) $outputlangs=$langs; + if (!is_object($outputlangs)) $outputlangs = $langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "supplier_proposal")); @@ -219,40 +219,40 @@ class pdf_aurore extends ModelePDFSupplierProposal $nblines = count($object->lines); // Loop on each lines to detect if there is at least one image to show - $realpatharray=array(); - if (! empty($conf->global->MAIN_GENERATE_SUPPLIER_PROPOSAL_WITH_PICTURE)) + $realpatharray = array(); + if (!empty($conf->global->MAIN_GENERATE_SUPPLIER_PROPOSAL_WITH_PICTURE)) { - for ($i = 0 ; $i < $nblines ; $i++) + for ($i = 0; $i < $nblines; $i++) { if (empty($object->lines[$i]->fk_product)) continue; $objphoto = new Product($this->db); $objphoto->fetch($object->lines[$i]->fk_product); - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { - $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product') . $object->lines[$i]->fk_product ."/photos/"; + $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/"; $dir = $conf->product->dir_output.'/'.$pdir; } else { - $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product') . dol_sanitizeFileName($objphoto->ref).'/'; + $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; $dir = $conf->product->dir_output.'/'.$pdir; } - $realpath=''; + $realpath = ''; foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) { - $filename=$obj['photo']; + $filename = $obj['photo']; //if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette']; $realpath = $dir.$filename; break; } - if ($realpath) $realpatharray[$i]=$realpath; + if ($realpath) $realpatharray[$i] = $realpath; } } - if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva; + if (count($realpatharray) == 0) $this->posxpicture = $this->posxtva; if ($conf->supplier_proposal->dir_output) { @@ -264,20 +264,20 @@ class pdf_aurore extends ModelePDFSupplierProposal if ($object->specimen) { $dir = $conf->supplier_proposal->dir_output; - $file = $dir . "/SPECIMEN.pdf"; + $file = $dir."/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); - $dir = $conf->supplier_proposal->dir_output . "/" . $objectref; - $file = $dir . "/" . $objectref . ".pdf"; + $dir = $conf->supplier_proposal->dir_output."/".$objectref; + $file = $dir."/".$objectref.".pdf"; } - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } @@ -285,23 +285,23 @@ class pdf_aurore extends ModelePDFSupplierProposal if (file_exists($dir)) { // Add pdfgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks // Create pdf instance - $pdf=pdf_getInstance($this->format); - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance - $heightforinfotot = 50; // Height reserved to output the info and total part - $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; + $pdf = pdf_getInstance($this->format); + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance + $heightforinfotot = 50; // Height reserved to output the info and total part + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; $pdf->SetAutoPageBreak(1, 0); if (class_exists('TCPDF')) @@ -311,14 +311,14 @@ class pdf_aurore extends ModelePDFSupplierProposal } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); } $pdf->Open(); - $pagenb=0; + $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); @@ -326,12 +326,12 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("CommercialAsk")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right // Positionne $this->atleastonediscount si on a au moins une remise - for ($i = 0 ; $i < $nblines ; $i++) + for ($i = 0; $i < $nblines; $i++) { if ($object->lines[$i]->remise_percent) { @@ -341,59 +341,59 @@ class pdf_aurore extends ModelePDFSupplierProposal if (empty($this->atleastonediscount)) { $delta = ($this->postotalht - $this->posxdiscount); - $this->posxpicture+=$delta; - $this->posxtva+=$delta; - $this->posxup+=$delta; - $this->posxqty+=$delta; - $this->posxunit+=$delta; - $this->posxdiscount+=$delta; + $this->posxpicture += $delta; + $this->posxtva += $delta; + $this->posxup += $delta; + $this->posxqty += $delta; + $this->posxunit += $delta; + $this->posxdiscount += $delta; // post of fields after are not modified, stay at same position } // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); - $tab_top = 90+$top_shift; - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10); + $tab_top = 90 + $top_shift; + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); // Affiche notes - $notetoshow=empty($object->note_public)?'':$object->note_public; - if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) + $notetoshow = empty($object->note_public) ? '' : $object->note_public; + if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) { // Get first sale rep if (is_object($object->thirdparty)) { - $salereparray=$object->thirdparty->getSalesRepresentatives($user); - $salerepobj=new User($this->db); + $salereparray = $object->thirdparty->getSalesRepresentatives($user); + $salerepobj = new User($this->db); $salerepobj->fetch($salereparray[0]['id']); - if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); + if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature); } } if ($notetoshow) { $tab_top -= 2; - $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); + $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object); complete_substitutions_array($substitutionarray, $outputlangs, $object); $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($notetoshow), 0, 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($notetoshow), 0, 1); $nexY = $pdf->GetY(); - $height_note=$nexY-$tab_top; + $height_note = $nexY - $tab_top; // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); - $tab_top = $nexY+6; + $tab_top = $nexY + 6; } $iniY = $tab_top + 7; @@ -401,105 +401,105 @@ class pdf_aurore extends ModelePDFSupplierProposal $nexY = $tab_top + 7; // Loop on each lines - for ($i = 0 ; $i < $nblines ; $i++) + for ($i = 0; $i < $nblines; $i++) { $curY = $nexY; - $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0, 0, 0); // Define size of image if we need it - $imglinesize=array(); - if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); + $imglinesize = array(); + if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]); $pdf->setTopMargin($tab_top_newpage); - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. - $pageposbefore=$pdf->getPage(); + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $pageposbefore = $pdf->getPage(); - $showpricebeforepagebreak=1; - $posYAfterImage=0; - $posYAfterDescription=0; + $showpricebeforepagebreak = 1; + $posYAfterImage = 0; + $posYAfterDescription = 0; // We start with Photo of product line - if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page + if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // If photo too high, we moved completely on new page { $pdf->AddPage('', '', true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposbefore+1); + $pdf->setPage($pageposbefore + 1); $curY = $tab_top_newpage; - $showpricebeforepagebreak=0; + $showpricebeforepagebreak = 0; } if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) { - $curX = $this->posxpicture-1; - $pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi + $curX = $this->posxpicture - 1; + $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi // $pdf->Image does not increase value return by getY, so we save it manually - $posYAfterImage=$curY+$imglinesize['height']; + $posYAfterImage = $curY + $imglinesize['height']; } // Description of product line - $curX = $this->posxdesc-1; + $curX = $this->posxdesc - 1; $pdf->startTransaction(); if ($posYAfterImage > 0) { - $descWidth = $this->posxpicture-$curX; + $descWidth = $this->posxpicture - $curX; } else { - $descWidth = $this->posxtva-$curX; + $descWidth = $this->posxtva - $curX; } pdf_writelinedesc($pdf, $object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1); - $pageposafter=$pdf->getPage(); + $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { $pdf->rollbackTransaction(true); - $pageposafter=$pageposbefore; + $pageposafter = $pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. pdf_writelinedesc($pdf, $object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc); - $pageposafter=$pdf->getPage(); - $posyafter=$pdf->GetY(); + $pageposafter = $pdf->getPage(); + $posyafter = $pdf->GetY(); //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text { - if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page + if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page { $pdf->AddPage('', '', true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposafter+1); + $pdf->setPage($pageposafter + 1); } } else { // We found a page break - $showpricebeforepagebreak=0; + $showpricebeforepagebreak = 0; } } else // No pagebreak { $pdf->commitTransaction(); } - $posYAfterDescription=$pdf->GetY(); + $posYAfterDescription = $pdf->GetY(); $nexY = $pdf->GetY(); - $pageposafter=$pdf->getPage(); + $pageposafter = $pdf->getPage(); $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. // We suppose that a too long description or photo were moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { $pdf->setPage($pageposafter); $curY = $tab_top_newpage; } - $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut + $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut // VAT Rate /* @@ -520,14 +520,14 @@ class pdf_aurore extends ModelePDFSupplierProposal // Quantity $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxqty, $curY); - $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R'); // Enough for 6 chars + $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); // Enough for 6 chars // Unit - if($conf->global->PRODUCT_USE_UNITS) + if ($conf->global->PRODUCT_USE_UNITS) { $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); $pdf->SetXY($this->posxunit, $curY); - $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L'); + $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L'); } // Discount on line @@ -547,54 +547,54 @@ class pdf_aurore extends ModelePDFSupplierProposal */ // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva - if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; - else $tvaligne=$object->lines[$i]->total_tva; + if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva; + else $tvaligne = $object->lines[$i]->total_tva; - $localtax1ligne=$object->lines[$i]->total_localtax1; - $localtax2ligne=$object->lines[$i]->total_localtax2; - $localtax1_rate=$object->lines[$i]->localtax1_tx; - $localtax2_rate=$object->lines[$i]->localtax2_tx; - $localtax1_type=$object->lines[$i]->localtax1_type; - $localtax2_type=$object->lines[$i]->localtax2_type; + $localtax1ligne = $object->lines[$i]->total_localtax1; + $localtax2ligne = $object->lines[$i]->total_localtax2; + $localtax1_rate = $object->lines[$i]->localtax1_tx; + $localtax2_rate = $object->lines[$i]->localtax2_tx; + $localtax1_type = $object->lines[$i]->localtax1_type; + $localtax2_type = $object->lines[$i]->localtax2_type; - if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; - if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; - if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; + if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100; + if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100; + if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100; - $vatrate=(string) $object->lines[$i]->tva_tx; + $vatrate = (string) $object->lines[$i]->tva_tx; // Retrieve type from database for backward compatibility with old records - if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined - && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax + if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined + && (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax { - $localtaxtmp_array=getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc); + $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc); $localtax1_type = $localtaxtmp_array[0]; $localtax2_type = $localtaxtmp_array[2]; } // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0) - $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; + $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; if ($localtax2_type && $localtax2ligne != 0) - $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; + $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; - if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; - if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; + if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*'; + if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0; $this->tva[$vatrate] += $tvaligne; - if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage; + if ($posYAfterImage > $posYAfterDescription) $nexY = $posYAfterImage; // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) + if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { $pdf->setPage($pageposafter); - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); + $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); + $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1); $pdf->SetLineStyle(array('dash'=>0)); } - $nexY+=2; // Add space between lines + $nexY += 2; // Add space between lines // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) @@ -611,10 +611,10 @@ class pdf_aurore extends ModelePDFSupplierProposal $this->_pagefoot($pdf, $object, $outputlangs, 1); $pagenb++; $pdf->setPage($pagenb); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { @@ -627,7 +627,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $this->_pagefoot($pdf, $object, $outputlangs, 1); // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } @@ -637,16 +637,16 @@ class pdf_aurore extends ModelePDFSupplierProposal if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } // Affiche zone infos - $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); + $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); // Affiche zone totaux //$posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs); @@ -669,31 +669,31 @@ class pdf_aurore extends ModelePDFSupplierProposal //Add pdfgeneration hook $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { $this->error = $hookmanager->error; $this->errors = $hookmanager->errors; } - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); $this->result = array('fullpath'=>$file); - return 1; // No error + return 1; // No error } else { - $this->error=$langs->trans("ErrorCanNotCreateDir", $dir); + $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); return 0; } } else { - $this->error=$langs->trans("ErrorConstantNotDefined", "SUPPLIER_PROPOSAL_OUTPUTDIR"); + $this->error = $langs->trans("ErrorConstantNotDefined", "SUPPLIER_PROPOSAL_OUTPUTDIR"); return 0; } } @@ -733,10 +733,10 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->SetFont('', '', $default_font_size - 1); - $posxval=52; + $posxval = 52; // Show shipping date - if (! empty($object->date_livraison)) + if (!empty($object->date_livraison)) { $outputlangs->load("sendings"); $pdf->SetFont('', 'B', $default_font_size - 2); @@ -745,10 +745,10 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->MultiCell(80, 4, $titre, 0, 'L'); $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); - $dlp=dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true); + $dlp = dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true); $pdf->MultiCell(80, 4, $dlp, 0, 'L'); - $posy=$pdf->GetY()+1; + $posy = $pdf->GetY() + 1; } else { $outputlangs->load("sendings"); @@ -761,7 +761,7 @@ class pdf_aurore extends ModelePDFSupplierProposal //$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true); $pdf->MultiCell(80, 4, $dlp, 0, 'L'); - $posy=$pdf->GetY()+1; + $posy = $pdf->GetY() + 1; } /* PHFAVRE elseif ($object->availability_code || $object->availability) // Show availability conditions @@ -790,14 +790,14 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->SetFont('', '', $default_font_size - 2); $pdf->SetXY($posxval, $posy); - $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc); - $lib_condition_paiement=str_replace('\n', "\n", $lib_condition_paiement); + $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc); + $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement); $pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L'); - $posy=$pdf->GetY()+3; + $posy = $pdf->GetY() + 3; } - if (! empty($conf->global->SUPPLIER_PROPOSAL_PDF_SHOW_PAYMENTTERMMODE)) + if (!empty($conf->global->SUPPLIER_PROPOSAL_PDF_SHOW_PAYMENTTERMMODE)) { // Show payment mode if ($object->mode_reglement_code @@ -805,24 +805,24 @@ class pdf_aurore extends ModelePDFSupplierProposal && $object->mode_reglement_code != 'VIR') { $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->SetXY($this->marge_gauche, $posy-2); + $pdf->SetXY($this->marge_gauche, $posy - 2); $titre = $outputlangs->transnoentities("PaymentMode").':'; $pdf->MultiCell(80, 5, $titre, 0, 'L'); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posxval, $posy-2); - $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement); + $pdf->SetXY($posxval, $posy - 2); + $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement); $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L'); - $posy=$pdf->GetY()+2; + $posy = $pdf->GetY() + 2; } // Show payment mode CHQ if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') { // Si mode reglement non force ou si force a CHQ - if (! empty($conf->global->FACTURE_CHQ_NUMBER)) + if (!empty($conf->global->FACTURE_CHQ_NUMBER)) { - $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE); + $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE); if ($conf->global->FACTURE_CHQ_NUMBER > 0) { @@ -832,14 +832,14 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0); - $posy=$pdf->GetY()+1; + $posy = $pdf->GetY() + 1; if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0); - $posy=$pdf->GetY()+2; + $posy = $pdf->GetY() + 2; } } if ($conf->global->FACTURE_CHQ_NUMBER == -1) @@ -847,14 +847,14 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0); - $posy=$pdf->GetY()+1; + $posy = $pdf->GetY() + 1; if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) { $pdf->SetXY($this->marge_gauche, $posy); $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0); - $posy=$pdf->GetY()+2; + $posy = $pdf->GetY() + 2; } } } @@ -863,18 +863,18 @@ class pdf_aurore extends ModelePDFSupplierProposal // If payment mode not forced or forced to VIR, show payment with BAN if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') { - if (! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER)) + if (!empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER)) { - $bankid=(empty($object->fk_bank)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_bank); + $bankid = (empty($object->fk_bank) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_bank); $account = new Account($this->db); $account->fetch($bankid); - $curx=$this->marge_gauche; - $cury=$posy; + $curx = $this->marge_gauche; + $cury = $posy; - $posy=pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size); + $posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size); - $posy+=2; + $posy += 2; } } } @@ -897,7 +897,7 @@ class pdf_aurore extends ModelePDFSupplierProposal protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { // phpcs:enable - global $conf,$mysoc; + global $conf, $mysoc; $default_font_size = pdf_getPDFFontSize($outputlangs); $tab2_top = $posy; @@ -908,29 +908,29 @@ class pdf_aurore extends ModelePDFSupplierProposal $col1x = 120; $col2x = 170; if ($this->page_largeur < 210) // To work with US executive format { - $col2x-=20; + $col2x -= 20; } $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); - $useborder=0; + $useborder = 0; $index = 0; // Total HT $pdf->SetFillColor(255, 255, 255); $pdf->SetXY($col1x, $tab2_top + 0); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + 0); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1); // Show VAT by rates and total $pdf->SetFillColor(248, 248, 248); - $this->atleastoneratenotnull=0; + $this->atleastoneratenotnull = 0; if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { - $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false); - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) + $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false); + if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) { // Nothing to do } @@ -939,28 +939,28 @@ class pdf_aurore extends ModelePDFSupplierProposal //Local tax 1 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ - foreach($this->localtax1 as $localtax_type => $localtax_rate) + foreach ($this->localtax1 as $localtax_type => $localtax_rate) { - if (in_array((string) $localtax_type, array('1','3','5'))) continue; + if (in_array((string) $localtax_type, array('1', '3', '5'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + foreach ($localtax_rate as $tvakey => $tvaval) { - if ($tvakey!=0) // On affiche pas taux 0 + if ($tvakey != 0) // On affiche pas taux 0 { //$this->atleastoneratenotnull++; $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); @@ -971,13 +971,13 @@ class pdf_aurore extends ModelePDFSupplierProposal //Local tax 2 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //{ - foreach($this->localtax2 as $localtax_type => $localtax_rate) + foreach ($this->localtax2 as $localtax_type => $localtax_rate) { - if (in_array((string) $localtax_type, array('1','3','5'))) continue; + if (in_array((string) $localtax_type, array('1', '3', '5'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + foreach ($localtax_rate as $tvakey => $tvaval) { - if ($tvakey!=0) // On affiche pas taux 0 + if ($tvakey != 0) // On affiche pas taux 0 { //$this->atleastoneratenotnull++; @@ -986,15 +986,15 @@ class pdf_aurore extends ModelePDFSupplierProposal $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); @@ -1003,7 +1003,7 @@ class pdf_aurore extends ModelePDFSupplierProposal } //} // VAT - foreach($this->tva as $tvakey => $tvaval) + foreach ($this->tva as $tvakey => $tvaval) { if ($tvakey > 0) // On affiche pas taux 0 { @@ -1012,15 +1012,15 @@ class pdf_aurore extends ModelePDFSupplierProposal $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } - $totalvat =$outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; - $totalvat.=vatrate($tvakey, 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; + $totalvat .= vatrate($tvakey, 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); @@ -1030,11 +1030,11 @@ class pdf_aurore extends ModelePDFSupplierProposal //Local tax 1 after VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ - foreach($this->localtax1 as $localtax_type => $localtax_rate) + foreach ($this->localtax1 as $localtax_type => $localtax_rate) { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; + if (in_array((string) $localtax_type, array('2', '4', '6'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + foreach ($localtax_rate as $tvakey => $tvaval) { if ($tvakey != 0) // On affiche pas taux 0 { @@ -1043,16 +1043,16 @@ class pdf_aurore extends ModelePDFSupplierProposal $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } @@ -1062,11 +1062,11 @@ class pdf_aurore extends ModelePDFSupplierProposal //Local tax 2 after VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //{ - foreach($this->localtax2 as $localtax_type => $localtax_rate) + foreach ($this->localtax2 as $localtax_type => $localtax_rate) { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; + if (in_array((string) $localtax_type, array('2', '4', '6'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + foreach ($localtax_rate as $tvakey => $tvaval) { // retrieve global local tax if ($tvakey != 0) // On affiche pas taux 0 @@ -1076,16 +1076,16 @@ class pdf_aurore extends ModelePDFSupplierProposal $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl=''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { - $tvakey=str_replace('*', '', $tvakey); + $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); @@ -1099,7 +1099,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetTextColor(0, 0, 60); $pdf->SetFillColor(224, 224, 224); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc, 0, $outputlangs), $useborder, 'R', 1); @@ -1118,7 +1118,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0); @@ -1143,7 +1143,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->SetTextColor(0, 0, 60); $pdf->SetFillColor(224, 224, 224); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1); @@ -1175,8 +1175,8 @@ class pdf_aurore extends ModelePDFSupplierProposal global $conf; // Force to disable hidetop and hidebottom - $hidebottom=0; - if ($hidetop) $hidetop=-1; + $hidebottom = 0; + if ($hidetop) $hidetop = -1; $currency = !empty($currency) ? $currency : $conf->currency; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -1188,24 +1188,24 @@ class pdf_aurore extends ModelePDFSupplierProposal if (empty($hidetop)) { $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; - if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); + if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); } $pdf->SetDrawColor(128, 128, 128); $pdf->SetFont('', '', $default_font_size - 1); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter if (empty($hidetop)) { - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line takes a position y in 2nd parameter and 4th parameter + $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line takes a position y in 2nd parameter and 4th parameter - $pdf->SetXY($this->posxdesc-1, $tab_top+1); + $pdf->SetXY($this->posxdesc - 1, $tab_top + 1); $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L'); } @@ -1215,26 +1215,26 @@ class pdf_aurore extends ModelePDFSupplierProposal //$pdf->line($this->posxtva-2, $tab_top, $this->posxtva-2, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxtva-5, $tab_top+1); - $pdf->MultiCell($this->posxup-$this->posxtva+3, 2, $outputlangs->transnoentities("VAT"), '', 'C'); + $pdf->SetXY($this->posxtva - 5, $tab_top + 1); + $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C'); } } - $pdf->line($this->posxup-3, $tab_top, $this->posxup-3, $tab_top + $tab_height); + $pdf->line($this->posxup - 3, $tab_top, $this->posxup - 3, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxup-1, $tab_top+1); - $pdf->MultiCell($this->posxqty-$this->posxup-1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C'); + $pdf->SetXY($this->posxup - 1, $tab_top + 1); + $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C'); } - $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); + $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxqty-1, $tab_top+1); - $pdf->MultiCell($this->posxunit-$this->posxqty-1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); + $pdf->SetXY($this->posxqty - 1, $tab_top + 1); + $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); } - if($conf->global->PRODUCT_USE_UNITS) { + if ($conf->global->PRODUCT_USE_UNITS) { $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxunit - 1, $tab_top + 1); @@ -1242,13 +1242,13 @@ class pdf_aurore extends ModelePDFSupplierProposal } } - $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); + $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height); if (empty($hidetop)) { if ($this->atleastonediscount) { - $pdf->SetXY($this->posxdiscount-1, $tab_top+1); - $pdf->MultiCell($this->postotalht-$this->posxdiscount+1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C'); + $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1); + $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C'); } } if ($this->atleastonediscount) @@ -1257,7 +1257,7 @@ class pdf_aurore extends ModelePDFSupplierProposal } if (empty($hidetop)) { - $pdf->SetXY($this->postotalht-1, $tab_top+1); + $pdf->SetXY($this->postotalht - 1, $tab_top + 1); $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C'); } } @@ -1284,7 +1284,7 @@ class pdf_aurore extends ModelePDFSupplierProposal pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); // Show Draft Watermark - if($object->statut==0 && (! empty($conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK)) ) + if ($object->statut == 0 && (!empty($conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK))) { pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK); } @@ -1292,19 +1292,19 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); - $posy=$this->marge_haute; - $posx=$this->page_largeur-$this->marge_droite-100; + $posy = $this->marge_haute; + $posx = $this->page_largeur - $this->marge_droite - 100; $pdf->SetXY($this->marge_gauche, $posy); // Logo - $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; + $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; if ($this->emetteur->logo) { if (is_readable($logo)) { - $height=pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + $height = pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) } else { @@ -1316,32 +1316,32 @@ class pdf_aurore extends ModelePDFSupplierProposal } else { - $text=$this->emetteur->name; + $text = $this->emetteur->name; $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } $pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $title=$outputlangs->transnoentities("CommercialAsk"); + $title = $outputlangs->transnoentities("CommercialAsk"); $pdf->MultiCell(100, 4, $title, '', 'R'); $pdf->SetFont('', 'B', $default_font_size); - $posy+=5; + $posy += 5; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R'); + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R'); - $posy+=1; + $posy += 1; $pdf->SetFont('', '', $default_font_size - 2); if ($object->ref_client) { - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); } /* PHFAVRE $posy+=4; @@ -1352,28 +1352,28 @@ class pdf_aurore extends ModelePDFSupplierProposal if ($object->thirdparty->code_fournisseur) { - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); } // Get contact if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) { - $arrayidcontact=$object->getIdContact('internal', 'SALESREPFOLL'); + $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); if (count($arrayidcontact) > 0) { - $usertmp=new User($this->db); + $usertmp = new User($this->db); $usertmp->fetch($arrayidcontact[0]); - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R'); } } - $posy+=2; + $posy += 2; $top_shift = 0; // Show list of linked objects @@ -1387,28 +1387,28 @@ class pdf_aurore extends ModelePDFSupplierProposal if ($showaddress) { // Sender properties - $carac_emetteur=''; + $carac_emetteur = ''; // Add internal contact of proposal if defined - $arrayidcontact=$object->getIdContact('internal', 'SALESREPFOLL'); + $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); if (count($arrayidcontact) > 0) { $object->fetch_user($arrayidcontact[0]); - $labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name")); - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name")); + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; } $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); // Show sender - $posy=42+$top_shift; - $posx=$this->marge_gauche; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; - $hautcadre=40; + $posy = 42 + $top_shift; + $posx = $this->marge_gauche; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80; + $hautcadre = 40; // Show sender frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx, $posy-5); + $pdf->SetXY($posx, $posy - 5); $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); @@ -1416,63 +1416,63 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->SetTextColor(0, 0, 60); // Show sender name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); - $posy=$pdf->getY(); + $posy = $pdf->getY(); // Show sender information - $pdf->SetXY($posx+2, $posy); + $pdf->SetXY($posx + 2, $posy); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); // If CUSTOMER contact defined, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external', 'CUSTOMER'); + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } // Recipient name - if (! empty($usecontact)) + if (!empty($usecontact)) { // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname; + if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname; else $socname = $object->thirdparty->name; - $carac_client_name=$outputlangs->convToOutputCharset($socname); + $carac_client_name = $outputlangs->convToOutputCharset($socname); } else { - $carac_client_name=$outputlangs->convToOutputCharset($object->thirdparty->name); + $carac_client_name = $outputlangs->convToOutputCharset($object->thirdparty->name); } - $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact?$object->contact:''), $usecontact, 'target', $object); + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); // Show recipient - $widthrecbox=100; - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format - $posy=42+$top_shift; - $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; + $widthrecbox = 100; + if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format + $posy = 42 + $top_shift; + $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; // Show recipient frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx+2, $posy-5); + $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L'); $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); // Show recipient name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L'); // Show recipient information $pdf->SetFont('', '', $default_font_size - 1); - $pdf->SetXY($posx+2, $posy+4+(dol_nboflines_bis($carac_client_name, 50)*4)); + $pdf->SetXY($posx + 2, $posy + 4 + (dol_nboflines_bis($carac_client_name, 50) * 4)); $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); } @@ -1493,7 +1493,7 @@ class pdf_aurore extends ModelePDFSupplierProposal protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); } } diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index fcff59cb21a..492590c65e4 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -45,7 +45,7 @@ if ($massaction == 'presend') $listofselectedthirdparties = array(); $listofselectedref = array(); - if (! GETPOST('cancel', 'alpha')) + if (!GETPOST('cancel', 'alpha')) { foreach ($arrayofselected as $toselectid) { @@ -66,25 +66,25 @@ if ($massaction == 'presend') print ''; - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); dol_fiche_head(null, '', ''); // Cree l'objet formulaire mail - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); $formmail->withform = -1; - $formmail->fromtype = (GETPOST('fromtype') ? GETPOST('fromtype') : (! empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE) ? $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE : 'user')); + $formmail->fromtype = (GETPOST('fromtype') ? GETPOST('fromtype') : (!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE) ? $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE : 'user')); if ($formmail->fromtype === 'user') { $formmail->fromid = $user->id; } $formmail->trackid = $trackid; - if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set + if (!empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set { - include DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; + include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $formmail->frommail = dolAddEmailTrackId($formmail->frommail, $trackid); } $formmail->withfrom = 1; @@ -112,10 +112,10 @@ if ($massaction == 'presend') $formmail->withtoreadonly = 1; } - $formmail->withoptiononeemailperrecipient = ((count($listofselectedref) == 1 && count(reset($listofselectedref)) == 1) || empty($liste)) ? 0 : ((GETPOST('oneemailperrecipient')=='on')?1:-1); + $formmail->withoptiononeemailperrecipient = ((count($listofselectedref) == 1 && count(reset($listofselectedref)) == 1) || empty($liste)) ? 0 : ((GETPOST('oneemailperrecipient') == 'on') ? 1 : -1); - $formmail->withto = empty($liste)?(GETPOST('sendto', 'alpha')?GETPOST('sendto', 'alpha'):array()):$liste; - $formmail->withtofree = empty($liste)?1:0; + $formmail->withto = empty($liste) ? (GETPOST('sendto', 'alpha') ?GETPOST('sendto', 'alpha') : array()) : $liste; + $formmail->withtofree = empty($liste) ? 1 : 0; $formmail->withtocc = 1; $formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC; $formmail->withtopic = $langs->transnoentities($topicmail, '__REF__', '__REFCLIENT__'); @@ -134,8 +134,8 @@ if ($massaction == 'presend') $substitutionarray = getCommonSubstitutionArray($langs, 0, null, $object); $substitutionarray['__EMAIL__'] = $sendto; - $substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? '' : ''; - $substitutionarray['__PERSONALIZED__'] = ''; // deprecated + $substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? '' : ''; + $substitutionarray['__PERSONALIZED__'] = ''; // deprecated $substitutionarray['__CONTACTCIVNAME__'] = ''; $parameters = array( @@ -152,11 +152,11 @@ if ($massaction == 'presend') $formmail->param['models_id'] = GETPOST('modelmailselected', 'int'); $formmail->param['id'] = join(',', $arrayofselected); // $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - if (! empty($conf->global->MAILING_LIMIT_SENDBYWEB) && count($listofselectedthirdparties) > $conf->global->MAILING_LIMIT_SENDBYWEB) + if (!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && count($listofselectedthirdparties) > $conf->global->MAILING_LIMIT_SENDBYWEB) { $langs->load("errors"); - print img_warning() . ' ' . $langs->trans('WarningNumberOfRecipientIsRestrictedInMassAction', $conf->global->MAILING_LIMIT_SENDBYWEB); - print ' - ' . $langs->trans("GoBack") . ''; + print img_warning().' '.$langs->trans('WarningNumberOfRecipientIsRestrictedInMassAction', $conf->global->MAILING_LIMIT_SENDBYWEB); + print ' - '.$langs->trans("GoBack").''; $arrayofmassactions = array(); } else @@ -172,7 +172,7 @@ $parameters = array( 'uploaddir' => $uploaddir ); -$reshook=$hookmanager->executeHooks('doPreMassActions', $parameters, $object, $action); +$reshook = $hookmanager->executeHooks('doPreMassActions', $parameters, $object, $action); if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } else { diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 5cde792bbb5..82a898a8ddf 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -1308,7 +1308,7 @@ class Cronjob extends CommonObject public function LibStatut($status, $mode = 0, $processing = 0, $lastresult = 0) { // phpcs:enable - $this->labelStatus = array(); // Force reset o array because label depends on other fields + $this->labelStatus = array(); // Force reset o array because label depends on other fields $this->labelStatusShort = array(); if (empty($this->labelStatus) || empty($this->labelStatusShort)) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index cbca46576a1..79e418206a5 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -389,7 +389,7 @@ if (empty($reshook)) // CONTENT $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; - $link = '' . $link . ''; + $link = ''.$link.''; $message = $langs->transnoentities("ExpenseReportWaitingForApprovalMessage", $expediteur->getFullName($langs), get_date_range($object->date_debut, $object->date_fin, '', $langs), $link); // Rebuild pdf @@ -509,7 +509,7 @@ if (empty($reshook)) // CONTENT $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; - $link = '' . $link . ''; + $link = ''.$link.''; $dateRefusEx = explode(" ", $object->date_refuse); $message = $langs->transnoentities("ExpenseReportWaitingForReApprovalMessage", $dateRefusEx[0], $object->detail_refuse, $expediteur->getFullName($langs), $link); @@ -635,7 +635,7 @@ if (empty($reshook)) // CONTENT $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; - $link = '' . $link . ''; + $link = ''.$link.''; $message = $langs->transnoentities("ExpenseReportApprovedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link); // Rebuilt pdf @@ -755,7 +755,7 @@ if (empty($reshook)) // CONTENT $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; - $link = '' . $link . ''; + $link = ''.$link.''; $message = $langs->transnoentities("ExpenseReportRefusedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $detailRefuse, $link); // Rebuilt pdf @@ -885,7 +885,7 @@ if (empty($reshook)) // CONTENT $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; - $link = '' . $link . ''; + $link = ''.$link.''; $message = $langs->transnoentities("ExpenseReportCanceledMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $detailCancel, $link); // Rebuilt pdf @@ -1111,7 +1111,7 @@ if (empty($reshook)) // CONTENT $link = $urlwithroot.'/expensereport/card.php?id='.$object->id; - $link = '' . $link . ''; + $link = ''.$link.''; $message = $langs->transnoentities("ExpenseReportPaidMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link); // Generate pdf before attachment diff --git a/htdocs/expensereport/class/expensereportstats.class.php b/htdocs/expensereport/class/expensereportstats.class.php index 9c614e4953c..f400d5e4277 100644 --- a/htdocs/expensereport/class/expensereportstats.class.php +++ b/htdocs/expensereport/class/expensereportstats.class.php @@ -22,8 +22,8 @@ * \ingroup expensereport * \brief Fichier de la classe de gestion des stats des expensereport et notes de frais */ -require_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php'; -require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/stats.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; /** * Classe permettant la gestion des stats des expensereports et notes de frais @@ -61,29 +61,29 @@ class ExpenseReportStats extends Stats $this->socid = $socid; $this->userid = $userid; - $object=new ExpenseReport($this->db); + $object = new ExpenseReport($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as e"; - $this->field='total_ht'; + $this->field = 'total_ht'; //$this->where = " e.fk_statut > 0"; //$this->where.= " AND e.date_valid > '2000-01-01'"; // To filter only correct "valid date". If date is invalid, the group by on it will fails. Launch a repair.php if you have. - $this->where.= ' e.entity IN ('.getEntity('expensereport').')'; + $this->where .= ' e.entity IN ('.getEntity('expensereport').')'; //$this->where.= " AND entity = ".$conf->entity; if ($this->socid) { - $this->where.=" AND e.fk_soc = ".$this->socid; + $this->where .= " AND e.fk_soc = ".$this->socid; } // Only me and subordinates if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) { $childids = $user->getAllChildIds(); - $childids[]=$user->id; - $this->where.=" AND e.fk_user_author IN (".(join(',', $childids)).")"; + $childids[] = $user->id; + $this->where .= " AND e.fk_user_author IN (".(join(',', $childids)).")"; } - if ($this->userid > 0) $this->where.=' AND e.fk_user_author = '.$this->userid; + if ($this->userid > 0) $this->where .= ' AND e.fk_user_author = '.$this->userid; } @@ -95,9 +95,9 @@ class ExpenseReportStats extends Stats public function getNbByYear() { $sql = "SELECT YEAR(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).") as dm, count(*)"; - $sql.= " FROM ".$this->from; - $sql.= " GROUP BY dm DESC"; - $sql.= " WHERE ".$this->where; + $sql .= " FROM ".$this->from; + $sql .= " GROUP BY dm DESC"; + $sql .= " WHERE ".$this->where; return $this->_getNbByYear($sql); } @@ -113,13 +113,13 @@ class ExpenseReportStats extends Stats public function getNbByMonth($year, $format = 0) { $sql = "SELECT MONTH(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).") as dm, count(*)"; - $sql.= " FROM ".$this->from; - $sql.= " WHERE YEAR(e.".$this->datetouse.") = ".$year; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " FROM ".$this->from; + $sql .= " WHERE YEAR(e.".$this->datetouse.") = ".$year; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); - $res=$this->_getNbByMonth($year, $sql, $format); + $res = $this->_getNbByMonth($year, $sql, $format); //var_dump($res);print '
'; return $res; } @@ -135,13 +135,13 @@ class ExpenseReportStats extends Stats public function getAmountByMonth($year, $format = 0) { $sql = "SELECT date_format(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).",'%m') as dm, sum(".$this->field.")"; - $sql.= " FROM ".$this->from; - $sql.= " WHERE date_format(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).",'%Y') = '".$year."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " FROM ".$this->from; + $sql .= " WHERE date_format(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).",'%Y') = '".$year."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); - $res=$this->_getAmountByMonth($year, $sql, $format); + $res = $this->_getAmountByMonth($year, $sql, $format); //var_dump($res);print '
'; return $res; } @@ -155,11 +155,11 @@ class ExpenseReportStats extends Stats public function getAverageByMonth($year) { $sql = "SELECT date_format(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).",'%m') as dm, avg(".$this->field.")"; - $sql.= " FROM ".$this->from; - $sql.= " WHERE date_format(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).",'%Y') = '".$year."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " FROM ".$this->from; + $sql .= " WHERE date_format(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).",'%Y') = '".$year."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); return $this->_getAverageByMonth($year, $sql); } @@ -172,10 +172,10 @@ class ExpenseReportStats extends Stats public function getAllByYear() { $sql = "SELECT date_format(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).",'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; - $sql.= " FROM ".$this->from; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY year"; - $sql.= $this->db->order('year', 'DESC'); + $sql .= " FROM ".$this->from; + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY year"; + $sql .= $this->db->order('year', 'DESC'); return $this->_getAllByYear($sql); } diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index 525a5b17c9e..f910001a5e0 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -379,7 +379,7 @@ if ($step == 2 && $action == 'select_model') { $fieldsarray = preg_split("/,(?! [^(]*\))/", $objexport->hexa); $i = 1; - foreach($fieldsarray as $val) + foreach ($fieldsarray as $val) { $array_selected[$val] = $i; $i++; diff --git a/htdocs/fourn/ajax/getSupplierPrices.php b/htdocs/fourn/ajax/getSupplierPrices.php index 2d18c6ea86e..0c0d8f42c9e 100644 --- a/htdocs/fourn/ajax/getSupplierPrices.php +++ b/htdocs/fourn/ajax/getSupplierPrices.php @@ -22,20 +22,20 @@ * \brief File to return an Ajax response to get list of possible prices for margin calculation */ -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; -$idprod=GETPOST('idprod', 'int'); +$idprod = GETPOST('idprod', 'int'); $prices = array(); // Load translation files required by the page -$langs->loadLangs(array("stocks","margins")); +$langs->loadLangs(array("stocks", "margins")); /* @@ -48,14 +48,14 @@ top_httphead(); if ($idprod > 0) { - $producttmp=new ProductFournisseur($db); + $producttmp = new ProductFournisseur($db); $producttmp->fetch($idprod); $sorttouse = 's.nom, pfp.quantity, pfp.price'; if (GETPOST('bestpricefirst')) $sorttouse = 'pfp.unitprice, s.nom, pfp.quantity, pfp.price'; - $productSupplierArray = $producttmp->list_product_fournisseur_price($idprod, $sorttouse); // We list all price per supplier, and then firstly with the lower quantity. So we can choose first one with enough quantity into list. - if ( is_array($productSupplierArray)) + $productSupplierArray = $producttmp->list_product_fournisseur_price($idprod, $sorttouse); // We list all price per supplier, and then firstly with the lower quantity. So we can choose first one with enough quantity into list. + if (is_array($productSupplierArray)) { foreach ($productSupplierArray as $productSupplier) { @@ -66,35 +66,35 @@ if ($idprod > 0) if ($productSupplier->fourn_qty == 1) { - $title.= price($price, 0, $langs, 0, 0, -1, $conf->currency)."/"; + $title .= price($price, 0, $langs, 0, 0, -1, $conf->currency)."/"; } - $title.= $productSupplier->fourn_qty.' '.($productSupplier->fourn_qty == 1 ? $langs->trans("Unit") : $langs->trans("Units")); + $title .= $productSupplier->fourn_qty.' '.($productSupplier->fourn_qty == 1 ? $langs->trans("Unit") : $langs->trans("Units")); if ($productSupplier->fourn_qty > 1) { - $title.=" - "; - $title.= price($unitprice, 0, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit"); + $title .= " - "; + $title .= price($unitprice, 0, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit"); $price = $unitprice; } $label = price($price, 0, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit"); - if ($productSupplier->fourn_ref) $label.=' ('.$productSupplier->fourn_ref.')'; + if ($productSupplier->fourn_ref) $label .= ' ('.$productSupplier->fourn_ref.')'; - $prices[] = array("id" => $productSupplier->product_fourn_price_id, "price" => price2num($price, 0, '', 0), "label" => $label, "title" => $title); // For price field, we must use price2num(), for label or title, price() + $prices[] = array("id" => $productSupplier->product_fourn_price_id, "price" => price2num($price, 0, '', 0), "label" => $label, "title" => $title); // For price field, we must use price2num(), for label or title, price() } } // After best supplier prices and before costprice - if(!empty($conf->stock->enabled)) + if (!empty($conf->stock->enabled)) { // Add price for pmp - $price=$producttmp->pmp; - $prices[] = array("id" => 'pmpprice', "price" => price2num($price), "label" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency)); // For price field, we must use price2num(), for label or title, price() + $price = $producttmp->pmp; + $prices[] = array("id" => 'pmpprice', "price" => price2num($price), "label" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency)); // For price field, we must use price2num(), for label or title, price() } // Add price for costprice (at end) - $price=$producttmp->cost_price; - $prices[] = array("id" => 'costprice', "price" => price2num($price), "label" => $langs->trans("CostPrice").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency)); // For price field, we must use price2num(), for label or title, price() + $price = $producttmp->cost_price; + $prices[] = array("id" => 'costprice', "price" => price2num($price), "label" => $langs->trans("CostPrice").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency)); // For price field, we must use price2num(), for label or title, price() } echo json_encode($prices); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 9064e8292fe..bd74d52a4d5 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -65,7 +65,7 @@ class CommandeFournisseur extends CommonOrder /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ - public $picto='order'; + public $picto = 'order'; /** * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe @@ -442,7 +442,7 @@ class CommandeFournisseur extends CommonOrder $line->fk_product = $objp->fk_product; - $line->libelle = $objp->product_label; // deprecated + $line->libelle = $objp->product_label; // deprecated $line->product_label = $objp->product_label; $line->product_desc = $objp->product_desc; @@ -1414,38 +1414,38 @@ class CommandeFournisseur extends CommonOrder */ public function createFromClone(User $user, $socid = 0) { - global $conf, $user,$hookmanager; + global $conf, $user, $hookmanager; - $error=0; + $error = 0; $this->db->begin(); // get lines so they will be clone - foreach($this->lines as $line) + foreach ($this->lines as $line) $line->fetch_optionals(); // Load source object $objFrom = clone $this; // Change socid if needed - if (! empty($socid) && $socid != $this->socid) + if (!empty($socid) && $socid != $this->socid) { $objsoc = new Societe($this->db); - if ($objsoc->fetch($socid)>0) + if ($objsoc->fetch($socid) > 0) { - $this->socid = $objsoc->id; - $this->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); - $this->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); - $this->fk_project = 0; - $this->fk_delivery_address = 0; + $this->socid = $objsoc->id; + $this->cond_reglement_id = (!empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); + $this->mode_reglement_id = (!empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); + $this->fk_project = 0; + $this->fk_delivery_address = 0; } // TODO Change product price if multi-prices } - $this->id=0; - $this->statut=self::STATUS_DRAFT; + $this->id = 0; + $this->statut = self::STATUS_DRAFT; // Clear fields $this->user_author_id = $user->id; @@ -2400,7 +2400,7 @@ class CommandeFournisseur extends CommonOrder $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseurdet"; $sql .= " (fk_commande, label, description, fk_product, price, qty, tva_tx, localtax1_tx, localtax2_tx, remise_percent, subprice, remise, ref)"; - $sql .= " VALUES (".$idc.", '" . $this->db->escape($label) . "','" . $this->db->escape($comclient->lines[$i]->desc) . "'"; + $sql .= " VALUES (".$idc.", '".$this->db->escape($label)."','".$this->db->escape($comclient->lines[$i]->desc)."'"; $sql .= ",".$comclient->lines[$i]->fk_product.",'".price2num($comclient->lines[$i]->price)."'"; $sql .= ", '".$comclient->lines[$i]->qty."', ".$comclient->lines[$i]->tva_tx.", ".$comclient->lines[$i]->localtax1_tx.", ".$comclient->lines[$i]->localtax2_tx.", ".$comclient->lines[$i]->remise_percent; $sql .= ", '".price2num($comclient->lines[$i]->subprice)."','0','".$ref."');"; @@ -2623,7 +2623,7 @@ class CommandeFournisseur extends CommonOrder if (is_array($array_options) && count($array_options) > 0) { // We replace values in this->line->array_options only for entries defined into $array_options - foreach($array_options as $key => $value) { + foreach ($array_options as $key => $value) { $this->line->array_options[$key] = $array_options[$key]; } } @@ -2795,26 +2795,26 @@ class CommandeFournisseur extends CommonOrder // phpcs:enable global $conf, $user; - $this->nb=array(); + $this->nb = array(); $clause = "WHERE"; $sql = "SELECT count(co.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as co"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON co.fk_soc = s.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as co"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON co.fk_soc = s.rowid"; if (!$user->rights->societe->client->voir && !$user->socid) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; - $sql.= " WHERE sc.fk_user = " .$user->id; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; + $sql .= " WHERE sc.fk_user = ".$user->id; $clause = "AND"; } - $sql.= " ".$clause." co.entity = ".$conf->entity; + $sql .= " ".$clause." co.entity = ".$conf->entity; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $this->nb["supplier_orders"]=$obj->nb; + $this->nb["supplier_orders"] = $obj->nb; } $this->db->free($resql); return 1; @@ -2843,41 +2843,41 @@ class CommandeFournisseur extends CommonOrder $clause = " WHERE"; $sql = "SELECT c.rowid, c.date_creation as datec, c.date_commande, c.fk_statut, c.date_livraison as delivery_date"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c"; if (!$user->rights->societe->client->voir && !$user->socid) { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc"; - $sql.= " WHERE sc.fk_user = " .$user->id; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc"; + $sql .= " WHERE sc.fk_user = ".$user->id; $clause = " AND"; } - $sql.= $clause." c.entity = ".$conf->entity; - if($mode==='awaiting'){ - $sql.= " AND c.fk_statut = ".self::STATUS_ORDERSENT; + $sql .= $clause." c.entity = ".$conf->entity; + if ($mode === 'awaiting') { + $sql .= " AND c.fk_statut = ".self::STATUS_ORDERSENT; } - else{ - $sql.= " AND c.fk_statut IN (".self::STATUS_VALIDATED.", ".self::STATUS_ACCEPTED.")"; + else { + $sql .= " AND c.fk_statut IN (".self::STATUS_VALIDATED.", ".self::STATUS_ACCEPTED.")"; } - if ($user->socid) $sql.=" AND c.fk_soc = ".$user->socid; + if ($user->socid) $sql .= " AND c.fk_soc = ".$user->socid; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $commandestatic = new CommandeFournisseur($this->db); $response = new WorkboardResponse(); - $response->warning_delay=$conf->commande->fournisseur->warning_delay/60/60/24; - $response->label=$langs->trans("SuppliersOrdersToProcess"); - $response->labelShort=$langs->trans("Opened"); - $response->url=DOL_URL_ROOT.'/fourn/commande/list.php?statut=1,2&mainmenu=commercial&leftmenu=orders_suppliers'; - $response->img=img_object('', "order"); + $response->warning_delay = $conf->commande->fournisseur->warning_delay / 60 / 60 / 24; + $response->label = $langs->trans("SuppliersOrdersToProcess"); + $response->labelShort = $langs->trans("Opened"); + $response->url = DOL_URL_ROOT.'/fourn/commande/list.php?statut=1,2&mainmenu=commercial&leftmenu=orders_suppliers'; + $response->img = img_object('', "order"); - if($mode==='awaiting'){ - $response->label=$langs->trans("SuppliersOrdersAwaitingReception"); - $response->labelShort=$langs->trans("AwaitingReception"); - $response->url=DOL_URL_ROOT.'/fourn/commande/list.php?statut=3&mainmenu=commercial&leftmenu=orders_suppliers'; + if ($mode === 'awaiting') { + $response->label = $langs->trans("SuppliersOrdersAwaitingReception"); + $response->labelShort = $langs->trans("AwaitingReception"); + $response->url = DOL_URL_ROOT.'/fourn/commande/list.php?statut=3&mainmenu=commercial&leftmenu=orders_suppliers'; } - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { $response->nbtodo++; @@ -2953,12 +2953,12 @@ class CommandeFournisseur extends CommonOrder $langs->load("suppliers"); - if (! dol_strlen($modele)) { + if (!dol_strlen($modele)) { $modele = 'muscadet'; if ($this->modelpdf) { $modele = $this->modelpdf; - } elseif (! empty($conf->global->COMMANDE_SUPPLIER_ADDON_PDF)) { + } elseif (!empty($conf->global->COMMANDE_SUPPLIER_ADDON_PDF)) { $modele = $conf->global->COMMANDE_SUPPLIER_ADDON_PDF; } } @@ -3642,20 +3642,20 @@ class CommandeFournisseurLigne extends CommonOrderLine { global $user; - $error=0; + $error = 0; $this->db->begin(); $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commande_fournisseurdet WHERE rowid=".$this->id; dol_syslog(__METHOD__, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if (!$notrigger) { // Call trigger - $result=$this->call_trigger('LINEORDER_SUPPLIER_DELETE', $user); + $result = $this->call_trigger('LINEORDER_SUPPLIER_DELETE', $user); if ($result < 0) $error++; // End call triggers } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 4bdb3c70a21..231a5e9e910 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1952,7 +1952,7 @@ class FactureFournisseur extends CommonInvoice if (is_array($array_options) && count($array_options) > 0) { // We replace values in this->line->array_options only for entries defined into $array_options - foreach($array_options as $key => $value) { + foreach ($array_options as $key => $value) { $this->line->array_options[$key] = $array_options[$key]; } } diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index 586b6b59036..b30d1463b50 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -433,19 +433,19 @@ class Loan extends CommonObject global $langs; // Load translation files required by the page - $langs->loadLangs(array("customers","bills")); + $langs->loadLangs(array("customers", "bills")); - unset($this->labelStatus); // Force to reset the array of status label, because label can change depending on parameters + unset($this->labelStatus); // Force to reset the array of status label, because label can change depending on parameters if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; //$langs->load("mymodule"); $this->labelStatus[self::STATUS_UNPAID] = $langs->trans('Unpaid'); $this->labelStatus[self::STATUS_PAID] = $langs->trans('Paid'); - if ($status == 0 && $alreadypaid > 0) $this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); + if ($status == 0 && $alreadypaid > 0) $this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans('Unpaid'); $this->labelStatusShort[self::STATUS_PAID] = $langs->trans('Enabled'); - if ($status == 0 && $alreadypaid > 0) $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); + if ($status == 0 && $alreadypaid > 0) $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); } $statusType = 'status1'; diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 51e35ab050a..f5d2d130e12 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -197,18 +197,18 @@ if ($dirins && $action == 'initmodule' && $modulename) 'Mon module'=>$modulename, 'mon module'=>$modulename, 'htdocs/modulebuilder/template'=>strtolower($modulename), - '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') + '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '') ); - if($conf->global->MAIN_FEATURES_LEVEL >= 2){ - if(!empty($conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME)) $arrayreplacement['Editor name'] = $conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME; - if(!empty($conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL)) $arrayreplacement['https://www.example.com'] = $conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL; - if(!empty($conf->global->MODULEBUILDER_SPECIFIC_AUTHOR)) $arrayreplacement['---Put here your own copyright and developer email---'] = dol_print_date($now, '%Y').' '.$conf->global->MODULEBUILDER_SPECIFIC_AUTHOR; - if(!empty($conf->global->MODULEBUILDER_SPECIFIC_VERSION)) $arrayreplacement['1.0'] = $conf->global->MODULEBUILDER_SPECIFIC_VERSION; - if(!empty($conf->global->MODULEBUILDER_SPECIFIC_FAMILY)) $arrayreplacement['other'] = $conf->global->MODULEBUILDER_SPECIFIC_FAMILY; + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { + if (!empty($conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME)) $arrayreplacement['Editor name'] = $conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME; + if (!empty($conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL)) $arrayreplacement['https://www.example.com'] = $conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL; + if (!empty($conf->global->MODULEBUILDER_SPECIFIC_AUTHOR)) $arrayreplacement['---Put here your own copyright and developer email---'] = dol_print_date($now, '%Y').' '.$conf->global->MODULEBUILDER_SPECIFIC_AUTHOR; + if (!empty($conf->global->MODULEBUILDER_SPECIFIC_VERSION)) $arrayreplacement['1.0'] = $conf->global->MODULEBUILDER_SPECIFIC_VERSION; + if (!empty($conf->global->MODULEBUILDER_SPECIFIC_FAMILY)) $arrayreplacement['other'] = $conf->global->MODULEBUILDER_SPECIFIC_FAMILY; } - $result=dolReplaceInFile($phpfileval['fullname'], $arrayreplacement); + $result = dolReplaceInFile($phpfileval['fullname'], $arrayreplacement); //var_dump($result); if ($result < 0) @@ -235,7 +235,7 @@ if ($dirins && $action == 'initmodule' && $modulename) if ($dirins && $action == 'initapi' && !empty($module)) { - $modulename = ucfirst($module); // Force first letter in uppercase + $modulename = ucfirst($module); // Force first letter in uppercase $objectname = $tabobj; dol_mkdir($dirins.'/'.strtolower($module).'/class'); @@ -248,7 +248,7 @@ if ($dirins && $action == 'initapi' && !empty($module)) if ($result > 0) { //var_dump($phpfileval['fullname']); - $arrayreplacement=array( + $arrayreplacement = array( 'mymodule'=>strtolower($modulename), 'MyModule'=>$modulename, 'MYMODULE'=>strtoupper($modulename), @@ -260,7 +260,7 @@ if ($dirins && $action == 'initapi' && !empty($module)) 'myobject'=>strtolower($objectname), 'MyObject'=>$objectname, 'MYOBJECT'=>strtoupper($objectname), - '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') + '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '') ); dolReplaceInFile($destfile, $arrayreplacement); @@ -273,7 +273,7 @@ if ($dirins && $action == 'initapi' && !empty($module)) } if ($dirins && $action == 'initphpunit' && !empty($module)) { - $modulename = ucfirst($module); // Force first letter in uppercase + $modulename = ucfirst($module); // Force first letter in uppercase $objectname = $tabobj; dol_mkdir($dirins.'/'.strtolower($module).'/class'); @@ -285,7 +285,7 @@ if ($dirins && $action == 'initphpunit' && !empty($module)) if ($result > 0) { //var_dump($phpfileval['fullname']); - $arrayreplacement=array( + $arrayreplacement = array( 'mymodule'=>strtolower($modulename), 'MyModule'=>$modulename, 'MYMODULE'=>strtoupper($modulename), @@ -297,7 +297,7 @@ if ($dirins && $action == 'initphpunit' && !empty($module)) 'myobject'=>strtolower($objectname), 'MyObject'=>$objectname, 'MYOBJECT'=>strtoupper($objectname), - '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') + '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '') ); dolReplaceInFile($destfile, $arrayreplacement); @@ -310,7 +310,7 @@ if ($dirins && $action == 'initphpunit' && !empty($module)) } if ($dirins && $action == 'initsqlextrafields' && !empty($module)) { - $modulename = ucfirst($module); // Force first letter in uppercase + $modulename = ucfirst($module); // Force first letter in uppercase $objectname = $tabobj; dol_mkdir($dirins.'/'.strtolower($module).'/sql'); @@ -326,10 +326,10 @@ if ($dirins && $action == 'initsqlextrafields' && !empty($module)) if ($result1 > 0 && $result2 > 0) { - $modulename = ucfirst($module); // Force first letter in uppercase + $modulename = ucfirst($module); // Force first letter in uppercase //var_dump($phpfileval['fullname']); - $arrayreplacement=array( + $arrayreplacement = array( 'mymodule'=>strtolower($modulename), 'MyModule'=>$modulename, 'MYMODULE'=>strtoupper($modulename), @@ -342,7 +342,7 @@ if ($dirins && $action == 'initsqlextrafields' && !empty($module)) 'MyObject'=>$objectname, 'my object'=>strtolower($objectname), 'myobject'=>strtolower($objectname), - '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') + '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '') ); dolReplaceInFile($destfile1, $arrayreplacement); @@ -446,7 +446,7 @@ if ($dirins && $action == 'initwidget' && !empty($module)) 'Mon module'=>$modulename, 'mon module'=>$modulename, 'htdocs/modulebuilder/template'=>strtolower($modulename), - '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') + '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '') ); dolReplaceInFile($destfile, $arrayreplacement); @@ -468,10 +468,10 @@ if ($dirins && $action == 'initcss' && !empty($module)) if ($result > 0) { - $modulename = ucfirst($module); // Force first letter in uppercase + $modulename = ucfirst($module); // Force first letter in uppercase //var_dump($phpfileval['fullname']); - $arrayreplacement=array( + $arrayreplacement = array( 'mymodule'=>strtolower($modulename), 'MyModule'=>$modulename, 'MYMODULE'=>strtoupper($modulename), @@ -480,7 +480,7 @@ if ($dirins && $action == 'initcss' && !empty($module)) 'Mon module'=>$modulename, 'mon module'=>$modulename, 'htdocs/modulebuilder/template'=>strtolower($modulename), - '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':''), + '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : ''), ); dolReplaceInFile($destfile, $arrayreplacement); @@ -507,10 +507,10 @@ if ($dirins && $action == 'initjs' && !empty($module)) if ($result > 0) { - $modulename = ucfirst($module); // Force first letter in uppercase + $modulename = ucfirst($module); // Force first letter in uppercase //var_dump($phpfileval['fullname']); - $arrayreplacement=array( + $arrayreplacement = array( 'mymodule'=>strtolower($modulename), 'MyModule'=>$modulename, 'MYMODULE'=>strtoupper($modulename), @@ -519,7 +519,7 @@ if ($dirins && $action == 'initjs' && !empty($module)) 'Mon module'=>$modulename, 'mon module'=>$modulename, 'htdocs/modulebuilder/template'=>strtolower($modulename), - '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') + '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '') ); dolReplaceInFile($destfile, $arrayreplacement); @@ -546,10 +546,10 @@ if ($dirins && $action == 'initcli' && !empty($module)) if ($result > 0) { - $modulename = ucfirst($module); // Force first letter in uppercase + $modulename = ucfirst($module); // Force first letter in uppercase //var_dump($phpfileval['fullname']); - $arrayreplacement=array( + $arrayreplacement = array( 'mymodule'=>strtolower($modulename), 'MyModule'=>$modulename, 'MYMODULE'=>strtoupper($modulename), @@ -707,15 +707,15 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray', );*/ $string = 'public $fields=array('."\n"; - $string.="
"; - $i=10; + $string .= "
"; + $i = 10; while ($obj = $db->fetch_object($_results)) { // fieldname $fieldname = $obj->Field; // type $type = $obj->Type; - if ($type == 'int(11)') $type='integer'; + if ($type == 'int(11)') $type = 'integer'; if ($obj->Field == 'fk_soc') $type = 'integer:Societe:societe/class/societe.class.php'; if (preg_match('/^fk_proj/', $obj->Field)) $type = 'integer:Project:projet/class/project.class.php:1:fk_statut=1'; if (preg_match('/^fk_prod/', $obj->Field)) $type = 'integer:Product:product/class/product.class.php:1'; @@ -723,22 +723,22 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray', if (preg_match('/^(fk_user|fk_commercial)/', $obj->Field)) $type = 'integer:User:user/class/user.class.php'; // notnull - $notnull = ($obj->Null == 'YES'?0:1); + $notnull = ($obj->Null == 'YES' ? 0 : 1); if ($fieldname == 'fk_user_modif') $notnull = -1; // label $label = preg_replace('/_/', ' ', ucfirst($fieldname)); - if ($fieldname == 'rowid') $label='TechnicalID'; - if ($fieldname == 'import_key') $label='ImportId'; - if ($fieldname == 'fk_soc') $label='ThirdParty'; - if ($fieldname == 'tms') $label='DateModification'; - if ($fieldname == 'datec') $label='DateCreation'; - if ($fieldname == 'date_valid') $label='DateValidation'; - if ($fieldname == 'datev') $label='DateValidation'; - if ($fieldname == 'note_private') $label='NotePublic'; - if ($fieldname == 'note_public') $label='NotePrivate'; - if ($fieldname == 'fk_user_creat') $label='UserAuthor'; - if ($fieldname == 'fk_user_modif') $label='UserModif'; - if ($fieldname == 'fk_user_valid') $label='UserValidation'; + if ($fieldname == 'rowid') $label = 'TechnicalID'; + if ($fieldname == 'import_key') $label = 'ImportId'; + if ($fieldname == 'fk_soc') $label = 'ThirdParty'; + if ($fieldname == 'tms') $label = 'DateModification'; + if ($fieldname == 'datec') $label = 'DateCreation'; + if ($fieldname == 'date_valid') $label = 'DateValidation'; + if ($fieldname == 'datev') $label = 'DateValidation'; + if ($fieldname == 'note_private') $label = 'NotePublic'; + if ($fieldname == 'note_public') $label = 'NotePrivate'; + if ($fieldname == 'fk_user_creat') $label = 'UserAuthor'; + if ($fieldname == 'fk_user_modif') $label = 'UserModif'; + if ($fieldname == 'fk_user_valid') $label = 'UserValidation'; // visible $visible = -1; if ($fieldname == 'entity') $visible = -2; @@ -750,28 +750,28 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray', $enabled = 1; // default $default = ''; - if ($fieldname == 'entity') $default=1; + if ($fieldname == 'entity') $default = 1; // position $position = $i; if (in_array($fieldname, array('status', 'statut', 'fk_status', 'fk_statut'))) $position = 500; // index $index = 0; - if ($fieldname == 'entity') $index=1; + if ($fieldname == 'entity') $index = 1; - $string.= "'".$obj->Field."' =>array('type'=>'".$type."', 'label'=>'".$label."',"; - if ($default != '') $string.= " 'default'=>".$default.","; - $string.= " 'enabled'=>".$enabled.","; - $string.= " 'visible'=>".$visible; - if ($notnull) $string.= ", 'notnull'=>".$notnull; - if ($fieldname == 'ref') $string.= ", 'showoncombobox'=>1"; - $string.= ", 'position'=>".$position; - if ($index) $string.= ", 'index'=>".$index; - $string.= "),\n"; - $string.="
"; - $i+=5; + $string .= "'".$obj->Field."' =>array('type'=>'".$type."', 'label'=>'".$label."',"; + if ($default != '') $string .= " 'default'=>".$default.","; + $string .= " 'enabled'=>".$enabled.","; + $string .= " 'visible'=>".$visible; + if ($notnull) $string .= ", 'notnull'=>".$notnull; + if ($fieldname == 'ref') $string .= ", 'showoncombobox'=>1"; + $string .= ", 'position'=>".$position; + if ($index) $string .= ", 'index'=>".$index; + $string .= "),\n"; + $string .= "
"; + $i += 5; } - $string.= ');'."\n"; - $string.="
"; + $string .= ');'."\n"; + $string .= "
"; print $string; exit; } @@ -891,14 +891,14 @@ if ($dirins && $action == 'initobject' && $module && $objectname) // Scan for object class files $listofobject = dol_dir_list($destdir.'/class', 'files', 0, '\.class\.php$'); - $firstobjectname=''; - foreach($listofobject as $fileobj) + $firstobjectname = ''; + foreach ($listofobject as $fileobj) { if (preg_match('/^api_/', $fileobj['name'])) continue; if (preg_match('/^actions_/', $fileobj['name'])) continue; - $tmpcontent=file_get_contents($fileobj['fullname']); - $reg=array(); + $tmpcontent = file_get_contents($fileobj['fullname']); + $reg = array(); if (preg_match('/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) { $objectnameloop = $reg[1]; @@ -951,7 +951,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) $stringtoadd = preg_replace('/mymodule/', strtolower($module), $stringtoadd); $stringtoadd = preg_replace('/myobject/', strtolower($objectnameloop), $stringtoadd); - $moduledescriptorfile=$destdir.'/core/modules/mod'.$module.'.class.php'; + $moduledescriptorfile = $destdir.'/core/modules/mod'.$module.'.class.php'; // TODO Allow a replace with regex using dolReplaceInFile with param arryreplacementisregex to 1 // TODO Avoid duplicate addition @@ -959,19 +959,19 @@ if ($dirins && $action == 'initobject' && $module && $objectname) dolReplaceInFile($moduledescriptorfile, array('END MODULEBUILDER LEFTMENU MYOBJECT */' => '*/'."\n".$stringtoadd."\n\t\t/* END MODULEBUILDER LEFTMENU MYOBJECT */")); // Add module descriptor to list of files to replace "MyObject' string with real name of object. - $filetogenerate[]='core/modules/mod'.$module.'.class.php'; + $filetogenerate[] = 'core/modules/mod'.$module.'.class.php'; } } - if (! $error) + if (!$error) { // Edit PHP files to make replacement - foreach($filetogenerate as $destfile) + foreach ($filetogenerate as $destfile) { $phpfileval['fullname'] = $destdir.'/'.$destfile; //var_dump($phpfileval['fullname']); - $arrayreplacement=array( + $arrayreplacement = array( 'mymodule'=>strtolower($module), 'MyModule'=>$module, 'MYMODULE'=>strtoupper($module), @@ -994,38 +994,38 @@ if ($dirins && $action == 'initobject' && $module && $objectname) } } - if (! $error) + if (!$error) { // Edit the class file to write properties - $object=rebuildObjectClass($destdir, $module, $objectname, $newmask); + $object = rebuildObjectClass($destdir, $module, $objectname, $newmask); if (is_numeric($object) && $object < 0) $error++; } - if (! $error) + if (!$error) { // Edit sql with new properties - $result=rebuildObjectSql($destdir, $module, $objectname, $newmask, '', $object); + $result = rebuildObjectSql($destdir, $module, $objectname, $newmask, '', $object); if ($result < 0) $error++; } - if (! $error) + if (!$error) { setEventMessages($langs->trans('FilesForObjectInitialized', $objectname), null); $tabobj = $objectname; } } -if ($dirins && ($action == 'droptable' || $action == 'droptableextrafields') && !empty($module) && ! empty($tabobj)) +if ($dirins && ($action == 'droptable' || $action == 'droptableextrafields') && !empty($module) && !empty($tabobj)) { $objectname = $tabobj; - $arrayoftables=array(); + $arrayoftables = array(); if ($action == 'droptable') $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).'_'.strtolower($tabobj); if ($action == 'droptableextrafields') $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).'_'.strtolower($tabobj).'_extrafields'; - foreach($arrayoftables as $tabletodrop) + foreach ($arrayoftables as $tabletodrop) { $nb = -1; - $sql="SELECT COUNT(*) as nb FROM ".$tabletodrop; + $sql = "SELECT COUNT(*) as nb FROM ".$tabletodrop; $resql = $db->query($sql); if ($resql) { @@ -1070,35 +1070,35 @@ if ($dirins && $action == 'addproperty' && !empty($module) && !empty($tabobj)) dol_mkdir($destdir); // We click on add property - if (! GETPOST('regenerateclasssql') && ! GETPOST('regeneratemissing')) + if (!GETPOST('regenerateclasssql') && !GETPOST('regeneratemissing')) { - if (! GETPOST('propname', 'aZ09')) + if (!GETPOST('propname', 'aZ09')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Name")), null, 'errors'); } - if (! GETPOST('proplabel', 'alpha')) + if (!GETPOST('proplabel', 'alpha')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); } - if (! GETPOST('proptype', 'alpha')) + if (!GETPOST('proptype', 'alpha')) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Type")), null, 'errors'); } - if (! $error) + if (!$error) { $addfieldentry = array( - 'name'=>GETPOST('propname', 'aZ09'),'label'=>GETPOST('proplabel', 'alpha'),'type'=>GETPOST('proptype', 'alpha'), - 'arrayofkeyval'=>GETPOST('proparrayofkeyval', 'none'), // Example json string '{"0":"Draft","1":"Active","-1":"Cancel"}' - 'visible'=>GETPOST('propvisible', 'int'),'enabled'=>GETPOST('propenabled', 'int'), - 'position'=>GETPOST('propposition', 'int'),'notnull'=>GETPOST('propnotnull', 'int'),'index'=>GETPOST('propindex', 'int'),'searchall'=>GETPOST('propsearchall', 'int'), - 'isameasure'=>GETPOST('propisameasure', 'int'), 'comment'=>GETPOST('propcomment', 'alpha'),'help'=>GETPOST('prophelp', 'alpha') + 'name'=>GETPOST('propname', 'aZ09'), 'label'=>GETPOST('proplabel', 'alpha'), 'type'=>GETPOST('proptype', 'alpha'), + 'arrayofkeyval'=>GETPOST('proparrayofkeyval', 'none'), // Example json string '{"0":"Draft","1":"Active","-1":"Cancel"}' + 'visible'=>GETPOST('propvisible', 'int'), 'enabled'=>GETPOST('propenabled', 'int'), + 'position'=>GETPOST('propposition', 'int'), 'notnull'=>GETPOST('propnotnull', 'int'), 'index'=>GETPOST('propindex', 'int'), 'searchall'=>GETPOST('propsearchall', 'int'), + 'isameasure'=>GETPOST('propisameasure', 'int'), 'comment'=>GETPOST('propcomment', 'alpha'), 'help'=>GETPOST('prophelp', 'alpha') ); - if (! empty($addfieldentry['arrayofkeyval']) && ! is_array($addfieldentry['arrayofkeyval'])) + if (!empty($addfieldentry['arrayofkeyval']) && !is_array($addfieldentry['arrayofkeyval'])) { $addfieldentry['arrayofkeyval'] = dol_json_decode($addfieldentry['arrayofkeyval'], true); } @@ -1112,9 +1112,9 @@ if ($dirins && $action == 'addproperty' && !empty($module) && !empty($tabobj)) }*/ // Edit the class file to write properties - if (! $error) + if (!$error) { - $object=rebuildObjectClass($destdir, $module, $objectname, $newmask, $srcdir, $addfieldentry); + $object = rebuildObjectClass($destdir, $module, $objectname, $newmask, $srcdir, $addfieldentry); if (is_numeric($object) && $object <= 0) { $error++; @@ -1122,23 +1122,23 @@ if ($dirins && $action == 'addproperty' && !empty($module) && !empty($tabobj)) } // Edit sql with new properties - if (! $error) + if (!$error) { - $result=rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object); + $result = rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object); if ($result <= 0) { $error++; } } - if (! $error) + if (!$error) { setEventMessages($langs->trans('FilesForObjectUpdated', $objectname), null); clearstatcache(true); // Make a redirect to reload all data - header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=objects&module='.$module.($forceddirread?'@'.$dirread:'').'&tabobj='.$objectname.'&nocache='.time()); + header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=objects&module='.$module.($forceddirread ? '@'.$dirread : '').'&tabobj='.$objectname.'&nocache='.time()); exit; } @@ -1173,7 +1173,7 @@ if ($dirins && $action == 'confirm_deleteproperty' && $propertykey) clearstatcache(true); // Make a redirect to reload all data - header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=objects&module='.$module.($forceddirread?'@'.$dirread:'').'&tabobj='.$objectname); + header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=objects&module='.$module.($forceddirread ? '@'.$dirread : '').'&tabobj='.$objectname); exit; } @@ -1250,10 +1250,10 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) ); $resultko = 0; - foreach($filetodelete as $filetodelete) + foreach ($filetodelete as $filetodelete) { $resulttmp = dol_delete_file($dir.'/'.$filetodelete, 0, 0, 1); - if (! $resulttmp) $resultko++; + if (!$resulttmp) $resultko++; } if ($resultko == 0) @@ -1407,24 +1407,24 @@ if ($action == 'savefile' && empty($cancel)) // Enable module if ($action == 'set' && $user->admin) { - $param=''; - if ($module) $param.='&module='.urlencode($module); - if ($tab) $param.='&tab='.urlencode($tab); - if ($tabobj) $param.='&tabobj='.urlencode($tabobj); + $param = ''; + if ($module) $param .= '&module='.urlencode($module); + if ($tab) $param .= '&tab='.urlencode($tab); + if ($tabobj) $param .= '&tabobj='.urlencode($tabobj); $value = GETPOST('value', 'alpha'); $resarray = activateModule($value); - if (! empty($resarray['errors'])) setEventMessages('', $resarray['errors'], 'errors'); + if (!empty($resarray['errors'])) setEventMessages('', $resarray['errors'], 'errors'); else { //var_dump($resarray);exit; if ($resarray['nbperms'] > 0) { - $tmpsql="SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."user WHERE admin <> 1"; - $resqltmp=$db->query($tmpsql); + $tmpsql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."user WHERE admin <> 1"; + $resqltmp = $db->query($tmpsql); if ($resqltmp) { - $obj=$db->fetch_object($resqltmp); + $obj = $db->fetch_object($resqltmp); //var_dump($obj->nb);exit; if ($obj && $obj->nb > 1) { @@ -1442,13 +1442,13 @@ if ($action == 'set' && $user->admin) // Disable module if ($action == 'reset' && $user->admin) { - $param=''; - if ($module) $param.='&module='.urlencode($module); - if ($tab) $param.='&tab='.urlencode($tab); - if ($tabobj) $param.='&tabobj='.urlencode($tabobj); + $param = ''; + if ($module) $param .= '&module='.urlencode($module); + if ($tab) $param .= '&tab='.urlencode($tab); + if ($tabobj) $param .= '&tabobj='.urlencode($tabobj); $value = GETPOST('value', 'alpha'); - $result=unActivateModule($value); + $result = unActivateModule($value); if ($result) setEventMessages($result, null, 'errors'); header("Location: ".$_SERVER["PHP_SELF"]."?".$param); exit; @@ -1479,27 +1479,27 @@ llxHeader('', $langs->trans("ModuleBuilder"), '', '', 0, 0, ), array()); -$text=$langs->trans("ModuleBuilder"); +$text = $langs->trans("ModuleBuilder"); print load_fiche_titre($text, '', 'title_setup'); print ''.$langs->trans("ModuleBuilderDesc", 'https://wiki.dolibarr.org/index.php/Module_development#Create_your_module').'
'; -$dirsrootforscan=array($dirread); +$dirsrootforscan = array($dirread); // Add also the core modules into the list of modules to show/edit -if ($dirread != DOL_DOCUMENT_ROOT && ($conf->global->MAIN_FEATURES_LEVEL >=2 || ! empty($conf->global->MODULEBUILDER_ADD_DOCUMENT_ROOT))) { $dirsrootforscan[]=DOL_DOCUMENT_ROOT; } +if ($dirread != DOL_DOCUMENT_ROOT && ($conf->global->MAIN_FEATURES_LEVEL >= 2 || !empty($conf->global->MODULEBUILDER_ADD_DOCUMENT_ROOT))) { $dirsrootforscan[] = DOL_DOCUMENT_ROOT; } // Search modules to edit print ''."\n"; -$listofmodules=array(); -$i=0; -foreach($dirsrootforscan as $dirread) +$listofmodules = array(); +$i = 0; +foreach ($dirsrootforscan as $dirread) { - $dirsincustom=dol_dir_list($dirread, 'directories'); + $dirsincustom = dol_dir_list($dirread, 'directories'); if (is_array($dirsincustom) && count($dirsincustom) > 0) { foreach ($dirsincustom as $dircustomcursor) { $fullname = $dircustomcursor['fullname']; - if (dol_is_file($fullname . '/' . $FILEFLAG)) + if (dol_is_file($fullname.'/'.$FILEFLAG)) { // Get real name of module (MyModule instead of mymodule) $dirtoscanrel = basename($fullname).'/core/modules/'; @@ -1546,8 +1546,8 @@ foreach($dirsrootforscan as $dirread) } // Show description of content - $newdircustom=$dirins; - if (empty($newdircustom)) $newdircustom=img_warning(); + $newdircustom = $dirins; + if (empty($newdircustom)) $newdircustom = img_warning(); // If dirread was forced to somewhere else, by using URL // htdocs/modulebuilder/index.php?module=Inventory@/home/ldestailleur/git/dolibarr/htdocs/product if (empty($i)) print $langs->trans("DirScanned").' : '; @@ -1558,27 +1558,27 @@ foreach($dirsrootforscan as $dirread) print '
'; //var_dump($listofmodules); -$message=''; -if (! $dirins) +$message = ''; +if (!$dirins) { - $message=info_admin($langs->trans("ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.'/custom', DOL_DOCUMENT_ROOT)); - $allowfromweb=-1; + $message = info_admin($langs->trans("ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.'/custom', DOL_DOCUMENT_ROOT)); + $allowfromweb = -1; } else { if ($dirins_ok) { - if (! is_writable(dol_osencode($dirins))) + if (!is_writable(dol_osencode($dirins))) { $langs->load("errors"); - $message=info_admin($langs->trans("ErrorFailedToWriteInDir", $dirins)); - $allowfromweb=0; + $message = info_admin($langs->trans("ErrorFailedToWriteInDir", $dirins)); + $allowfromweb = 0; } } else { - $message=info_admin($langs->trans("NotExistsDirect", $dirins).$langs->trans("InfDirAlt").$langs->trans("InfDirExample")); - $allowfromweb=0; + $message = info_admin($langs->trans("NotExistsDirect", $dirins).$langs->trans("InfDirAlt").$langs->trans("InfDirExample")); + $allowfromweb = 0; } } if ($message) @@ -1664,7 +1664,7 @@ if ($module == 'initmodule') print '
'; - print '
'; + print '
'; print ''; } elseif ($module == 'deletemodule') @@ -1678,121 +1678,121 @@ elseif ($module == 'deletemodule') print $langs->trans("EnterNameOfModuleToDeleteDesc").'

'; print ''; - print ''; + print ''; print ''; } -elseif (! empty($module)) +elseif (!empty($module)) { // Tabs for module - if (! $error) + if (!$error) { $dirread = $listofmodules[strtolower($module)]['moduledescriptorrootpath']; $head2 = array(); - $h=0; + $h = 0; - $modulelowercase=strtolower($module); + $modulelowercase = strtolower($module); $const_name = 'MAIN_MODULE_'.strtoupper($module); - $param=''; - if ($tab) $param.='&tab='.urlencode($tab); - if ($module) $param.='&module='.urlencode($module); - if ($tabobj) $param.='&tabobj='.urlencode($tabobj); + $param = ''; + if ($tab) $param .= '&tab='.urlencode($tab); + if ($module) $param .= '&module='.urlencode($module); + if ($tabobj) $param .= '&tabobj='.urlencode($tabobj); - $urltomodulesetup=''.$langs->trans('Home').'-'.$langs->trans("Setup").'-'.$langs->trans("Modules").''; - $linktoenabledisable=''; - if (! empty($conf->global->$const_name)) // If module is already activated + $urltomodulesetup = ''.$langs->trans('Home').'-'.$langs->trans("Setup").'-'.$langs->trans("Modules").''; + $linktoenabledisable = ''; + if (!empty($conf->global->$const_name)) // If module is already activated { - $linktoenabledisable.=''; - $linktoenabledisable.=img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', '', 1); - $linktoenabledisable.=''; + $linktoenabledisable .= ''; + $linktoenabledisable .= img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', '', 1); + $linktoenabledisable .= ''; } else { - $linktoenabledisable.=''; - $linktoenabledisable.=img_picto($langs->trans("Disabled"), 'switch_off', '', false, 0, 0, '', '', 1); - $linktoenabledisable.="\n"; + $linktoenabledisable .= ''; + $linktoenabledisable .= img_picto($langs->trans("Disabled"), 'switch_off', '', false, 0, 0, '', '', 1); + $linktoenabledisable .= "\n"; } if (empty($conf->$modulelowercase->enabled)) { - $modulestatusinfo=$form->textwithpicto($langs->trans("ModuleIsNotActive", $urltomodulesetup), '', -1, 'help'); + $modulestatusinfo = $form->textwithpicto($langs->trans("ModuleIsNotActive", $urltomodulesetup), '', -1, 'help'); } else { - $modulestatusinfo=$form->textwithpicto($langs->trans("ModuleIsLive"), $langs->trans("Warning"), -1, 'warning'); + $modulestatusinfo = $form->textwithpicto($langs->trans("ModuleIsLive"), $langs->trans("Warning"), -1, 'warning'); } - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=description&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=description&module='.$module.($forceddirread ? '@'.$dirread : ''); $head2[$h][1] = $langs->trans("Description"); $head2[$h][2] = 'description'; $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=languages&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=languages&module='.$module.($forceddirread ? '@'.$dirread : ''); $head2[$h][1] = $langs->trans("Languages"); $head2[$h][2] = 'languages'; $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=dictionaries&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=dictionaries&module='.$module.($forceddirread ? '@'.$dirread : ''); $head2[$h][1] = $langs->trans("Dictionaries"); $head2[$h][2] = 'dictionaries'; $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread ? '@'.$dirread : ''); $head2[$h][1] = $langs->trans("Objects"); $head2[$h][2] = 'objects'; $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=menus&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=menus&module='.$module.($forceddirread ? '@'.$dirread : ''); $head2[$h][1] = $langs->trans("Menus"); $head2[$h][2] = 'menus'; $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=permissions&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=permissions&module='.$module.($forceddirread ? '@'.$dirread : ''); $head2[$h][1] = $langs->trans("Permissions"); $head2[$h][2] = 'permissions'; $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=hooks&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=hooks&module='.$module.($forceddirread ? '@'.$dirread : ''); $head2[$h][1] = $langs->trans("Hooks"); $head2[$h][2] = 'hooks'; $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=triggers&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=triggers&module='.$module.($forceddirread ? '@'.$dirread : ''); $head2[$h][1] = $langs->trans("Triggers"); $head2[$h][2] = 'triggers'; $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=widgets&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=widgets&module='.$module.($forceddirread ? '@'.$dirread : ''); $head2[$h][1] = $langs->trans("Widgets"); $head2[$h][2] = 'widgets'; $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=css&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=css&module='.$module.($forceddirread ? '@'.$dirread : ''); $head2[$h][1] = $langs->trans("CSS"); $head2[$h][2] = 'css'; $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=js&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=js&module='.$module.($forceddirread ? '@'.$dirread : ''); $head2[$h][1] = $langs->trans("JS"); $head2[$h][2] = 'js'; $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=cli&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=cli&module='.$module.($forceddirread ? '@'.$dirread : ''); $head2[$h][1] = $langs->trans("CLI"); $head2[$h][2] = 'cli'; $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=cron&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=cron&module='.$module.($forceddirread ? '@'.$dirread : ''); $head2[$h][1] = $langs->trans("CronList"); $head2[$h][2] = 'cron'; $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=specifications&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=specifications&module='.$module.($forceddirread ? '@'.$dirread : ''); $head2[$h][1] = $langs->trans("Documentation"); $head2[$h][2] = 'specifications'; $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=buildpackage&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=buildpackage&module='.$module.($forceddirread ? '@'.$dirread : ''); $head2[$h][1] = $langs->trans("BuildPackage"); $head2[$h][2] = 'buildpackage'; $h++; @@ -1826,15 +1826,15 @@ elseif (! empty($module)) print ''; print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; - print ''.img_picto($langs->trans("Edit"), 'edit').''; + print ''.img_picto($langs->trans("Edit"), 'edit').''; print ''; print ' '.$langs->trans("ReadmeFile").' : '.$pathtofilereadme.''; - print ''.img_picto($langs->trans("Edit"), 'edit').''; + print ''.img_picto($langs->trans("Edit"), 'edit').''; print ''; print ' '.$langs->trans("ChangeLog").' : '.$pathtochangelog.''; - print ''.img_picto($langs->trans("Edit"), 'edit').''; + print ''.img_picto($langs->trans("Edit"), 'edit').''; print ''; print ''; @@ -1906,7 +1906,7 @@ elseif (! empty($module)) print $langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module).'
'; } - if (! empty($moduleobj)) + if (!empty($moduleobj)) { print '

'; @@ -1995,8 +1995,8 @@ elseif (! empty($module)) { $pathtofile = $modulelowercase.'/langs/'.$langfile['relativename']; print ' '.$langs->trans("LanguageFile").' '.basename(dirname($pathtofile)).' : '.$pathtofile.''; - print ''.img_picto($langs->trans("Edit"), 'edit').''; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Edit"), 'edit').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; print ''; } print ''; @@ -2041,16 +2041,16 @@ elseif (! empty($module)) if ($action != 'editfile' || empty($file)) { print ''; - $htmlhelp=$langs->trans("DictionariesDefDescTooltip", ''.$langs->trans('Setup').' - '.$langs->trans('Dictionaries').''); + $htmlhelp = $langs->trans("DictionariesDefDescTooltip", ''.$langs->trans('Setup').' - '.$langs->trans('Dictionaries').''); print $form->textwithpicto($langs->trans("DictionariesDefDesc"), $htmlhelp, 1, 'help', '', 0, 2, 'helpondesc').'
'; print '
'; print '
'; print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print ' '.$langs->trans("LanguageFile").' : '; - if (! is_array($dicts) || empty($dicts)) print ''.$langs->trans("NoDictionaries").''; + if (!is_array($dicts) || empty($dicts)) print ''.$langs->trans("NoDictionaries").''; else print ''.$dicts['langs'].''; print '
'; @@ -2143,7 +2143,7 @@ elseif (! empty($module)) } else { - $fullpathoffile=dol_buildpath($file, 0); + $fullpathoffile = dol_buildpath($file, 0); $content = file_get_contents($fullpathoffile); @@ -2155,8 +2155,8 @@ elseif (! empty($module)) print ''; print ''; - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09')?GETPOST('format', 'aZ09'):'html')); + $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ?GETPOST('format', 'aZ09') : 'html')); print '
'; print '
'; print ''; @@ -2171,12 +2171,12 @@ elseif (! empty($module)) if ($tab == 'objects') { $head3 = array(); - $h=0; + $h = 0; // Dir for module $dir = $dirread.'/'.$modulelowercase.'/class'; - $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:'').'&tabobj=newobject'; + $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread ? '@'.$dirread : '').'&tabobj=newobject'; $head3[$h][1] = ''.$langs->trans("NewObjectInModulebuilder").''; $head3[$h][2] = 'newobject'; $h++; @@ -2229,10 +2229,10 @@ elseif (! empty($module)) print ''.$langs->trans("EnterNameOfObjectDesc").'

'; - print '
'; + print '
'; print ' '.$form->textwithpicto($langs->trans("IncludeRefGeneration"), $langs->trans("IncludeRefGenerationHelp")).'
'; print ' '.$form->textwithpicto($langs->trans("IncludeDocGeneration"), $langs->trans("IncludeDocGenerationHelp")).'
'; - print ''; + print ''; print '
'; print '
'; print '
'; @@ -2322,15 +2322,15 @@ elseif (! empty($module)) } print '
'; - print ' '.$langs->trans("ClassFile").' : '.($realpathtoclass?'':'').$pathtoclass.($realpathtoclass?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.$langs->trans("ClassFile").' : '.($realpathtoclass ? '' : '').$pathtoclass.($realpathtoclass ? '' : '').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; - print ' '.$langs->trans("ApiClassFile").' : '.($realpathtoapi?'':'').$pathtoapi.($realpathtoapi?'':'').''; + print ' '.$langs->trans("ApiClassFile").' : '.($realpathtoapi ? '' : '').$pathtoapi.($realpathtoapi ? '' : '').''; if ($realpathtoapi) { - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print ' '; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; print '   '; if (empty($conf->global->$const_name)) // If module is not activated { @@ -2344,67 +2344,67 @@ elseif (! empty($module)) else { //print ''.$langs->trans("FileNotYetGenerated").' '; - print ''; + print ''; } // PHPUnit print '
'; - print ' '.$langs->trans("TestClassFile").' : '.($realpathtophpunit?'':'').$pathtophpunit.($realpathtophpunit?'':'').''; + print ' '.$langs->trans("TestClassFile").' : '.($realpathtophpunit ? '' : '').$pathtophpunit.($realpathtophpunit ? '' : '').''; if ($realpathtophpunit) { - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print ' '; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; } else { //print ''.$langs->trans("FileNotYetGenerated").' '; - print ''; + print ''; } print '
'; print '
'; - print ' '.$langs->trans("PageForLib").' : '.($realpathtolib?'':'').$pathtolib.($realpathtolib?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.$langs->trans("PageForLib").' : '.($realpathtolib ? '' : '').$pathtolib.($realpathtolib ? '' : '').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; - print ' '.$langs->trans("PageForObjLib").' : '.($realpathtoobjlib?'':'').$pathtoobjlib.($realpathtoobjlib?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.$langs->trans("PageForObjLib").' : '.($realpathtoobjlib ? '' : '').$pathtoobjlib.($realpathtoobjlib ? '' : '').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; - print ' '.$langs->trans("Image").' : '.($realpathtopicto?'':'').$pathtopicto.($realpathtopicto?'':'').''; + print ' '.$langs->trans("Image").' : '.($realpathtopicto ? '' : '').$pathtopicto.($realpathtopicto ? '' : '').''; //print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print '
'; - print ' '.$langs->trans("SqlFile").' : '.($realpathtosql?'':'').$pathtosql.($realpathtosql?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '   '.$langs->trans("DropTableIfEmpty").''; + print ' '.$langs->trans("SqlFile").' : '.($realpathtosql ? '' : '').$pathtosql.($realpathtosql ? '' : '').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '   '.$langs->trans("DropTableIfEmpty").''; //print '   '.$langs->trans("RunSql").''; print '
'; - print ' '.$langs->trans("SqlFileKey").' : '.($realpathtosqlkey?'':'').$pathtosqlkey.($realpathtosqlkey?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.$langs->trans("SqlFileKey").' : '.($realpathtosqlkey ? '' : '').$pathtosqlkey.($realpathtosqlkey ? '' : '').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; //print '   '.$langs->trans("RunSql").''; print '
'; - print ' '.$langs->trans("SqlFileExtraFields").' : '.($realpathtosqlextra?'':'').$pathtosqlextra.($realpathtosqlextra?'':'').''; + print ' '.$langs->trans("SqlFileExtraFields").' : '.($realpathtosqlextra ? '' : '').$pathtosqlextra.($realpathtosqlextra ? '' : '').''; if ($realpathtosqlextra) { - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print ' '; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; print '   '; - print ''.$langs->trans("DropTableIfEmpty").''; + print ''.$langs->trans("DropTableIfEmpty").''; } else { - print ''; + print ''; } //print '   '.$langs->trans("RunSql").''; print '
'; - print ' '.$langs->trans("SqlFileKeyExtraFields").' : '.($realpathtosqlextrakey?'':'').$pathtosqlextrakey.($realpathtosqlextrakey?'':'').''; + print ' '.$langs->trans("SqlFileKeyExtraFields").' : '.($realpathtosqlextrakey ? '' : '').$pathtosqlextrakey.($realpathtosqlextrakey ? '' : '').''; if ($realpathtosqlextrakey) { - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print ' '; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; } //print '   '.$langs->trans("RunSql").''; print '
'; @@ -2416,34 +2416,34 @@ elseif (! empty($module)) $urlofcard = dol_buildpath($pathtocard, 1); print '
'; - print ' '.$langs->trans("PageForList").' : '.($realpathtolist?'':'').$pathtolist.($realpathtolist?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.$langs->trans("PageForList").' : '.($realpathtolist ? '' : '').$pathtolist.($realpathtolist ? '' : '').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; - print ' '.$langs->trans("PageForCreateEditView").' : '.($realpathtocard?'':'').$pathtocard.($realpathtocard?'':'').'?action=create'; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.$langs->trans("PageForCreateEditView").' : '.($realpathtocard ? '' : '').$pathtocard.($realpathtocard ? '' : '').'?action=create'; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; - print ' '.$langs->trans("PageForAgendaTab").' : '.($realpathtoagenda?'':'').$pathtoagenda.($realpathtoagenda?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.$langs->trans("PageForAgendaTab").' : '.($realpathtoagenda ? '' : '').$pathtoagenda.($realpathtoagenda ? '' : '').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; if ($realpathtoagenda) { print ' '; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; } print '
'; - print ' '.$langs->trans("PageForDocumentTab").' : '.($realpathtodocument?'':'').$pathtodocument.($realpathtodocument?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.$langs->trans("PageForDocumentTab").' : '.($realpathtodocument ? '' : '').$pathtodocument.($realpathtodocument ? '' : '').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; if ($realpathtodocument) { print ' '; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; } print '
'; - print ' '.$langs->trans("PageForNoteTab").' : '.($realpathtonote?'':'').$pathtonote.($realpathtonote?'':'').''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.$langs->trans("PageForNoteTab").' : '.($realpathtonote ? '' : '').$pathtonote.($realpathtonote ? '' : '').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; if ($realpathtonote) { print ' '; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; } print '
'; @@ -2579,25 +2579,25 @@ elseif (! empty($module)) if (in_array($propname, array('fk_element', 'lines'))) continue; }*/ - $propname=$propkey; - $proplabel=$propval['label']; - $proptype=$propval['type']; - $proparrayofkeyval=$propval['arrayofkeyval']; - $propnotnull=$propval['notnull']; - $propdefault=$propval['default']; - $propindex=$propval['index']; - $propforeignkey=$propval['foreignkey']; - $propposition=$propval['position']; - $propenabled=$propval['enabled']; - $propvisible=$propval['visible']; - $propnoteditable=$propval['noteditable']; - $propsearchall=$propval['searchall']; - $propisameasure=$propval['isameasure']; - $propcss=$propval['css']; - $prophelp=$propval['help']; - $propshowoncombobox=$propval['showoncombobox']; + $propname = $propkey; + $proplabel = $propval['label']; + $proptype = $propval['type']; + $proparrayofkeyval = $propval['arrayofkeyval']; + $propnotnull = $propval['notnull']; + $propdefault = $propval['default']; + $propindex = $propval['index']; + $propforeignkey = $propval['foreignkey']; + $propposition = $propval['position']; + $propenabled = $propval['enabled']; + $propvisible = $propval['visible']; + $propnoteditable = $propval['noteditable']; + $propsearchall = $propval['searchall']; + $propisameasure = $propval['isameasure']; + $propcss = $propval['css']; + $prophelp = $propval['help']; + $propshowoncombobox = $propval['showoncombobox']; //$propdisabled=$propval['disabled']; - $propcomment=$propval['comment']; + $propcomment = $propval['comment']; print ''; @@ -2622,37 +2622,37 @@ elseif (! empty($module)) print $propdefault; print ''; print ''; - print $propindex?'1':''; + print $propindex ? '1' : ''; print ''; print ''; - print $propforeignkey?$propforeignkey:''; + print $propforeignkey ? $propforeignkey : ''; print ''; print ''; print $propposition; print ''; print ''; - print $propenabled?$propenabled:''; + print $propenabled ? $propenabled : ''; print ''; print ''; - print $propvisible?$propvisible:''; + print $propvisible ? $propvisible : ''; print ''; print ''; - print $propnoteditable?$propnoteditable:''; + print $propnoteditable ? $propnoteditable : ''; print ''; print ''; - print $propsearchall?'1':''; + print $propsearchall ? '1' : ''; print ''; print ''; - print $propisameasure?$propisameasure:''; + print $propisameasure ? $propisameasure : ''; print ''; print ''; - print $propcss?$propcss:''; + print $propcss ? $propcss : ''; print ''; print ''; - print $prophelp?$prophelp:''; + print $prophelp ? $prophelp : ''; print ''; print ''; - print $propshowoncombobox?$propshowoncombobox:''; + print $propshowoncombobox ? $propshowoncombobox : ''; print ''; /*print ''; print $propdisabled?$propdisabled:''; @@ -2687,7 +2687,7 @@ elseif (! empty($module)) $format = 'asciidoc'; if (preg_match('/\.md$/i', $spec['name'])) $format = 'markdown'; print ' '.$langs->trans("SpecificationFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; } } @@ -2785,13 +2785,13 @@ elseif (! empty($module)) if ($action != 'editfile' || empty($file)) { print ''; - $htmlhelp=$langs->trans("MenusDefDescTooltip", ''.$langs->trans('Setup').' - '.$langs->trans('Menus').''); + $htmlhelp = $langs->trans("MenusDefDescTooltip", ''.$langs->trans('Setup').' - '.$langs->trans('Menus').''); print $form->textwithpicto($langs->trans("MenusDefDesc"), $htmlhelp, 1, 'help', '', 0, 2, 'helpondesc').'
'; print '
'; print '
'; print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print '
'; @@ -2925,13 +2925,13 @@ elseif (! empty($module)) if ($action != 'editfile' || empty($file)) { print ''; - $htmlhelp=$langs->trans("PermissionsDefDescTooltip", ''.$langs->trans('DefaultPermissions').''); + $htmlhelp = $langs->trans("PermissionsDefDescTooltip", ''.$langs->trans('DefaultPermissions').''); print $form->textwithpicto($langs->trans("PermissionsDefDesc"), $htmlhelp, 1, 'help', '', 0, 2, 'helpondesc').'
'; print '
'; print '
'; print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print '
'; @@ -3028,7 +3028,7 @@ elseif (! empty($module)) $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; print ''; - print ''.img_picto($langs->trans("Edit"), 'edit').''; + print ''.img_picto($langs->trans("Edit"), 'edit').''; print ''; print ''; @@ -3037,13 +3037,13 @@ elseif (! empty($module)) if (dol_is_file($dirins.'/'.$pathtohook)) { print ''.$pathtohook.''; - print ''.img_picto($langs->trans("Edit"), 'edit').''; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Edit"), 'edit').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; } else { print ''.$langs->trans("FileNotYetGenerated").''; - print ''; + print ''; } print ''; } @@ -3095,8 +3095,8 @@ elseif (! empty($module)) print ''; print ' '.$langs->trans("TriggersFile").' : '.$pathtofile.''; - print ''.img_picto($langs->trans("Edit"), 'edit').''; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Edit"), 'edit').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; print ''; } } @@ -3104,7 +3104,7 @@ elseif (! empty($module)) { print ''; print ' '.$langs->trans("NoTrigger"); - print ''; + print ''; print ''; } print ''; @@ -3151,19 +3151,19 @@ elseif (! empty($module)) if (dol_is_file($dirins.'/'.$pathtohook)) { print ''.$pathtohook.''; - print ''.img_picto($langs->trans("Edit"), 'edit').''; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Edit"), 'edit').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; } else { print ''.$langs->trans("FileNotYetGenerated").''; - print ''; + print ''; } print ''; } else { - $fullpathoffile=dol_buildpath($file, 0); + $fullpathoffile = dol_buildpath($file, 0); $content = file_get_contents($fullpathoffile); @@ -3175,8 +3175,8 @@ elseif (! empty($module)) print ''; print ''; - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09')?GETPOST('format', 'aZ09'):'html')); + $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ?GETPOST('format', 'aZ09') : 'html')); print '
'; print '
'; print ''; @@ -3203,19 +3203,19 @@ elseif (! empty($module)) if (dol_is_file($dirins.'/'.$pathtohook)) { print ''.$pathtohook.''; - print ''.img_picto($langs->trans("Edit"), 'edit').''; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Edit"), 'edit').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; } else { print ''.$langs->trans("FileNotYetGenerated").''; - print ''; + print ''; } print ''; } else { - $fullpathoffile=dol_buildpath($file, 0); + $fullpathoffile = dol_buildpath($file, 0); $content = file_get_contents($fullpathoffile); @@ -3227,8 +3227,8 @@ elseif (! empty($module)) print ''; print ''; - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09')?GETPOST('format', 'aZ09'):'html')); + $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ?GETPOST('format', 'aZ09') : 'html')); print '
'; print '
'; print ''; @@ -3259,15 +3259,15 @@ elseif (! empty($module)) $pathtofile = $widget['relpath']; print ' '.$langs->trans("WidgetFile").' : '.$pathtofile.''; - print ''.img_picto($langs->trans("Edit"), 'edit').''; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Edit"), 'edit').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; print ''; } } else { print ' '.$langs->trans("NoWidget"); - print ''; + print ''; print ''; } print ''; @@ -3345,15 +3345,15 @@ elseif (! empty($module)) $pathtofile = $clifile['relpath']; print ' '.$langs->trans("CLIFile").' : '.$pathtofile.''; - print ''.img_picto($langs->trans("Edit"), 'edit').''; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Edit"), 'edit').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; print ''; } } else { print ' '.$langs->trans("NoCLIFile"); - print ''; + print ''; print ''; } print ''; @@ -3397,7 +3397,7 @@ elseif (! empty($module)) print '
'; print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print '
'; @@ -3526,8 +3526,8 @@ elseif (! empty($module)) if (preg_match('/\.md$/i', $spec['name'])) $format = 'markdown'; print ''; print ' '.$langs->trans("SpecificationFile").' : '.$pathtofile.''; - print ''.img_picto($langs->trans("Edit"), 'edit').''; - print ''.img_picto($langs->trans("Delete"), 'delete').''; + print ''.img_picto($langs->trans("Edit"), 'edit').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; print ''; } } @@ -3535,7 +3535,7 @@ elseif (! empty($module)) { print ''; print ' '.$langs->trans("FileNotYetGenerated"); - print ''; + print ''; print ''; } print ''; @@ -3613,7 +3613,7 @@ elseif (! empty($module)) print ''; print ''; print ''; print ''; } @@ -3623,28 +3623,28 @@ elseif (! empty($module)) print ''.$langs->trans("BuildPackageDesc").''; print '
'; - if (! class_exists('ZipArchive') && ! defined('ODTPHP_PATHTOPCLZIP')) + if (!class_exists('ZipArchive') && !defined('ODTPHP_PATHTOPCLZIP')) { print img_warning().' '.$langs->trans("ErrNoZipEngine"); print '
'; } - $modulelowercase=strtolower($module); + $modulelowercase = strtolower($module); // Zip file to build - $FILENAMEZIP=''; + $FILENAMEZIP = ''; // Load module $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; dol_include_once($pathtofile); - $class='mod'.$module; + $class = 'mod'.$module; if (class_exists($class)) { try { $moduleobj = new $class($db); } - catch(Exception $e) + catch (Exception $e) { $error++; dol_print_error($e->getMessage()); diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 596e47e12c0..0845d5ecaf2 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -237,13 +237,13 @@ class MyObject extends CommonObject // Translate some data of arrayofkeyval if (is_object($langs)) { - foreach($this->fields as $key => $val) + foreach ($this->fields as $key => $val) { if (is_array($val['arrayofkeyval'])) { - foreach($val['arrayofkeyval'] as $key2 => $val2) + foreach ($val['arrayofkeyval'] as $key2 => $val2) { - $this->fields[$key]['arrayofkeyval'][$key2]=$langs->trans($val2); + $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); } } } @@ -733,7 +733,7 @@ class MyObject extends CommonObject $label .= '
'; $label .= ''.$langs->trans('Ref').': '.$this->ref; if (isset($this->status)) { - $label.= '
' . $langs->trans("Status").": ".$this->getLibStatut(5); + $label .= '
'.$langs->trans("Status").": ".$this->getLibStatut(5); } $url = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.$this->id; diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 46f347618f4..f7f2252ba3c 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -142,14 +142,14 @@ foreach($object->fields as $key => $val) // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) { $arrayfields["ef.".$key] = array( 'label'=>$extrafields->attributes[$object->table_element]['label'][$key], - 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), + 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], - 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key]) + 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]) ); } } @@ -429,7 +429,7 @@ foreach ($object->fields as $key => $val) elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } - elseif (! preg_match('/^(date|timestamp)/', $val['type'])) print ''; + elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; print ''; } } diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index d3845ed412b..01f23cb1cf3 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -965,7 +965,7 @@ class Mo extends CommonObject $label .= '
'; $label .= ''.$langs->trans('Ref').': '.$this->ref; if (isset($this->status)) { - $label.= '
' . $langs->trans("Status").": ".$this->getLibStatut(5); + $label .= '
'.$langs->trans("Status").": ".$this->getLibStatut(5); } $url = dol_buildpath('/mrp/mo_card.php', 1).'?id='.$this->id; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 5eb8ab904cc..17a1e4952ce 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -844,10 +844,10 @@ class Product extends CommonObject $this->height_units = trim($this->height_units); // set unit not defined if (is_numeric($this->length_units)) { - $this->width_units = $this->length_units; // Not used yet + $this->width_units = $this->length_units; // Not used yet } if (is_numeric($this->length_units)) { - $this->height_units = $this->length_units; // Not used yet + $this->height_units = $this->length_units; // Not used yet } // Automated compute surface and volume if not filled if (empty($this->surface) && !empty($this->length) && !empty($this->width) && $this->length_units == $this->width_units) { @@ -1882,7 +1882,7 @@ class Product extends CommonObject $newminprice = 0; } if (empty($newminprice)) { - $newminprice=0; + $newminprice = 0; } // Check parameters @@ -4348,8 +4348,8 @@ class Product extends CommonObject $label .= '
'.$langs->trans('ProductAccountancyBuyCode').': '.length_accountg($this->accountancy_code_buy); } if (isset($this->status) && isset($this->status_buy)) { - $label.= '
' . $langs->trans("Status").": ".$this->getLibStatut(5, 0); - $label.= ' '.$this->getLibStatut(5, 1); + $label .= '
'.$langs->trans("Status").": ".$this->getLibStatut(5, 0); + $label .= ' '.$this->getLibStatut(5, 1); } if (!empty($this->entity)) { @@ -4801,7 +4801,7 @@ class Product extends CommonObject } if (!empty($conf->fournisseur->enabled) && !empty($conf->reception->enabled)) { - $result = $this->load_stats_reception(0, '4', 1); // Use same tables than when module reception is not used. + $result = $this->load_stats_reception(0, '4', 1); // Use same tables than when module reception is not used. if ($result < 0) dol_print_error($this->db, $this->error); $stock_reception_fournisseur = $this->stats_reception['qty']; } diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 836861f6131..df65a79f14b 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -191,7 +191,7 @@ $arrayfields = array( 'p.tva_tx'=>array('label'=>$langs->trans("VATRate"), 'checked'=>0, 'enabled'=>(!empty($user->rights->fournisseur->lire)), 'position'=>43), 'p.pmp'=>array('label'=>$langs->trans("PMPValueShort"), 'checked'=>0, 'enabled'=>(!empty($user->rights->fournisseur->lire)), 'position'=>44), 'p.seuil_stock_alerte'=>array('label'=>$langs->trans("StockLimit"), 'checked'=>0, 'enabled'=>(!empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service'), 'position'=>50), - 'p.desiredstock'=>array('label'=>$langs->trans("DesiredStock"), 'checked'=>1, 'enabled'=>(!empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service'),'position'=>51), + 'p.desiredstock'=>array('label'=>$langs->trans("DesiredStock"), 'checked'=>1, 'enabled'=>(!empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service'), 'position'=>51), 'p.stock'=>array('label'=>$langs->trans("PhysicalStock"), 'checked'=>1, 'enabled'=>(!empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service'), 'position'=>52), 'stock_virtual'=>array('label'=>$langs->trans("VirtualStock"), 'checked'=>1, 'enabled'=>(!empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service' && $virtualdiffersfromphysical), 'position'=>53), 'p.tobatch'=>array('label'=>$langs->trans("ManageLotSerial"), 'checked'=>0, 'enabled'=>(!empty($conf->productbatch->enabled)), 'position'=>60), @@ -321,7 +321,7 @@ if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_combination pac ON pac.fk_product_child = p.rowid"; } -if (!empty($conf->global->PRODUCT_USE_UNITS)) $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_units cu ON cu.rowid = p.fk_unit"; +if (!empty($conf->global->PRODUCT_USE_UNITS)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_units cu ON cu.rowid = p.fk_unit"; $sql .= ' WHERE p.entity IN ('.getEntity('product').')'; @@ -488,11 +488,11 @@ if ($resql) //'builddoc'=>$langs->trans("PDFMerge"), //'presend'=>$langs->trans("SendByMail"), ); - $rightskey='produit'; - if ($type == Product::TYPE_SERVICE) $rightskey='service'; + $rightskey = 'produit'; + if ($type == Product::TYPE_SERVICE) $rightskey = 'service'; if ($user->rights->{$rightskey}->supprimer) $arrayofmassactions['predelete'] = "".$langs->trans("Delete"); - if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $newcardbutton = ''; if ($type === "") $perm = ($user->rights->produit->creer || $user->rights->service->creer); diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index b63a891973c..e07dcf0536d 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -38,20 +38,20 @@ require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; $langs->loadLangs(array('products', 'stocks', 'productbatch')); // Security check -if ($user->socid) $socid=$user->socid; -$result=restrictedArea($user, 'produit|service'); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'produit|service'); -$action=GETPOST('action', 'alpha'); -$sref=GETPOST("sref", 'alpha'); -$snom=GETPOST("snom", 'alpha'); -$sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$type=GETPOST("type", "int"); -$search_barcode=GETPOST("search_barcode", 'alpha'); -$search_warehouse=GETPOST('search_warehouse', 'alpha'); -$search_batch=GETPOST('search_batch', 'alpha'); -$catid=GETPOST('catid', 'int'); -$toolowstock=GETPOST('toolowstock'); +$action = GETPOST('action', 'alpha'); +$sref = GETPOST("sref", 'alpha'); +$snom = GETPOST("snom", 'alpha'); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$type = GETPOST("type", "int"); +$search_barcode = GETPOST("search_barcode", 'alpha'); +$search_warehouse = GETPOST('search_warehouse', 'alpha'); +$search_batch = GETPOST('search_batch', 'alpha'); +$catid = GETPOST('catid', 'int'); +$toolowstock = GETPOST('toolowstock'); $tosell = GETPOST("tosell"); $tobuy = GETPOST("tobuy"); $fourn_id = GETPOST("fourn_id", 'int'); @@ -60,20 +60,20 @@ $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); if (empty($page) || $page < 0) $page = 0; -if (! $sortfield) $sortfield="p.ref"; -if (! $sortorder) $sortorder="ASC"; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +if (!$sortfield) $sortfield = "p.ref"; +if (!$sortorder) $sortorder = "ASC"; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $limit * $page ; +$offset = $limit * $page; // Load sale and categ filters $search_sale = GETPOST("search_sale"); $search_categ = GETPOST("search_categ"); // Get object canvas (By default, this is not defined, so standard usage of dolibarr) -$canvas=GETPOST("canvas"); -$objcanvas=null; -if (! empty($canvas)) +$canvas = GETPOST("canvas"); +$objcanvas = null; +if (!empty($canvas)) { require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db, $action); @@ -88,20 +88,20 @@ if (! empty($canvas)) if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers { - $sref=""; - $snom=""; - $sall=""; - $tosell=""; - $tobuy=""; - $search_sale=""; - $search_categ=""; - $type=""; - $catid=''; - $toolowstock=''; - $search_batch=''; - $search_warehouse=''; - $fourn_id=''; - $sbarcode=''; + $sref = ""; + $snom = ""; + $sall = ""; + $tosell = ""; + $tobuy = ""; + $search_sale = ""; + $search_categ = ""; + $type = ""; + $catid = ''; + $toolowstock = ''; + $search_batch = ''; + $search_warehouse = ''; + $fourn_id = ''; + $sbarcode = ''; } @@ -109,64 +109,64 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' * View */ -$helpurl='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; +$helpurl = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; -$form=new Form($db); -$htmlother=new FormOther($db); +$form = new Form($db); +$htmlother = new FormOther($db); -$title=$langs->trans("ProductsAndServices"); +$title = $langs->trans("ProductsAndServices"); $sql = 'SELECT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,'; -$sql.= ' p.fk_product_type, p.tms as datem,'; -$sql.= ' p.duration, p.tosell as statut, p.tobuy, p.seuil_stock_alerte, p.desiredstock, p.stock, p.tosell, p.tobuy, p.tobatch,'; -$sql.= ' ps.fk_entrepot,'; -$sql.= ' e.ref as warehouse_ref, e.lieu as warehouse_lieu, e.fk_parent as warehouse_parent,'; -$sql.= ' pb.batch, pb.eatby as oldeatby, pb.sellby as oldsellby,'; -$sql.= ' pl.rowid as lotid, pl.eatby, pl.sellby,'; -$sql.= ' SUM(pb.qty) as stock_physique, COUNT(pb.rowid) as nbinbatchtable'; -$sql.= ' FROM '.MAIN_DB_PREFIX.'product as p'; -$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as ps on p.rowid = ps.fk_product'; // Detail for each warehouse -$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot as e on ps.fk_entrepot = e.rowid'; // Link on unique key -$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_batch as pb on pb.fk_product_stock = ps.rowid'; // Detail for each lot on each warehouse -$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lot as pl on pl.fk_product = p.rowid AND pl.batch = pb.batch'; // Link on unique key +$sql .= ' p.fk_product_type, p.tms as datem,'; +$sql .= ' p.duration, p.tosell as statut, p.tobuy, p.seuil_stock_alerte, p.desiredstock, p.stock, p.tosell, p.tobuy, p.tobatch,'; +$sql .= ' ps.fk_entrepot,'; +$sql .= ' e.ref as warehouse_ref, e.lieu as warehouse_lieu, e.fk_parent as warehouse_parent,'; +$sql .= ' pb.batch, pb.eatby as oldeatby, pb.sellby as oldsellby,'; +$sql .= ' pl.rowid as lotid, pl.eatby, pl.sellby,'; +$sql .= ' SUM(pb.qty) as stock_physique, COUNT(pb.rowid) as nbinbatchtable'; +$sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as ps on p.rowid = ps.fk_product'; // Detail for each warehouse +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot as e on ps.fk_entrepot = e.rowid'; // Link on unique key +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_batch as pb on pb.fk_product_stock = ps.rowid'; // Detail for each lot on each warehouse +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lot as pl on pl.fk_product = p.rowid AND pl.batch = pb.batch'; // Link on unique key // We'll need this table joined to the select in order to filter by categ -if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_product as cp"; -$sql.= " WHERE p.entity IN (".getEntity('product').")"; -if ($search_categ) $sql.= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ -if ($sall) $sql.=natural_search(array('p.ref','p.label','p.description','p.note'), $sall); +if ($search_categ) $sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp"; +$sql .= " WHERE p.entity IN (".getEntity('product').")"; +if ($search_categ) $sql .= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ +if ($sall) $sql .= natural_search(array('p.ref', 'p.label', 'p.description', 'p.note'), $sall); // if the type is not 1, we show all products (type = 0,2,3) if (dol_strlen($type)) { - if ($type==1) + if ($type == 1) { - $sql.= " AND p.fk_product_type = '1'"; + $sql .= " AND p.fk_product_type = '1'"; } else { - $sql.= " AND p.fk_product_type <> '1'"; + $sql .= " AND p.fk_product_type <> '1'"; } } -if ($sref) $sql.= natural_search("p.ref", $sref); -if ($search_barcode) $sql.= natural_search("p.barcode", $search_barcode); -if ($snom) $sql.= natural_search("p.label", $snom); -if (! empty($tosell)) $sql.= " AND p.tosell = ".$tosell; -if (! empty($tobuy)) $sql.= " AND p.tobuy = ".$tobuy; -if (! empty($canvas)) $sql.= " AND p.canvas = '".$db->escape($canvas)."'"; -if($catid) $sql.= " AND cp.fk_categorie = ".$catid; -if ($fourn_id > 0) $sql.= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id; +if ($sref) $sql .= natural_search("p.ref", $sref); +if ($search_barcode) $sql .= natural_search("p.barcode", $search_barcode); +if ($snom) $sql .= natural_search("p.label", $snom); +if (!empty($tosell)) $sql .= " AND p.tosell = ".$tosell; +if (!empty($tobuy)) $sql .= " AND p.tobuy = ".$tobuy; +if (!empty($canvas)) $sql .= " AND p.canvas = '".$db->escape($canvas)."'"; +if ($catid) $sql .= " AND cp.fk_categorie = ".$catid; +if ($fourn_id > 0) $sql .= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id; // Insert categ filter if ($search_categ) $sql .= " AND cp.fk_categorie = ".$db->escape($search_categ); if ($search_warehouse) $sql .= natural_search("e.ref", $search_warehouse); if ($search_batch) $sql .= natural_search("pb.batch", $search_batch); -$sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,"; -$sql.= " p.fk_product_type, p.tms,"; -$sql.= " p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock, p.stock, p.tosell, p.tobuy, p.tobatch,"; -$sql.= " ps.fk_entrepot,"; -$sql.= " e.ref, e.lieu, e.fk_parent,"; -$sql.= " pb.batch, pb.eatby, pb.sellby,"; -$sql.= " pl.rowid, pl.eatby, pl.sellby"; -if ($toolowstock) $sql.= " HAVING SUM(".$db->ifsql('ps.reel IS NULL', '0', 'ps.reel').") < p.seuil_stock_alerte"; // Not used yet -$sql.= $db->order($sortfield, $sortorder); +$sql .= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,"; +$sql .= " p.fk_product_type, p.tms,"; +$sql .= " p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock, p.stock, p.tosell, p.tobuy, p.tobatch,"; +$sql .= " ps.fk_entrepot,"; +$sql .= " e.ref, e.lieu, e.fk_parent,"; +$sql .= " pb.batch, pb.eatby, pb.sellby,"; +$sql .= " pl.rowid, pl.eatby, pl.sellby"; +if ($toolowstock) $sql .= " HAVING SUM(".$db->ifsql('ps.reel IS NULL', '0', 'ps.reel').") < p.seuil_stock_alerte"; // Not used yet +$sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -180,7 +180,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) } } -$sql.= $db->plimit($limit + 1, $offset); +$sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); if ($resql) @@ -198,35 +198,35 @@ if ($resql) if (isset($type)) { - if ($type==1) { $texte = $langs->trans("Services"); } + if ($type == 1) { $texte = $langs->trans("Services"); } else { $texte = $langs->trans("Products"); } } else { $texte = $langs->trans("ProductsAndServices"); } - $texte.=' ('.$langs->trans("StocksByLotSerial").')'; + $texte .= ' ('.$langs->trans("StocksByLotSerial").')'; - $param=''; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($sall) $param.="&sall=".urlencode($sall); - if ($tosell) $param.="&tosell=".urlencode($tosell); - if ($tobuy) $param.="&tobuy=".urlencode($tobuy); - if ($type) $param.="&type=".urlencode($type); - if ($fourn_id) $param.="&fourn_id=".urlencode($fourn_id); - if ($snom) $param.="&snom=".urlencode($snom); - if ($sref) $param.="&sref=".urlencode($sref); - if ($search_batch) $param.="&search_batch=".urlencode($search_batch); - if ($sbarcode) $param.="&sbarcode=".urlencode($sbarcode); - if ($search_warehouse) $param.="&search_warehouse=".urlencode($search_warehouse); - if ($catid) $param.="&catid=".urlencode($catid); - if ($toolowstock) $param.="&toolowstock=".urlencode($toolowstock); - if ($search_sale) $param.="&search_sale=".urlencode($search_sale); - if ($search_categ) $param.="&search_categ=".urlencode($search_categ); + $param = ''; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($sall) $param .= "&sall=".urlencode($sall); + if ($tosell) $param .= "&tosell=".urlencode($tosell); + if ($tobuy) $param .= "&tobuy=".urlencode($tobuy); + if ($type) $param .= "&type=".urlencode($type); + if ($fourn_id) $param .= "&fourn_id=".urlencode($fourn_id); + if ($snom) $param .= "&snom=".urlencode($snom); + if ($sref) $param .= "&sref=".urlencode($sref); + if ($search_batch) $param .= "&search_batch=".urlencode($search_batch); + if ($sbarcode) $param .= "&sbarcode=".urlencode($sbarcode); + if ($search_warehouse) $param .= "&search_warehouse=".urlencode($search_warehouse); + if ($catid) $param .= "&catid=".urlencode($catid); + if ($toolowstock) $param .= "&toolowstock=".urlencode($toolowstock); + if ($search_sale) $param .= "&search_sale=".urlencode($search_sale); + if ($search_categ) $param .= "&search_categ=".urlencode($search_categ); /*if ($eatby) $param.="&eatby=".$eatby; if ($sellby) $param.="&sellby=".$sellby;*/ llxHeader("", $title, $helpurl, $texte); - print '
'; + print ''; print ''; print ''; print ''; @@ -236,7 +236,7 @@ if ($resql) print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'products', 0, '', '', $limit); - if (! empty($catid)) + if (!empty($catid)) { print "
"; $c = new Categorie($db); @@ -247,29 +247,29 @@ if ($resql) } // Filter on categories - $moreforfilter=''; - if (! empty($conf->categorie->enabled)) + $moreforfilter = ''; + if (!empty($conf->categorie->enabled)) { - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('Categories'). ': '; - $moreforfilter.=$htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ'); - $moreforfilter.='
'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('Categories').': '; + $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ'); + $moreforfilter .= '
'; } //$moreforfilter.=$langs->trans("StockTooLow").' '; - if (! empty($moreforfilter)) + if (!empty($moreforfilter)) { print '
'; print $moreforfilter; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; } print '
'; - print ''; + print '
'; // Fields title search print ''; @@ -279,7 +279,7 @@ if ($resql) print ''; - if (! empty($conf->service->enabled) && $type == 1) + if (!empty($conf->service->enabled) && $type == 1) { print ''; print ''; print ''; print ''; @@ -303,7 +303,7 @@ if ($resql) print ""; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", $param, "", "", $sortfield, $sortorder); - if (! empty($conf->service->enabled) && $type == 1) print_liste_field_titre("Duration", $_SERVER["PHP_SELF"], "p.duration", $param, "", '', $sortfield, $sortorder, 'center '); + if (!empty($conf->service->enabled) && $type == 1) print_liste_field_titre("Duration", $_SERVER["PHP_SELF"], "p.duration", $param, "", '', $sortfield, $sortorder, 'center '); print_liste_field_titre("Warehouse", $_SERVER["PHP_SELF"], "e.ref", $param, "", '', $sortfield, $sortorder); //print_liste_field_titre("DesiredStock", $_SERVER["PHP_SELF"], "p.desiredstock",$param,"",'',$sortfield,$sortorder, 'right ); print_liste_field_titre("Batch", $_SERVER["PHP_SELF"], "pb.batch", $param, "", '', $sortfield, $sortorder, 'center '); @@ -318,52 +318,52 @@ if ($resql) print_liste_field_titre(''); print "\n"; - $product_static=new Product($db); - $product_lot_static=new Productlot($db); - $warehousetmp=new Entrepot($db); + $product_static = new Product($db); + $product_lot_static = new Productlot($db); + $warehousetmp = new Entrepot($db); while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active + if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active { $sql = "SELECT label"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sql.= " WHERE fk_product=".$objp->rowid; - $sql.= " AND lang='". $langs->getDefaultLang() ."'"; - $sql.= " LIMIT 1"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sql .= " WHERE fk_product=".$objp->rowid; + $sql .= " AND lang='".$langs->getDefaultLang()."'"; + $sql .= " LIMIT 1"; $result = $db->query($sql); if ($result) { $objtp = $db->fetch_object($result); - if (! empty($objtp->label)) $objp->label = $objtp->label; + if (!empty($objtp->label)) $objp->label = $objtp->label; } } - $product_static->ref=$objp->ref; - $product_static->id=$objp->rowid; + $product_static->ref = $objp->ref; + $product_static->id = $objp->rowid; $product_static->label = $objp->label; - $product_static->type=$objp->fk_product_type; - $product_static->entity=$objp->entity; - $product_static->status=$objp->tosell; - $product_static->status_buy=$objp->tobuy; - $product_static->status_batch=$objp->tobatch; + $product_static->type = $objp->fk_product_type; + $product_static->entity = $objp->entity; + $product_static->status = $objp->tosell; + $product_static->status_buy = $objp->tobuy; + $product_static->status_batch = $objp->tobatch; - $product_lot_static->batch=$objp->batch; - $product_lot_static->product_id=$objp->rowid; - $product_lot_static->id=$objp->lotid; - $product_lot_static->eatby=$objp->eatby; - $product_lot_static->sellby=$objp->sellby; + $product_lot_static->batch = $objp->batch; + $product_lot_static->product_id = $objp->rowid; + $product_lot_static->id = $objp->lotid; + $product_lot_static->eatby = $objp->eatby; + $product_lot_static->sellby = $objp->sellby; - $warehousetmp->id=$objp->fk_entrepot; - $warehousetmp->ref=$objp->warehouse_ref; - $warehousetmp->label=$objp->warehouse_ref; - $warehousetmp->fk_parent=$objp->warehouse_parent; + $warehousetmp->id = $objp->fk_entrepot; + $warehousetmp->ref = $objp->warehouse_ref; + $warehousetmp->label = $objp->warehouse_ref; + $warehousetmp->fk_parent = $objp->warehouse_parent; print ''; @@ -376,7 +376,7 @@ if ($resql) // Label print ''; - if (! empty($conf->service->enabled) && $type == 1) + if (!empty($conf->service->enabled) && $type == 1) { print ''; @@ -1615,11 +1615,11 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) } else { - $userstatic->id = $task_time->fk_user; + $userstatic->id = $task_time->fk_user; $userstatic->lastname = $task_time->lastname; - $userstatic->firstname = $task_time->firstname; - $userstatic->photo = $task_time->photo; - $userstatic->statut = $task_time->user_status; + $userstatic->firstname = $task_time->firstname; + $userstatic->photo = $task_time->photo; + $userstatic->statut = $task_time->user_status; print $userstatic->getNomUrl(-1); } print ''; @@ -1763,11 +1763,11 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) } else { - $userstatic->id = $task_time->fk_user; + $userstatic->id = $task_time->fk_user; $userstatic->lastname = $task_time->lastname; - $userstatic->firstname = $task_time->firstname; - $userstatic->photo = $task_time->photo; - $userstatic->statut = $task_time->user_status; + $userstatic->firstname = $task_time->firstname; + $userstatic->photo = $task_time->photo; + $userstatic->statut = $task_time->user_status; print $userstatic->getNomUrl(-1); } print ''; diff --git a/htdocs/public/demo/index.php b/htdocs/public/demo/index.php index 7a962a15b79..c470055dbce 100644 --- a/htdocs/public/demo/index.php +++ b/htdocs/public/demo/index.php @@ -24,74 +24,74 @@ * \brief Entry page to access demo */ -define("NOLOGIN", 1); // This means this output page does not require to be logged. -define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. +define("NOLOGIN", 1); // This means this output page does not require to be logged. +define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. require '../../main.inc.php'; require_once '../../core/lib/functions2.lib.php'; $langs->loadLangs(array("main", "install", "other")); -$conf->dol_hide_topmenu=GETPOST('dol_hide_topmenu', 'int'); -$conf->dol_hide_leftmenu=GETPOST('dol_hide_leftmenu', 'int'); -$conf->dol_optimize_smallscreen=GETPOST('dol_optimize_smallscreen', 'int'); -$conf->dol_no_mouse_hover=GETPOST('dol_no_mouse_hover', 'int'); -$conf->dol_use_jmobile=GETPOST('dol_use_jmobile', 'int'); +$conf->dol_hide_topmenu = GETPOST('dol_hide_topmenu', 'int'); +$conf->dol_hide_leftmenu = GETPOST('dol_hide_leftmenu', 'int'); +$conf->dol_optimize_smallscreen = GETPOST('dol_optimize_smallscreen', 'int'); +$conf->dol_no_mouse_hover = GETPOST('dol_no_mouse_hover', 'int'); +$conf->dol_use_jmobile = GETPOST('dol_use_jmobile', 'int'); // Security check global $dolibarr_main_demo; if (empty($dolibarr_main_demo)) accessforbidden('Parameter dolibarr_main_demo must be defined in conf file with value "default login,default pass" to enable the demo entry page', 0, 0, 1); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$res=$hookmanager->initHooks(array('demo')); +$res = $hookmanager->initHooks(array('demo')); -$demoprofiles=array(); -$alwayscheckedmodules=array(); -$alwaysuncheckedmodules=array(); -$alwayshiddencheckedmodules=array(); -$alwayshiddenuncheckedmodules=array(); +$demoprofiles = array(); +$alwayscheckedmodules = array(); +$alwaysuncheckedmodules = array(); +$alwayshiddencheckedmodules = array(); +$alwayshiddenuncheckedmodules = array(); -$url=''; -$url.=($url?'&':'').($conf->dol_hide_topmenu?'dol_hide_topmenu='.$conf->dol_hide_topmenu:''); -$url.=($url?'&':'').($conf->dol_hide_leftmenu?'dol_hide_leftmenu='.$conf->dol_hide_leftmenu:''); -$url.=($url?'&':'').($conf->dol_optimize_smallscreen?'dol_optimize_smallscreen='.$conf->dol_optimize_smallscreen:''); -$url.=($url?'&':'').($conf->dol_no_mouse_hover?'dol_no_mouse_hover='.$conf->dol_no_mouse_hover:''); -$url.=($url?'&':'').($conf->dol_use_jmobile?'dol_use_jmobile='.$conf->dol_use_jmobile:''); -$url=DOL_URL_ROOT.'/index.php'.($url?'?'.$url:''); +$url = ''; +$url .= ($url ? '&' : '').($conf->dol_hide_topmenu ? 'dol_hide_topmenu='.$conf->dol_hide_topmenu : ''); +$url .= ($url ? '&' : '').($conf->dol_hide_leftmenu ? 'dol_hide_leftmenu='.$conf->dol_hide_leftmenu : ''); +$url .= ($url ? '&' : '').($conf->dol_optimize_smallscreen ? 'dol_optimize_smallscreen='.$conf->dol_optimize_smallscreen : ''); +$url .= ($url ? '&' : '').($conf->dol_no_mouse_hover ? 'dol_no_mouse_hover='.$conf->dol_no_mouse_hover : ''); +$url .= ($url ? '&' : '').($conf->dol_use_jmobile ? 'dol_use_jmobile='.$conf->dol_use_jmobile : ''); +$url = DOL_URL_ROOT.'/index.php'.($url ? '?'.$url : ''); $tmpaction = 'view'; -$parameters=array(); -$object=new stdClass(); -$reshook=$hookmanager->executeHooks('addDemoProfile', $parameters, $object, $tmpaction); // Note that $action and $object may have been modified by some hooks -$error=$hookmanager->error; $errors=$hookmanager->errors; +$parameters = array(); +$object = new stdClass(); +$reshook = $hookmanager->executeHooks('addDemoProfile', $parameters, $object, $tmpaction); // Note that $action and $object may have been modified by some hooks +$error = $hookmanager->error; $errors = $hookmanager->errors; if (empty($reshook)) { - $demoprofiles=array( - array('default'=>'1', 'key'=>'profdemoservonly','label'=>'DemoCompanyServiceOnly', + $demoprofiles = array( + array('default'=>'1', 'key'=>'profdemoservonly', 'label'=>'DemoCompanyServiceOnly', 'disablemodules'=>'adherent,barcode,bom,cashdesk,don,expedition,externalsite,ftp,incoterm,mailmanspip,margin,mrp,prelevement,product,productbatch,stock,takepos', //'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot8.png', 'icon'=>DOL_URL_ROOT.'/public/demo/demo-profile-service.jpg', 'url'=>$url ), - array('default'=>'0', 'key'=>'profmanufacture','label'=>'DemoCompanyManufacturing', + array('default'=>'0', 'key'=>'profmanufacture', 'label'=>'DemoCompanyManufacturing', 'disablemodules'=>'adherent,contrat,don,externalsite,ficheinter,ftp,mailmanspip,prelevement,service', 'icon'=>DOL_URL_ROOT.'/public/demo/demo-profile-manufacturing.jpg', 'url'=>$url ), - array('default'=>'0', 'key'=>'profdemoprodstock','label'=>'DemoCompanyProductAndStocks', + array('default'=>'0', 'key'=>'profdemoprodstock', 'label'=>'DemoCompanyProductAndStocks', 'disablemodules'=>'adherent,bom,contrat,don,externalsite,ficheinter,ftp,mailmanspip,mrp,prelevement,service', //'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot2.png', 'icon'=>DOL_URL_ROOT.'/public/demo/demo-profile-product.jpg', 'url'=>$url ), - array('default'=>'0', 'key'=>'profdemofun2','label'=>'DemoFundation2', + array('default'=>'0', 'key'=>'profdemofun2', 'label'=>'DemoFundation2', 'disablemodules'=>'barcode,cashdesk,bom,commande,commercial,compta,comptabilite,contrat,expedition,externalsite,ficheinter,ftp,incoterm,mailmanspip,margin,mrp,prelevement,product,productbatch,projet,propal,propale,service,societe,stock,tax,takepos', //'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot6.png', 'icon'=>DOL_URL_ROOT.'/public/demo/demo-profile-foundation.jpg', 'url'=>$url ), // All demo profile - array('default'=>'0', 'key'=>'profdemoall','label'=>'ChooseYourDemoProfilMore', + array('default'=>'0', 'key'=>'profdemoall', 'label'=>'ChooseYourDemoProfilMore', 'disablemodules'=>'adherent,cashdesk,don,externalsite,mailmanspip', //'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot9.png' 'icon'=>DOL_URL_ROOT.'/public/demo/demo-profile-all.jpg' @@ -100,21 +100,21 @@ if (empty($reshook)) // Visible - $alwayscheckedmodules=array('barcode','bookmark','categorie','externalrss','fckeditor','geoipmaxmind','gravatar','memcached','syslog','user','webservices'); // Technical module we always want - $alwaysuncheckedmodules=array('dav','dynamicprices','incoterm','loan','multicurrency','paybox','paypal','stripe','google','printing','scanner','skype','website'); // Module we dont want by default + $alwayscheckedmodules = array('barcode', 'bookmark', 'categorie', 'externalrss', 'fckeditor', 'geoipmaxmind', 'gravatar', 'memcached', 'syslog', 'user', 'webservices'); // Technical module we always want + $alwaysuncheckedmodules = array('dav', 'dynamicprices', 'incoterm', 'loan', 'multicurrency', 'paybox', 'paypal', 'stripe', 'google', 'printing', 'scanner', 'skype', 'website'); // Module we dont want by default // Not visible - $alwayshiddencheckedmodules=array('accounting','api','barcode','blockedlog','bookmark','clicktodial','comptabilite','cron','document','domain','externalrss','externalsite','fckeditor','geoipmaxmind','gravatar','label','ldap', - 'mailmanspip','notification','oauth','syslog','user','webservices','workflow', + $alwayshiddencheckedmodules = array('accounting', 'api', 'barcode', 'blockedlog', 'bookmark', 'clicktodial', 'comptabilite', 'cron', 'document', 'domain', 'externalrss', 'externalsite', 'fckeditor', 'geoipmaxmind', 'gravatar', 'label', 'ldap', + 'mailmanspip', 'notification', 'oauth', 'syslog', 'user', 'webservices', 'workflow', // Extended modules - 'memcached','numberwords','zipautofillfr'); - $alwayshiddenuncheckedmodules=array('dav','debugbar','emailcollector','ftp','hrm','modulebuilder','printing','webservicesclient', + 'memcached', 'numberwords', 'zipautofillfr'); + $alwayshiddenuncheckedmodules = array('dav', 'debugbar', 'emailcollector', 'ftp', 'hrm', 'modulebuilder', 'printing', 'webservicesclient', // Extended modules - 'awstats','bittorrent','bootstrap','cabinetmed','cmcic','concatpdf','customfield','deplacement','dolicloud','filemanager','lightbox','mantis','monitoring','moretemplates','multicompany','nltechno','numberingpack','openstreetmap', - 'ovh','phenix','phpsysinfo','pibarcode','postnuke','selectbank','skincoloreditor','submiteverywhere','survey','thomsonphonebook','topten','tvacerfa','voyage','webcalendar','webmail'); + 'awstats', 'bittorrent', 'bootstrap', 'cabinetmed', 'cmcic', 'concatpdf', 'customfield', 'deplacement', 'dolicloud', 'filemanager', 'lightbox', 'mantis', 'monitoring', 'moretemplates', 'multicompany', 'nltechno', 'numberingpack', 'openstreetmap', + 'ovh', 'phenix', 'phpsysinfo', 'pibarcode', 'postnuke', 'selectbank', 'skincoloreditor', 'submiteverywhere', 'survey', 'thomsonphonebook', 'topten', 'tvacerfa', 'voyage', 'webcalendar', 'webmail'); } // Search modules -$dirlist=$conf->file->dol_document_root; +$dirlist = $conf->file->dol_document_root; // Search modules dirs @@ -132,13 +132,13 @@ $j = 0; // j is module number. Automatically affected if module number not defin foreach ($modulesdir as $dir) { // Charge tableaux modules, nom, numero, orders depuis repertoire dir - $handle=@opendir($dir); + $handle = @opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { //print "$i ".$file."\n
"; - if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') + if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') { $modName = substr($file, 0, dol_strlen($file) - 10); @@ -158,25 +158,25 @@ foreach ($modulesdir as $dir) $j = 1000 + $i; } - $modulequalified=1; + $modulequalified = 1; // We discard modules according to features level (PS: if module is activated we always show it) $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod))); - if ($objMod->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2 && empty($conf->global->$const_name)) $modulequalified=0; - if ($objMod->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1 && empty($conf->global->$const_name)) $modulequalified=0; + if ($objMod->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2 && empty($conf->global->$const_name)) $modulequalified = 0; + if ($objMod->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1 && empty($conf->global->$const_name)) $modulequalified = 0; if ($modulequalified) { $modules[$i] = $objMod; - $filename[$i]= $modName; - $orders[$i] = $objMod->family."_".$j; // Tri par famille puis numero module + $filename[$i] = $modName; + $orders[$i] = $objMod->family."_".$j; // Tri par famille puis numero module //print "x".$modName." ".$orders[$i]."\n
"; $dirmod[$i] = $dirroot; $j++; $i++; } } - catch(Exception $e) + catch (Exception $e) { dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR); } @@ -197,7 +197,7 @@ asort($orders); if (GETPOST('action', 'aZ09') == 'gotodemo') // Action run when we click on "Start" after selection modules { //print 'ee'.GETPOST("demochoice"); - $disablestring=''; + $disablestring = ''; // If we disable modules using a profile choice if (GETPOST("demochoice")) { @@ -205,27 +205,27 @@ if (GETPOST('action', 'aZ09') == 'gotodemo') // Action run when we click on { if ($profilearray['key'] == GETPOST("demochoice")) { - $disablestring=$profilearray['disablemodules']; + $disablestring = $profilearray['disablemodules']; break; } } } // If we disable modules using personalized list - foreach($modules as $val) + foreach ($modules as $val) { - $modulekeyname=strtolower($val->name); - if (empty($_POST[$modulekeyname]) && empty($val->always_enabled) && ! in_array($modulekeyname, $alwayscheckedmodules)) + $modulekeyname = strtolower($val->name); + if (empty($_POST[$modulekeyname]) && empty($val->always_enabled) && !in_array($modulekeyname, $alwayscheckedmodules)) { - $disablestring.=$modulekeyname.','; - if ($modulekeyname=='propale') $disablestring.='propal,'; + $disablestring .= $modulekeyname.','; + if ($modulekeyname == 'propale') $disablestring .= 'propal,'; } } // Do redirect to login page if ($disablestring) { - if (GETPOST('urlfrom')) $url.=(preg_match('/\?/', $url)?'&':'?').'urlfrom='.urlencode(GETPOST('urlfrom', 'alpha')); - $url.=(preg_match('/\?/', $url)?'&':'?').'disablemodules='.$disablestring; + if (GETPOST('urlfrom')) $url .= (preg_match('/\?/', $url) ? '&' : '?').'urlfrom='.urlencode(GETPOST('urlfrom', 'alpha')); + $url .= (preg_match('/\?/', $url) ? '&' : '?').'disablemodules='.$disablestring; //var_dump($url);exit; header("Location: ".$url); exit; @@ -237,11 +237,11 @@ if (GETPOST('action', 'aZ09') == 'gotodemo') // Action run when we click on * View */ -$head=''; -$head.=''."\n"; -$head.=''."\n"; +$head = ''; +$head .= ''."\n"; +$head .= ''."\n"; -$head.=' +$head .= ' ' . "\n"; + print ''."\n"; print '
'; print '
'; - print $langs->trans("ThirdPartyType") . ':     '; + print $langs->trans("ThirdPartyType").':     '; print '
'; print ''; print '     '; print '
'; print ''; print ''; print ' '; @@ -294,7 +294,7 @@ if ($resql) print '  '; - $searchpicto=$form->showFilterAndCheckAddButtons(0); + $searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
'.$objp->label.''; if (preg_match('/([0-9]+)y/i', $objp->duration, $regs)) print $regs[1].' '.$langs->trans("DurationYear"); diff --git a/htdocs/product/stock/class/api_stockmovements.class.php b/htdocs/product/stock/class/api_stockmovements.class.php index 1c18627f2cf..0c61ae605c0 100644 --- a/htdocs/product/stock/class/api_stockmovements.class.php +++ b/htdocs/product/stock/class/api_stockmovements.class.php @@ -99,47 +99,47 @@ class StockMovements extends DolibarrApi $obj_ret = array(); - if(! DolibarrApiAccess::$user->rights->stock->lire) { + if (!DolibarrApiAccess::$user->rights->stock->lire) { throw new RestException(401); } $sql = "SELECT t.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."stock_mouvement as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as t"; //$sql.= ' WHERE t.entity IN ('.getEntity('stock').')'; - $sql.= ' WHERE 1 = 1'; + $sql .= ' WHERE 1 = 1'; // Add sql filters if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - $sql.= $db->order($sortfield, $sortorder); - if ($limit) { + $sql .= $db->order($sortfield, $sortorder); + if ($limit) { if ($page < 0) { $page = 0; } $offset = $limit * $page; - $sql.= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); } $result = $db->query($sql); if ($result) { - $i=0; + $i = 0; $num = $db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); while ($i < $min) { $obj = $db->fetch_object($result); $stockmovement_static = new MouvementStock($db); - if($stockmovement_static->fetch($obj->rowid)) { + if ($stockmovement_static->fetch($obj->rowid)) { $obj_ret[] = $this->_cleanObjectDatas($stockmovement_static); } $i++; @@ -148,7 +148,7 @@ class StockMovements extends DolibarrApi else { throw new RestException(503, 'Error when retrieve stock movement list : '.$db->lasterror()); } - if( ! count($obj_ret)) { + if (!count($obj_ret)) { throw new RestException(404, 'No stock movement found'); } return $obj_ret; @@ -177,7 +177,7 @@ class StockMovements extends DolibarrApi */ public function post($product_id, $warehouse_id, $qty, $lot = '', $movementcode = '', $movementlabel = '', $price = '', $dlc = '', $dluo = '') { - if(! DolibarrApiAccess::$user->rights->stock->creer) { + if (!DolibarrApiAccess::$user->rights->stock->creer) { throw new RestException(401); } @@ -187,7 +187,7 @@ class StockMovements extends DolibarrApi // Type increase or decrease $type = 2; - if ($qty >= 0){ + if ($qty >= 0) { $type = 3; } @@ -195,7 +195,7 @@ class StockMovements extends DolibarrApi $eatBy = empty($dluo) ? '' : dol_stringtotime($dluo); $sellBy = empty($dlc) ? '' : dol_stringtotime($dlc); - if($this->stockmovement->_create(DolibarrApiAccess::$user, $product_id, $warehouse_id, $qty, $type, $price, $movementlabel, $movementcode, '', $eatBy, $sellBy, $lot) <= 0) { + if ($this->stockmovement->_create(DolibarrApiAccess::$user, $product_id, $warehouse_id, $qty, $type, $price, $movementlabel, $movementcode, '', $eatBy, $sellBy, $lot) <= 0) { $errormessage = $this->stockmovement->error; if (empty($errormessage)) $errormessage = join(',', $this->stockmovement->errors); throw new RestException(503, 'Error when create stock movement : '.$errormessage); diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index ab3dfde9bf0..40c358967ce 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -37,18 +37,18 @@ class Entrepot extends CommonObject /** * @var string ID to identify managed object */ - public $element='stock'; + public $element = 'stock'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='entrepot'; + public $table_element = 'entrepot'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ - public $picto='stock'; - public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + public $picto = 'stock'; + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe /** * @var string Label @@ -102,7 +102,7 @@ class Entrepot extends CommonObject /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( + public $fields = array( 'rowid' =>array('type'=>'integer', 'label'=>'ID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>10), 'ref' =>array('type'=>'varchar(255)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-2, 'showoncombobox'=>1, 'position'=>25), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>30), @@ -181,7 +181,7 @@ class Entrepot extends CommonObject return 0; } - $now=dol_now(); + $now = dol_now(); $this->db->begin(); @@ -189,7 +189,7 @@ class Entrepot extends CommonObject $sql .= " VALUES ('".$this->db->escape($this->libelle)."', ".$conf->entity.", '".$this->db->idate($now)."', ".$user->id.", ".($this->fk_parent > 0 ? $this->fk_parent : "NULL").")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { $id = $this->db->last_insert_id(MAIN_DB_PREFIX."entrepot"); @@ -197,7 +197,7 @@ class Entrepot extends CommonObject { $this->id = $id; - if (! $error) + if (!$error) { $result = $this->update($id, $user); if ($result <= 0) @@ -207,11 +207,11 @@ class Entrepot extends CommonObject } // Actions on extra fields - if (! $error) + if (!$error) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; @@ -219,7 +219,7 @@ class Entrepot extends CommonObject } } - if (! $error) + if (!$error) { $this->db->commit(); return $id; @@ -232,14 +232,14 @@ class Entrepot extends CommonObject } } else { - $this->error="Failed to get insert id"; + $this->error = "Failed to get insert id"; dol_syslog(get_class($this)."::create return -2"); return -2; } } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); dol_syslog(get_class($this)."::create Error ".$this->db->error()); $this->db->rollback(); return -1; @@ -257,56 +257,56 @@ class Entrepot extends CommonObject { global $conf; - $error=0; + $error = 0; if (empty($id)) $id = $this->id; // Check if new parent is already a child of current warehouse - if(!empty($this->fk_parent)) + if (!empty($this->fk_parent)) { $TChildWarehouses = array($id); $TChildWarehouses = $this->get_children_warehouses($this->id, $TChildWarehouses); - if(in_array($this->fk_parent, $TChildWarehouses)) + if (in_array($this->fk_parent, $TChildWarehouses)) { $this->error = 'ErrorCannotAddThisParentWarehouse'; return -2; } } - $this->libelle=trim($this->libelle); - $this->description=trim($this->description); + $this->libelle = trim($this->libelle); + $this->description = trim($this->description); - $this->lieu=trim($this->lieu); + $this->lieu = trim($this->lieu); - $this->address=trim($this->address); - $this->zip=trim($this->zip); - $this->town=trim($this->town); - $this->country_id=($this->country_id > 0 ? $this->country_id : 0); + $this->address = trim($this->address); + $this->zip = trim($this->zip); + $this->town = trim($this->town); + $this->country_id = ($this->country_id > 0 ? $this->country_id : 0); $sql = "UPDATE ".MAIN_DB_PREFIX."entrepot "; - $sql .= " SET ref = '" . $this->db->escape($this->libelle) ."'"; - $sql .= ", fk_parent = " . (($this->fk_parent > 0) ? $this->fk_parent : "NULL"); - $sql .= ", description = '" . $this->db->escape($this->description) ."'"; - $sql .= ", statut = " . $this->statut; - $sql .= ", lieu = '" . $this->db->escape($this->lieu) ."'"; - $sql .= ", address = '" . $this->db->escape($this->address) ."'"; - $sql .= ", zip = '" . $this->db->escape($this->zip) ."'"; - $sql .= ", town = '" . $this->db->escape($this->town) ."'"; - $sql .= ", fk_pays = " . $this->country_id; - $sql .= " WHERE rowid = " . $id; + $sql .= " SET ref = '".$this->db->escape($this->libelle)."'"; + $sql .= ", fk_parent = ".(($this->fk_parent > 0) ? $this->fk_parent : "NULL"); + $sql .= ", description = '".$this->db->escape($this->description)."'"; + $sql .= ", statut = ".$this->statut; + $sql .= ", lieu = '".$this->db->escape($this->lieu)."'"; + $sql .= ", address = '".$this->db->escape($this->address)."'"; + $sql .= ", zip = '".$this->db->escape($this->zip)."'"; + $sql .= ", town = '".$this->db->escape($this->town)."'"; + $sql .= ", fk_pays = ".$this->country_id; + $sql .= " WHERE rowid = ".$id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); - if (! $resql) { + if (!$resql) { $error++; - $this->errors[]="Error ".$this->db->lasterror(); + $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) { - $result=$this->insertExtraFields(); + if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options) > 0) { + $result = $this->insertExtraFields(); if ($result < 0) { $error++; @@ -318,7 +318,7 @@ class Entrepot extends CommonObject return 1; } else { $this->db->rollback(); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -341,24 +341,24 @@ class Entrepot extends CommonObject $this->db->begin(); - if (! $error && empty($notrigger)) + if (!$error && empty($notrigger)) { // Call trigger - $result=$this->call_trigger('WAREHOUSE_DELETE', $user); + $result = $this->call_trigger('WAREHOUSE_DELETE', $user); if ($result < 0) { $error++; } // End call triggers } - $elements = array('stock_mouvement','product_stock','product_warehouse_properties'); - foreach($elements as $table) + $elements = array('stock_mouvement', 'product_stock', 'product_warehouse_properties'); + foreach ($elements as $table) { - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table; - $sql.= " WHERE fk_entrepot = " . $this->id; + $sql .= " WHERE fk_entrepot = ".$this->id; - $result=$this->db->query($sql); - if (! $result) + $result = $this->db->query($sql); + if (!$result) { $error++; $this->errors[] = $this->db->lasterror(); @@ -367,11 +367,11 @@ class Entrepot extends CommonObject } // Removed extrafields - if (! $error) + if (!$error) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->deleteExtraFields(); + $result = $this->deleteExtraFields(); if ($result < 0) { $error++; @@ -380,12 +380,12 @@ class Entrepot extends CommonObject } } - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."entrepot"; - $sql.= " WHERE rowid = " . $this->id; - $resql1=$this->db->query($sql); - if (! $resql1) + $sql .= " WHERE rowid = ".$this->id; + $resql1 = $this->db->query($sql); + if (!$resql1) { $error++; $this->errors[] = $this->db->lasterror(); @@ -393,12 +393,12 @@ class Entrepot extends CommonObject } } - if (! $error) + if (!$error) { // Update denormalized fields because we change content of produt_stock. Warning: Do not use "SET p.stock", does not works with pgsql $sql = "UPDATE ".MAIN_DB_PREFIX."product as p SET stock = (SELECT SUM(ps.reel) FROM ".MAIN_DB_PREFIX."product_stock as ps WHERE ps.fk_product = p.rowid)"; - $resql2=$this->db->query($sql); - if (! $resql2) + $resql2 = $this->db->query($sql); + if (!$resql2) { $error++; $this->errors[] = $this->db->lasterror(); @@ -406,7 +406,7 @@ class Entrepot extends CommonObject } } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -433,9 +433,9 @@ class Entrepot extends CommonObject dol_syslog(get_class($this)."::fetch id=".$id." ref=".$ref); // Check parameters - if (! $id && ! $ref) + if (!$id && !$ref) { - $this->error='ErrorWrongParameters'; + $this->error = 'ErrorWrongParameters'; dol_syslog(get_class($this)."::fetch ".$this->error); return -1; } @@ -444,12 +444,12 @@ class Entrepot extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."entrepot"; if ($id) { - $sql.= " WHERE rowid = '".$id."'"; + $sql .= " WHERE rowid = '".$id."'"; } else { - $sql.= " WHERE entity = " .$conf->entity; - if ($ref) $sql.= " AND ref = '".$this->db->escape($ref)."'"; + $sql .= " WHERE entity = ".$conf->entity; + if ($ref) $sql .= " AND ref = '".$this->db->escape($ref)."'"; } $result = $this->db->query($sql); @@ -457,13 +457,13 @@ class Entrepot extends CommonObject { if ($this->db->num_rows($result) > 0) { - $obj=$this->db->fetch_object($result); + $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; $this->fk_parent = $obj->fk_parent; $this->ref = $obj->label; $this->label = $obj->label; - $this->libelle = $obj->label; // deprecated + $this->libelle = $obj->label; // deprecated $this->description = $obj->description; $this->statut = $obj->statut; $this->lieu = $obj->lieu; @@ -477,21 +477,21 @@ class Entrepot extends CommonObject $this->fetch_optionals(); include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - $tmp=getCountry($this->country_id, 'all'); - $this->country=$tmp['label']; - $this->country_code=$tmp['code']; + $tmp = getCountry($this->country_id, 'all'); + $this->country = $tmp['label']; + $this->country_code = $tmp['code']; return 1; } else { - $this->error="Record Not Found"; + $this->error = "Record Not Found"; return 0; } } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -506,11 +506,11 @@ class Entrepot extends CommonObject public function info($id) { $sql = "SELECT e.rowid, e.datec, e.tms as datem, e.fk_user_author"; - $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e"; - $sql.= " WHERE e.rowid = ".$id; + $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e"; + $sql .= " WHERE e.rowid = ".$id; dol_syslog(get_class($this)."::info", LOG_DEBUG); - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -522,7 +522,7 @@ class Entrepot extends CommonObject if ($obj->fk_user_author) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_valid) { @@ -557,14 +557,14 @@ class Entrepot extends CommonObject $liste = array(); $sql = "SELECT rowid, ref as label"; - $sql.= " FROM ".MAIN_DB_PREFIX."entrepot"; - $sql.= " WHERE entity IN (".getEntity('stock').")"; - $sql.= " AND statut = ".$status; + $sql .= " FROM ".MAIN_DB_PREFIX."entrepot"; + $sql .= " WHERE entity IN (".getEntity('stock').")"; + $sql .= " AND statut = ".$status; $result = $this->db->query($sql); $i = 0; $num = $this->db->num_rows($result); - if ( $result ) + if ($result) { while ($i < $num) { @@ -586,25 +586,25 @@ class Entrepot extends CommonObject public function nb_different_products() { // phpcs:enable - $ret=array(); + $ret = array(); $sql = "SELECT count(distinct p.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; - $sql.= ", ".MAIN_DB_PREFIX."product as p"; - $sql.= " WHERE ps.fk_entrepot = ".$this->id; - $sql.= " AND ps.fk_product = p.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; + $sql .= ", ".MAIN_DB_PREFIX."product as p"; + $sql .= " WHERE ps.fk_entrepot = ".$this->id; + $sql .= " AND ps.fk_product = p.rowid"; //print $sql; $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); - $ret['nb']=$obj->nb; + $ret['nb'] = $obj->nb; $this->db->free($result); } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } @@ -620,26 +620,26 @@ class Entrepot extends CommonObject public function nb_products() { // phpcs:enable - $ret=array(); + $ret = array(); $sql = "SELECT sum(ps.reel) as nb, sum(ps.reel * p.pmp) as value"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; - $sql.= ", ".MAIN_DB_PREFIX."product as p"; - $sql.= " WHERE ps.fk_entrepot = ".$this->id; - $sql.= " AND ps.fk_product = p.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; + $sql .= ", ".MAIN_DB_PREFIX."product as p"; + $sql .= " WHERE ps.fk_entrepot = ".$this->id; + $sql .= " AND ps.fk_product = p.rowid"; //print $sql; $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); - $ret['nb']=$obj->nb; - $ret['value']=$obj->value; + $ret['nb'] = $obj->nb; + $ret['value'] = $obj->value; $this->db->free($result); } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } @@ -695,40 +695,40 @@ class Entrepot extends CommonObject global $conf, $langs; $langs->load("stocks"); - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips - $result=''; + $result = ''; - $label = '' . $langs->trans("ShowWarehouse").''; - $label.= '
' . $langs->trans('Ref') . ': ' . (empty($this->ref)?(empty($this->label)?$this->libelle:$this->label):$this->ref); - if (! empty($this->lieu)) { - $label.= '
' . $langs->trans('LocationSummary').': '.$this->lieu; + $label = ''.$langs->trans("ShowWarehouse").''; + $label .= '
'.$langs->trans('Ref').': '.(empty($this->ref) ? (empty($this->label) ? $this->libelle : $this->label) : $this->ref); + if (!empty($this->lieu)) { + $label .= '
'.$langs->trans('LocationSummary').': '.$this->lieu; } if (isset($this->statut)) { - $label.= '
' . $langs->trans("Status").": ".$this->getLibStatut(5); + $label .= '
'.$langs->trans("Status").": ".$this->getLibStatut(5); } $url = DOL_URL_ROOT.'/product/stock/card.php?id='.$this->id; - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowWarehouse"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowWarehouse"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip"'; } $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= ($showfullpath ? $this->get_full_arbo() : (empty($this->label)?$this->libelle:$this->label)); + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= ($showfullpath ? $this->get_full_arbo() : (empty($this->label) ? $this->libelle : $this->label)); $result .= $linkend; return $result; @@ -743,23 +743,23 @@ class Entrepot extends CommonObject */ public function initAsSpecimen() { - global $user,$langs,$conf,$mysoc; + global $user, $langs, $conf, $mysoc; - $now=dol_now(); + $now = dol_now(); // Initialize parameters - $this->id=0; + $this->id = 0; $this->libelle = 'WAREHOUSE SPECIMEN'; $this->description = 'WAREHOUSE SPECIMEN '.dol_print_date($now, 'dayhourlog'); - $this->statut=1; - $this->specimen=1; + $this->statut = 1; + $this->specimen = 1; - $this->lieu='Location test'; - $this->address='21 jump street'; - $this->zip='99999'; - $this->town='MyTown'; - $this->country_id=1; - $this->country_code='FR'; + $this->lieu = 'Location test'; + $this->address = '21 jump street'; + $this->zip = '99999'; + $this->town = 'MyTown'; + $this->country_id = 1; + $this->country_code = 'FR'; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -771,16 +771,16 @@ class Entrepot extends CommonObject public function get_full_arbo() { // phpcs:enable - global $user,$langs,$conf; + global $user, $langs, $conf; - $TArbo = array(empty($this->label)?$this->libelle:$this->label); + $TArbo = array(empty($this->label) ? $this->libelle : $this->label); - $protection=100; // We limit depth of warehouses to 100 + $protection = 100; // We limit depth of warehouses to 100 $warehousetmp = new Entrepot($this->db); - $parentid = $this->fk_parent; // If parent_id not defined on current object, we do not start consecutive searches of parents - $i=0; + $parentid = $this->fk_parent; // If parent_id not defined on current object, we do not start consecutive searches of parents + $i = 0; while ($parentid > 0 && $i < $protection) { $sql = 'SELECT fk_parent FROM '.MAIN_DB_PREFIX.'entrepot WHERE rowid = '.$parentid; @@ -821,8 +821,8 @@ class Entrepot extends CommonObject WHERE fk_parent = '.$id; $resql = $this->db->query($sql); - if($resql) { - while($res = $this->db->fetch_object($resql)) { + if ($resql) { + while ($res = $this->db->fetch_object($resql)) { $TChildWarehouses[] = $res->rowid; $this->get_children_warehouses($res->rowid, $TChildWarehouses); } @@ -843,16 +843,16 @@ class Entrepot extends CommonObject */ public function generateDocument($modele, $outputlangs = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { - global $conf,$user,$langs; + global $conf, $user, $langs; $langs->load("stocks"); - if (! dol_strlen($modele)) { + if (!dol_strlen($modele)) { $modele = 'standard'; if ($this->modelpdf) { $modele = $this->modelpdf; - } elseif (! empty($conf->global->STOCK_ADDON_PDF)) { + } elseif (!empty($conf->global->STOCK_ADDON_PDF)) { $modele = $conf->global->STOCK_ADDON_PDF; } } @@ -877,12 +877,12 @@ class Entrepot extends CommonObject $type_categ = Categorie::TYPE_WAREHOUSE; // Handle single category - if (! is_array($categories)) { + if (!is_array($categories)) { $categories = array($categories); } // Get current categories - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $c = new Categorie($this->db); $existing = $c->containing($this->id, $type_categ, 'id'); @@ -896,7 +896,7 @@ class Entrepot extends CommonObject } // Process - foreach($to_del as $del) { + foreach ($to_del as $del) { if ($c->fetch($del) > 0) { $c->del_type($this, $type_categ); } diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 527afee2607..4b36fda5ccb 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -200,52 +200,52 @@ jQuery(document).ready(function() { $sql = "SELECT"; -$sql.= " t.rowid,"; -$sql.= " t.entity,"; -$sql.= " t.fk_product,"; -$sql.= " t.batch,"; -$sql.= " t.sellby,"; -$sql.= " t.eatby,"; -$sql.= " t.datec as date_creation,"; -$sql.= " t.tms as date_update,"; -$sql.= " t.fk_user_creat,"; -$sql.= " t.fk_user_modif,"; -$sql.= " t.import_key,"; -$sql.= " p.fk_product_type as product_type,"; -$sql.= " p.ref as product_ref,"; -$sql.= " p.label as product_label,"; -$sql.= " p.tosell,"; -$sql.= " p.tobuy,"; -$sql.= " p.tobatch"; +$sql .= " t.rowid,"; +$sql .= " t.entity,"; +$sql .= " t.fk_product,"; +$sql .= " t.batch,"; +$sql .= " t.sellby,"; +$sql .= " t.eatby,"; +$sql .= " t.datec as date_creation,"; +$sql .= " t.tms as date_update,"; +$sql .= " t.fk_user_creat,"; +$sql .= " t.fk_user_modif,"; +$sql .= " t.import_key,"; +$sql .= " p.fk_product_type as product_type,"; +$sql .= " p.ref as product_ref,"; +$sql .= " p.label as product_label,"; +$sql .= " p.tosell,"; +$sql .= " p.tobuy,"; +$sql .= " p.tobatch"; // Add fields for extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql.= " FROM ".MAIN_DB_PREFIX."product_lot as t"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; -$sql.= ", ".MAIN_DB_PREFIX."product as p"; -$sql.= " WHERE p.rowid = t.fk_product"; -$sql.= " AND p.entity IN (".getEntity('product').")"; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= " FROM ".MAIN_DB_PREFIX."product_lot as t"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +$sql .= ", ".MAIN_DB_PREFIX."product as p"; +$sql .= " WHERE p.rowid = t.fk_product"; +$sql .= " AND p.entity IN (".getEntity('product').")"; -if ($search_entity) $sql.= natural_search("entity", $search_entity); -if ($search_product) $sql.= natural_search("p.ref", $search_product); -if ($search_batch) $sql.= natural_search("batch", $search_batch); -if ($search_fk_user_creat) $sql.= natural_search("fk_user_creat", $search_fk_user_creat); -if ($search_fk_user_modif) $sql.= natural_search("fk_user_modif", $search_fk_user_modif); -if ($search_import_key) $sql.= natural_search("import_key", $search_import_key); +if ($search_entity) $sql .= natural_search("entity", $search_entity); +if ($search_product) $sql .= natural_search("p.ref", $search_product); +if ($search_batch) $sql .= natural_search("batch", $search_batch); +if ($search_fk_user_creat) $sql .= natural_search("fk_user_creat", $search_fk_user_creat); +if ($search_fk_user_modif) $sql .= natural_search("fk_user_modif", $search_fk_user_modif); +if ($search_import_key) $sql .= natural_search("import_key", $search_import_key); -if ($sall) $sql.= natural_search(array_keys($fieldstosearchall), $sall); +if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql.=$db->order($sortfield, $sortorder); +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= $db->order($sortfield, $sortorder); //$sql.= $db->plimit($conf->liste_limit+1, $offset); // Count total nb of records diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 2fcb012f3c4..613daa18ab0 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -156,7 +156,7 @@ class Task extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task ("; $sql .= "fk_projet"; $sql .= ", ref"; - $sql.= ", entity"; + $sql .= ", entity"; $sql .= ", fk_task_parent"; $sql .= ", label"; $sql .= ", description"; @@ -169,7 +169,7 @@ class Task extends CommonObject $sql .= ") VALUES ("; $sql .= $this->fk_project; $sql .= ", ".(!empty($this->ref) ? "'".$this->db->escape($this->ref)."'" : 'null'); - $sql.= ", ".$conf->entity; + $sql .= ", ".$conf->entity; $sql .= ", ".$this->fk_task_parent; $sql .= ", '".$this->db->escape($this->label)."'"; $sql .= ", '".$this->db->escape($this->description)."'"; diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index efaaa5b75ca..291ab4ab949 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -43,7 +43,7 @@ $action = GETPOST('action', 'alpha'); $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) $confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); -$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'alpha'); @@ -237,8 +237,8 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$_POST["cancel $object->fetch($id, $ref); $object->timespent_note = $_POST["timespent_note_line"]; $object->timespent_old_duration = $_POST["old_duration"]; - $object->timespent_duration = $_POST["new_durationhour"] * 60 * 60; // We store duration in seconds - $object->timespent_duration += ($_POST["new_durationmin"] ? $_POST["new_durationmin"] : 0) * 60; // We store duration in seconds + $object->timespent_duration = $_POST["new_durationhour"] * 60 * 60; // We store duration in seconds + $object->timespent_duration += ($_POST["new_durationmin"] ? $_POST["new_durationmin"] : 0) * 60; // We store duration in seconds if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) // If hour was entered { $object->timespent_date = dol_mktime(GETPOST("timelinehour"), GETPOST("timelinemin"), 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear")); @@ -387,18 +387,18 @@ if ($action == 'confirm_generateinvoice') if ($idprod > 0) { $tmpproduct->fetch($idprod); - if ($tmpproduct->duration_unit=='i') - $prodDurationHours = 1./60; - if ($tmpproduct->duration_unit=='h') + if ($tmpproduct->duration_unit == 'i') + $prodDurationHours = 1. / 60; + if ($tmpproduct->duration_unit == 'h') $prodDurationHours = 1.; - if ($tmpproduct->duration_unit=='d') + if ($tmpproduct->duration_unit == 'd') $prodDurationHours = 24.; - if ($tmpproduct->duration_unit=='w') - $prodDurationHours = 24.*7; - if ($tmpproduct->duration_unit=='m') - $prodDurationHours = 24.*30; - if ($tmpproduct->duration_unit=='y') - $prodDurationHours = 24.*365; + if ($tmpproduct->duration_unit == 'w') + $prodDurationHours = 24. * 7; + if ($tmpproduct->duration_unit == 'm') + $prodDurationHours = 24. * 30; + if ($tmpproduct->duration_unit == 'y') + $prodDurationHours = 24. * 365; $prodDurationHours *= $tmpproduct->duration_value; $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0); @@ -433,7 +433,7 @@ if ($action == 'confirm_generateinvoice') if (!$error) { - if ($generateinvoicemode=='onelineperuser') { + if ($generateinvoicemode == 'onelineperuser') { $arrayoftasks = array(); foreach ($toselect as $key => $value) { @@ -460,7 +460,7 @@ if ($action == 'confirm_generateinvoice') } // Add lines - $lineid = $tmpinvoice->addline($langs->trans("TimeSpentForInvoice", $username).' : '.$qtyhourtext, $pu_ht, round($qtyhour/$prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); + $lineid = $tmpinvoice->addline($langs->trans("TimeSpentForInvoice", $username).' : '.$qtyhourtext, $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); // Update lineid into line of timespent $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.$lineid.', invoice_id = '.$tmpinvoice->id; @@ -474,7 +474,7 @@ if ($action == 'confirm_generateinvoice') } } } - elseif ($generateinvoicemode=='onelineperperiod') { + elseif ($generateinvoicemode == 'onelineperperiod') { $arrayoftasks = array(); foreach ($toselect as $key => $value) { @@ -504,7 +504,7 @@ if ($action == 'confirm_generateinvoice') } // Add lines - $lineid = $tmpinvoice->addline($value['note'], $pu_ht, round($qtyhour/$prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); + $lineid = $tmpinvoice->addline($value['note'], $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); // Update lineid into line of timespent $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.$lineid.', invoice_id = '.$tmpinvoice->id; @@ -518,7 +518,7 @@ if ($action == 'confirm_generateinvoice') } } } - elseif ($generateinvoicemode=='onelinepertask') { + elseif ($generateinvoicemode == 'onelinepertask') { $arrayoftasks = array(); foreach ($toselect as $key => $value) { @@ -545,7 +545,7 @@ if ($action == 'confirm_generateinvoice') // Add lines $lineName = $ftask->ref.' - '.$ftask->label; - $lineid = $tmpinvoice->addline($lineName, $pu_ht, round($qtyhour/$prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); + $lineid = $tmpinvoice->addline($lineName, $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); // Update lineid into line of timespent $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.$lineid.', invoice_id = '.$tmpinvoice->id; @@ -1346,7 +1346,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) print '
'; if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) { - $formproject->selectTasks(-1, GETPOST('taskid', 'int')?GETPOST('taskid', 'int'):$task_time->fk_task, 'taskid', 0, 0, 1, 1, 0, 0, 'maxwidth300', $projectstatic->id, ''); + $formproject->selectTasks(-1, GETPOST('taskid', 'int') ?GETPOST('taskid', 'int') : $task_time->fk_task, 'taskid', 0, 0, 1, 1, 0, 0, 'maxwidth300', $projectstatic->id, ''); } else { @@ -1392,11 +1392,11 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) } else { - $userstatic->id = $task_time->fk_user; + $userstatic->id = $task_time->fk_user; $userstatic->lastname = $task_time->lastname; - $userstatic->firstname = $task_time->firstname; - $userstatic->photo = $task_time->photo; - $userstatic->statut = $task_time->user_status; + $userstatic->firstname = $task_time->firstname; + $userstatic->photo = $task_time->photo; + $userstatic->statut = $task_time->user_status; print $userstatic->getNomUrl(-1); } print '
'."\n"; print ''; - if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) + if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) { print ''; } @@ -1346,7 +1346,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { foreach ($balance->available as $cpt) { - $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); + $arrayzerounitcurrency = array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); if (!in_array($cpt->currency, $arrayzerounitcurrency)) { $currencybalance[$cpt->currency]['available'] = $cpt->amount / 100; } else { @@ -1360,11 +1360,11 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { foreach ($balance->pending as $cpt) { - $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); + $arrayzerounitcurrency = array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); if (!in_array($cpt->currency, $arrayzerounitcurrency)) { - $currencybalance[$cpt->currency]['pending'] = $currencybalance[$cpt->currency]['available']+$cpt->amount / 100; + $currencybalance[$cpt->currency]['pending'] = $currencybalance[$cpt->currency]['available'] + $cpt->amount / 100; } else { - $currencybalance[$cpt->currency]['pending'] = $currencybalance[$cpt->currency]['available']+$cpt->amount; + $currencybalance[$cpt->currency]['pending'] = $currencybalance[$cpt->currency]['available'] + $cpt->amount; } } } @@ -1373,7 +1373,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { foreach ($currencybalance as $cpt) { - print ''; + print ''; } } @@ -1383,14 +1383,14 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' // List of bank accounts - $morehtmlright= dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=create'); + $morehtmlright = dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=create'); print load_fiche_titre($langs->trans("BankAccounts"), $morehtmlright, ''); $rib_list = $object->get_all_rib(); if (is_array($rib_list)) { - 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 '
'.$langs->trans('LocalID').'
'.$langs->trans("Currency".strtoupper($cpt['currency'])).''.price($cpt['available'], 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price($cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price($cpt['available']+$cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).'
'.$langs->trans("Currency".strtoupper($cpt['currency'])).''.price($cpt['available'], 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price($cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price($cpt['available'] + $cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).'
'; print ''; diff --git a/htdocs/stripe/charge.php b/htdocs/stripe/charge.php index d198555e421..bea6223ff32 100644 --- a/htdocs/stripe/charge.php +++ b/htdocs/stripe/charge.php @@ -26,17 +26,17 @@ require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.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('compta', 'salaries', 'bills', 'hrm', 'stripe')); // Security check $socid = GETPOST("socid", "int"); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; //$result = restrictedArea($user, 'salaries', '', '', ''); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $rowid = GETPOST("rowid", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); @@ -154,16 +154,16 @@ if (!$rowid) } // The metadata FULLTAG is defined by the online payment page - $FULLTAG=$charge->metadata->FULLTAG; + $FULLTAG = $charge->metadata->FULLTAG; // Save into $tmparray all metadata $tmparray = dolExplodeIntoArray($FULLTAG, '.', '='); // Load origin object according to metadata - if (! empty($tmparray['CUS']) && $tmparray['CUS'] > 0) + if (!empty($tmparray['CUS']) && $tmparray['CUS'] > 0) { $societestatic->fetch($tmparray['CUS']); } - elseif (! empty($charge->metadata->dol_thirdparty_id) && $charge->metadata->dol_thirdparty_id > 0) + elseif (!empty($charge->metadata->dol_thirdparty_id) && $charge->metadata->dol_thirdparty_id > 0) { $societestatic->fetch($charge->metadata->dol_thirdparty_id); } diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index bcd7a8bccb9..35adc33c749 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -589,7 +589,7 @@ class SupplierProposal extends CommonObject $productFournisseur->find_min_price_product_fournisseur($fk_product); $this->line->fk_fournprice = $productFournisseur->product_fourn_price_id; } else { - $this->line->fk_fournprice = ($fk_fournprice > 0 ? $fk_fournprice : 0); // If fk_fournprice is -1, we will not use fk_fournprice + $this->line->fk_fournprice = ($fk_fournprice > 0 ? $fk_fournprice : 0); // If fk_fournprice is -1, we will not use fk_fournprice } $this->line->pa_ht = $pa_ht; //var_dump($this->line->fk_fournprice);exit; @@ -777,9 +777,9 @@ class SupplierProposal extends CommonObject } $this->line->pa_ht = $pa_ht; - if (is_array($array_options) && count($array_options)>0) { + if (is_array($array_options) && count($array_options) > 0) { // We replace values in this->line->array_options only for entries defined into $array_options - foreach($array_options as $key => $value) { + foreach ($array_options as $key => $value) { $this->line->array_options[$key] = $array_options[$key]; } } diff --git a/htdocs/takepos/floors.php b/htdocs/takepos/floors.php index 01f0a0b4b25..8624948e6ff 100644 --- a/htdocs/takepos/floors.php +++ b/htdocs/takepos/floors.php @@ -25,65 +25,65 @@ //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 -$langs->loadLangs(array("bills","orders","commercial","cashdesk")); +$langs->loadLangs(array("bills", "orders", "commercial", "cashdesk")); -$floor=GETPOST('floor', 'int'); -if ($floor=="") $floor=1; +$floor = GETPOST('floor', 'int'); +if ($floor == "") $floor = 1; $id = GETPOST('id', 'int'); $action = GETPOST('action', 'alpha'); $left = GETPOST('left', 'alpha'); $top = GETPOST('top', 'alpha'); -$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant +$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant $newname = GETPOST('newname', 'alpha'); $mode = GETPOST('mode', 'alpha'); -if ($action=="getTables") +if ($action == "getTables") { - $sql="SELECT rowid, entity, label, leftpos, toppos, floor FROM ".MAIN_DB_PREFIX."takepos_floor_tables where floor=".$floor; + $sql = "SELECT rowid, entity, label, leftpos, toppos, floor FROM ".MAIN_DB_PREFIX."takepos_floor_tables where floor=".$floor; $resql = $db->query($sql); $rows = array(); - while($row = $db->fetch_array($resql)){ + while ($row = $db->fetch_array($resql)) { $rows[] = $row; } echo json_encode($rows); exit; } -if ($action=="update") +if ($action == "update") { - if ($left>95) $left=95; - if ($top>95) $top=95; - if ($left>3 or $top>4) $db->query("UPDATE ".MAIN_DB_PREFIX."takepos_floor_tables set leftpos=".$left.", toppos=".$top." WHERE rowid='".$place."'"); + if ($left > 95) $left = 95; + if ($top > 95) $top = 95; + if ($left > 3 or $top > 4) $db->query("UPDATE ".MAIN_DB_PREFIX."takepos_floor_tables set leftpos=".$left.", toppos=".$top." WHERE rowid='".$place."'"); else $db->query("DELETE from ".MAIN_DB_PREFIX."takepos_floor_tables where rowid='".$place."'"); } -if ($action=="updatename") +if ($action == "updatename") { $newname = preg_replace("/[^a-zA-Z0-9\s]/", "", $newname); // Only English chars if (strlen($newname) > 3) $newname = substr($newname, 0, 3); // Only 3 chars $db->query("UPDATE ".MAIN_DB_PREFIX."takepos_floor_tables set label='".$db->escape($newname)."' WHERE rowid='".$place."'"); } -if ($action=="add") +if ($action == "add") { - $sql="INSERT INTO ".MAIN_DB_PREFIX."takepos_floor_tables(entity, label, leftpos, toppos, floor) VALUES (".$conf->entity.", '', '45', '45', ".$floor.")"; - $asdf=$db->query($sql); + $sql = "INSERT INTO ".MAIN_DB_PREFIX."takepos_floor_tables(entity, label, leftpos, toppos, floor) VALUES (".$conf->entity.", '', '45', '45', ".$floor.")"; + $asdf = $db->query($sql); $db->query("update ".MAIN_DB_PREFIX."takepos_floor_tables set label=rowid where label=''"); // No empty table names } // Title -$title='TakePOS - Dolibarr '.DOL_VERSION; -if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title='TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE; +$title = 'TakePOS - Dolibarr '.DOL_VERSION; +if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $title = 'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE; top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); ?> @@ -169,10 +169,10 @@ $( document ).ready(function() { admin) {?> loadLangs(array("bills", "cashdesk")); -$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant +$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant $idline = GETPOST('idline', 'int'); $action = GETPOST('action', 'alpha'); @@ -46,7 +46,7 @@ $action = GETPOST('action', 'alpha'); */ $arrayofcss = array('/takepos/css/pos.css.php'); -$arrayofjs=array(); +$arrayofjs = array(); top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index 96ccea0a4d7..ec619015496 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -68,7 +68,7 @@ else } $arrayofcss = array('/takepos/css/pos.css.php'); -$arrayofjs=array(); +$arrayofjs = array(); top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); diff --git a/htdocs/takepos/receipt.php b/htdocs/takepos/receipt.php index 1ae64888095..1df223716fb 100644 --- a/htdocs/takepos/receipt.php +++ b/htdocs/takepos/receipt.php @@ -135,11 +135,11 @@ if ($conf->global->TAKEPOS_CUSTOM_RECEIPT && $conf->global->TAKEPOS_SHOW_CUSTOME - - - + + + global->TAKEPOS_CUSTOM_RECEIPT && $conf->global->TAKEPOS_SHOW_CUSTOME
product_label)) echo $line->product_label; - else echo $line->description;?> + else echo $line->description; ?> qty;?>total_ttc / $line->qty, 'MT'), 1);?>total_ttc, 1);?>qty; ?>total_ttc / $line->qty, 'MT'), 1); ?>total_ttc, 1); ?>
- - + + -global->TAKEPOS_TICKET_VAT_GROUPPED) { +global->TAKEPOS_TICKET_VAT_GROUPPED) { $vat_groups = array(); foreach ($object->lines as $line) { - if(!array_key_exists($line->tva_tx, $vat_groups)) { + if (!array_key_exists($line->tva_tx, $vat_groups)) { $vat_groups[$line->tva_tx] = 0; } $vat_groups[$line->tva_tx] += $line->total_tva; } - foreach($vat_groups as $key => $val) { + foreach ($vat_groups as $key => $val) { ?> - - + + - + - +
trans("TotalHT");?>total_ht, 1, '', 1, - 1, - 1, $conf->currency)."\n";?>trans("TotalHT"); ?>total_ht, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?>
trans("VAT").' '.vatrate($key, 1);?>currency)."\n";?>trans("VAT").' '.vatrate($key, 1); ?>currency)."\n"; ?>
trans("TotalVAT").''.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency)."\n";?>trans("TotalVAT").''.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?>
trans("TotalTTC").''.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency)."\n";?>trans("TotalTTC").''.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?>
diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index 0c594bc3f13..75145154c22 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -565,7 +565,7 @@ function OpenDrawer(){ console.log("OpenDrawer"); $.ajax({ type: "POST", - url: 'http://global->TAKEPOS_PRINT_SERVER;?>:8111/print', + url: 'http://global->TAKEPOS_PRINT_SERVER; ?>:8111/print', data: "opendrawer" }); } @@ -667,10 +667,10 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { trans("Customer"); ?>
- " autofocus> + " autofocus> - - + +
@@ -679,7 +679,7 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { } ?> -
+
@@ -747,7 +747,7 @@ else $menus[$r++] = array('title'=>'
'.$langs->trans("Place").'
', 'action'=>'Floors();'); } -if (! empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { +if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { $menus[$r++] = array('title'=>'
'.$langs->trans("Customer").'
', 'action'=>'Customer();'); } $menus[$r++] = array('title'=>'
'.$langs->trans("History").'
', 'action'=>'History();'); @@ -763,29 +763,29 @@ if ($conf->global->TAKEPOS_BAR_RESTAURANT) { if ($conf->global->TAKEPOS_ORDER_PRINTERS) { - $menus[$r++]=array('title'=>$langs->trans("Order"), 'action'=>'TakeposPrintingOrder();'); + $menus[$r++] = array('title'=>$langs->trans("Order"), 'action'=>'TakeposPrintingOrder();'); } //add temp ticket button if ($conf->global->TAKEPOS_BAR_RESTAURANT) { if ($conf->global->TAKEPOSCONNECTOR) { - $menus[$r++]=array('title'=>'
'.$langs->trans("Receipt").'
','action'=>'TakeposPrinting(placeid);'); + $menus[$r++] = array('title'=>'
'.$langs->trans("Receipt").'
', 'action'=>'TakeposPrinting(placeid);'); } else { - $menus[$r++]=array('title'=>'
'.$langs->trans("Receipt").'
','action'=>'Print(placeid);'); + $menus[$r++] = array('title'=>'
'.$langs->trans("Receipt").'
', 'action'=>'Print(placeid);'); } } - if ($conf->global->TAKEPOSCONNECTOR && $conf->global->TAKEPOS_ORDER_NOTES==1) + if ($conf->global->TAKEPOSCONNECTOR && $conf->global->TAKEPOS_ORDER_NOTES == 1) { - $menus[$r++]=array('title'=>'
'.$langs->trans("OrderNotes").'
', 'action'=>'TakeposOrderNotes();'); + $menus[$r++] = array('title'=>'
'.$langs->trans("OrderNotes").'
', 'action'=>'TakeposOrderNotes();'); } if ($conf->global->TAKEPOS_SUPPLEMENTS) { - $menus[$r++]=array('title'=>'
'.$langs->trans("ProductSupplements").'
', 'action'=>'LoadProducts(\'supplements\');'); + $menus[$r++] = array('title'=>'
'.$langs->trans("ProductSupplements").'
', 'action'=>'LoadProducts(\'supplements\');'); } } if ($conf->global->TAKEPOSCONNECTOR) { - $menus[$r++]=array('title'=>'
'.$langs->trans("DOL_OPEN_DRAWER").'
', 'action'=>'OpenDrawer();'); + $menus[$r++] = array('title'=>'
'.$langs->trans("DOL_OPEN_DRAWER").'
', 'action'=>'OpenDrawer();'); } if ($conf->global->TAKEPOS_DOLIBARR_PRINTER) { $menus[$r++] = array( @@ -795,17 +795,17 @@ if ($conf->global->TAKEPOS_DOLIBARR_PRINTER) { } $hookmanager->initHooks(array('takeposfrontend')); -$reshook=$hookmanager->executeHooks('ActionButtons'); +$reshook = $hookmanager->executeHooks('ActionButtons'); if (!empty($reshook)) { - $menus[$r++]=$reshook; + $menus[$r++] = $reshook; } -if ($r % 3 == 2) $menus[$r++]=array('title'=>'', 'style'=>'visibility: hidden;'); +if ($r % 3 == 2) $menus[$r++] = array('title'=>'', 'style'=>'visibility: hidden;'); -$menus[$r++]=array('title'=>'
'.$langs->trans("BackOffice").'
', 'action'=>'window.open(\''.(DOL_URL_ROOT ? DOL_URL_ROOT : '/').'\', \'_backoffice\');'); +$menus[$r++] = array('title'=>'
'.$langs->trans("BackOffice").'
', 'action'=>'window.open(\''.(DOL_URL_ROOT ? DOL_URL_ROOT : '/').'\', \'_backoffice\');'); -if (! empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { - $menus[$r++]=array('title'=>'
'.$langs->trans("Logout").'
', 'action'=>'window.location.href=\''.DOL_URL_ROOT.'/user/logout.php\';'); +if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { + $menus[$r++] = array('title'=>'
'.$langs->trans("Logout").'
', 'action'=>'window.location.href=\''.DOL_URL_ROOT.'/user/logout.php\';'); } ?> @@ -813,7 +813,7 @@ if (! empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
9 and $i == 9) @@ -825,7 +825,7 @@ if (! empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { else echo ''; } - if (! empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { + if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { print ''."\n"; print '
'; print ' '; @@ -836,7 +836,7 @@ if (! empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
-
+
diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index 268f1885327..8f5820c6d6f 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -1,5 +1,5 @@ +if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> /*