From 74239d48bff092a554afc26ba8eaba94db07cea4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Nov 2019 11:11:08 +0100 Subject: [PATCH 01/47] Fix translation of extrafields when $extralabels not loaded --- htdocs/core/tpl/extrafields_list_search_title.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/extrafields_list_search_title.tpl.php b/htdocs/core/tpl/extrafields_list_search_title.tpl.php index 5772f3fc989..aea871b1109 100644 --- a/htdocs/core/tpl/extrafields_list_search_title.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_title.tpl.php @@ -24,7 +24,7 @@ if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_ $sortonfield = $extrafieldsobjectprefix.$key; if (! empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key])) $sortonfield=''; if ($extrafields->attributes[$extrafieldsobjectkey]['type'][$key] == 'separate') print ''; - else print getTitleFieldOfList($langs->trans($extralabels[$key]), 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'" data-titlekey="'.$key.'"':'data-titlekey="'.$key.'"'), $sortfield, $sortorder)."\n"; + else print getTitleFieldOfList($langs->trans($extrafields->attributes[$extrafieldsobjectkey]['label'][$key]), 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'" data-titlekey="'.$key.'"':'data-titlekey="'.$key.'"'), $sortfield, $sortorder)."\n"; } } } From 0497c399d7a6d6cdf2cde60cc2fe0859ada2de0a Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 13 Nov 2019 14:59:07 +0100 Subject: [PATCH 02/47] Missing language key --- htdocs/langs/en_US/holiday.lang | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index c3cdda3cfd6..bfff50de4c8 100644 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -127,4 +127,5 @@ HolidaysNumberingModules=Leave requests numbering models TemplatePDFHolidays=Template for leave requests PDF FreeLegalTextOnHolidays=Free text on PDF WatermarkOnDraftHolidayCards=Watermarks on draft leave requests -HolidaysToApprove=Holidays to approve \ No newline at end of file +HolidaysToApprove=Holidays to approve +NobodyHasPermissionToValidateHolidays=Nobody has permission to validate holidays From 85e2546019b3a63de87ba885433b31c9bdc3e70c Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 13 Nov 2019 15:25:23 +0100 Subject: [PATCH 03/47] Missing language key --- htdocs/langs/en_US/admin.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index de1e5f52fcd..d70bfe959e9 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -857,6 +857,7 @@ Permission20003=Delete leave requests Permission20004=Read all leave requests (even of user not subordinates) Permission20005=Create/modify leave requests for everybody (even of user not subordinates) Permission20006=Admin leave requests (setup and update balance) +Permission20007=Approve leave requests Permission23001=Read Scheduled job Permission23002=Create/update Scheduled job Permission23003=Delete Scheduled job From 3ec7568559fc3852cbe83c954e4f8b0fb676ee92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 13 Nov 2019 20:44:21 +0100 Subject: [PATCH 04/47] FIX #12385 --- htdocs/comm/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index be60c4fa574..49a12f6c490 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -477,7 +477,7 @@ if ($object->id > 0) print ''; if ($action == 'editshipping') { - $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->shipping_method_id,'shipping_method_id'); + $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->shipping_method_id,'shipping_method_id', 1); } else { From 75667833feb0618541b889f63a98f2f4977ebd84 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Nov 2019 10:01:05 +0100 Subject: [PATCH 05/47] Fix missing ->msgid --- htdocs/core/class/CMailFile.class.php | 20 ++++++++++++++------ htdocs/core/class/smtps.class.php | 7 ------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 22ba7b66ec8..335c1b50111 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -78,6 +78,7 @@ class CMailFile //! Defined background directly in body tag public $bodyCSS; + public $msgid; public $headers; public $message; /** @@ -263,7 +264,8 @@ class CMailFile // Add autocopy to (Note: Adding bcc for specific modules are also done from pages) if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) $addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO; - // Action according to choosed sending method + // We set all data according to choosed sending method. + // We also set a value for ->msgid if ($this->sendmode == 'mail') { // Use mail php function (default PHP method) @@ -274,7 +276,7 @@ class CMailFile $text_body = ""; $files_encoded = ""; - // Define smtp_headers + // Define smtp_headers (this also set ->msgid) $smtp_headers = $this->write_smtpheaders(); if (!empty($moreinheader)) $smtp_headers .= $moreinheader; // $moreinheader contains the \r\n @@ -365,6 +367,9 @@ class CMailFile $smtps->setErrorsTo($errors_to); $smtps->setDeliveryReceipt($deliveryreceipt); + $host=dol_getprefix('email'); + $this->msgid = time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host; + $this->smtps = $smtps; } elseif ($this->sendmode == 'swiftmailer') @@ -386,7 +391,8 @@ class CMailFile // Adding a trackid header to a message $headers = $this->message->getHeaders(); $headers->addTextHeader('X-Dolibarr-TRACKID', $trackid.'@'.$host); - $headerID = time().'.swiftmailer-dolibarr-'.$trackid.'@'.$host; + $this->msgid = time().'.swiftmailer-dolibarr-'.$trackid.'@'.$host; + $headerID = $this->msgid; $msgid = $headers->get('Message-ID'); $msgid->setId($headerID); $headers->addIdHeader('References', $headerID); @@ -1038,13 +1044,15 @@ class CMailFile if ($trackid) { // References is kept in response and Message-ID is returned into In-Reply-To: - $out .= 'Message-ID: <'.time().'.phpmail-dolibarr-'.$trackid.'@'.$host.">".$this->eol2; // Uppercase seems replaced by phpmail - $out .= 'References: <'.time().'.phpmail-dolibarr-'.$trackid.'@'.$host.">".$this->eol2; + $this->msgid = time().'.phpmail-dolibarr-'.$trackid.'@'.$host; + $out .= 'Message-ID: <'.$this->msgid.">".$this->eol2; // Uppercase seems replaced by phpmail + $out .= 'References: <'.$this->msgid.">".$this->eol2; $out .= 'X-Dolibarr-TRACKID: '.$trackid.'@'.$host.$this->eol2; } else { - $out .= 'Message-ID: <'.time().'.phpmail@'.$host.">".$this->eol2; + $this->msgid = time().'.phpmail@'.$host; + $out .= 'Message-ID: <'.$this->msgid.">".$this->eol2; } if (!empty($_SERVER['REMOTE_ADDR'])) $out .= "X-RemoteAddr: ".$_SERVER['REMOTE_ADDR'].$this->eol2; diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index 5c5975b9284..9eebf9091b2 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -1304,13 +1304,6 @@ class SMTPs $_header .= 'Bcc: ' . $this->getBCC() . "\r\n"; */ - $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=dol_getprefix('email'); //NOTE: Message-ID should probably contain the username of the user who sent the msg From 52787b56b25fbb6e37cb1074c96a823cf1851abd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Nov 2019 11:00:49 +0100 Subject: [PATCH 06/47] Fix when limit = 0 Look and feel v11 --- htdocs/admin/mails.php | 6 +- htdocs/admin/mails_emailing.php | 6 +- htdocs/admin/mails_senderprofile_list.php | 193 ++++++++++++------ htdocs/core/lib/admin.lib.php | 2 +- htdocs/core/lib/functions.lib.php | 6 +- htdocs/langs/en_US/admin.lang | 1 + .../modulebuilder/template/myobject_list.php | 10 +- 7 files changed, 151 insertions(+), 73 deletions(-) diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index d459de3707b..c52f899a03f 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -111,6 +111,8 @@ if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'testhtml') $ * View */ +$form = new Form($db); + $linuxlike=1; if (preg_match('/^win/i', PHP_OS)) $linuxlike=0; if (preg_match('/^mac/i', PHP_OS)) $linuxlike=0; @@ -139,8 +141,6 @@ $listofmethods['swiftmailer']='Swift Mailer socket library'; if ($action == 'edit') { - $form=new Form($db); - if ($conf->use_javascript_ajax) { print "\n".''; // Checkbox to select from free text -print ' '.$langs->trans("FillBarCodeTypeAndValueManually").'   '; +print ' '.$langs->trans("FillBarCodeTypeAndValueManually").'   '; print '
'; -if (! empty($user->rights->produit->lire) || ! empty($user->rights->service->lire)) +if (!empty($user->rights->produit->lire) || !empty($user->rights->service->lire)) { - print ' '.$langs->trans("FillBarCodeTypeAndValueFromProduct").'   '; + print ' '.$langs->trans("FillBarCodeTypeAndValueFromProduct").'   '; print '
'; print '
'; $form->select_produits(GETPOST('productid'), 'productid', '', '', 0, -1, 2, '', 0, array(), 0, '1', 0, 'minwidth400imp', 1); @@ -385,9 +385,9 @@ if (! empty($user->rights->produit->lire) || ! empty($user->rights->service->lir print '
'; } -if (! empty($user->rights->societe->lire)) +if (!empty($user->rights->societe->lire)) { - print ' '.$langs->trans("FillBarCodeTypeAndValueFromThirdParty").'   '; + print ' '.$langs->trans("FillBarCodeTypeAndValueFromThirdParty").'   '; print '
'; print '
'; print $form->select_company(GETPOST('socid'), 'socid', '', 'SelectThirdParty', 0, 0, array(), 0, 'minwidth300'); @@ -435,7 +435,7 @@ print '
'; print '
'; -print '
'; +print '
'; print ''; print '
'; diff --git a/htdocs/blockedlog/class/authority.class.php b/htdocs/blockedlog/class/authority.class.php index cec6410b7b6..234aeceb2a6 100644 --- a/htdocs/blockedlog/class/authority.class.php +++ b/htdocs/blockedlog/class/authority.class.php @@ -67,12 +67,12 @@ class BlockedLogAuthority $this->signature = $block_static->getSignature(); - $blocks = $block_static->getLog('all', 0, 0, 'rowid', 'ASC') ; + $blocks = $block_static->getLog('all', 0, 0, 'rowid', 'ASC'); $this->blockchain = ''; - foreach($blocks as &$b) { - $this->blockchain.=$b->signature; + foreach ($blocks as &$b) { + $this->blockchain .= $b->signature; } return $this->blockchain; @@ -98,7 +98,7 @@ class BlockedLogAuthority public function checkBlockchain($hash) { - return ($hash === $this->getBlockchainHash() ); + return ($hash === $this->getBlockchainHash()); } /** @@ -110,7 +110,7 @@ class BlockedLogAuthority public function addBlock($block) { - $this->blockchain.=$block; + $this->blockchain .= $block; } /** @@ -122,14 +122,14 @@ class BlockedLogAuthority public function checkBlock($block) { - if(strlen($block)!=64) return false; + if (strlen($block) != 64) return false; $blocks = str_split($this->blockchain, 64); - if(!in_array($block, $blocks)) { + if (!in_array($block, $blocks)) { return true; } - else{ + else { return false; } } @@ -151,44 +151,44 @@ class BlockedLogAuthority if (empty($id) && empty($signature)) { - $this->error='BadParameter'; + $this->error = 'BadParameter'; return -1; } $langs->load("blockedlog"); $sql = "SELECT b.rowid, b.signature, b.blockchain, b.tms"; - $sql.= " FROM ".MAIN_DB_PREFIX."blockedlog_authority as b"; + $sql .= " FROM ".MAIN_DB_PREFIX."blockedlog_authority as b"; - if ($id) $sql.= " WHERE b.rowid = ". $id; - elseif($signature)$sql.= " WHERE b.signature = '". $this->db->escape($signature) ."'" ; + if ($id) $sql .= " WHERE b.rowid = ".$id; + elseif ($signature)$sql .= " WHERE b.signature = '".$this->db->escape($signature)."'"; - $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->ref = $obj->rowid; + $this->id = $obj->rowid; + $this->ref = $obj->rowid; - $this->signature = $obj->signature; - $this->blockchain = $obj->blockchain; + $this->signature = $obj->signature; + $this->blockchain = $obj->blockchain; - $this->tms = $this->db->jdate($obj->tms); + $this->tms = $this->db->jdate($obj->tms); return 1; } else { - $this->error=$langs->trans("RecordNotFound"); + $this->error = $langs->trans("RecordNotFound"); return 0; } } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -202,23 +202,23 @@ class BlockedLogAuthority public function create($user) { - global $conf,$langs,$hookmanager; + global $conf, $langs, $hookmanager; $langs->load('blockedlog'); - $error=0; + $error = 0; dol_syslog(get_class($this).'::create', LOG_DEBUG); $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."blockedlog_authority ("; - $sql.= " signature,"; - $sql.= " blockchain"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->escape($this->signature)."',"; - $sql.= "'".$this->db->escape($this->blockchain)."'"; - $sql.= ")"; + $sql .= " signature,"; + $sql .= " blockchain"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->escape($this->signature)."',"; + $sql .= "'".$this->db->escape($this->blockchain)."'"; + $sql .= ")"; $res = $this->db->query($sql); if ($res) @@ -241,7 +241,7 @@ class BlockedLogAuthority } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -256,19 +256,19 @@ class BlockedLogAuthority public function update($user) { - global $conf,$langs,$hookmanager; + global $conf, $langs, $hookmanager; $langs->load('blockedlog'); - $error=0; + $error = 0; dol_syslog(get_class($this).'::create', LOG_DEBUG); $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."blockedlog_authority SET "; - $sql.= " blockchain='".$this->db->escape($this->blockchain)."'"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " blockchain='".$this->db->escape($this->blockchain)."'"; + $sql .= " WHERE rowid=".$this->id; $res = $this->db->query($sql); if ($res) @@ -279,7 +279,7 @@ class BlockedLogAuthority } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -296,7 +296,7 @@ class BlockedLogAuthority //TODO create cron task on activation - if(empty($conf->global->BLOCKEDLOG_AUTHORITY_URL) || empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) { + if (empty($conf->global->BLOCKEDLOG_AUTHORITY_URL) || empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) { $this->error = $langs->trans('NoAuthorityURLDefined'); return -2; } @@ -307,14 +307,14 @@ class BlockedLogAuthority $blocks = $block_static->getLog('not_certified', 0, 0, 'rowid', 'ASC'); - $signature=$block_static->getSignature(); + $signature = $block_static->getSignature(); - foreach($blocks as &$block) { + foreach ($blocks as &$block) { $url = $conf->global->BLOCKEDLOG_AUTHORITY_URL.'/blockedlog/ajax/authority.php?s='.$signature.'&b='.$block->signature; $res = file_get_contents($url); - echo $block->signature.' '.$url. ' '.$res.'
'; - if($res === 'blockalreadyadded' || $res === 'blockadded') { + echo $block->signature.' '.$url.' '.$res.'
'; + if ($res === 'blockalreadyadded' || $res === 'blockadded') { $block->setCertified(); } else { diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 14dbd9941b7..3c6f7563590 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -115,7 +115,7 @@ class BlockedLog public $ref_object = ''; public $object_data = null; - public $user_fullname=''; + public $user_fullname = ''; /** * Array of tracked event codes @@ -138,14 +138,14 @@ class BlockedLog $this->trackedevents = array(); - if ($conf->facture->enabled) $this->trackedevents['BILL_VALIDATE']='logBILL_VALIDATE'; - if ($conf->facture->enabled) $this->trackedevents['BILL_DELETE']='logBILL_DELETE'; - if ($conf->facture->enabled) $this->trackedevents['BILL_SENTBYMAIL']='logBILL_SENTBYMAIL'; - if ($conf->facture->enabled) $this->trackedevents['DOC_DOWNLOAD']='BlockedLogBillDownload'; - if ($conf->facture->enabled) $this->trackedevents['DOC_PREVIEW']='BlockedLogBillPreview'; + if ($conf->facture->enabled) $this->trackedevents['BILL_VALIDATE'] = 'logBILL_VALIDATE'; + if ($conf->facture->enabled) $this->trackedevents['BILL_DELETE'] = 'logBILL_DELETE'; + if ($conf->facture->enabled) $this->trackedevents['BILL_SENTBYMAIL'] = 'logBILL_SENTBYMAIL'; + if ($conf->facture->enabled) $this->trackedevents['DOC_DOWNLOAD'] = 'BlockedLogBillDownload'; + if ($conf->facture->enabled) $this->trackedevents['DOC_PREVIEW'] = 'BlockedLogBillPreview'; - if ($conf->facture->enabled) $this->trackedevents['PAYMENT_CUSTOMER_CREATE']='logPAYMENT_CUSTOMER_CREATE'; - if ($conf->facture->enabled) $this->trackedevents['PAYMENT_CUSTOMER_DELETE']='logPAYMENT_CUSTOMER_DELETE'; + if ($conf->facture->enabled) $this->trackedevents['PAYMENT_CUSTOMER_CREATE'] = 'logPAYMENT_CUSTOMER_CREATE'; + if ($conf->facture->enabled) $this->trackedevents['PAYMENT_CUSTOMER_DELETE'] = 'logPAYMENT_CUSTOMER_DELETE'; /* Supplier if ($conf->fournisseur->enabled) $this->trackedevents['BILL_SUPPLIER_VALIDATE']='BlockedLogSupplierBillValidate'; @@ -158,12 +158,12 @@ class BlockedLog if ($conf->fournisseur->enabled) $this->trackedevents['PAYMENT_SUPPLIER_DELETE']='BlockedLogsupplierBillPaymentCreate'; */ - if ($conf->don->enabled) $this->trackedevents['DON_VALIDATE']='logDON_VALIDATE'; - if ($conf->don->enabled) $this->trackedevents['DON_DELETE']='logDON_DELETE'; + if ($conf->don->enabled) $this->trackedevents['DON_VALIDATE'] = 'logDON_VALIDATE'; + if ($conf->don->enabled) $this->trackedevents['DON_DELETE'] = 'logDON_DELETE'; //if ($conf->don->enabled) $this->trackedevents['DON_SENTBYMAIL']='logDON_SENTBYMAIL'; - if ($conf->don->enabled) $this->trackedevents['DONATION_PAYMENT_CREATE']='logDONATION_PAYMENT_CREATE'; - if ($conf->don->enabled) $this->trackedevents['DONATION_PAYMENT_DELETE']='logDONATION_PAYMENT_DELETE'; + if ($conf->don->enabled) $this->trackedevents['DONATION_PAYMENT_CREATE'] = 'logDONATION_PAYMENT_CREATE'; + if ($conf->don->enabled) $this->trackedevents['DONATION_PAYMENT_DELETE'] = 'logDONATION_PAYMENT_DELETE'; /* if ($conf->salary->enabled) $this->trackedevents['PAYMENT_SALARY_CREATE']='BlockedLogSalaryPaymentCreate'; @@ -171,18 +171,18 @@ class BlockedLog if ($conf->salary->enabled) $this->trackedevents['PAYMENT_SALARY_DELETE']='BlockedLogSalaryPaymentCreate'; */ - if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_CREATE']='logMEMBER_SUBSCRIPTION_CREATE'; - if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_MODIFY']='logMEMBER_SUBSCRIPTION_MODIFY'; - if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_DELETE']='logMEMBER_SUBSCRIPTION_DELETE'; + if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_CREATE'] = 'logMEMBER_SUBSCRIPTION_CREATE'; + if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_MODIFY'] = 'logMEMBER_SUBSCRIPTION_MODIFY'; + if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_DELETE'] = 'logMEMBER_SUBSCRIPTION_DELETE'; - if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_CREATE']='logPAYMENT_VARIOUS_CREATE'; - if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_MODIFY']='logPAYMENT_VARIOUS_MODIFY'; - if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_DELETE']='logPAYMENT_VARIOUS_DELETE'; + if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_CREATE'] = 'logPAYMENT_VARIOUS_CREATE'; + if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_MODIFY'] = 'logPAYMENT_VARIOUS_MODIFY'; + if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_DELETE'] = 'logPAYMENT_VARIOUS_DELETE'; // $conf->global->BANK_ENABLE_POS_CASHCONTROL must be set to 1 by all POS modules - $moduleposenabled = ($conf->cashdesk->enabled || $conf->takepos->enabled || ! empty($conf->global->BANK_ENABLE_POS_CASHCONTROL)); - if ($moduleposenabled) $this->trackedevents['CASHCONTROL_VALIDATE']='logCASHCONTROL_VALIDATE'; + $moduleposenabled = ($conf->cashdesk->enabled || $conf->takepos->enabled || !empty($conf->global->BANK_ENABLE_POS_CASHCONTROL)); + if ($moduleposenabled) $this->trackedevents['CASHCONTROL_VALIDATE'] = 'logCASHCONTROL_VALIDATE'; } /** @@ -193,102 +193,102 @@ class BlockedLog { global $langs; - if($this->element === 'facture') { + if ($this->element === 'facture') { require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $object = new Facture($this->db); - if ($object->fetch($this->fk_object)>0) { + if ($object->fetch($this->fk_object) > 0) { return $object->getNomUrl(1); } - else{ + else { $this->error++; } } - if($this->element === 'invoice_supplier') { + if ($this->element === 'invoice_supplier') { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; $object = new FactureFournisseur($this->db); - if ($object->fetch($this->fk_object)>0) { + if ($object->fetch($this->fk_object) > 0) { return $object->getNomUrl(1); } - else{ + else { $this->error++; } } - elseif($this->element === 'payment') { + elseif ($this->element === 'payment') { require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; $object = new Paiement($this->db); - if ($object->fetch($this->fk_object)>0) { + if ($object->fetch($this->fk_object) > 0) { return $object->getNomUrl(1); } - else{ + else { $this->error++; } } - elseif($this->element === 'payment_supplier') { + elseif ($this->element === 'payment_supplier') { require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; $object = new PaiementFourn($this->db); - if ($object->fetch($this->fk_object)>0) { + if ($object->fetch($this->fk_object) > 0) { return $object->getNomUrl(1); } - else{ + else { $this->error++; } } - elseif($this->element === 'payment_donation') { + elseif ($this->element === 'payment_donation') { require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php'; $object = new PaymentDonation($this->db); - if ($object->fetch($this->fk_object)>0) { + if ($object->fetch($this->fk_object) > 0) { return $object->getNomUrl(1); } - else{ + else { $this->error++; } } - elseif($this->element === 'payment_various') { + elseif ($this->element === 'payment_various') { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; $object = new PaymentVarious($this->db); - if ($object->fetch($this->fk_object)>0) { + if ($object->fetch($this->fk_object) > 0) { return $object->getNomUrl(1); } - else{ + else { $this->error++; } } - elseif($this->element === 'don' || $this->element === 'donation') { + elseif ($this->element === 'don' || $this->element === 'donation') { require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; $object = new Don($this->db); - if ($object->fetch($this->fk_object)>0) { + if ($object->fetch($this->fk_object) > 0) { return $object->getNomUrl(1); } - else{ + else { $this->error++; } } - elseif($this->element === 'subscription') { + elseif ($this->element === 'subscription') { require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; $object = new Subscription($this->db); - if ($object->fetch($this->fk_object)>0) { + if ($object->fetch($this->fk_object) > 0) { return $object->getNomUrl(1); } - else{ + else { $this->error++; } } - elseif($this->element === 'cashcontrol') { + elseif ($this->element === 'cashcontrol') { require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php'; $object = new CashControl($this->db); - if ($object->fetch($this->fk_object)>0) { + if ($object->fetch($this->fk_object) > 0) { return $object->getNomUrl(1); } - else{ + else { $this->error++; } } @@ -318,16 +318,16 @@ class BlockedLog { global $langs, $cachedUser; - if(empty($cachedUser))$cachedUser=array(); + if (empty($cachedUser))$cachedUser = array(); - if(empty($cachedUser[$this->fk_user])) { - $u=new User($this->db); - if($u->fetch($this->fk_user)>0) { + if (empty($cachedUser[$this->fk_user])) { + $u = new User($this->db); + if ($u->fetch($this->fk_user) > 0) { $cachedUser[$this->fk_user] = $u; } } - if(!empty($cachedUser[$this->fk_user])) { + if (!empty($cachedUser[$this->fk_user])) { return $cachedUser[$this->fk_user]->getNomUrl(1); } @@ -354,25 +354,25 @@ class BlockedLog // action $this->action = $action; // amount - $this->amounts= $amounts; + $this->amounts = $amounts; // date if ($object->element == 'payment' || $object->element == 'payment_supplier') { $this->date_object = $object->datepaye; } - elseif ($object->element=='payment_salary') + elseif ($object->element == 'payment_salary') { $this->date_object = $object->datev; } elseif ($object->element == 'payment_donation' || $object->element == 'payment_various') { - $this->date_object = $object->datepaid?$object->datepaid:$object->datep; + $this->date_object = $object->datepaid ? $object->datepaid : $object->datep; } - elseif ($object->element=='subscription') + elseif ($object->element == 'subscription') { $this->date_object = $object->dateh; } - elseif ($object->element=='cashcontrol') + elseif ($object->element == 'cashcontrol') { $this->date_object = $object->date_creation; } @@ -380,7 +380,7 @@ class BlockedLog $this->date_object = $object->date; } // ref - $this->ref_object = ((! empty($object->newref)) ? $object->newref : $object->ref); // newref is set when validating a draft, ref is set in other cases + $this->ref_object = ((!empty($object->newref)) ? $object->newref : $object->ref); // newref is set when validating a draft, ref is set in other cases // type of object $this->element = $object->element; // id of object @@ -388,11 +388,11 @@ class BlockedLog // Set object_data - $this->object_data=new stdClass(); + $this->object_data = new stdClass(); // Add fields to exclude $arrayoffieldstoexclude = array( - 'table_element','fields','ref_previous','ref_next','origin','origin_id','oldcopy','picto','error','errors','modelpdf','last_main_doc','civility_id','contact','contact_id', - 'table_element_line','ismultientitymanaged','isextrafieldmanaged', + 'table_element', 'fields', 'ref_previous', 'ref_next', 'origin', 'origin_id', 'oldcopy', 'picto', 'error', 'errors', 'modelpdf', 'last_main_doc', 'civility_id', 'contact', 'contact_id', + 'table_element_line', 'ismultientitymanaged', 'isextrafieldmanaged', 'linkedObjectsIds', 'linkedObjects', 'fk_delivery_address', @@ -402,48 +402,48 @@ class BlockedLog // Add more fields to exclude depending on object type if ($this->element == 'cashcontrol') { $arrayoffieldstoexclude = array_merge($arrayoffieldstoexclude, array( - 'name','lastname','firstname','region','region_id','region_code','state','state_id','state_code','country','country_id','country_code', - 'total_ht','total_tva','total_ttc','total_localtax1','total_localtax2', - 'barcode_type','barcode_type_code','barcode_type_label','barcode_type_coder','mode_reglement_id','cond_reglement_id','mode_reglement','cond_reglement','shipping_method_id', - 'fk_incoterms','label_incoterms','location_incoterms','lines') + 'name', 'lastname', 'firstname', 'region', 'region_id', 'region_code', 'state', 'state_id', 'state_code', 'country', 'country_id', 'country_code', + 'total_ht', 'total_tva', 'total_ttc', 'total_localtax1', 'total_localtax2', + 'barcode_type', 'barcode_type_code', 'barcode_type_label', 'barcode_type_coder', 'mode_reglement_id', 'cond_reglement_id', 'mode_reglement', 'cond_reglement', 'shipping_method_id', + 'fk_incoterms', 'label_incoterms', 'location_incoterms', 'lines') ); } // Add thirdparty info if (empty($object->thirdparty) && method_exists($object, 'fetch_thirdparty')) $object->fetch_thirdparty(); - if (! empty($object->thirdparty)) + if (!empty($object->thirdparty)) { $this->object_data->thirdparty = new stdClass(); - foreach($object->thirdparty as $key=>$value) + foreach ($object->thirdparty as $key=>$value) { - if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties - if (! in_array($key, array( - 'name','name_alias','ref_ext','address','zip','town','state_code','country_code','idprof1','idprof2','idprof3','idprof4','idprof5','idprof6','phone','fax','email','barcode', + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties + if (!in_array($key, array( + 'name', 'name_alias', 'ref_ext', 'address', 'zip', 'town', 'state_code', 'country_code', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', 'phone', 'fax', 'email', 'barcode', 'tva_intra', 'localtax1_assuj', 'localtax1_value', 'localtax2_assuj', 'localtax2_value', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur' - ))) continue; // Discard if not into a dedicated list + ))) continue; // Discard if not into a dedicated list if (!is_object($value)) $this->object_data->thirdparty->{$key} = $value; } } // Add company info - if (! empty($mysoc)) + if (!empty($mysoc)) { $this->object_data->mycompany = new stdClass(); - foreach($mysoc as $key=>$value) + foreach ($mysoc as $key=>$value) { - if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties - if (! in_array($key, array( - 'name','name_alias','ref_ext','address','zip','town','state_code','country_code','idprof1','idprof2','idprof3','idprof4','idprof5','idprof6','phone','fax','email','barcode', + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties + if (!in_array($key, array( + 'name', 'name_alias', 'ref_ext', 'address', 'zip', 'town', 'state_code', 'country_code', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', 'phone', 'fax', 'email', 'barcode', 'tva_intra', 'localtax1_assuj', 'localtax1_value', 'localtax2_assuj', 'localtax2_value', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur' - ))) continue; // Discard if not into a dedicated list + ))) continue; // Discard if not into a dedicated list if (!is_object($value)) $this->object_data->mycompany->{$key} = $value; } } // Add user info - if (! empty($user)) + if (!empty($user)) { $this->fk_user = $user->id; $this->user_fullname = $user->getFullName($langs); @@ -452,25 +452,25 @@ class BlockedLog // Field specific to object if ($this->element == 'facture') { - foreach($object as $key=>$value) + foreach ($object as $key=>$value) { - if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties - if (! in_array($key, array( - 'ref','ref_client','ref_supplier','date','datef','datev','type','total_ht','total_tva','total_ttc','localtax1','localtax2','revenuestamp','datepointoftax','note_public','lines' - ))) continue; // Discard if not into a dedicated list + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties + if (!in_array($key, array( + 'ref', 'ref_client', 'ref_supplier', 'date', 'datef', 'datev', 'type', 'total_ht', 'total_tva', 'total_ttc', 'localtax1', 'localtax2', 'revenuestamp', 'datepointoftax', 'note_public', 'lines' + ))) continue; // Discard if not into a dedicated list if ($key == 'lines') { - $lineid=0; - foreach($value as $tmpline) // $tmpline is object FactureLine + $lineid = 0; + foreach ($value as $tmpline) // $tmpline is object FactureLine { $lineid++; - foreach($tmpline as $keyline => $valueline) + foreach ($tmpline as $keyline => $valueline) { - if (! in_array($keyline, array( - 'ref','multicurrency_code','multicurrency_total_ht','multicurrency_total_tva','multicurrency_total_ttc','qty','product_type','vat_src_code','tva_tx','info_bits','localtax1_tx','localtax2_tx','total_ht','total_tva','total_ttc','total_localtax1','total_localtax2' - ))) continue; // Discard if not into a dedicated list + if (!in_array($keyline, array( + 'ref', 'multicurrency_code', 'multicurrency_total_ht', 'multicurrency_total_tva', 'multicurrency_total_ttc', 'qty', 'product_type', 'vat_src_code', 'tva_tx', 'info_bits', 'localtax1_tx', 'localtax2_tx', 'total_ht', 'total_tva', 'total_ttc', 'total_localtax1', 'total_localtax2' + ))) continue; // Discard if not into a dedicated list - if (! is_object($this->object_data->invoiceline[$lineid])) $this->object_data->invoiceline[$lineid] = new stdClass(); + if (!is_object($this->object_data->invoiceline[$lineid])) $this->object_data->invoiceline[$lineid] = new stdClass(); $this->object_data->invoiceline[$lineid]->{$keyline} = $valueline; } @@ -479,43 +479,43 @@ class BlockedLog elseif (!is_object($value)) $this->object_data->{$key} = $value; } - if (! empty($object->newref)) $this->object_data->ref = $object->newref; + if (!empty($object->newref)) $this->object_data->ref = $object->newref; } elseif ($this->element == 'invoice_supplier') { - foreach($object as $key=>$value) + foreach ($object as $key=>$value) { - if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties - if (! in_array($key, array( - 'ref','ref_client','ref_supplier','date','datef','type','total_ht','total_tva','total_ttc','localtax1','localtax2','revenuestamp','datepointoftax','note_public' - ))) continue; // Discard if not into a dedicated list + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties + if (!in_array($key, array( + 'ref', 'ref_client', 'ref_supplier', 'date', 'datef', 'type', 'total_ht', 'total_tva', 'total_ttc', 'localtax1', 'localtax2', 'revenuestamp', 'datepointoftax', 'note_public' + ))) continue; // Discard if not into a dedicated list if (!is_object($value)) $this->object_data->{$key} = $value; } - if (! empty($object->newref)) $this->object_data->ref = $object->newref; + if (!empty($object->newref)) $this->object_data->ref = $object->newref; } elseif ($this->element == 'payment' || $this->element == 'payment_supplier' || $this->element == 'payment_donation' || $this->element == 'payment_various') { - $datepayment = $object->datepaye?$object->datepaye:($object->datepaid?$object->datepaid:$object->datep); - $paymenttypeid = $object->paiementid?$object->paiementid:($object->paymenttype?$object->paymenttype:$object->type_payment); + $datepayment = $object->datepaye ? $object->datepaye : ($object->datepaid ? $object->datepaid : $object->datep); + $paymenttypeid = $object->paiementid ? $object->paiementid : ($object->paymenttype ? $object->paymenttype : $object->type_payment); $this->object_data->ref = $object->ref; $this->object_data->date = $datepayment; $this->object_data->type_code = dol_getIdFromCode($this->db, $paymenttypeid, 'c_paiement', 'id', 'code'); - $this->object_data->payment_num = ($object->num_paiement?$object->num_paiement:$object->num_payment); + $this->object_data->payment_num = ($object->num_paiement ? $object->num_paiement : $object->num_payment); //$this->object_data->fk_account = $object->fk_account; $this->object_data->note = $object->note; //var_dump($this->object_data);exit; - $totalamount=0; + $totalamount = 0; - if (! is_array($object->amounts) && $object->amount) + if (!is_array($object->amounts) && $object->amount) { - $object->amounts=array($object->id => $object->amount); + $object->amounts = array($object->id => $object->amount); } - $paymentpartnumber=0; - foreach($object->amounts as $objid => $amount) + $paymentpartnumber = 0; + foreach ($object->amounts as $objid => $amount) { if (empty($amount)) continue; @@ -543,7 +543,7 @@ class BlockedLog $tmpobject = new PaymentVarious($this->db); } - if (! is_object($tmpobject)) + if (!is_object($tmpobject)) { continue; } @@ -561,12 +561,12 @@ class BlockedLog $paymentpart = new stdClass(); $paymentpart->amount = $amount; - if (! in_array($this->element, array('payment_donation', 'payment_various'))) + if (!in_array($this->element, array('payment_donation', 'payment_various'))) { $result = $tmpobject->fetch_thirdparty(); if ($result == 0) { - $this->error='Failed to fetch thirdparty for object with id '.$tmpobject->id; + $this->error = 'Failed to fetch thirdparty for object with id '.$tmpobject->id; $this->errors[] = $this->error; dol_syslog("Failed to fetch thirdparty for object with id ".$tmpobject->id, LOG_ERR); return -1; @@ -610,43 +610,43 @@ class BlockedLog } } - $paymentpartnumber++; // first payment will be 1 + $paymentpartnumber++; // first payment will be 1 $this->object_data->payment_part[$paymentpartnumber] = $paymentpart; } } $this->object_data->amount = $totalamount; - if (! empty($object->newref)) $this->object_data->ref = $object->newref; + if (!empty($object->newref)) $this->object_data->ref = $object->newref; } - elseif($this->element == 'payment_salary') + elseif ($this->element == 'payment_salary') { $this->object_data->amounts = array($object->amount); - if (! empty($object->newref)) $this->object_data->ref = $object->newref; + if (!empty($object->newref)) $this->object_data->ref = $object->newref; } - elseif($this->element == 'subscription') + elseif ($this->element == 'subscription') { - foreach($object as $key=>$value) + foreach ($object as $key=>$value) { - if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties - if (! in_array($key, array( - 'id','datec','dateh','datef','fk_adherent','amount','import_key','statut','note' - ))) continue; // Discard if not into a dedicated list + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties + if (!in_array($key, array( + 'id', 'datec', 'dateh', 'datef', 'fk_adherent', 'amount', 'import_key', 'statut', 'note' + ))) continue; // Discard if not into a dedicated list if (!is_object($value)) $this->object_data->{$key} = $value; } - if (! empty($object->newref)) $this->object_data->ref = $object->newref; + if (!empty($object->newref)) $this->object_data->ref = $object->newref; } else // Generic case { - foreach($object as $key=>$value) + foreach ($object as $key=>$value) { - if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties if (!is_object($value)) $this->object_data->{$key} = $value; } - if (! empty($object->newref)) $this->object_data->ref = $object->newref; + if (!empty($object->newref)) $this->object_data->ref = $object->newref; } return 1; @@ -667,59 +667,59 @@ class BlockedLog if (empty($id)) { - $this->error='BadParameter'; + $this->error = 'BadParameter'; return -1; } $langs->load("blockedlog"); $sql = "SELECT b.rowid, b.date_creation, b.signature, b.signature_line, b.amounts, b.action, b.element, b.fk_object, b.entity,"; - $sql.= " b.certified, b.tms, b.fk_user, b.user_fullname, b.date_object, b.ref_object, b.object_data"; - $sql.= " FROM ".MAIN_DB_PREFIX."blockedlog as b"; - if ($id) $sql.= " WHERE b.rowid = ". $id; + $sql .= " b.certified, b.tms, b.fk_user, b.user_fullname, b.date_object, b.ref_object, b.object_data"; + $sql .= " FROM ".MAIN_DB_PREFIX."blockedlog as b"; + if ($id) $sql .= " WHERE b.rowid = ".$id; - $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->entity = $obj->entity; + $this->id = $obj->rowid; + $this->entity = $obj->entity; $this->ref = $obj->rowid; - $this->date_creation = $this->db->jdate($obj->date_creation); + $this->date_creation = $this->db->jdate($obj->date_creation); $this->tms = $this->db->jdate($obj->tms); $this->amounts = (double) $obj->amounts; - $this->action = $obj->action; + $this->action = $obj->action; $this->element = $obj->element; - $this->fk_object = $obj->fk_object; - $this->date_object = $this->db->jdate($obj->date_object); - $this->ref_object = $obj->ref_object; + $this->fk_object = $obj->fk_object; + $this->date_object = $this->db->jdate($obj->date_object); + $this->ref_object = $obj->ref_object; - $this->fk_user = $obj->fk_user; - $this->user_fullname = $obj->user_fullname; + $this->fk_user = $obj->fk_user; + $this->user_fullname = $obj->user_fullname; - $this->object_data = $this->dolDecodeBlockedData($obj->object_data); + $this->object_data = $this->dolDecodeBlockedData($obj->object_data); $this->signature = $obj->signature; - $this->signature_line = $obj->signature_line; + $this->signature_line = $obj->signature_line; $this->certified = ($obj->certified == 1); return 1; } else { - $this->error=$langs->trans("RecordNotFound"); + $this->error = $langs->trans("RecordNotFound"); return 0; } } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -739,7 +739,7 @@ class BlockedLog //include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $aaa = unserialize($data); //$aaa = unserialize($data); - } catch(Exception $e) { + } catch (Exception $e) { //print $e->getErrs); } return $aaa; @@ -755,7 +755,7 @@ class BlockedLog { $res = $this->db->query("UPDATE ".MAIN_DB_PREFIX."blockedlog SET certified=1 WHERE rowid=".$this->id); - if($res===false) return false; + if ($res === false) return false; return true; } @@ -770,82 +770,82 @@ class BlockedLog public function create($user, $forcesignature = '') { - global $conf,$langs,$hookmanager; + global $conf, $langs, $hookmanager; $langs->load('blockedlog'); - $error=0; + $error = 0; // Clean data - $this->amounts=(double) $this->amounts; + $this->amounts = (double) $this->amounts; dol_syslog(get_class($this).'::create action='.$this->action.' fk_user='.$this->fk_user.' user_fullname='.$this->user_fullname, LOG_DEBUG); // Check parameters/properties - if (! isset($this->amounts)) // amount can be 0 for some events (like when module is disabled) + if (!isset($this->amounts)) // amount can be 0 for some events (like when module is disabled) { - $this->error=$langs->trans("BlockLogNeedAmountsValue"); + $this->error = $langs->trans("BlockLogNeedAmountsValue"); dol_syslog($this->error, LOG_WARNING); return -1; } if (empty($this->element)) { - $this->error=$langs->trans("BlockLogNeedElement"); + $this->error = $langs->trans("BlockLogNeedElement"); dol_syslog($this->error, LOG_WARNING); return -2; } if (empty($this->action)) { - $this->error=$langs->trans("BadParameterWhenCallingCreateOfBlockedLog"); + $this->error = $langs->trans("BadParameterWhenCallingCreateOfBlockedLog"); dol_syslog($this->error, LOG_WARNING); return -3; } - if (empty($this->fk_user)) $this->user_fullname='(Anonymous)'; + if (empty($this->fk_user)) $this->user_fullname = '(Anonymous)'; $this->date_creation = dol_now(); $this->db->begin(); - $previoushash = $this->getPreviousHash(1, 0); // This get last record and lock database until insert is done + $previoushash = $this->getPreviousHash(1, 0); // This get last record and lock database until insert is done $keyforsignature = $this->buildKeyForSignature(); - $this->signature_line = dol_hash($keyforsignature, '5'); // Not really usefull - $this->signature = dol_hash($previoushash . $keyforsignature, '5'); + $this->signature_line = dol_hash($keyforsignature, '5'); // Not really usefull + $this->signature = dol_hash($previoushash.$keyforsignature, '5'); if ($forcesignature) $this->signature = $forcesignature; //var_dump($keyforsignature);var_dump($previoushash);var_dump($this->signature_line);var_dump($this->signature); $sql = "INSERT INTO ".MAIN_DB_PREFIX."blockedlog ("; - $sql.= " date_creation,"; - $sql.= " action,"; - $sql.= " amounts,"; - $sql.= " signature,"; - $sql.= " signature_line,"; - $sql.= " element,"; - $sql.= " fk_object,"; - $sql.= " date_object,"; - $sql.= " ref_object,"; - $sql.= " object_data,"; - $sql.= " certified,"; - $sql.= " fk_user,"; - $sql.= " user_fullname,"; - $sql.= " entity"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->idate($this->date_creation)."',"; - $sql.= "'".$this->db->escape($this->action)."',"; - $sql.= $this->amounts.","; - $sql.= "'".$this->db->escape($this->signature)."',"; - $sql.= "'".$this->db->escape($this->signature_line)."',"; - $sql.= "'".$this->db->escape($this->element)."',"; - $sql.= $this->fk_object.","; - $sql.= "'".$this->db->idate($this->date_object)."',"; - $sql.= "'".$this->db->escape($this->ref_object)."',"; - $sql.= "'".$this->db->escape(serialize($this->object_data))."',"; - $sql.= "0,"; - $sql.= $this->fk_user.","; - $sql.= "'".$this->db->escape($this->user_fullname)."',"; - $sql.= ($this->entity ? $this->entity : $conf->entity); - $sql.= ")"; + $sql .= " date_creation,"; + $sql .= " action,"; + $sql .= " amounts,"; + $sql .= " signature,"; + $sql .= " signature_line,"; + $sql .= " element,"; + $sql .= " fk_object,"; + $sql .= " date_object,"; + $sql .= " ref_object,"; + $sql .= " object_data,"; + $sql .= " certified,"; + $sql .= " fk_user,"; + $sql .= " user_fullname,"; + $sql .= " entity"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->idate($this->date_creation)."',"; + $sql .= "'".$this->db->escape($this->action)."',"; + $sql .= $this->amounts.","; + $sql .= "'".$this->db->escape($this->signature)."',"; + $sql .= "'".$this->db->escape($this->signature_line)."',"; + $sql .= "'".$this->db->escape($this->element)."',"; + $sql .= $this->fk_object.","; + $sql .= "'".$this->db->idate($this->date_object)."',"; + $sql .= "'".$this->db->escape($this->ref_object)."',"; + $sql .= "'".$this->db->escape(serialize($this->object_data))."',"; + $sql .= "0,"; + $sql .= $this->fk_user.","; + $sql .= "'".$this->db->escape($this->user_fullname)."',"; + $sql .= ($this->entity ? $this->entity : $conf->entity); + $sql .= ")"; $res = $this->db->query($sql); if ($res) @@ -868,7 +868,7 @@ class BlockedLog } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -891,8 +891,8 @@ class BlockedLog // Recalculate hash $keyforsignature = $this->buildKeyForSignature(); - $signature_line = dol_hash($keyforsignature, '5'); // Not really usefull - $signature = dol_hash($previoushash . $keyforsignature, '5'); + $signature_line = dol_hash($keyforsignature, '5'); // Not really usefull + $signature = dol_hash($previoushash.$keyforsignature, '5'); //var_dump($previoushash); var_dump($keyforsignature); var_dump($signature_line); var_dump($signature); $res = ($signature === $this->signature); @@ -929,13 +929,13 @@ class BlockedLog { global $conf; - $previoussignature=''; + $previoussignature = ''; $sql = "SELECT rowid, signature FROM ".MAIN_DB_PREFIX."blockedlog"; - $sql.= " WHERE entity=".$conf->entity; - if ($beforeid) $sql.= " AND rowid < ".(int) $beforeid; - $sql.=" ORDER BY rowid DESC LIMIT 1"; - $sql.=($withlock ? " FOR UPDATE ": ""); + $sql .= " WHERE entity=".$conf->entity; + if ($beforeid) $sql .= " AND rowid < ".(int) $beforeid; + $sql .= " ORDER BY rowid DESC LIMIT 1"; + $sql .= ($withlock ? " FOR UPDATE " : ""); $resql = $this->db->query($sql); if ($resql) { @@ -981,38 +981,38 @@ class BlockedLog global $conf, $cachedlogs; /* $cachedlogs allow fastest search */ - if (empty($cachedlogs)) $cachedlogs=array(); + if (empty($cachedlogs)) $cachedlogs = array(); - if ($element=='all') { - $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog + if ($element == 'all') { + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog WHERE entity=".$conf->entity; } - elseif ($element=='not_certified') { - $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog + elseif ($element == 'not_certified') { + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog WHERE entity=".$conf->entity." AND certified = 0"; } - elseif ($element=='just_certified') { - $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog + elseif ($element == 'just_certified') { + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog WHERE entity=".$conf->entity." AND certified = 1"; } - else{ - $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog + else { + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog WHERE entity=".$conf->entity." AND element='".$element."' AND fk_object=".(int) $fk_object; } - if ($search_fk_user > 0) $sql.=natural_search("fk_user", $search_fk_user, 2); - if ($search_start > 0) $sql.=" AND date_creation >= '".$this->db->idate($search_start)."'"; - if ($search_end > 0) $sql.=" AND date_creation <= '".$this->db->idate($search_end)."'"; - if ($search_ref != '') $sql.=natural_search("ref_object", $search_ref); - if ($search_amount != '') $sql.=natural_search("amounts", $search_amount, 1); - if ($search_code != '' && $search_code != '-1') $sql.=natural_search("action", $search_code, 3); + if ($search_fk_user > 0) $sql .= natural_search("fk_user", $search_fk_user, 2); + if ($search_start > 0) $sql .= " AND date_creation >= '".$this->db->idate($search_start)."'"; + if ($search_end > 0) $sql .= " AND date_creation <= '".$this->db->idate($search_end)."'"; + if ($search_ref != '') $sql .= natural_search("ref_object", $search_ref); + if ($search_amount != '') $sql .= natural_search("amounts", $search_amount, 1); + if ($search_code != '' && $search_code != '-1') $sql .= natural_search("action", $search_code, 3); - $sql.=$this->db->order($sortfield, $sortorder); - $sql.=$this->db->plimit($limit+1); // We want more, because we will stop into loop later with error if we reach max + $sql .= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->plimit($limit + 1); // We want more, because we will stop into loop later with error if we reach max $res = $this->db->query($sql); - if($res) { - $results=array(); + if ($res) { + $results = array(); $i = 0; while ($obj = $this->db->fetch_object($res)) @@ -1026,7 +1026,7 @@ class BlockedLog if (!isset($cachedlogs[$obj->rowid])) { - $b=new BlockedLog($this->db); + $b = new BlockedLog($this->db); $b->fetch($obj->rowid); $cachedlogs[$obj->rowid] = $b; @@ -1048,7 +1048,7 @@ class BlockedLog */ public function getSignature() { - global $db,$conf,$mysoc; + global $db, $conf, $mysoc; if (empty($conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT)) { // creation of a unique fingerprint require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; @@ -1059,7 +1059,7 @@ class BlockedLog dolibarr_set_const($db, 'BLOCKEDLOG_ENTITY_FINGERPRINT', $fingerprint, 'chaine', 0, 'Numeric Unique Fingerprint', $conf->entity); - $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT=$fingerprint; + $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT = $fingerprint; } return $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT; @@ -1079,12 +1079,12 @@ class BlockedLog $result = false; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog"; - $sql.= " WHERE entity = ".$conf->entity; - if ($ignoresystem) $sql.=" AND action not in ('MODULE_SET','MODULE_RESET')"; - $sql.= $this->db->plimit(1); + $sql .= " WHERE entity = ".$conf->entity; + if ($ignoresystem) $sql .= " AND action not in ('MODULE_SET','MODULE_RESET')"; + $sql .= $this->db->plimit(1); $res = $this->db->query($sql); - if ($res!==false) + if ($res !== false) { $obj = $this->db->fetch_object($res); if ($obj) $result = true; diff --git a/htdocs/cashdesk/tpl/liste_articles.tpl.php b/htdocs/cashdesk/tpl/liste_articles.tpl.php index d892c1df0e6..6fffbd3ed52 100644 --- a/htdocs/cashdesk/tpl/liste_articles.tpl.php +++ b/htdocs/cashdesk/tpl/liste_articles.tpl.php @@ -18,7 +18,7 @@ */ // Protection to avoid direct call of template -if (empty($langs) || ! is_object($langs)) +if (empty($langs) || !is_object($langs)) { print "Error, template page can't be called as URL"; exit; @@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; // Load translation files required by the page -$langs->loadLangs(array("main","bills","cashdesk")); +$langs->loadLangs(array("main", "bills", "cashdesk")); ?> @@ -45,18 +45,18 @@ $societe = new Societe($db); $societe->fetch($thirdpartyid); /** end add Ditto */ -$tab = (! empty($_SESSION['poscart'])?$_SESSION['poscart']:array()); +$tab = (!empty($_SESSION['poscart']) ? $_SESSION['poscart'] : array()); -$tab_size=count($tab); +$tab_size = count($tab); if ($tab_size <= 0) print '
'.$langs->trans("NoArticle").'

'; else { - for ($i=0;$i < $tab_size;$i++) + for ($i = 0; $i < $tab_size; $i++) { echo ('
'."\n"); echo ('

'.$tab[$i]['ref'].' - '.$tab[$i]['label'].'

'."\n"); - if ( $tab[$i]['remise_percent'] > 0 ) { + if ($tab[$i]['remise_percent'] > 0) { $remise_percent = ' -'.$tab[$i]['remise_percent'].'%'; } else { $remise_percent = ''; diff --git a/htdocs/cashdesk/tpl/validation1.tpl.php b/htdocs/cashdesk/tpl/validation1.tpl.php index fcbd95e8f29..4bc66eff4ad 100644 --- a/htdocs/cashdesk/tpl/validation1.tpl.php +++ b/htdocs/cashdesk/tpl/validation1.tpl.php @@ -17,14 +17,14 @@ */ // Protection to avoid direct call of template -if (empty($langs) || ! is_object($langs)) +if (empty($langs) || !is_object($langs)) { print "Error, template page can't be called as URL"; exit; } // Load translation files required by the page -$langs->loadLangs(array("main","bills","banks")); +$langs->loadLangs(array("main", "bills", "banks")); // Object $form must de defined @@ -53,30 +53,30 @@ else { case 'ESP': echo $langs->trans("Cash"); - $filtre='courant=2'; + $filtre = 'courant=2'; if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"])) $selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"]; break; case 'CB': echo $langs->trans("CreditCard"); - $filtre='courant=1'; + $filtre = 'courant=1'; if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"])) $selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CB"]; break; case 'CHQ': echo $langs->trans("Cheque"); - $filtre='courant=1'; + $filtre = 'courant=1'; if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"])) $selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"]; break; case 'DIF': echo $langs->trans("Reported"); - $filtre='courant=1 OR courant=2'; - $selected=''; + $filtre = 'courant=1 OR courant=2'; + $selected = ''; break; default: - $filtre='courant=1 OR courant=2'; - $selected=''; + $filtre = 'courant=1 OR courant=2'; + $selected = ''; } ?> @@ -103,7 +103,7 @@ if ( $obj_facturation->montantRendu() ) {

trans("BankToPay"). "
"; + echo $langs->trans("BankToPay")."
"; $form->select_comptes($selected, 'cashdeskbank', 0, $filtre); ?>

diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 25cf0287292..033f3f38100 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -107,7 +107,7 @@ class Categorie extends CommonObject 'member' => 'member', 'contact' => 'socpeople', 'user' => 'user', - 'account' => 'account', // old key for bank_account + 'account' => 'account', // old key for bank_account 'bank_account' => 'account', 'project' => 'project', 'warehouse'=> 'warehouse', @@ -125,7 +125,7 @@ class Categorie extends CommonObject 'member' => 'member', 'contact' => 'contact', 'user' => 'user', - 'account' => 'account', // old key for bank_account + 'account' => 'account', // old key for bank_account 'bank_account'=> 'account', 'project' => 'project', 'warehouse'=> 'warehouse', @@ -853,29 +853,29 @@ class Categorie extends CommonObject $sub_type = $type; $subcol_name = "fk_".$type; - if ($type=="customer") { - $sub_type="societe"; - $subcol_name="fk_soc"; + if ($type == "customer") { + $sub_type = "societe"; + $subcol_name = "fk_soc"; } - if ($type=="supplier") { - $sub_type="fournisseur"; - $subcol_name="fk_soc"; + if ($type == "supplier") { + $sub_type = "fournisseur"; + $subcol_name = "fk_soc"; } - if ($type=="contact") { - $subcol_name="fk_socpeople"; + if ($type == "contact") { + $subcol_name = "fk_socpeople"; } $idoftype = array_search($type, self::$MAP_ID_TO_CODE); $sql = "SELECT s.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."categorie as s"; - $sql.= " , ".MAIN_DB_PREFIX."categorie_".$sub_type." as sub "; - $sql.= ' WHERE s.entity IN ('.getEntity('category').')'; - $sql.= ' AND s.type='.$idoftype; - $sql.= ' AND s.rowid = sub.fk_categorie'; - $sql.= ' AND sub.'.$subcol_name.' = '.$id; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie as s"; + $sql .= " , ".MAIN_DB_PREFIX."categorie_".$sub_type." as sub "; + $sql .= ' WHERE s.entity IN ('.getEntity('category').')'; + $sql .= ' AND s.type='.$idoftype; + $sql .= ' AND s.rowid = sub.fk_categorie'; + $sql .= ' AND sub.'.$subcol_name.' = '.$id; - $sql.= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->order($sortfield, $sortorder); $offset = 0; $nbtotalofrecords = ''; @@ -897,13 +897,13 @@ class Categorie extends CommonObject } $offset = $limit * $page; - $sql.= $this->db->plimit($limit + 1, $offset); + $sql .= $this->db->plimit($limit + 1, $offset); } $result = $this->db->query($sql); if ($result) { - $i=0; + $i = 0; $num = $this->db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); while ($i < $min) @@ -1636,8 +1636,8 @@ class Categorie extends CommonObject if (is_array($file['name']) && count($file['name']) > 0) { $nbfile = count($file['name']); - for ($i = 0; $i <= $nbfile; $i ++) { - $originImage = $dir . $file['name'][$i]; + for ($i = 0; $i <= $nbfile; $i++) { + $originImage = $dir.$file['name'][$i]; // Cree fichier en taille origine dol_move_uploaded_file($file['tmp_name'][$i], $originImage, 1, 0, 0); diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index 5dbd6e68c47..2556c2d2084 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -36,13 +36,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php'; $langs->loadlangs(array('categories', 'bills')); -$id=GETPOST('id', 'int'); -$ref=GETPOST('ref'); -$type=GETPOST('type'); -$action=GETPOST('action', 'aZ09'); -$confirm=GETPOST('confirm'); +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref'); +$type = GETPOST('type'); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm'); -if (is_numeric($type)) $type=Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility +if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility if ($id == "") { @@ -66,7 +66,7 @@ if ($id > 0) * Actions */ -if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) +if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && $_POST["sendit"] && !empty($conf->global->MAIN_UPLOAD_DOC)) { if ($object->id) { $file = $_FILES['userfile']; @@ -74,15 +74,15 @@ if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && $_POST["sen { foreach ($file['name'] as $i => $name) { - if(empty($file['tmp_name'][$i]) || intval($conf->global->MAIN_UPLOAD_DOC) * 1000 <= filesize($file['tmp_name'][$i]) ) + if (empty($file['tmp_name'][$i]) || intval($conf->global->MAIN_UPLOAD_DOC) * 1000 <= filesize($file['tmp_name'][$i])) { - setEventMessage($file['name'][$i] .' : '. $langs->trans(empty($file['tmp_name'][$i])? 'ErrorFailedToSaveFile' : 'MaxSizeForUploadedFiles')); + setEventMessage($file['name'][$i].' : '.$langs->trans(empty($file['tmp_name'][$i]) ? 'ErrorFailedToSaveFile' : 'MaxSizeForUploadedFiles')); unset($file['name'][$i], $file['type'][$i], $file['tmp_name'][$i], $file['error'][$i], $file['size'][$i]); } } } - if(!empty($file['tmp_name'])) { + if (!empty($file['tmp_name'])) { $object->add_photo($upload_dir, $file); } } @@ -110,15 +110,15 @@ $formother = new FormOther($db); if ($object->id) { - if ($type == Categorie::TYPE_PRODUCT) $title=$langs->trans("ProductsCategoryShort"); - elseif ($type == Categorie::TYPE_SUPPLIER) $title=$langs->trans("SuppliersCategoryShort"); - elseif ($type == Categorie::TYPE_CUSTOMER) $title=$langs->trans("CustomersCategoryShort"); - elseif ($type == Categorie::TYPE_MEMBER) $title=$langs->trans("MembersCategoryShort"); - elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort"); - elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort"); - elseif ($type == Categorie::TYPE_PROJECT) $title=$langs->trans("ProjectsCategoriesShort"); - elseif ($type == Categorie::TYPE_USER) $title=$langs->trans("UsersCategoriesShort"); - else $title=$langs->trans("Category"); + if ($type == Categorie::TYPE_PRODUCT) $title = $langs->trans("ProductsCategoryShort"); + elseif ($type == Categorie::TYPE_SUPPLIER) $title = $langs->trans("SuppliersCategoryShort"); + elseif ($type == Categorie::TYPE_CUSTOMER) $title = $langs->trans("CustomersCategoryShort"); + elseif ($type == Categorie::TYPE_MEMBER) $title = $langs->trans("MembersCategoryShort"); + elseif ($type == Categorie::TYPE_CONTACT) $title = $langs->trans("ContactCategoriesShort"); + elseif ($type == Categorie::TYPE_ACCOUNT) $title = $langs->trans("AccountsCategoriesShort"); + elseif ($type == Categorie::TYPE_PROJECT) $title = $langs->trans("ProjectsCategoriesShort"); + elseif ($type == Categorie::TYPE_USER) $title = $langs->trans("UsersCategoriesShort"); + else $title = $langs->trans("Category"); $head = categories_prepare_head($object, $type); @@ -181,7 +181,7 @@ if ($object->id) if ($action != 'ajout_photo' && $user->rights->categorie->creer) { - if (! empty($conf->global->MAIN_UPLOAD_DOC)) + if (!empty($conf->global->MAIN_UPLOAD_DOC)) { print ''; print $langs->trans("AddPhoto").''; @@ -198,23 +198,23 @@ if ($object->id) /* * Ajouter une photo */ - if ($action == 'ajout_photo' && $user->rights->categorie->creer && ! empty($conf->global->MAIN_UPLOAD_DOC)) + if ($action == 'ajout_photo' && $user->rights->categorie->creer && !empty($conf->global->MAIN_UPLOAD_DOC)) { // Affiche formulaire upload - $formfile=new FormFile($db); + $formfile = new FormFile($db); $formfile->form_attach_new_file($_SERVER['PHP_SELF'].'?id='.$object->id.'&type='.$type, $langs->trans("AddPhoto"), 1, '', $user->rights->categorie->creer, 50, $object, '', false, '', 0); } // Affiche photos if ($action != 'ajout_photo') { - $nbphoto=0; - $nbbyrow=5; + $nbphoto = 0; + $nbbyrow = 5; $maxWidth = 160; $maxHeight = 120; - $pdir = get_exdir($object->id, 2, 0, 0, $object, 'category') . $object->id ."/photos/"; + $pdir = get_exdir($object->id, 2, 0, 0, $object, 'category').$object->id."/photos/"; $dir = $upload_dir.'/'.$pdir; $listofphoto = $object->liste_photos($dir); @@ -229,22 +229,22 @@ if ($object->id) $nbphoto++; if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) print ''; - if ($nbbyrow) print ''; + if ($nbbyrow) print ''; print ''; // Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine if ($obj['photo_vignette']) { - $filename=$obj['photo_vignette']; + $filename = $obj['photo_vignette']; } else { - $filename=$obj['photo']; + $filename = $obj['photo']; } // Nom affiche - $viewfilename=$obj['photo']; + $viewfilename = $obj['photo']; // Taille de l'image $object->get_image_size($dir.$filename); @@ -274,7 +274,7 @@ if ($object->id) // Ferme tableau while ($nbphoto % $nbbyrow) { - print ' '; + print ' '; $nbphoto++; } diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 442e1b8bdd9..69f748412a1 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -38,7 +38,7 @@ class ActionComm extends CommonObject /** * @var string ID to identify managed object */ - public $element='action'; + public $element = 'action'; /** * @var string Name of table without prefix where object is stored @@ -364,174 +364,174 @@ class ActionComm extends CommonObject */ public function create(User $user, $notrigger = 0) { - global $langs,$conf,$hookmanager; + global $langs, $conf, $hookmanager; - $error=0; - $now=dol_now(); + $error = 0; + $now = dol_now(); // Check parameters - if (! isset($this->userownerid) || $this->userownerid === '') // $this->userownerid may be 0 (anonymous event) of > 0 + if (!isset($this->userownerid) || $this->userownerid === '') // $this->userownerid may be 0 (anonymous event) of > 0 { dol_syslog("You tried to create an event but mandatory property ownerid was not defined", LOG_WARNING); - $this->errors[]='ErrorPropertyUserowneridNotDefined'; + $this->errors[] = 'ErrorPropertyUserowneridNotDefined'; return -1; } // Clean parameters - $this->label=dol_trunc(trim($this->label), 128); - $this->location=dol_trunc(trim($this->location), 128); - $this->note=dol_htmlcleanlastbr(trim($this->note)); + $this->label = dol_trunc(trim($this->label), 128); + $this->location = dol_trunc(trim($this->location), 128); + $this->note = dol_htmlcleanlastbr(trim($this->note)); if (empty($this->percentage)) $this->percentage = 0; - if (empty($this->priority) || ! is_numeric($this->priority)) $this->priority = 0; + if (empty($this->priority) || !is_numeric($this->priority)) $this->priority = 0; if (empty($this->fulldayevent)) $this->fulldayevent = 0; if (empty($this->punctual)) $this->punctual = 0; if (empty($this->transparency)) $this->transparency = 0; if ($this->percentage > 100) $this->percentage = 100; //if ($this->percentage == 100 && ! $this->dateend) $this->dateend = $this->date; - if (! empty($this->datep) && ! empty($this->datef)) $this->durationp=($this->datef - $this->datep); // deprecated + if (!empty($this->datep) && !empty($this->datef)) $this->durationp = ($this->datef - $this->datep); // deprecated //if (! empty($this->date) && ! empty($this->dateend)) $this->durationa=($this->dateend - $this->date); - if (! empty($this->datep) && ! empty($this->datef) && $this->datep > $this->datef) $this->datef=$this->datep; + if (!empty($this->datep) && !empty($this->datef) && $this->datep > $this->datef) $this->datef = $this->datep; //if (! empty($this->date) && ! empty($this->dateend) && $this->date > $this->dateend) $this->dateend=$this->date; - if (! isset($this->fk_project) || $this->fk_project < 0) $this->fk_project = 0; + if (!isset($this->fk_project) || $this->fk_project < 0) $this->fk_project = 0; // For backward compatibility - if ($this->elementtype=='facture') $this->elementtype='invoice'; - if ($this->elementtype=='commande') $this->elementtype='order'; - if ($this->elementtype=='contrat') $this->elementtype='contract'; + if ($this->elementtype == 'facture') $this->elementtype = 'invoice'; + if ($this->elementtype == 'commande') $this->elementtype = 'order'; + if ($this->elementtype == 'contrat') $this->elementtype = 'contract'; - if (! is_array($this->userassigned) && ! empty($this->userassigned)) // For backward compatibility when userassigned was an int instead fo array + if (!is_array($this->userassigned) && !empty($this->userassigned)) // For backward compatibility when userassigned was an int instead fo array { - $tmpid=$this->userassigned; - $this->userassigned=array(); - $this->userassigned[$tmpid]=array('id'=>$tmpid, 'transparency'=>$this->transparency); + $tmpid = $this->userassigned; + $this->userassigned = array(); + $this->userassigned[$tmpid] = array('id'=>$tmpid, 'transparency'=>$this->transparency); } - $userownerid=$this->userownerid; - $userdoneid=$this->userdoneid; + $userownerid = $this->userownerid; + $userdoneid = $this->userdoneid; // Be sure assigned user is defined as an array of array('id'=>,'mandatory'=>,...). - if (empty($this->userassigned) || count($this->userassigned) == 0 || ! is_array($this->userassigned)) + if (empty($this->userassigned) || count($this->userassigned) == 0 || !is_array($this->userassigned)) $this->userassigned = array($userownerid=>array('id'=>$userownerid, 'transparency'=>$this->transparency)); - if (! $this->type_id || ! $this->type_code) + if (!$this->type_id || !$this->type_code) { - $key=empty($this->type_id)?$this->type_code:$this->type_id; + $key = empty($this->type_id) ? $this->type_code : $this->type_id; // Get id from code - $cactioncomm=new CActionComm($this->db); - $result=$cactioncomm->fetch($key); + $cactioncomm = new CActionComm($this->db); + $result = $cactioncomm->fetch($key); if ($result > 0) { - $this->type_id=$cactioncomm->id; - $this->type_code=$cactioncomm->code; + $this->type_id = $cactioncomm->id; + $this->type_code = $cactioncomm->code; } elseif ($result == 0) { - $this->error='Failed to get record with id '.$this->type_id.' code '.$this->type_code.' from dictionary "type of events"'; + $this->error = 'Failed to get record with id '.$this->type_id.' code '.$this->type_code.' from dictionary "type of events"'; return -1; } else { - $this->error=$cactioncomm->error; + $this->error = $cactioncomm->error; return -1; } } - $code = empty($this->code)?$this->type_code:$this->code; + $code = empty($this->code) ? $this->type_code : $this->code; // Check parameters - if (! $this->type_id) + if (!$this->type_id) { - $this->error="ErrorWrongParameters"; + $this->error = "ErrorWrongParameters"; return -1; } $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm"; - $sql.= "(datec,"; - $sql.= "datep,"; - $sql.= "datep2,"; - $sql.= "durationp,"; // deprecated - $sql.= "fk_action,"; - $sql.= "code,"; - $sql.= "fk_soc,"; - $sql.= "fk_project,"; - $sql.= "note,"; - $sql.= "fk_contact,"; - $sql.= "fk_user_author,"; - $sql.= "fk_user_action,"; - $sql.= "fk_user_done,"; - $sql.= "label,percent,priority,fulldayevent,location,punctual,"; - $sql.= "transparency,"; - $sql.= "fk_element,"; - $sql.= "elementtype,"; - $sql.= "entity,"; - $sql.= "extraparams,"; + $sql .= "(datec,"; + $sql .= "datep,"; + $sql .= "datep2,"; + $sql .= "durationp,"; // deprecated + $sql .= "fk_action,"; + $sql .= "code,"; + $sql .= "fk_soc,"; + $sql .= "fk_project,"; + $sql .= "note,"; + $sql .= "fk_contact,"; + $sql .= "fk_user_author,"; + $sql .= "fk_user_action,"; + $sql .= "fk_user_done,"; + $sql .= "label,percent,priority,fulldayevent,location,punctual,"; + $sql .= "transparency,"; + $sql .= "fk_element,"; + $sql .= "elementtype,"; + $sql .= "entity,"; + $sql .= "extraparams,"; // Fields emails - $sql.= "email_msgid,"; - $sql.= "email_from,"; - $sql.= "email_sender,"; - $sql.= "email_to,"; - $sql.= "email_tocc,"; - $sql.= "email_tobcc,"; - $sql.= "email_subject,"; - $sql.= "errors_to"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->idate($now)."', "; - $sql.= (strval($this->datep)!=''?"'".$this->db->idate($this->datep)."'":"null").", "; - $sql.= (strval($this->datef)!=''?"'".$this->db->idate($this->datef)."'":"null").", "; - $sql.= ((isset($this->durationp) && $this->durationp >= 0 && $this->durationp != '')?"'".$this->db->escape($this->durationp)."'":"null").", "; // deprecated - $sql.= (isset($this->type_id)?$this->type_id:"null").","; - $sql.= ($code?("'".$code."'"):"null").", "; - $sql.= ((isset($this->socid) && $this->socid > 0) ? $this->socid:"null").", "; - $sql.= ((isset($this->fk_project) && $this->fk_project > 0) ? $this->fk_project:"null").", "; - $sql.= " '".$this->db->escape($this->note_private?$this->note_private:$this->note)."', "; - $sql.= ((isset($this->contactid) && $this->contactid > 0) ? $this->contactid:"null").", "; - $sql.= (isset($user->id) && $user->id > 0 ? $user->id:"null").", "; - $sql.= ($userownerid>0 ? $userownerid:"null").", "; - $sql.= ($userdoneid>0 ? $userdoneid:"null").", "; - $sql.= "'".$this->db->escape($this->label)."','".$this->db->escape($this->percentage)."','".$this->db->escape($this->priority)."','".$this->db->escape($this->fulldayevent)."','".$this->db->escape($this->location)."','".$this->db->escape($this->punctual)."', "; - $sql.= "'".$this->db->escape($this->transparency)."', "; - $sql.= (! empty($this->fk_element)?$this->fk_element:"null").", "; - $sql.= (! empty($this->elementtype)?"'".$this->db->escape($this->elementtype)."'":"null").", "; - $sql.= $conf->entity.","; - $sql.= (! empty($this->extraparams)?"'".$this->db->escape($this->extraparams)."'":"null").", "; + $sql .= "email_msgid,"; + $sql .= "email_from,"; + $sql .= "email_sender,"; + $sql .= "email_to,"; + $sql .= "email_tocc,"; + $sql .= "email_tobcc,"; + $sql .= "email_subject,"; + $sql .= "errors_to"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->idate($now)."', "; + $sql .= (strval($this->datep) != '' ? "'".$this->db->idate($this->datep)."'" : "null").", "; + $sql .= (strval($this->datef) != '' ? "'".$this->db->idate($this->datef)."'" : "null").", "; + $sql .= ((isset($this->durationp) && $this->durationp >= 0 && $this->durationp != '') ? "'".$this->db->escape($this->durationp)."'" : "null").", "; // deprecated + $sql .= (isset($this->type_id) ? $this->type_id : "null").","; + $sql .= ($code ? ("'".$code."'") : "null").", "; + $sql .= ((isset($this->socid) && $this->socid > 0) ? $this->socid : "null").", "; + $sql .= ((isset($this->fk_project) && $this->fk_project > 0) ? $this->fk_project : "null").", "; + $sql .= " '".$this->db->escape($this->note_private ? $this->note_private : $this->note)."', "; + $sql .= ((isset($this->contactid) && $this->contactid > 0) ? $this->contactid : "null").", "; + $sql .= (isset($user->id) && $user->id > 0 ? $user->id : "null").", "; + $sql .= ($userownerid > 0 ? $userownerid : "null").", "; + $sql .= ($userdoneid > 0 ? $userdoneid : "null").", "; + $sql .= "'".$this->db->escape($this->label)."','".$this->db->escape($this->percentage)."','".$this->db->escape($this->priority)."','".$this->db->escape($this->fulldayevent)."','".$this->db->escape($this->location)."','".$this->db->escape($this->punctual)."', "; + $sql .= "'".$this->db->escape($this->transparency)."', "; + $sql .= (!empty($this->fk_element) ? $this->fk_element : "null").", "; + $sql .= (!empty($this->elementtype) ? "'".$this->db->escape($this->elementtype)."'" : "null").", "; + $sql .= $conf->entity.","; + $sql .= (!empty($this->extraparams) ? "'".$this->db->escape($this->extraparams)."'" : "null").", "; // Fields emails - $sql.= (! empty($this->email_msgid)?"'".$this->db->escape($this->email_msgid)."'":"null").", "; - $sql.= (! empty($this->email_from)?"'".$this->db->escape($this->email_from)."'":"null").", "; - $sql.= (! empty($this->email_sender)?"'".$this->db->escape($this->email_sender)."'":"null").", "; - $sql.= (! empty($this->email_to)?"'".$this->db->escape($this->email_to)."'":"null").", "; - $sql.= (! empty($this->email_tocc)?"'".$this->db->escape($this->email_tocc)."'":"null").", "; - $sql.= (! empty($this->email_tobcc)?"'".$this->db->escape($this->email_tobcc)."'":"null").", "; - $sql.= (! empty($this->email_subject)?"'".$this->db->escape($this->email_subject)."'":"null").", "; - $sql.= (! empty($this->errors_to)?"'".$this->db->escape($this->errors_to)."'":"null"); - $sql.= ")"; + $sql .= (!empty($this->email_msgid) ? "'".$this->db->escape($this->email_msgid)."'" : "null").", "; + $sql .= (!empty($this->email_from) ? "'".$this->db->escape($this->email_from)."'" : "null").", "; + $sql .= (!empty($this->email_sender) ? "'".$this->db->escape($this->email_sender)."'" : "null").", "; + $sql .= (!empty($this->email_to) ? "'".$this->db->escape($this->email_to)."'" : "null").", "; + $sql .= (!empty($this->email_tocc) ? "'".$this->db->escape($this->email_tocc)."'" : "null").", "; + $sql .= (!empty($this->email_tobcc) ? "'".$this->db->escape($this->email_tobcc)."'" : "null").", "; + $sql .= (!empty($this->email_subject) ? "'".$this->db->escape($this->email_subject)."'" : "null").", "; + $sql .= (!empty($this->errors_to) ? "'".$this->db->escape($this->errors_to)."'" : "null"); + $sql .= ")"; dol_syslog(get_class($this)."::add", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm", "id"); // Now insert assignedusers - if (! $error) + if (!$error) { - foreach($this->userassigned as $key => $val) + foreach ($this->userassigned as $key => $val) { - if (! is_array($val)) // For backward compatibility when val=id + if (!is_array($val)) // For backward compatibility when val=id { - $val=array('id'=>$val); + $val = array('id'=>$val); } - $sql ="INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; - $sql.=" VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory'])?'0':$val['mandatory']).", ".(empty($val['transparency'])?'0':$val['transparency']).", ".(empty($val['answer_status'])?'0':$val['answer_status']).")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; + $sql .= " VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory']) ? '0' : $val['mandatory']).", ".(empty($val['transparency']) ? '0' : $val['transparency']).", ".(empty($val['answer_status']) ? '0' : $val['answer_status']).")"; $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); } //var_dump($sql);exit; } @@ -543,27 +543,27 @@ class ActionComm extends CommonObject { foreach ($this->socpeopleassigned as $id => $Tab) { - $sql ="INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; - $sql.=" VALUES(".$this->id.", 'socpeople', ".$id.", 0, 0, 0)"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; + $sql .= " VALUES(".$this->id.", 'socpeople', ".$id.", 0, 0, 0)"; $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); } } } } - if (! $error) + if (!$error) { - $action='create'; + $action = 'create'; // Actions on extra fields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; @@ -571,15 +571,15 @@ class ActionComm extends CommonObject } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('ACTION_CREATE', $user); + $result = $this->call_trigger('ACTION_CREATE', $user); if ($result < 0) { $error++; } // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; @@ -593,7 +593,7 @@ class ActionComm extends CommonObject else { $this->db->rollback(); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -609,8 +609,8 @@ class ActionComm extends CommonObject { global $db, $conf, $hookmanager; - $error=0; - $now=dol_now(); + $error = 0; + $now = dol_now(); $this->db->begin(); @@ -624,26 +624,26 @@ class ActionComm extends CommonObject //$this->fetch_userassigned(); $this->fetchResources(); - $this->id=0; + $this->id = 0; // Create clone - $this->context['createfromclone']='createfromclone'; - $result=$this->create($fuser); + $this->context['createfromclone'] = 'createfromclone'; + $result = $this->create($fuser); if ($result < 0) $error++; - if (! $error) + if (!$error) { // Hook of thirdparty module if (is_object($hookmanager)) { - $parameters=array('objFrom'=>$objFrom); - $action=''; - $reshook=$hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('objFrom'=>$objFrom); + $action = ''; + $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) $error++; } // Call trigger - $result=$this->call_trigger('ACTION_CLONE', $fuser); + $result = $this->call_trigger('ACTION_CLONE', $fuser); if ($result < 0) { $error++; } // End call triggers } @@ -651,7 +651,7 @@ class ActionComm extends CommonObject unset($this->context['createfromclone']); // End - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; @@ -676,38 +676,38 @@ class ActionComm extends CommonObject global $langs; $sql = "SELECT a.id,"; - $sql.= " a.id as ref,"; - $sql.= " a.ref_ext,"; - $sql.= " a.datep,"; - $sql.= " a.datep2,"; - $sql.= " a.durationp,"; // deprecated - $sql.= " a.datec,"; - $sql.= " a.tms as datem,"; - $sql.= " a.code, a.label, a.note,"; - $sql.= " a.fk_soc,"; - $sql.= " a.fk_project,"; - $sql.= " a.fk_user_author, a.fk_user_mod,"; - $sql.= " a.fk_user_action, a.fk_user_done,"; - $sql.= " a.fk_contact, a.percent as percentage,"; - $sql.= " a.fk_element as elementid, a.elementtype,"; - $sql.= " a.priority, a.fulldayevent, a.location, a.punctual, a.transparency,"; - $sql.= " c.id as type_id, c.code as type_code, c.libelle as type_label, c.color as type_color, c.picto as type_picto,"; - $sql.= " s.nom as socname,"; - $sql.= " u.firstname, u.lastname as lastname"; - $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a "; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action=c.id "; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc"; - $sql.= " WHERE "; - if ($ref) $sql.= " a.id=".$ref; // No field ref, we use id - elseif ($ref_ext) $sql.= " a.ref_ext='".$this->db->escape($ref_ext)."'"; - else $sql.= " a.id=".$id; + $sql .= " a.id as ref,"; + $sql .= " a.ref_ext,"; + $sql .= " a.datep,"; + $sql .= " a.datep2,"; + $sql .= " a.durationp,"; // deprecated + $sql .= " a.datec,"; + $sql .= " a.tms as datem,"; + $sql .= " a.code, a.label, a.note,"; + $sql .= " a.fk_soc,"; + $sql .= " a.fk_project,"; + $sql .= " a.fk_user_author, a.fk_user_mod,"; + $sql .= " a.fk_user_action, a.fk_user_done,"; + $sql .= " a.fk_contact, a.percent as percentage,"; + $sql .= " a.fk_element as elementid, a.elementtype,"; + $sql .= " a.priority, a.fulldayevent, a.location, a.punctual, a.transparency,"; + $sql .= " c.id as type_id, c.code as type_code, c.libelle as type_label, c.color as type_color, c.picto as type_picto,"; + $sql .= " s.nom as socname,"; + $sql .= " u.firstname, u.lastname as lastname"; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a "; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action=c.id "; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc"; + $sql .= " WHERE "; + if ($ref) $sql .= " a.id=".$ref; // No field ref, we use id + elseif ($ref_ext) $sql .= " a.ref_ext='".$this->db->escape($ref_ext)."'"; + else $sql .= " a.id=".$id; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $num=$this->db->num_rows($resql); + $num = $this->db->num_rows($resql); if ($num) { $obj = $this->db->fetch_object($resql); @@ -721,12 +721,12 @@ class ActionComm extends CommonObject $this->type_code = $obj->type_code; $this->type_color = $obj->type_color; $this->type_picto = $obj->type_picto; - $transcode=$langs->trans("Action".$obj->type_code); - $this->type = (($transcode!="Action".$obj->type_code) ? $transcode : $obj->type_label); - $transcode=$langs->trans("Action".$obj->type_code.'Short'); - $this->type_short = (($transcode!="Action".$obj->type_code.'Short') ? $transcode : ''); + $transcode = $langs->trans("Action".$obj->type_code); + $this->type = (($transcode != "Action".$obj->type_code) ? $transcode : $obj->type_label); + $transcode = $langs->trans("Action".$obj->type_code.'Short'); + $this->type_short = (($transcode != "Action".$obj->type_code.'Short') ? $transcode : ''); - $this->code = $obj->code; + $this->code = $obj->code; $this->label = $obj->label; $this->datep = $this->db->jdate($obj->datep); $this->datef = $this->db->jdate($obj->datep2); @@ -734,38 +734,38 @@ class ActionComm extends CommonObject $this->datec = $this->db->jdate($obj->datec); $this->datem = $this->db->jdate($obj->datem); - $this->note = $obj->note; - $this->note_private = $obj->note; - $this->percentage = $obj->percentage; + $this->note = $obj->note; + $this->note_private = $obj->note; + $this->percentage = $obj->percentage; - $this->authorid = $obj->fk_user_author; - $this->usermodid = $obj->fk_user_mod; + $this->authorid = $obj->fk_user_author; + $this->usermodid = $obj->fk_user_mod; if (!is_object($this->author)) $this->author = new stdClass(); // To avoid warning - $this->author->id = $obj->fk_user_author; // deprecated - $this->author->firstname = $obj->firstname; // deprecated - $this->author->lastname = $obj->lastname; // deprecated + $this->author->id = $obj->fk_user_author; // deprecated + $this->author->firstname = $obj->firstname; // deprecated + $this->author->lastname = $obj->lastname; // deprecated if (!is_object($this->usermod)) $this->usermod = new stdClass(); // To avoid warning - $this->usermod->id = $obj->fk_user_mod; // deprecated + $this->usermod->id = $obj->fk_user_mod; // deprecated - $this->userownerid = $obj->fk_user_action; - $this->userdoneid = $obj->fk_user_done; + $this->userownerid = $obj->fk_user_action; + $this->userdoneid = $obj->fk_user_done; $this->priority = $obj->priority; $this->fulldayevent = $obj->fulldayevent; $this->location = $obj->location; $this->transparency = $obj->transparency; - $this->punctual = $obj->punctual; // deprecated + $this->punctual = $obj->punctual; // deprecated - $this->socid = $obj->fk_soc; // To have fetch_thirdparty method working - $this->contactid = $obj->fk_contact; // To have fetch_contact method working - $this->fk_project = $obj->fk_project; // To have fetch_projet method working + $this->socid = $obj->fk_soc; // To have fetch_thirdparty method working + $this->contactid = $obj->fk_contact; // To have fetch_contact method working + $this->fk_project = $obj->fk_project; // To have fetch_projet method working //$this->societe->id = $obj->fk_soc; // deprecated //$this->contact->id = $obj->fk_contact; // deprecated - $this->fk_element = $obj->elementid; - $this->elementid = $obj->elementid; - $this->elementtype = $obj->elementtype; + $this->fk_element = $obj->elementid; + $this->elementid = $obj->elementid; + $this->elementtype = $obj->elementtype; $this->fetchResources(); } @@ -773,7 +773,7 @@ class ActionComm extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } @@ -787,18 +787,18 @@ class ActionComm extends CommonObject */ public function fetchResources() { - $sql ='SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency'; - $sql.=' FROM '.MAIN_DB_PREFIX.'actioncomm_resources'; - $sql.=' WHERE fk_actioncomm = '.$this->id; - $sql.=" AND element_type IN ('user', 'socpeople')"; - $resql=$this->db->query($sql); + $sql = 'SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm_resources'; + $sql .= ' WHERE fk_actioncomm = '.$this->id; + $sql .= " AND element_type IN ('user', 'socpeople')"; + $resql = $this->db->query($sql); if ($resql) { - $this->userassigned=array(); - $this->socpeopleassigned=array(); + $this->userassigned = array(); + $this->socpeopleassigned = array(); // If owner is known, we must but id first into list - if ($this->userownerid > 0) $this->userassigned[$this->userownerid]=array('id'=>$this->userownerid); // Set first so will be first into list. + if ($this->userownerid > 0) $this->userassigned[$this->userownerid] = array('id'=>$this->userownerid); // Set first so will be first into list. while ($obj = $this->db->fetch_object($resql)) { @@ -806,11 +806,11 @@ class ActionComm extends CommonObject { switch ($obj->element_type) { case 'user': - $this->userassigned[$obj->fk_element]=array('id'=>$obj->fk_element, 'mandatory'=>$obj->mandatory, 'answer_status'=>$obj->answer_status, 'transparency'=>$obj->transparency); - if (empty($this->userownerid)) $this->userownerid=$obj->fk_element; // If not defined (should not happened, we fix this) + $this->userassigned[$obj->fk_element] = array('id'=>$obj->fk_element, 'mandatory'=>$obj->mandatory, 'answer_status'=>$obj->answer_status, 'transparency'=>$obj->transparency); + if (empty($this->userownerid)) $this->userownerid = $obj->fk_element; // If not defined (should not happened, we fix this) break; case 'socpeople': - $this->socpeopleassigned[$obj->fk_element]=array('id'=>$obj->fk_element, 'mandatory'=>$obj->mandatory, 'answer_status'=>$obj->answer_status, 'transparency'=>$obj->transparency); + $this->socpeopleassigned[$obj->fk_element] = array('id'=>$obj->fk_element, 'mandatory'=>$obj->mandatory, 'answer_status'=>$obj->answer_status, 'transparency'=>$obj->transparency); break; } } @@ -928,15 +928,15 @@ class ActionComm extends CommonObject if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('ACTION_DELETE', $user); + $result = $this->call_trigger('ACTION_DELETE', $user); if ($result < 0) { $error++; } // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -950,7 +950,7 @@ class ActionComm extends CommonObject else { $this->db->rollback(); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -965,70 +965,70 @@ class ActionComm extends CommonObject */ public function update($user, $notrigger = 0) { - global $langs,$conf,$hookmanager; + global $langs, $conf, $hookmanager; - $error=0; + $error = 0; // Clean parameters - $this->label=trim($this->label); - $this->note=trim($this->note); + $this->label = trim($this->label); + $this->note = trim($this->note); if (empty($this->percentage)) $this->percentage = 0; - if (empty($this->priority) || ! is_numeric($this->priority)) $this->priority = 0; + if (empty($this->priority) || !is_numeric($this->priority)) $this->priority = 0; if (empty($this->transparency)) $this->transparency = 0; if (empty($this->fulldayevent)) $this->fulldayevent = 0; if ($this->percentage > 100) $this->percentage = 100; //if ($this->percentage == 100 && ! $this->dateend) $this->dateend = $this->date; - if ($this->datep && $this->datef) $this->durationp=($this->datef - $this->datep); // deprecated + if ($this->datep && $this->datef) $this->durationp = ($this->datef - $this->datep); // deprecated //if ($this->date && $this->dateend) $this->durationa=($this->dateend - $this->date); - if ($this->datep && $this->datef && $this->datep > $this->datef) $this->datef=$this->datep; + if ($this->datep && $this->datef && $this->datep > $this->datef) $this->datef = $this->datep; //if ($this->date && $this->dateend && $this->date > $this->dateend) $this->dateend=$this->date; if ($this->fk_project < 0) $this->fk_project = 0; // Check parameters if ($this->percentage == 0 && $this->userdoneid > 0) { - $this->error="ErrorCantSaveADoneUserWithZeroPercentage"; + $this->error = "ErrorCantSaveADoneUserWithZeroPercentage"; return -1; } - $socid=(($this->socid > 0)?$this->socid:0); - $contactid=(($this->contactid > 0)?$this->contactid:0); - $userownerid=($this->userownerid?$this->userownerid:0); - $userdoneid=($this->userdoneid?$this->userdoneid:0); + $socid = (($this->socid > 0) ? $this->socid : 0); + $contactid = (($this->contactid > 0) ? $this->contactid : 0); + $userownerid = ($this->userownerid ? $this->userownerid : 0); + $userdoneid = ($this->userdoneid ? $this->userdoneid : 0); $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm "; - $sql.= " SET percent = '".$this->db->escape($this->percentage)."'"; - if ($this->type_id > 0) $sql.= ", fk_action = '".$this->db->escape($this->type_id)."'"; - $sql.= ", label = ".($this->label ? "'".$this->db->escape($this->label)."'":"null"); - $sql.= ", datep = ".(strval($this->datep)!='' ? "'".$this->db->idate($this->datep)."'" : 'null'); - $sql.= ", datep2 = ".(strval($this->datef)!='' ? "'".$this->db->idate($this->datef)."'" : 'null'); - $sql.= ", durationp = ".(isset($this->durationp) && $this->durationp >= 0 && $this->durationp != ''?"'".$this->db->escape($this->durationp)."'":"null"); // deprecated - $sql.= ", note = '".$this->db->escape($this->note_private?$this->note_private:$this->note)."'"; - $sql.= ", fk_project =". ($this->fk_project > 0 ? $this->fk_project:"null"); - $sql.= ", fk_soc =". ($socid > 0 ? $socid:"null"); - $sql.= ", fk_contact =". ($contactid > 0 ? $contactid:"null"); - $sql.= ", priority = '".$this->db->escape($this->priority)."'"; - $sql.= ", fulldayevent = '".$this->db->escape($this->fulldayevent)."'"; - $sql.= ", location = ".($this->location ? "'".$this->db->escape($this->location)."'":"null"); - $sql.= ", transparency = '".$this->db->escape($this->transparency)."'"; - $sql.= ", fk_user_mod = ".$user->id; - $sql.= ", fk_user_action=".($userownerid > 0 ? "'".$userownerid."'":"null"); - $sql.= ", fk_user_done=".($userdoneid > 0 ? "'".$userdoneid."'":"null"); - if (! empty($this->fk_element)) $sql.= ", fk_element=".($this->fk_element?$this->db->escape($this->fk_element):"null"); - if (! empty($this->elementtype)) $sql.= ", elementtype=".($this->elementtype?"'".$this->db->escape($this->elementtype)."'":"null"); - $sql.= " WHERE id=".$this->id; + $sql .= " SET percent = '".$this->db->escape($this->percentage)."'"; + if ($this->type_id > 0) $sql .= ", fk_action = '".$this->db->escape($this->type_id)."'"; + $sql .= ", label = ".($this->label ? "'".$this->db->escape($this->label)."'" : "null"); + $sql .= ", datep = ".(strval($this->datep) != '' ? "'".$this->db->idate($this->datep)."'" : 'null'); + $sql .= ", datep2 = ".(strval($this->datef) != '' ? "'".$this->db->idate($this->datef)."'" : 'null'); + $sql .= ", durationp = ".(isset($this->durationp) && $this->durationp >= 0 && $this->durationp != '' ? "'".$this->db->escape($this->durationp)."'" : "null"); // deprecated + $sql .= ", note = '".$this->db->escape($this->note_private ? $this->note_private : $this->note)."'"; + $sql .= ", fk_project =".($this->fk_project > 0 ? $this->fk_project : "null"); + $sql .= ", fk_soc =".($socid > 0 ? $socid : "null"); + $sql .= ", fk_contact =".($contactid > 0 ? $contactid : "null"); + $sql .= ", priority = '".$this->db->escape($this->priority)."'"; + $sql .= ", fulldayevent = '".$this->db->escape($this->fulldayevent)."'"; + $sql .= ", location = ".($this->location ? "'".$this->db->escape($this->location)."'" : "null"); + $sql .= ", transparency = '".$this->db->escape($this->transparency)."'"; + $sql .= ", fk_user_mod = ".$user->id; + $sql .= ", fk_user_action=".($userownerid > 0 ? "'".$userownerid."'" : "null"); + $sql .= ", fk_user_done=".($userdoneid > 0 ? "'".$userdoneid."'" : "null"); + if (!empty($this->fk_element)) $sql .= ", fk_element=".($this->fk_element ? $this->db->escape($this->fk_element) : "null"); + if (!empty($this->elementtype)) $sql .= ", elementtype=".($this->elementtype ? "'".$this->db->escape($this->elementtype)."'" : "null"); + $sql .= " WHERE id=".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); if ($this->db->query($sql)) { - $action='update'; + $action = 'update'; // Actions on extra fields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) { $error++; @@ -1036,25 +1036,25 @@ class ActionComm extends CommonObject } // Now insert assignedusers - if (! $error) + if (!$error) { - $sql ="DELETE FROM ".MAIN_DB_PREFIX."actioncomm_resources where fk_actioncomm = ".$this->id." AND element_type = 'user'"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_resources where fk_actioncomm = ".$this->id." AND element_type = 'user'"; $resql = $this->db->query($sql); - foreach($this->userassigned as $key => $val) + foreach ($this->userassigned as $key => $val) { - if (! is_array($val)) // For backward compatibility when val=id + if (!is_array($val)) // For backward compatibility when val=id { - $val=array('id'=>$val); + $val = array('id'=>$val); } - $sql ="INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; - $sql.=" VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory'])?'0':$val['mandatory']).", ".(empty($val['transparency'])?'0':$val['transparency']).", ".(empty($val['answer_status'])?'0':$val['answer_status']).")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; + $sql .= " VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory']) ? '0' : $val['mandatory']).", ".(empty($val['transparency']) ? '0' : $val['transparency']).", ".(empty($val['answer_status']) ? '0' : $val['answer_status']).")"; $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); } //var_dump($sql);exit; } @@ -1062,35 +1062,35 @@ class ActionComm extends CommonObject if (!$error) { - $sql ="DELETE FROM ".MAIN_DB_PREFIX."actioncomm_resources where fk_actioncomm = ".$this->id." AND element_type = 'socpeople'"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_resources where fk_actioncomm = ".$this->id." AND element_type = 'socpeople'"; $resql = $this->db->query($sql); if (!empty($this->socpeopleassigned)) { foreach (array_keys($this->socpeopleassigned) as $id) { - $sql ="INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; - $sql.=" VALUES(".$this->id.", 'socpeople', ".$id.", 0, 0, 0)"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; + $sql .= " VALUES(".$this->id.", 'socpeople', ".$id.", 0, 0, 0)"; $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); } } } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('ACTION_MODIFY', $user); + $result = $this->call_trigger('ACTION_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -1105,7 +1105,7 @@ class ActionComm extends CommonObject else { $this->db->rollback(); - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -1128,31 +1128,31 @@ class ActionComm extends CommonObject { global $conf, $langs; - $resarray=array(); + $resarray = array(); dol_syslog(get_class()."::getActions", LOG_DEBUG); $sql = "SELECT a.id"; - $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; - $sql.= " WHERE a.entity IN (".getEntity('agenda').")"; - if (! empty($socid)) $sql.= " AND a.fk_soc = ".$socid; - if (! empty($elementtype)) + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; + $sql .= " WHERE a.entity IN (".getEntity('agenda').")"; + if (!empty($socid)) $sql .= " AND a.fk_soc = ".$socid; + if (!empty($elementtype)) { - if ($elementtype == 'project') $sql.= ' AND a.fk_project = '.$fk_element; - else $sql.= " AND a.fk_element = ".(int) $fk_element." AND a.elementtype = '".$elementtype."'"; + if ($elementtype == 'project') $sql .= ' AND a.fk_project = '.$fk_element; + else $sql .= " AND a.fk_element = ".(int) $fk_element." AND a.elementtype = '".$elementtype."'"; } - if (! empty($filter)) $sql.= $filter; - if ($sortorder && $sortfield) $sql.=$db->order($sortfield, $sortorder); - $sql.=$db->plimit($limit, 0); + if (!empty($filter)) $sql .= $filter; + if ($sortorder && $sortfield) $sql .= $db->order($sortfield, $sortorder); + $sql .= $db->plimit($limit, 0); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); if ($num) { - for($i=0;$i<$num;$i++) + for ($i = 0; $i < $num; $i++) { $obj = $db->fetch_object($resql); $actioncommstatic = new ActionComm($db); @@ -1242,16 +1242,16 @@ class ActionComm extends CommonObject public function info($id) { $sql = 'SELECT '; - $sql.= ' a.id,'; - $sql.= ' datec,'; - $sql.= ' tms as datem,'; - $sql.= ' fk_user_author,'; - $sql.= ' fk_user_mod'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; - $sql.= ' WHERE a.id = '.$id; + $sql .= ' a.id,'; + $sql .= ' datec,'; + $sql .= ' tms as datem,'; + $sql .= ' fk_user_author,'; + $sql .= ' fk_user_mod'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a'; + $sql .= ' WHERE a.id = '.$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)) @@ -1262,7 +1262,7 @@ class ActionComm extends CommonObject { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_mod) { @@ -1271,8 +1271,8 @@ class ActionComm extends CommonObject $this->user_modification = $muser; } - $this->date_creation = $this->db->jdate($obj->datec); - if (! empty($obj->fk_user_mod)) $this->date_modification = $this->db->jdate($obj->datem); + $this->date_creation = $this->db->jdate($obj->datec); + if (!empty($obj->fk_user_mod)) $this->date_modification = $this->db->jdate($obj->datem); } $this->db->free($result); } @@ -1312,57 +1312,57 @@ class ActionComm extends CommonObject if ($mode == 0) { - if ($percent==-1 && ! $hidenastatus) return $langs->trans('StatusNotApplicable'); - elseif ($percent==0) return $langs->trans('StatusActionToDo').' (0%)'; + if ($percent == -1 && !$hidenastatus) return $langs->trans('StatusNotApplicable'); + elseif ($percent == 0) return $langs->trans('StatusActionToDo').' (0%)'; elseif ($percent > 0 && $percent < 100) return $langs->trans('StatusActionInProcess').' ('.$percent.'%)'; elseif ($percent >= 100) return $langs->trans('StatusActionDone').' (100%)'; } elseif ($mode == 1) { - if ($percent==-1 && ! $hidenastatus) return $langs->trans('StatusNotApplicable'); - elseif ($percent==0) return $langs->trans('StatusActionToDo'); + if ($percent == -1 && !$hidenastatus) return $langs->trans('StatusNotApplicable'); + elseif ($percent == 0) return $langs->trans('StatusActionToDo'); elseif ($percent > 0 && $percent < 100) return $percent.'%'; elseif ($percent >= 100) return $langs->trans('StatusActionDone'); } elseif ($mode == 2) { - if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans('StatusNotApplicable'), 'statut9').' '.$langs->trans('StatusNotApplicable'); - elseif ($percent==0) return img_picto($langs->trans('StatusActionToDo'), 'statut1').' '.$langs->trans('StatusActionToDo'); - elseif ($percent > 0 && $percent < 100) return img_picto($langs->trans('StatusActionInProcess'), 'statut3').' '. $percent.'%'; + if ($percent == -1 && !$hidenastatus) return img_picto($langs->trans('StatusNotApplicable'), 'statut9').' '.$langs->trans('StatusNotApplicable'); + elseif ($percent == 0) return img_picto($langs->trans('StatusActionToDo'), 'statut1').' '.$langs->trans('StatusActionToDo'); + elseif ($percent > 0 && $percent < 100) return img_picto($langs->trans('StatusActionInProcess'), 'statut3').' '.$percent.'%'; elseif ($percent >= 100) return img_picto($langs->trans('StatusActionDone'), 'statut6').' '.$langs->trans('StatusActionDone'); } elseif ($mode == 3) { - if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans("Status").': '.$langs->trans('StatusNotApplicable'), 'statut9'); - elseif ($percent==0) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionToDo').' (0%)', 'statut1'); + if ($percent == -1 && !$hidenastatus) return img_picto($langs->trans("Status").': '.$langs->trans('StatusNotApplicable'), 'statut9'); + elseif ($percent == 0) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionToDo').' (0%)', 'statut1'); elseif ($percent > 0 && $percent < 100) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionInProcess').' ('.$percent.'%)', 'statut3'); elseif ($percent >= 100) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionDone').' (100%)', 'statut6'); } elseif ($mode == 4) { - if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans('StatusNotApplicable'), 'statut9').' '.$langs->trans('StatusNotApplicable'); - elseif ($percent==0) return img_picto($langs->trans('StatusActionToDo'), 'statut1').' '.$langs->trans('StatusActionToDo').' (0%)'; + if ($percent == -1 && !$hidenastatus) return img_picto($langs->trans('StatusNotApplicable'), 'statut9').' '.$langs->trans('StatusNotApplicable'); + elseif ($percent == 0) return img_picto($langs->trans('StatusActionToDo'), 'statut1').' '.$langs->trans('StatusActionToDo').' (0%)'; elseif ($percent > 0 && $percent < 100) return img_picto($langs->trans('StatusActionInProcess'), 'statut3').' '.$langs->trans('StatusActionInProcess').' ('.$percent.'%)'; elseif ($percent >= 100) return img_picto($langs->trans('StatusActionDone'), 'statut6').' '.$langs->trans('StatusActionDone').' (100%)'; } elseif ($mode == 5) { - if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans('StatusNotApplicable'), 'statut9'); - elseif ($percent==0) return '0% '.img_picto($langs->trans('StatusActionToDo'), 'statut1'); + if ($percent == -1 && !$hidenastatus) return img_picto($langs->trans('StatusNotApplicable'), 'statut9'); + elseif ($percent == 0) return '0% '.img_picto($langs->trans('StatusActionToDo'), 'statut1'); elseif ($percent > 0 && $percent < 100) return $percent.'% '.img_picto($langs->trans('StatusActionInProcess').' - '.$percent.'%', 'statut3'); elseif ($percent >= 100) return $langs->trans('StatusActionDone').' '.img_picto($langs->trans('StatusActionDone'), 'statut6'); } elseif ($mode == 6) { - if ($percent==-1 && ! $hidenastatus) return $langs->trans('StatusNotApplicable').' '.img_picto($langs->trans('StatusNotApplicable'), 'statut9'); - elseif ($percent==0) return $langs->trans('StatusActionToDo').' (0%) '.img_picto($langs->trans('StatusActionToDo'), 'statut1'); + if ($percent == -1 && !$hidenastatus) return $langs->trans('StatusNotApplicable').' '.img_picto($langs->trans('StatusNotApplicable'), 'statut9'); + elseif ($percent == 0) return $langs->trans('StatusActionToDo').' (0%) '.img_picto($langs->trans('StatusActionToDo'), 'statut1'); elseif ($percent > 0 && $percent < 100) return $langs->trans('StatusActionInProcess').' ('.$percent.'%) '.img_picto($langs->trans('StatusActionInProcess').' - '.$percent.'%', 'statut3'); elseif ($percent >= 100) return $langs->trans('StatusActionDone').' (100%) '.img_picto($langs->trans('StatusActionDone'), 'statut6'); } elseif ($mode == 7) { - if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans('StatusNotApplicable'), 'statut9'); - elseif ($percent==0) return '0% '.img_picto($langs->trans('StatusActionToDo'), 'statut1'); + if ($percent == -1 && !$hidenastatus) return img_picto($langs->trans('StatusNotApplicable'), 'statut9'); + elseif ($percent == 0) return '0% '.img_picto($langs->trans('StatusActionToDo'), 'statut1'); elseif ($percent > 0 && $percent < 100) return $percent.'% '.img_picto($langs->trans('StatusActionInProcess').' - '.$percent.'%', 'statut3'); elseif ($percent >= 100) return img_picto($langs->trans('StatusActionDone'), 'statut6'); } @@ -1387,7 +1387,7 @@ class ActionComm extends CommonObject { global $conf, $langs, $user, $hookmanager, $action; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips if ((!$user->rights->agenda->allactions->read && $this->authorid != $user->id) || (!$user->rights->agenda->myactions->read && $this->authorid == $user->id)) { @@ -1395,45 +1395,45 @@ class ActionComm extends CommonObject } $label = $this->label; - if (empty($label)) $label=$this->libelle; // For backward compatibility + if (empty($label)) $label = $this->libelle; // For backward compatibility - $result=''; + $result = ''; // Set label of type $labeltype = ''; if ($this->type_code) { - $labeltype = ($langs->transnoentities("Action".$this->type_code) != "Action".$this->type_code)?$langs->transnoentities("Action".$this->type_code):$this->type_label; + $labeltype = ($langs->transnoentities("Action".$this->type_code) != "Action".$this->type_code) ? $langs->transnoentities("Action".$this->type_code) : $this->type_label; } if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { if ($this->type_code != 'AC_OTH_AUTO') $labeltype = $langs->trans('ActionAC_MANUAL'); } - $tooltip = '' . $langs->trans('ShowAction') . ''; - if (! empty($this->ref)) - $tooltip .= '
' . $langs->trans('Ref') . ': ' . $this->ref; - if (! empty($label)) - $tooltip .= '
' . $langs->trans('Title') . ': ' . $label; - if (! empty($labeltype)) - $tooltip .= '
' . $langs->trans('Type') . ': ' . $labeltype; - if (! empty($this->location)) - $tooltip .= '
' . $langs->trans('Location') . ': ' . $this->location; - if (! empty($this->note)) - $tooltip .= '
' . $langs->trans('Note') . ': ' . (dol_textishtml($this->note) ? str_replace(array("\r","\n"), "", $this->note) : str_replace(array("\r","\n"), '
', $this->note)); - $linkclose=''; - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE) && $this->type_color) + $tooltip = ''.$langs->trans('ShowAction').''; + if (!empty($this->ref)) + $tooltip .= '
'.$langs->trans('Ref').': '.$this->ref; + if (!empty($label)) + $tooltip .= '
'.$langs->trans('Title').': '.$label; + if (!empty($labeltype)) + $tooltip .= '
'.$langs->trans('Type').': '.$labeltype; + if (!empty($this->location)) + $tooltip .= '
'.$langs->trans('Location').': '.$this->location; + if (!empty($this->note)) + $tooltip .= '
'.$langs->trans('Note').': '.(dol_textishtml($this->note) ? str_replace(array("\r", "\n"), "", $this->note) : str_replace(array("\r", "\n"), '
', $this->note)); + $linkclose = ''; + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && $this->type_color) $linkclose = ' style="background-color:#'.$this->type_color.'"'; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowAction"); - $linkclose.=' alt="'.dol_escape_htmltag($tooltip, 1).'"'; + $label = $langs->trans("ShowAction"); + $linkclose .= ' alt="'.dol_escape_htmltag($tooltip, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($tooltip, 1).'"'; - $linkclose.=' class="'.$classname.' classfortooltip"'; + $linkclose .= ' title="'.dol_escape_htmltag($tooltip, 1).'"'; + $linkclose .= ' class="'.$classname.' classfortooltip"'; /* $hookmanager->initHooks(array('actiondao')); @@ -1442,24 +1442,24 @@ class ActionComm extends CommonObject $linkclose = ($hookmanager->resPrint ? $hookmanager->resPrint : $linkclose); */ } - else $linkclose.=' class="'.$classname.'"'; + else $linkclose .= ' class="'.$classname.'"'; - $url=''; - if ($option=='birthday') + $url = ''; + if ($option == 'birthday') $url = DOL_URL_ROOT.'/contact/perso.php?id='.$this->id; else $url = DOL_URL_ROOT.'/comm/action/card.php?id='.$this->id; if ($option !== 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; } $linkstart = '
'; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; if ($option == 'nolink') { $linkstart = ''; @@ -1468,38 +1468,38 @@ class ActionComm extends CommonObject if ($withpicto == 2) { - $libelle=$label; - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $libelle=$labeltype; - $libelleshort=''; + $libelle = $label; + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) $libelle = $labeltype; + $libelleshort = ''; } else { - $libelle=(empty($this->libelle)?$label:$this->libelle.(($label && $label != $this->libelle)?' '.$label:'')); - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($libelle)) $libelle=$labeltype; - if ($maxlength < 0) $libelleshort=$this->ref; - else $libelleshort=dol_trunc($libelle, $maxlength); + $libelle = (empty($this->libelle) ? $label : $this->libelle.(($label && $label != $this->libelle) ? ' '.$label : '')); + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($libelle)) $libelle = $labeltype; + if ($maxlength < 0) $libelleshort = $this->ref; + else $libelleshort = dol_trunc($libelle, $maxlength); } if ($withpicto) { - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) // Add code into () + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) // Add code into () { if ($labeltype) { - $libelle.=(preg_match('/'.preg_quote($labeltype, '/').'/', $libelle)?'':' ('.$langs->transnoentities("Action".$this->type_code).')'); + $libelle .= (preg_match('/'.preg_quote($labeltype, '/').'/', $libelle) ? '' : ' ('.$langs->transnoentities("Action".$this->type_code).')'); } } } - $result.=$linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$langs->trans("ShowAction").': '.$libelle), ($overwritepicto?$overwritepicto:'action'), ($notooltip?'class="'.(($withpicto != 2) ? 'paddingright ' : '').'valigntextbottom"':'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip valigntextbottom"'), 0, 0, $notooltip?0:1); - $result.=$libelleshort; - $result.=$linkend; + $result .= $linkstart; + if ($withpicto) $result .= img_object(($notooltip ? '' : $langs->trans("ShowAction").': '.$libelle), ($overwritepicto ? $overwritepicto : 'action'), ($notooltip ? 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'valigntextbottom"' : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip valigntextbottom"'), 0, 0, $notooltip ? 0 : 1); + $result .= $libelleshort; + $result .= $linkend; global $action; $hookmanager->initHooks(array('actiondao')); - $parameters=array('id'=>$this->id, 'getnomurl'=>$result); - $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) $result = $hookmanager->resPrint; else $result .= $hookmanager->resPrint; @@ -1523,11 +1523,11 @@ class ActionComm extends CommonObject global $hookmanager; // phpcs:enable - global $conf,$langs,$dolibarr_main_url_root,$mysoc; + global $conf, $langs, $dolibarr_main_url_root, $mysoc; - require_once DOL_DOCUMENT_ROOT ."/core/lib/xcal.lib.php"; - require_once DOL_DOCUMENT_ROOT ."/core/lib/date.lib.php"; - require_once DOL_DOCUMENT_ROOT ."/core/lib/files.lib.php"; + require_once DOL_DOCUMENT_ROOT."/core/lib/xcal.lib.php"; + require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"; + require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; dol_syslog(get_class($this)."::build_exportfile Build export file format=".$format.", type=".$type.", cachedelay=".$cachedelay.", filename=".$filename.", filters size=".count($filters), LOG_DEBUG); @@ -1535,21 +1535,21 @@ class ActionComm extends CommonObject if (empty($format)) return -1; // Clean parameters - if (! $filename) + if (!$filename) { - $extension='vcs'; - if ($format == 'ical') $extension='ics'; - $filename=$format.'.'.$extension; + $extension = 'vcs'; + if ($format == 'ical') $extension = 'ics'; + $filename = $format.'.'.$extension; } // Create dir and define output file (definitive and temporary) - $result=dol_mkdir($conf->agenda->dir_temp); - $outputfile=$conf->agenda->dir_temp.'/'.$filename; + $result = dol_mkdir($conf->agenda->dir_temp); + $outputfile = $conf->agenda->dir_temp.'/'.$filename; - $result=0; + $result = 0; - $buildfile=true; - $login='';$logina='';$logind='';$logint=''; + $buildfile = true; + $login = ''; $logina = ''; $logind = ''; $logint = ''; $now = dol_now(); @@ -1774,7 +1774,7 @@ class ActionComm extends CommonObject dol_syslog(get_class($this)."::build_exportfile build_xxxfile function fails to for format=".$format." outputfiletmp=".$outputfile, LOG_ERR); dol_delete_file($outputfiletmp, 0, 1); $langs->load("errors"); - $this->error=$langs->trans("ErrorFailToCreateFile", $outputfile); + $this->error = $langs->trans("ErrorFailToCreateFile", $outputfile); } } @@ -1792,32 +1792,32 @@ class ActionComm extends CommonObject { global $user; - $now=dol_now(); + $now = dol_now(); // Initialise parametres - $this->id=0; - $this->specimen=1; + $this->id = 0; + $this->specimen = 1; - $this->type_code='AC_OTH'; - $this->code='AC_SPECIMEN_CODE'; - $this->label='Label of event Specimen'; - $this->datec=$now; - $this->datem=$now; - $this->datep=$now; - $this->datef=$now; - $this->author=$user; - $this->usermod=$user; - $this->usertodo=$user; - $this->fulldayevent=0; - $this->punctual=0; - $this->percentage=0; - $this->location='Location'; - $this->transparency=1; // 1 means opaque - $this->priority=1; + $this->type_code = 'AC_OTH'; + $this->code = 'AC_SPECIMEN_CODE'; + $this->label = 'Label of event Specimen'; + $this->datec = $now; + $this->datem = $now; + $this->datep = $now; + $this->datef = $now; + $this->author = $user; + $this->usermod = $user; + $this->usertodo = $user; + $this->fulldayevent = 0; + $this->punctual = 0; + $this->percentage = 0; + $this->location = 'Location'; + $this->transparency = 1; // 1 means opaque + $this->priority = 1; $this->note = 'Note'; - $this->userownerid=$user->id; - $this->userassigned[$user->id]=array('id'=>$user->id, 'transparency'=> 1); + $this->userownerid = $user->id; + $this->userassigned[$user->id] = array('id'=>$user->id, 'transparency'=> 1); return 1; } @@ -1865,7 +1865,7 @@ class ActionComm extends CommonObject $error = 0; $this->output = ''; - $this->error=''; + $this->error = ''; if (empty($conf->agenda->enabled)) // Should not happen. If module disabled, cron job should not be visible. { diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php index 67ec7414e7c..9c589c4ae3d 100644 --- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php +++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php @@ -35,7 +35,7 @@ class FormAdvTargetEmailing extends Form /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * Constructor @@ -62,15 +62,15 @@ class FormAdvTargetEmailing extends Form $options_array = array(); $sql = "SELECT code, label"; - $sql .= " FROM " . MAIN_DB_PREFIX . "c_prospectlevel"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_prospectlevel"; $sql .= " WHERE active > 0"; $sql .= " ORDER BY sortorder"; - dol_syslog(get_class($this) . '::multiselectProspectionStatus sql=' . $sql, LOG_DEBUG); + dol_syslog(get_class($this).'::multiselectProspectionStatus sql='.$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ( $i < $num ) { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $level = $langs->trans($obj->code); @@ -78,7 +78,7 @@ class FormAdvTargetEmailing extends Form $level = $langs->trans($obj->label); $options_array[$obj->code] = $level; - $i ++; + $i++; } } else { dol_print_error($this->db); @@ -102,16 +102,16 @@ class FormAdvTargetEmailing extends Form $out = ''; $countryArray = array(); - $label = array (); + $label = array(); $options_array = array(); $sql = "SELECT rowid, code as code_iso, label"; - $sql .= " FROM " . MAIN_DB_PREFIX . "c_country"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_country"; $sql .= " WHERE active = 1 AND code<>''"; $sql .= " ORDER BY code ASC"; - dol_syslog(get_class($this) . "::select_country sql=" . $sql); + dol_syslog(get_class($this)."::select_country sql=".$sql); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -123,9 +123,9 @@ class FormAdvTargetEmailing extends Form $obj = $this->db->fetch_object($resql); $countryArray [$i] ['rowid'] = $obj->rowid; $countryArray [$i] ['code_iso'] = $obj->code_iso; - $countryArray [$i] ['label'] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country" . $obj->code_iso) != "Country" . $obj->code_iso ? $langs->transnoentitiesnoconv("Country" . $obj->code_iso) : ($obj->label != '-' ? $obj->label : '')); + $countryArray [$i] ['label'] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country".$obj->code_iso) != "Country".$obj->code_iso ? $langs->transnoentitiesnoconv("Country".$obj->code_iso) : ($obj->label != '-' ? $obj->label : '')); $label[$i] = $countryArray[$i]['label']; - $i ++; + $i++; } array_multisort($label, SORT_ASC, $countryArray); @@ -133,7 +133,7 @@ class FormAdvTargetEmailing extends Form foreach ($countryArray as $row) { $label = dol_trunc($row['label'], $maxlength, 'middle'); if ($row['code_iso']) - $label .= ' (' . $row['code_iso'] . ')'; + $label .= ' ('.$row['code_iso'].')'; $options_array[$row['rowid']] = $label; } @@ -158,23 +158,23 @@ class FormAdvTargetEmailing extends Form global $conf; - $options_array = array (); + $options_array = array(); - $sql_usr = ''; + $sql_usr = ''; $sql_usr .= "SELECT DISTINCT u2.rowid, u2.lastname as name, u2.firstname, u2.login"; - $sql_usr .= " FROM " . MAIN_DB_PREFIX . "user as u2, " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; - $sql_usr .= " WHERE u2.entity IN (0," . $conf->entity . ")"; + $sql_usr .= " FROM ".MAIN_DB_PREFIX."user as u2, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql_usr .= " WHERE u2.entity IN (0,".$conf->entity.")"; $sql_usr .= " AND u2.rowid = sc.fk_user "; - if (! empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX)) + if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX)) $sql_usr .= " AND u2.statut<>0 "; $sql_usr .= " ORDER BY name ASC"; // print $sql_usr;exit; $resql_usr = $this->db->query($sql_usr); if ($resql_usr) { - while ( $obj_usr = $this->db->fetch_object($resql_usr) ) { - $label = $obj_usr->firstname . " " . $obj_usr->name . " (" . $obj_usr->login . ')'; + while ($obj_usr = $this->db->fetch_object($resql_usr)) { + $label = $obj_usr->firstname." ".$obj_usr->name." (".$obj_usr->login.')'; $options_array [$obj_usr->rowid] = $label; } @@ -196,11 +196,11 @@ class FormAdvTargetEmailing extends Form public function multiselectselectLanguage($htmlname = '', $selected_array = array()) { - global $conf,$langs; + global $conf, $langs; - $options_array = array (); + $options_array = array(); - $langs_available=$langs->get_available_languages(DOL_DOCUMENT_ROOT, 12); + $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12); foreach ($langs_available as $key => $value) { @@ -222,7 +222,7 @@ class FormAdvTargetEmailing extends Form */ public function advMultiselectarraySelllist($htmlname, $sqlqueryparam = array(), $selected_array = array()) { - $options_array=array(); + $options_array = array(); if (is_array($sqlqueryparam)) { @@ -238,39 +238,39 @@ class FormAdvTargetEmailing extends Form if (count($InfoFieldList) >= 3) { if (strpos($InfoFieldList [3], 'extra.') !== false) { - $keyList = 'main.' . $InfoFieldList [2] . ' as rowid'; + $keyList = 'main.'.$InfoFieldList [2].' as rowid'; } else { - $keyList = $InfoFieldList [2] . ' as rowid'; + $keyList = $InfoFieldList [2].' as rowid'; } } - $sql = 'SELECT ' . $keyList . ', ' . $InfoFieldList [1]; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList [0]; - if (! empty($InfoFieldList [3])) { + $sql = 'SELECT '.$keyList.', '.$InfoFieldList [1]; + $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList [0]; + if (!empty($InfoFieldList [3])) { // We have to join on extrafield table if (strpos($InfoFieldList [3], 'extra') !== false) { - $sql .= ' as main, ' . MAIN_DB_PREFIX . $InfoFieldList [0] . '_extrafields as extra'; - $sql .= ' WHERE extra.fk_object=main.' . $InfoFieldList [2] . ' AND ' . $InfoFieldList [3]; + $sql .= ' as main, '.MAIN_DB_PREFIX.$InfoFieldList [0].'_extrafields as extra'; + $sql .= ' WHERE extra.fk_object=main.'.$InfoFieldList [2].' AND '.$InfoFieldList [3]; } else { - $sql .= ' WHERE ' . $InfoFieldList [3]; + $sql .= ' WHERE '.$InfoFieldList [3]; } } - if (! empty($InfoFieldList[1])) { + if (!empty($InfoFieldList[1])) { $sql .= " ORDER BY nom"; } // $sql.= ' WHERE entity = '.$conf->entity; - dol_syslog(get_class($this) . "::".__METHOD__, LOG_DEBUG); + dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); $i = 0; if ($num) { - while ( $i < $num ) { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $labeltoshow = dol_trunc($obj->$InfoFieldList [1], 90); - $options_array[$obj->rowid]=$labeltoshow; - $i ++; + $options_array[$obj->rowid] = $labeltoshow; + $i++; } } $this->db->free($resql); @@ -289,17 +289,17 @@ class FormAdvTargetEmailing extends Form */ public function multiselectCivility($htmlname = 'civilite_id', $selected_array = array()) { - global $conf,$langs,$user; + global $conf, $langs, $user; $langs->load("dict"); - $options_array=array(); + $options_array = array(); $sql = "SELECT rowid, code, label as civilite, active FROM ".MAIN_DB_PREFIX."c_civility"; - $sql.= " WHERE active = 1"; + $sql .= " WHERE active = 1"; dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -310,10 +310,10 @@ class FormAdvTargetEmailing extends Form { $obj = $this->db->fetch_object($resql); // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut - $label= ($langs->trans("Civility".$obj->code)!="Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->civilite!='-'?$obj->civilite:'')); + $label = ($langs->trans("Civility".$obj->code) != "Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->civilite != '-' ? $obj->civilite : '')); - $options_array[$obj->code]=$label; + $options_array[$obj->code] = $label; $i++; } @@ -340,7 +340,7 @@ class FormAdvTargetEmailing extends Form { global $conf, $langs; - $form=new Form($this->db); + $form = new Form($this->db); $return = $form->multiselectarray($htmlname, $options_array, $selected_array, 0, 0, '', 0, 295); return $return; } @@ -379,16 +379,16 @@ class FormAdvTargetEmailing extends Form */ public function multiselectCategories($htmlname = '', $selected_array = array(), $type = 0) { - global $conf,$langs,$user; + global $conf, $langs, $user; $langs->load("dict"); - $options_array=array(); + $options_array = array(); $sql = "SELECT rowid, label FROM ".MAIN_DB_PREFIX."categorie"; - $sql.= " WHERE type=".$type; + $sql .= " WHERE type=".$type; dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -399,7 +399,7 @@ class FormAdvTargetEmailing extends Form { $obj = $this->db->fetch_object($resql); - $options_array[$obj->rowid]=$obj->label; + $options_array[$obj->rowid] = $obj->label; $i++; } @@ -429,32 +429,32 @@ class FormAdvTargetEmailing extends Form $out = ''; $sql = "SELECT c.rowid, c.name, c.fk_element"; - $sql .= " FROM " . MAIN_DB_PREFIX . "advtargetemailing as c"; + $sql .= " FROM ".MAIN_DB_PREFIX."advtargetemailing as c"; $sql .= " WHERE type_element='$type_element'"; $sql .= " ORDER BY c.name"; - dol_syslog(get_class($this) . "::".__METHOD__, LOG_DEBUG); + dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $out .= ''; if ($showempty) $out .= ''; $num = $this->db->num_rows($resql); $i = 0; if ($num) { - while ( $i < $num ) { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $label = $obj->name; if (empty($label)) { - $label=$obj->fk_element; + $label = $obj->fk_element; } if ($selected > 0 && $selected == $obj->rowid) { - $out .= ''; + $out .= ''; } else { - $out .= ''; + $out .= ''; } - $i ++; + $i++; } } $out .= ''; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 57cff121010..ec29e4e5240 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -28,7 +28,7 @@ * \ingroup bank * \brief File of class to manage bank accounts */ -require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; /** @@ -92,7 +92,7 @@ class Account extends CommonObject * Does it need to be conciliated? * @var int */ - public $rappro=1; + public $rappro = 1; /** * Webpage @@ -315,18 +315,18 @@ class Account extends CommonObject { // phpcs:enable $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_url ("; - $sql.= "fk_bank"; - $sql.= ", url_id"; - $sql.= ", url"; - $sql.= ", label"; - $sql.= ", type"; - $sql.= ") VALUES ("; - $sql.= "'".$line_id."'"; - $sql.= ", '".$url_id."'"; - $sql.= ", '".$url."'"; - $sql.= ", '".$this->db->escape($label)."'"; - $sql.= ", '".$type."'"; - $sql.= ")"; + $sql .= "fk_bank"; + $sql .= ", url_id"; + $sql .= ", url"; + $sql .= ", label"; + $sql .= ", type"; + $sql .= ") VALUES ("; + $sql .= "'".$line_id."'"; + $sql .= ", '".$url_id."'"; + $sql .= ", '".$url."'"; + $sql .= ", '".$this->db->escape($label)."'"; + $sql .= ", '".$type."'"; + $sql .= ")"; dol_syslog(get_class($this)."::add_url_line", LOG_DEBUG); if ($this->db->query($sql)) @@ -336,7 +336,7 @@ class Account extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -357,20 +357,20 @@ class Account extends CommonObject $lines = array(); // Check parameters - if (! empty($fk_bank) && (! empty($url_id) || ! empty($type))) + if (!empty($fk_bank) && (!empty($url_id) || !empty($type))) { - $this->error="ErrorBadParameter"; + $this->error = "ErrorBadParameter"; return -1; } $sql = "SELECT fk_bank, url_id, url, label, type"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_url"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank_url"; if ($fk_bank > 0) { - $sql.= " WHERE fk_bank = ".$fk_bank; + $sql .= " WHERE fk_bank = ".$fk_bank; } - else { $sql.= " WHERE url_id = ".$url_id." AND type = '".$type."'"; + else { $sql .= " WHERE url_id = ".$url_id." AND type = '".$type."'"; } - $sql.= " ORDER BY type, label"; + $sql .= " ORDER BY type, label"; dol_syslog(get_class($this)."::get_url", LOG_DEBUG); $result = $this->db->query($sql); @@ -420,25 +420,25 @@ class Account extends CommonObject { // Deprecation warning if (is_numeric($oper)) { - dol_syslog(__METHOD__ . ": using numeric operations is deprecated", LOG_WARNING); + dol_syslog(__METHOD__.": using numeric operations is deprecated", LOG_WARNING); } // Clean parameters - $emetteur=trim($emetteur); - $banque=trim($banque); + $emetteur = trim($emetteur); + $banque = trim($banque); - $now=dol_now(); + $now = dol_now(); if (is_numeric($oper)) // Clean operation to have a code instead of a rowid { $sql = "SELECT code FROM ".MAIN_DB_PREFIX."c_paiement"; - $sql.= " WHERE id=".$oper; - $sql.= " AND entity IN (".getEntity('c_paiement').")"; - $resql=$this->db->query($sql); + $sql .= " WHERE id=".$oper; + $sql .= " AND entity IN (".getEntity('c_paiement').")"; + $resql = $this->db->query($sql); if ($resql) { - $obj=$this->db->fetch_object($resql); - $oper=$obj->code; + $obj = $this->db->fetch_object($resql); + $oper = $obj->code; } else { @@ -448,19 +448,19 @@ class Account extends CommonObject } // Check parameters - if (! $oper) + if (!$oper) { - $this->error="oper not defined"; + $this->error = "oper not defined"; return -1; } - if (! $this->rowid) + if (!$this->rowid) { - $this->error="this->rowid not defined"; + $this->error = "this->rowid not defined"; return -2; } if ($this->courant == Account::TYPE_CASH && $oper != 'LIQ') { - $this->error="ErrorCashAccountAcceptsOnlyCashMoney"; + $this->error = "ErrorCashAccountAcceptsOnlyCashMoney"; return -3; } @@ -492,7 +492,7 @@ class Account extends CommonObject } if ($accline->insert() > 0) { - if ($categorie>0) { + if ($categorie > 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class ("; $sql .= "lineid, fk_categ"; $sql .= ") VALUES ("; @@ -525,32 +525,32 @@ class Account extends CommonObject */ public function create(User $user, $notrigger = 0) { - global $langs,$conf, $hookmanager; + global $langs, $conf, $hookmanager; - $error=0; + $error = 0; // Clean parameters - if (! $this->min_allowed) $this->min_allowed=0; - if (! $this->min_desired) $this->min_desired=0; - $this->state_id = ($this->state_id?$this->state_id:$this->state_id); - $this->country_id = ($this->country_id?$this->country_id:$this->country_id); + if (!$this->min_allowed) $this->min_allowed = 0; + if (!$this->min_desired) $this->min_desired = 0; + $this->state_id = ($this->state_id ? $this->state_id : $this->state_id); + $this->country_id = ($this->country_id ? $this->country_id : $this->country_id); // Check parameters if (empty($this->country_id)) { - $this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Country")); + $this->error = $langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Country")); dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); return -1; } if (empty($this->ref)) { - $this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")); + $this->error = $langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")); dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); return -1; } if (empty($this->date_solde)) { - $this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateInitialBalance")); + $this->error = $langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateInitialBalance")); dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); return -1; } @@ -558,67 +558,67 @@ class Account extends CommonObject // Chargement librairie pour acces fonction controle RIB require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; - $now=dol_now(); + $now = dol_now(); $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_account ("; - $sql.= "datec"; - $sql.= ", ref"; - $sql.= ", label"; - $sql.= ", entity"; - $sql.= ", account_number"; - $sql.= ", fk_accountancy_journal"; - $sql.= ", bank"; - $sql.= ", code_banque"; - $sql.= ", code_guichet"; - $sql.= ", number"; - $sql.= ", cle_rib"; - $sql.= ", bic"; - $sql.= ", iban_prefix"; - $sql.= ", domiciliation"; - $sql.= ", proprio"; - $sql.= ", owner_address"; - $sql.= ", currency_code"; - $sql.= ", rappro"; - $sql.= ", min_allowed"; - $sql.= ", min_desired"; - $sql.= ", comment"; - $sql.= ", state_id"; - $sql.= ", fk_pays"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->idate($now)."'"; - $sql.= ", '".$this->db->escape($this->ref)."'"; - $sql.= ", '".$this->db->escape($this->label)."'"; - $sql.= ", ".$conf->entity; - $sql.= ", '".$this->db->escape($this->account_number)."'"; - $sql.= ", ".($this->fk_accountancy_journal > 0 ? $this->db->escape($this->fk_accountancy_journal) : "null"); - $sql.= ", '".$this->db->escape($this->bank)."'"; - $sql.= ", '".$this->db->escape($this->code_banque)."'"; - $sql.= ", '".$this->db->escape($this->code_guichet)."'"; - $sql.= ", '".$this->db->escape($this->number)."'"; - $sql.= ", '".$this->db->escape($this->cle_rib)."'"; - $sql.= ", '".$this->db->escape($this->bic)."'"; - $sql.= ", '".$this->db->escape($this->iban)."'"; - $sql.= ", '".$this->db->escape($this->domiciliation)."'"; - $sql.= ", '".$this->db->escape($this->proprio)."'"; - $sql.= ", '".$this->db->escape($this->owner_address)."'"; - $sql.= ", '".$this->db->escape($this->currency_code)."'"; - $sql.= ", ".$this->rappro; - $sql.= ", ".price2num($this->min_allowed); - $sql.= ", ".price2num($this->min_desired); - $sql.= ", '".$this->db->escape($this->comment)."'"; - $sql.= ", ".($this->state_id>0?$this->state_id:"null"); - $sql.= ", ".$this->country_id; - $sql.= ")"; + $sql .= "datec"; + $sql .= ", ref"; + $sql .= ", label"; + $sql .= ", entity"; + $sql .= ", account_number"; + $sql .= ", fk_accountancy_journal"; + $sql .= ", bank"; + $sql .= ", code_banque"; + $sql .= ", code_guichet"; + $sql .= ", number"; + $sql .= ", cle_rib"; + $sql .= ", bic"; + $sql .= ", iban_prefix"; + $sql .= ", domiciliation"; + $sql .= ", proprio"; + $sql .= ", owner_address"; + $sql .= ", currency_code"; + $sql .= ", rappro"; + $sql .= ", min_allowed"; + $sql .= ", min_desired"; + $sql .= ", comment"; + $sql .= ", state_id"; + $sql .= ", fk_pays"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->idate($now)."'"; + $sql .= ", '".$this->db->escape($this->ref)."'"; + $sql .= ", '".$this->db->escape($this->label)."'"; + $sql .= ", ".$conf->entity; + $sql .= ", '".$this->db->escape($this->account_number)."'"; + $sql .= ", ".($this->fk_accountancy_journal > 0 ? $this->db->escape($this->fk_accountancy_journal) : "null"); + $sql .= ", '".$this->db->escape($this->bank)."'"; + $sql .= ", '".$this->db->escape($this->code_banque)."'"; + $sql .= ", '".$this->db->escape($this->code_guichet)."'"; + $sql .= ", '".$this->db->escape($this->number)."'"; + $sql .= ", '".$this->db->escape($this->cle_rib)."'"; + $sql .= ", '".$this->db->escape($this->bic)."'"; + $sql .= ", '".$this->db->escape($this->iban)."'"; + $sql .= ", '".$this->db->escape($this->domiciliation)."'"; + $sql .= ", '".$this->db->escape($this->proprio)."'"; + $sql .= ", '".$this->db->escape($this->owner_address)."'"; + $sql .= ", '".$this->db->escape($this->currency_code)."'"; + $sql .= ", ".$this->rappro; + $sql .= ", ".price2num($this->min_allowed); + $sql .= ", ".price2num($this->min_desired); + $sql .= ", '".$this->db->escape($this->comment)."'"; + $sql .= ", ".($this->state_id > 0 ? $this->state_id : "null"); + $sql .= ", ".$this->country_id; + $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."bank_account"); - $result=$this->update($user, 1); + $result = $this->update($user, 1); if ($result > 0) { $accline = new AccountLine($this->db); @@ -637,16 +637,16 @@ class Account extends CommonObject $this->errors = $accline->errors; } - if (! $error) + if (!$error) { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) $error++; } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('BANKACCOUNT_CREATE', $user); + $result = $this->call_trigger('BANKACCOUNT_CREATE', $user); if ($result < 0) $error++; // End call triggers } @@ -660,16 +660,16 @@ class Account extends CommonObject { if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $this->error=$langs->trans("ErrorBankLabelAlreadyExists"); + $this->error = $langs->trans("ErrorBankLabelAlreadyExists"); $error++; } else { - $this->error=$this->db->error()." sql=".$sql; + $this->error = $this->db->error()." sql=".$sql; $error++; } } - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; @@ -677,7 +677,7 @@ class Account extends CommonObject else { $this->db->rollback(); - return -1*$error; + return -1 * $error; } } @@ -690,63 +690,63 @@ class Account extends CommonObject */ public function update(User $user, $notrigger = 0) { - global $langs,$conf, $hookmanager; + global $langs, $conf, $hookmanager; - $error=0; + $error = 0; $this->db->begin(); // Clean parameters - $this->state_id = ($this->state_id?$this->state_id:$this->state_id); - $this->country_id = ($this->country_id?$this->country_id:$this->country_id); + $this->state_id = ($this->state_id ? $this->state_id : $this->state_id); + $this->country_id = ($this->country_id ? $this->country_id : $this->country_id); // Check parameters if (empty($this->country_id)) { - $this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Country")); + $this->error = $langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Country")); dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR); return -1; } if (empty($this->ref)) { - $this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")); + $this->error = $langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")); dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR); return -1; } - if (! $this->label) $this->label = "???"; + if (!$this->label) $this->label = "???"; $sql = "UPDATE ".MAIN_DB_PREFIX."bank_account SET "; - $sql.= " ref = '".$this->db->escape($this->ref)."'"; - $sql.= ",label = '".$this->db->escape($this->label)."'"; + $sql .= " ref = '".$this->db->escape($this->ref)."'"; + $sql .= ",label = '".$this->db->escape($this->label)."'"; - $sql.= ",courant = ".$this->courant; - $sql.= ",clos = ".$this->clos; - $sql.= ",rappro = ".$this->rappro; - $sql.= ",url = ".($this->url?"'".$this->db->escape($this->url)."'":"null"); - $sql.= ",account_number = '".$this->db->escape($this->account_number)."'"; - $sql.= ",fk_accountancy_journal = ".($this->fk_accountancy_journal > 0 ? $this->db->escape($this->fk_accountancy_journal) : "null"); - $sql.= ",bank = '".$this->db->escape($this->bank)."'"; - $sql.= ",code_banque='".$this->db->escape($this->code_banque)."'"; - $sql.= ",code_guichet='".$this->db->escape($this->code_guichet)."'"; - $sql.= ",number='".$this->db->escape($this->number)."'"; - $sql.= ",cle_rib='".$this->db->escape($this->cle_rib)."'"; - $sql.= ",bic='".$this->db->escape($this->bic)."'"; - $sql.= ",iban_prefix = '".$this->db->escape($this->iban)."'"; - $sql.= ",domiciliation='".$this->db->escape($this->domiciliation)."'"; - $sql.= ",proprio = '".$this->db->escape($this->proprio)."'"; - $sql.= ",owner_address = '".$this->db->escape($this->owner_address)."'"; + $sql .= ",courant = ".$this->courant; + $sql .= ",clos = ".$this->clos; + $sql .= ",rappro = ".$this->rappro; + $sql .= ",url = ".($this->url ? "'".$this->db->escape($this->url)."'" : "null"); + $sql .= ",account_number = '".$this->db->escape($this->account_number)."'"; + $sql .= ",fk_accountancy_journal = ".($this->fk_accountancy_journal > 0 ? $this->db->escape($this->fk_accountancy_journal) : "null"); + $sql .= ",bank = '".$this->db->escape($this->bank)."'"; + $sql .= ",code_banque='".$this->db->escape($this->code_banque)."'"; + $sql .= ",code_guichet='".$this->db->escape($this->code_guichet)."'"; + $sql .= ",number='".$this->db->escape($this->number)."'"; + $sql .= ",cle_rib='".$this->db->escape($this->cle_rib)."'"; + $sql .= ",bic='".$this->db->escape($this->bic)."'"; + $sql .= ",iban_prefix = '".$this->db->escape($this->iban)."'"; + $sql .= ",domiciliation='".$this->db->escape($this->domiciliation)."'"; + $sql .= ",proprio = '".$this->db->escape($this->proprio)."'"; + $sql .= ",owner_address = '".$this->db->escape($this->owner_address)."'"; - $sql.= ",currency_code = '".$this->db->escape($this->currency_code)."'"; + $sql .= ",currency_code = '".$this->db->escape($this->currency_code)."'"; - $sql.= ",min_allowed = ".($this->min_allowed != '' ? price2num($this->min_allowed) : "null"); - $sql.= ",min_desired = ".($this->min_desired != '' ? price2num($this->min_desired) : "null"); - $sql.= ",comment = '".$this->db->escape($this->comment)."'"; + $sql .= ",min_allowed = ".($this->min_allowed != '' ? price2num($this->min_allowed) : "null"); + $sql .= ",min_desired = ".($this->min_desired != '' ? price2num($this->min_desired) : "null"); + $sql .= ",comment = '".$this->db->escape($this->comment)."'"; - $sql.= ",state_id = ".($this->state_id>0?$this->state_id:"null"); - $sql.= ",fk_pays = ".$this->country_id; + $sql .= ",state_id = ".($this->state_id > 0 ? $this->state_id : "null"); + $sql .= ",fk_pays = ".$this->country_id; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); $result = $this->db->query($sql); @@ -755,17 +755,17 @@ class Account extends CommonObject // Actions on extra fields (by external module or standard code) if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - if (! $error) + if (!$error) { - $result=$this->insertExtraFields(); + $result = $this->insertExtraFields(); if ($result < 0) $error++; } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('BANKACCOUNT_UPDATE', $user); + $result = $this->call_trigger('BANKACCOUNT_UPDATE', $user); if ($result < 0) $error++; // End call triggers } @@ -773,11 +773,11 @@ class Account extends CommonObject else { $error++; - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); dol_print_error($this->db); } - if (! $error) + if (!$error) { $this->db->commit(); return $this->id; @@ -785,7 +785,7 @@ class Account extends CommonObject else { $this->db->rollback(); - return -1*$error; + return -1 * $error; } } @@ -800,11 +800,11 @@ class Account extends CommonObject public function update_bban(User $user = null) { // phpcs:enable - global $conf,$langs; + global $conf, $langs; // Clean parameters - $this->state_id = ($this->state_id?$this->state_id:$this->state_id); - $this->country_id = ($this->country_id?$this->country_id:$this->country_id); + $this->state_id = ($this->state_id ? $this->state_id : $this->state_id); + $this->country_id = ($this->country_id ? $this->country_id : $this->country_id); // Chargement librairie pour acces fonction controle RIB require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; @@ -812,27 +812,27 @@ class Account extends CommonObject dol_syslog(get_class($this)."::update_bban $this->code_banque,$this->code_guichet,$this->number,$this->cle_rib,$this->iban"); // Check parameters - if (! $this->ref) + if (!$this->ref) { - $this->error=$langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->trans("Ref")); + $this->error = $langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->trans("Ref")); return -2; } $sql = "UPDATE ".MAIN_DB_PREFIX."bank_account SET "; - $sql.= " bank = '".$this->db->escape($this->bank)."'"; - $sql.= ",code_banque='".$this->db->escape($this->code_banque)."'"; - $sql.= ",code_guichet='".$this->db->escape($this->code_guichet)."'"; - $sql.= ",number='".$this->db->escape($this->number)."'"; - $sql.= ",cle_rib='".$this->db->escape($this->cle_rib)."'"; - $sql.= ",bic='".$this->db->escape($this->bic)."'"; - $sql.= ",iban_prefix = '".$this->db->escape($this->iban)."'"; - $sql.= ",domiciliation='".$this->db->escape($this->domiciliation)."'"; - $sql.= ",proprio = '".$this->db->escape($this->proprio)."'"; - $sql.= ",owner_address = '".$this->db->escape($this->owner_address)."'"; - $sql.= ",state_id = ".($this->state_id>0?$this->state_id:"null"); - $sql.= ",fk_pays = ".$this->country_id; - $sql.= " WHERE rowid = ".$this->id; - $sql.= " AND entity = ".$conf->entity; + $sql .= " bank = '".$this->db->escape($this->bank)."'"; + $sql .= ",code_banque='".$this->db->escape($this->code_banque)."'"; + $sql .= ",code_guichet='".$this->db->escape($this->code_guichet)."'"; + $sql .= ",number='".$this->db->escape($this->number)."'"; + $sql .= ",cle_rib='".$this->db->escape($this->cle_rib)."'"; + $sql .= ",bic='".$this->db->escape($this->bic)."'"; + $sql .= ",iban_prefix = '".$this->db->escape($this->iban)."'"; + $sql .= ",domiciliation='".$this->db->escape($this->domiciliation)."'"; + $sql .= ",proprio = '".$this->db->escape($this->proprio)."'"; + $sql .= ",owner_address = '".$this->db->escape($this->owner_address)."'"; + $sql .= ",state_id = ".($this->state_id > 0 ? $this->state_id : "null"); + $sql .= ",fk_pays = ".$this->country_id; + $sql .= " WHERE rowid = ".$this->id; + $sql .= " AND entity = ".$conf->entity; dol_syslog(get_class($this)."::update_bban", LOG_DEBUG); @@ -843,7 +843,7 @@ class Account extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); dol_print_error($this->db); return -1; } @@ -863,26 +863,26 @@ class Account extends CommonObject if (empty($id) && empty($ref)) { - $this->error="ErrorBadParameters"; + $this->error = "ErrorBadParameters"; return -1; } $sql = "SELECT ba.rowid, ba.ref, ba.label, ba.bank, ba.number, ba.courant, ba.clos, ba.rappro, ba.url,"; - $sql.= " ba.code_banque, ba.code_guichet, ba.cle_rib, ba.bic, ba.iban_prefix as iban,"; - $sql.= " ba.domiciliation, ba.proprio, ba.owner_address, ba.state_id, ba.fk_pays as country_id,"; - $sql.= " ba.account_number, ba.fk_accountancy_journal, ba.currency_code,"; - $sql.= " ba.min_allowed, ba.min_desired, ba.comment,"; - $sql.= " ba.datec as date_creation, ba.tms as date_update,"; - $sql.= ' c.code as country_code, c.label as country,'; - $sql.= ' d.code_departement as state_code, d.nom as state'; - $sql.= ' , aj.code as accountancy_journal'; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON ba.fk_pays = c.rowid'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON ba.state_id = d.rowid'; - $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'accounting_journal as aj ON aj.rowid=ba.fk_accountancy_journal'; - $sql.= " WHERE ba.entity IN (".getEntity($this->element).")"; - if ($id) $sql.= " AND ba.rowid = ".$id; - if ($ref) $sql.= " AND ba.ref = '".$this->db->escape($ref)."'"; + $sql .= " ba.code_banque, ba.code_guichet, ba.cle_rib, ba.bic, ba.iban_prefix as iban,"; + $sql .= " ba.domiciliation, ba.proprio, ba.owner_address, ba.state_id, ba.fk_pays as country_id,"; + $sql .= " ba.account_number, ba.fk_accountancy_journal, ba.currency_code,"; + $sql .= " ba.min_allowed, ba.min_desired, ba.comment,"; + $sql .= " ba.datec as date_creation, ba.tms as date_update,"; + $sql .= ' c.code as country_code, c.label as country,'; + $sql .= ' d.code_departement as state_code, d.nom as state'; + $sql .= ' , aj.code as accountancy_journal'; + $sql .= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON ba.fk_pays = c.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON ba.state_id = d.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'accounting_journal as aj ON aj.rowid=ba.fk_accountancy_journal'; + $sql .= " WHERE ba.entity IN (".getEntity($this->element).")"; + if ($id) $sql .= " AND ba.rowid = ".$id; + if ($ref) $sql .= " AND ba.ref = '".$this->db->escape($ref)."'"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); @@ -926,7 +926,7 @@ class Account extends CommonObject $this->accountancy_journal = $obj->accountancy_journal; $this->currency_code = $obj->currency_code; - $this->account_currency_code = $obj->currency_code; + $this->account_currency_code = $obj->currency_code; $this->min_allowed = $obj->min_allowed; $this->min_desired = $obj->min_desired; $this->comment = $obj->comment; @@ -947,8 +947,8 @@ class Account extends CommonObject } else { - $this->error=$this->db->lasterror; - $this->errors[]=$this->error; + $this->error = $this->db->lasterror; + $this->errors[] = $this->error; return -1; } } @@ -966,12 +966,12 @@ class Account extends CommonObject public function setCategories($categories) { // 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, Categorie::TYPE_ACCOUNT, 'id'); @@ -985,7 +985,7 @@ class Account extends CommonObject } // Process - foreach($to_del as $del) { + foreach ($to_del as $del) { if ($c->fetch($del) > 0) { $c->del_type($this, Categorie::TYPE_ACCOUNT); } @@ -1009,15 +1009,15 @@ class Account extends CommonObject { global $conf; - $error=0; + $error = 0; $this->db->begin(); // Delete link between tag and bank account - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account"; - $sql.= " WHERE fk_account = ".$this->id; + $sql .= " WHERE fk_account = ".$this->id; $resql = $this->db->query($sql); if (!$resql) @@ -1027,10 +1027,10 @@ class Account extends CommonObject } } - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_account"; - $sql.= " WHERE rowid = ".$this->rowid; + $sql .= " WHERE rowid = ".$this->rowid; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $result = $this->db->query($sql); @@ -1039,7 +1039,7 @@ class Account extends CommonObject // Remove extrafields if ((empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used { - $result=$this->deleteExtraFields(); + $result = $this->deleteExtraFields(); if ($result < 0) { $error++; @@ -1054,7 +1054,7 @@ class Account extends CommonObject } } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -1115,16 +1115,16 @@ class Account extends CommonObject public function can_be_deleted() { // phpcs:enable - $can_be_deleted=false; + $can_be_deleted = false; $sql = "SELECT COUNT(rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank"; - $sql.= " WHERE fk_account=".$this->id; + $sql .= " FROM ".MAIN_DB_PREFIX."bank"; + $sql .= " WHERE fk_account=".$this->id; $resql = $this->db->query($sql); if ($resql) { - $obj=$this->db->fetch_object($resql); - if ($obj->nb <= 1) $can_be_deleted=true; // Juste le solde + $obj = $this->db->fetch_object($resql); + if ($obj->nb <= 1) $can_be_deleted = true; // Juste le solde } else { dol_print_error($this->db); @@ -1151,24 +1151,24 @@ class Account extends CommonObject */ public function solde($option = 0) { - $solde=0; + $solde = 0; $sql = "SELECT sum(amount) as amount"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank"; - $sql.= " WHERE fk_account = ".$this->id; - if ($option == 1) $sql.= " AND dateo <= '".$this->db->idate(dol_now())."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank"; + $sql .= " WHERE fk_account = ".$this->id; + if ($option == 1) $sql .= " AND dateo <= '".$this->db->idate(dol_now())."'"; $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { - $obj=$this->db->fetch_object($resql); + $obj = $this->db->fetch_object($resql); $solde = $obj->amount; } $this->db->free($resql); } else { - $this->errors[]=$this->db->lasterror; + $this->errors[] = $this->db->lasterror; return -1; } @@ -1228,7 +1228,7 @@ class Account extends CommonObject else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -1287,14 +1287,14 @@ class Account extends CommonObject return 0; } - $nb=0; + $nb = 0; $sql = "SELECT COUNT(ba.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE ba.rappro > 0 and ba.clos = 0"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - if (empty($conf->global->BANK_CAN_RECONCILIATE_CASHACCOUNT)) $sql.= " AND ba.courant != 2"; - $resql=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE ba.rappro > 0 and ba.clos = 0"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + if (empty($conf->global->BANK_CAN_RECONCILIATE_CASHACCOUNT)) $sql .= " AND ba.courant != 2"; + $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); @@ -1319,23 +1319,23 @@ class Account extends CommonObject { global $conf, $langs, $user; - $result=''; - $label = '' . $langs->trans("ShowAccount") . ''; - $label .= '
' . $langs->trans('BankAccount') . ': ' . $this->label; - $label .= '
' . $langs->trans('AccountNumber') . ': ' . $this->number; - $label .= '
' . $langs->trans("AccountCurrency") . ': ' . $this->currency_code; + $result = ''; + $label = ''.$langs->trans("ShowAccount").''; + $label .= '
'.$langs->trans('BankAccount').': '.$this->label; + $label .= '
'.$langs->trans('AccountNumber').': '.$this->number; + $label .= '
'.$langs->trans("AccountCurrency").': '.$this->currency_code; if (empty($user->rights->banque->lire) || !empty($user->socid)) { $option = 'nolink'; } - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; $langs->load("accountancy"); - $label .= '
' . $langs->trans('AccountAccounting') . ': ' . length_accountg($this->account_number); - $label .= '
' . $langs->trans('AccountancyJournal') . ': ' . $this->accountancy_journal; + $label .= '
'.$langs->trans('AccountAccounting').': '.length_accountg($this->account_number); + $label .= '
'.$langs->trans('AccountancyJournal').': '.$this->accountancy_journal; } $linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; @@ -1352,9 +1352,9 @@ class Account 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'; } $linkstart = 'ref.($option == 'reflabel' && $this->label ? ' - '.$this->label : ''); + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref.($option == 'reflabel' && $this->label ? ' - '.$this->label : ''); $result .= $linkend; return $result; @@ -1384,13 +1384,13 @@ class Account extends CommonObject */ public function verif() { - require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; $this->error_number = 0; // Call function to check BAN - if (! checkIbanForAccount($this) || ! checkSwiftForAccount($this)) + if (!checkIbanForAccount($this) || !checkSwiftForAccount($this)) { $this->error_number = 12; $this->error_message = 'IBANSWIFTControlError'; @@ -1421,26 +1421,26 @@ class Account extends CommonObject global $mysoc; // We return country code of bank account - if (! empty($this->country_code)) return $this->country_code; + if (!empty($this->country_code)) return $this->country_code; // For backward compatibility, we try to guess country from other information - if (! empty($this->iban)) + if (!empty($this->iban)) { // If IBAN defined, we can know country of account from it if (preg_match("/^([a-zA-Z][a-zA-Z])/i", $this->iban, $reg)) return $reg[1]; } // If this class is linked to a third party - if (! empty($this->socid)) + if (!empty($this->socid)) { - require_once DOL_DOCUMENT_ROOT .'/societe/class/societe.class.php'; - $company=new Societe($this->db); - $result=$company->fetch($this->socid); - if (! empty($company->country_code)) return $company->country_code; + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $company = new Societe($this->db); + $result = $company->fetch($this->socid); + if (!empty($company->country_code)) return $company->country_code; } // We return country code of managed company - if (! empty($mysoc->country_code)) return $mysoc->country_code; + if (!empty($mysoc->country_code)) return $mysoc->country_code; return ''; } @@ -1455,10 +1455,10 @@ class Account extends CommonObject */ public function useDetailedBBAN() { - $country_code=$this->getCountryCode(); + $country_code = $this->getCountryCode(); - if (in_array($country_code, array('FR','ES','GA','IT','NC'))) return 1; // France, Spain, Gabon, ... - Not valid for CH - if (in_array($country_code, array('AU','BE','CA','DE','DK','GR','GB','ID','IE','IR','KR','NL','NZ','UK','US'))) return 2; // Australia, England... + if (in_array($country_code, array('FR', 'ES', 'GA', 'IT', 'NC'))) return 1; // France, Spain, Gabon, ... - Not valid for CH + if (in_array($country_code, array('AU', 'BE', 'CA', 'DE', 'DK', 'GR', 'GB', 'ID', 'IE', 'IR', 'KR', 'NL', 'NZ', 'UK', 'US'))) return 2; // Australia, England... return 0; } @@ -1469,41 +1469,41 @@ class Account extends CommonObject */ public function needIBAN() { - $country_code=$this->getCountryCode(); + $country_code = $this->getCountryCode(); - $country_code_in_EEC=array( - 'AT', // Austria - 'BE', // Belgium - 'BG', // Bulgaria - 'CY', // Cyprus - 'CZ', // Czech republic - 'DE', // Germany - 'DK', // Danemark - 'EE', // Estonia - 'ES', // Spain - 'FI', // Finland - 'FR', // France - 'GB', // United Kingdom - 'GR', // Greece - 'HR', // Croatia - 'NL', // Holland - 'HU', // Hungary - 'IE', // Ireland - 'IM', // Isle of Man - Included in UK - 'IT', // Italy - 'LT', // Lithuania - 'LU', // Luxembourg - 'LV', // Latvia - 'MC', // Monaco - Included in France - 'MT', // Malta + $country_code_in_EEC = array( + 'AT', // Austria + 'BE', // Belgium + 'BG', // Bulgaria + 'CY', // Cyprus + 'CZ', // Czech republic + 'DE', // Germany + 'DK', // Danemark + 'EE', // Estonia + 'ES', // Spain + 'FI', // Finland + 'FR', // France + 'GB', // United Kingdom + 'GR', // Greece + 'HR', // Croatia + 'NL', // Holland + 'HU', // Hungary + 'IE', // Ireland + 'IM', // Isle of Man - Included in UK + 'IT', // Italy + 'LT', // Lithuania + 'LU', // Luxembourg + 'LV', // Latvia + 'MC', // Monaco - Included in France + 'MT', // Malta //'NO', // Norway - 'PL', // Poland - 'PT', // Portugal - 'RO', // Romania - 'SE', // Sweden - 'SK', // Slovakia - 'SI', // Slovenia - 'UK', // United Kingdom + 'PL', // Poland + 'PT', // Portugal + 'RO', // Romania + 'SE', // Sweden + 'SK', // Slovakia + 'SI', // Slovenia + 'UK', // United Kingdom //'CH', // Switzerland - No. Swizerland in not in EEC ); @@ -1541,23 +1541,23 @@ class Account extends CommonObject $detailedBBAN = $this->useDetailedBBAN(); if ($detailedBBAN == 0) { - $fieldarray= array( + $fieldarray = array( 'BankAccountNumber' ); } elseif ($detailedBBAN == 2) { - $fieldarray= array( + $fieldarray = array( 'BankCode', 'BankAccountNumber' ); } else { - $fieldarray=self::getAccountNumberOrder(); + $fieldarray = self::getAccountNumberOrder(); } //if ($this->needIBAN()) { // return always IBAN and BIC (this was old behaviour) if ($includeibanbic) { - $fieldarray[]='IBAN'; - $fieldarray[]='BIC'; + $fieldarray[] = 'IBAN'; + $fieldarray[] = 'BIC'; } //} @@ -1647,7 +1647,7 @@ class AccountLine extends CommonObject /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var DoliDB Database handler. @@ -1657,12 +1657,12 @@ class AccountLine extends CommonObject /** * @var string ID to identify managed object */ - public $element='bank'; + public $element = 'bank'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='bank'; + public $table_element = 'bank'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -1724,10 +1724,10 @@ class AccountLine extends CommonObject */ public $fk_type; - public $rappro; // Is it conciliated - public $num_releve; // If conciliated, what is bank statement - public $num_chq; // Num of cheque - public $bank_chq; // Bank of cheque + public $rappro; // Is it conciliated + public $num_releve; // If conciliated, what is bank statement + public $num_chq; // Num of cheque + public $bank_chq; // Bank of cheque /** * @var int ID of cheque receipt @@ -1739,7 +1739,7 @@ class AccountLine extends CommonObject */ public $fk_account; - public $bank_account_label; // Label of bank account + public $bank_account_label; // Label of bank account /** * Issuer @@ -1773,55 +1773,55 @@ class AccountLine extends CommonObject if (empty($rowid) && empty($ref) && empty($num)) return -1; $sql = "SELECT b.rowid, b.datec, b.datev, b.dateo, b.amount, b.label as label, b.fk_account,"; - $sql.= " b.fk_user_author, b.fk_user_rappro,"; - $sql.= " b.fk_type, b.num_releve, b.num_chq, b.rappro, b.note,"; - $sql.= " b.fk_bordereau, b.banque, b.emetteur,"; + $sql .= " b.fk_user_author, b.fk_user_rappro,"; + $sql .= " b.fk_type, b.num_releve, b.num_chq, b.rappro, b.note,"; + $sql .= " b.fk_bordereau, b.banque, b.emetteur,"; //$sql.= " b.author"; // Is this used ? - $sql.= " ba.ref as bank_account_ref, ba.label as bank_account_label"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b,"; - $sql.= " ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - if ($num) $sql.= " AND b.num_chq='".$this->db->escape($num)."'"; - elseif ($ref) $sql.= " AND b.rowid='".$this->db->escape($ref)."'"; - else $sql.= " AND b.rowid=".$rowid; + $sql .= " ba.ref as bank_account_ref, ba.label as bank_account_label"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b,"; + $sql .= " ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + if ($num) $sql .= " AND b.num_chq='".$this->db->escape($num)."'"; + elseif ($ref) $sql .= " AND b.rowid='".$this->db->escape($ref)."'"; + else $sql .= " AND b.rowid=".$rowid; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { - $ret=0; + $ret = 0; $obj = $this->db->fetch_object($result); if ($obj) { - $this->id = $obj->rowid; + $this->id = $obj->rowid; $this->rowid = $obj->rowid; - $this->ref = $obj->rowid; + $this->ref = $obj->rowid; $this->datec = $obj->datec; $this->datev = $obj->datev; $this->dateo = $obj->dateo; - $this->amount = $obj->amount; + $this->amount = $obj->amount; $this->label = $obj->label; $this->note = $obj->note; $this->fk_user_author = $obj->fk_user_author; $this->fk_user_rappro = $obj->fk_user_rappro; - $this->fk_type = $obj->fk_type; // Type of transaction - $this->rappro = $obj->rappro; - $this->num_releve = $obj->num_releve; + $this->fk_type = $obj->fk_type; // Type of transaction + $this->rappro = $obj->rappro; + $this->num_releve = $obj->num_releve; - $this->num_chq = $obj->num_chq; - $this->bank_chq = $obj->banque; - $this->fk_bordereau = $obj->fk_bordereau; + $this->num_chq = $obj->num_chq; + $this->bank_chq = $obj->banque; + $this->fk_bordereau = $obj->fk_bordereau; - $this->fk_account = $obj->fk_account; + $this->fk_account = $obj->fk_account; $this->bank_account_ref = $obj->bank_account_ref; $this->bank_account_label = $obj->bank_account_label; - $ret=1; + $ret = 1; } $this->db->free($result); return $ret; @@ -1858,7 +1858,7 @@ class AccountLine extends CommonObject $sql .= ", '".$this->db->idate($this->datev)."'"; $sql .= ", '".$this->db->escape($this->label)."'"; $sql .= ", ".price2num($this->amount); - $sql .= ", ".($this->fk_user_author > 0 ? $this->fk_user_author :"null"); + $sql .= ", ".($this->fk_user_author > 0 ? $this->fk_user_author : "null"); $sql .= ", ".($this->num_chq ? "'".$this->db->escape($this->num_chq)."'" : "null"); $sql .= ", '".$this->db->escape($this->fk_account)."'"; $sql .= ", '".$this->db->escape($this->fk_type)."'"; @@ -1889,19 +1889,19 @@ class AccountLine extends CommonObject */ public function delete(User $user = null) { - $nbko=0; + $nbko = 0; if ($this->rappro) { // Protection to avoid any delete of consolidated lines - $this->error="ErrorDeleteNotPossibleLineIsConsolidated"; + $this->error = "ErrorDeleteNotPossibleLineIsConsolidated"; return -1; } $this->db->begin(); // Delete urls - $result=$this->delete_urls($user); + $result = $this->delete_urls($user); if ($result < 0) { $nbko++; @@ -1910,14 +1910,14 @@ class AccountLine extends CommonObject $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid=".(int) $this->rowid; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $result = $this->db->query($sql); - if (! $result) $nbko++; + if (!$result) $nbko++; $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank WHERE rowid=".(int) $this->rowid; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $result = $this->db->query($sql); - if (! $result) $nbko++; + if (!$result) $nbko++; - if (! $nbko) + if (!$nbko) { $this->db->commit(); return 1; @@ -1940,12 +1940,12 @@ class AccountLine extends CommonObject public function delete_urls(User $user = null) { // phpcs:enable - $nbko=0; + $nbko = 0; if ($this->rappro) { // Protection to avoid any delete of consolidated lines - $this->error="ErrorDeleteNotPossibleLineIsConsolidated"; + $this->error = "ErrorDeleteNotPossibleLineIsConsolidated"; return -1; } @@ -1954,9 +1954,9 @@ class AccountLine extends CommonObject $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url WHERE fk_bank=".(int) $this->rowid; dol_syslog(get_class($this)."::delete_urls", LOG_DEBUG); $result = $this->db->query($sql); - if (! $result) $nbko++; + if (!$result) $nbko++; - if (! $nbko) + if (!$nbko) { $this->db->commit(); return 1; @@ -1981,10 +1981,10 @@ class AccountLine extends CommonObject $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."bank SET"; - $sql.= " amount = ".price2num($this->amount).","; - $sql.= " datev='".$this->db->idate($this->datev)."',"; - $sql.= " dateo='".$this->db->idate($this->dateo)."'"; - $sql.= " WHERE rowid = ".$this->rowid; + $sql .= " amount = ".price2num($this->amount).","; + $sql .= " datev='".$this->db->idate($this->datev)."',"; + $sql .= " dateo='".$this->db->idate($this->dateo)."'"; + $sql .= " WHERE rowid = ".$this->rowid; dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); @@ -1996,7 +1996,7 @@ class AccountLine extends CommonObject else { $this->db->rollback(); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2014,39 +2014,39 @@ class AccountLine extends CommonObject public function update_conciliation(User $user, $cat, $conciliated = 1) { // phpcs:enable - global $conf,$langs; + global $conf, $langs; $this->db->begin(); // Check statement field - if (! empty($conf->global->BANK_STATEMENT_REGEX_RULE)) + if (!empty($conf->global->BANK_STATEMENT_REGEX_RULE)) { - if (! preg_match('/'.$conf->global->BANK_STATEMENT_REGEX_RULE.'/', $this->num_releve)) + if (!preg_match('/'.$conf->global->BANK_STATEMENT_REGEX_RULE.'/', $this->num_releve)) { - $this->errors[]=$langs->trans("ErrorBankStatementNameMustFollowRegex", $conf->global->BANK_STATEMENT_REGEX_RULE); + $this->errors[] = $langs->trans("ErrorBankStatementNameMustFollowRegex", $conf->global->BANK_STATEMENT_REGEX_RULE); return -1; } } $sql = "UPDATE ".MAIN_DB_PREFIX."bank SET"; - $sql.= " rappro = ".$conciliated; - $sql.= ", num_releve = '".$this->db->escape($this->num_releve)."'"; - if ($conciliated) $sql.= ", fk_user_rappro = ".$user->id; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " rappro = ".$conciliated; + $sql .= ", num_releve = '".$this->db->escape($this->num_releve)."'"; + if ($conciliated) $sql .= ", fk_user_rappro = ".$user->id; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::update_conciliation", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - if (! empty($cat)) + if (!empty($cat)) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class ("; - $sql.= "lineid"; - $sql.= ", fk_categ"; - $sql.= ") VALUES ("; - $sql.= $this->id; - $sql.= ", ".$cat; - $sql.= ")"; + $sql .= "lineid"; + $sql .= ", fk_categ"; + $sql .= ") VALUES ("; + $sql .= $this->id; + $sql .= ", ".$cat; + $sql .= ")"; dol_syslog(get_class($this)."::update_conciliation", LOG_DEBUG); $this->db->query($sql); @@ -2054,7 +2054,7 @@ class AccountLine extends CommonObject // No error check. Can fail if category already affected } - $this->rappro=1; + $this->rappro = 1; $this->db->commit(); return 1; @@ -2082,12 +2082,12 @@ class AccountLine extends CommonObject $resql = $this->db->query($sql); if ($resql) { - $obj=$this->db->fetch_object($resql); - $newdate=$this->db->jdate($obj->datev)+(3600*24*$sign); + $obj = $this->db->fetch_object($resql); + $newdate = $this->db->jdate($obj->datev) + (3600 * 24 * $sign); $sql = "UPDATE ".MAIN_DB_PREFIX."bank SET"; - $sql.= " datev = '".$this->db->idate($newdate)."'"; - $sql.= " WHERE rowid = ".$rowid; + $sql .= " datev = '".$this->db->idate($newdate)."'"; + $sql .= " WHERE rowid = ".$rowid; $result = $this->db->query($sql); if ($result) @@ -2149,12 +2149,12 @@ class AccountLine extends CommonObject $resql = $this->db->query($sql); if ($resql) { - $obj=$this->db->fetch_object($resql); - $newdate=$this->db->jdate($obj->dateo)+(3600*24*$sign); + $obj = $this->db->fetch_object($resql); + $newdate = $this->db->jdate($obj->dateo) + (3600 * 24 * $sign); $sql = "UPDATE ".MAIN_DB_PREFIX."bank SET"; - $sql.= " dateo = '".$this->db->idate($newdate)."'"; - $sql.= " WHERE rowid = ".$rowid; + $sql .= " dateo = '".$this->db->idate($newdate)."'"; + $sql .= " WHERE rowid = ".$rowid; $result = $this->db->query($sql); if ($result) @@ -2210,11 +2210,11 @@ class AccountLine extends CommonObject public function info($id) { $sql = 'SELECT b.rowid, b.datec, b.tms as datem,'; - $sql.= ' b.fk_user_author, b.fk_user_rappro'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'bank as b'; - $sql.= ' WHERE b.rowid = '.$id; + $sql .= ' b.fk_user_author, b.fk_user_rappro'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'bank as b'; + $sql .= ' WHERE b.rowid = '.$id; - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -2226,7 +2226,7 @@ class AccountLine extends CommonObject { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_rappro) { @@ -2261,32 +2261,32 @@ class AccountLine extends CommonObject { global $langs; - $result=''; - $label=$langs->trans("ShowTransaction").': '.$this->rowid; + $result = ''; + $label = $langs->trans("ShowTransaction").': '.$this->rowid; $linkstart = ''; - $linkend=''; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'account'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.=($this->ref?$this->ref:$this->rowid); + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'account'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= ($this->ref ? $this->ref : $this->rowid); $result .= $linkend; - if ($option == 'showall' || $option == 'showconciliated') $result.=' ('; + if ($option == 'showall' || $option == 'showconciliated') $result .= ' ('; if ($option == 'showall') { - $result.=$langs->trans("BankAccount").': '; - $accountstatic=new Account($this->db); - $accountstatic->id=$this->fk_account; - $accountstatic->ref=$this->bank_account_ref; - $accountstatic->label=$this->bank_account_label; - $result.=$accountstatic->getNomUrl(0).', '; + $result .= $langs->trans("BankAccount").': '; + $accountstatic = new Account($this->db); + $accountstatic->id = $this->fk_account; + $accountstatic->ref = $this->bank_account_ref; + $accountstatic->label = $this->bank_account_label; + $result .= $accountstatic->getNomUrl(0).', '; } if ($option == 'showall' || $option == 'showconciliated') { - $result.=$langs->trans("BankLineConciliated").': '; - $result.=yn($this->rappro); + $result .= $langs->trans("BankLineConciliated").': '; + $result .= yn($this->rappro); } - if ($option == 'showall' || $option == 'showconciliated') $result.=')'; + if ($option == 'showall' || $option == 'showconciliated') $result .= ')'; return $result; } diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php index a58d7a7c6ea..47b251b788b 100644 --- a/htdocs/compta/localtax/card.php +++ b/htdocs/compta/localtax/card.php @@ -63,18 +63,18 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) { $db->begin(); - $datev=dol_mktime(12, 0, 0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]); - $datep=dol_mktime(12, 0, 0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]); + $datev = dol_mktime(12, 0, 0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]); + $datep = dol_mktime(12, 0, 0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]); - $object->accountid=GETPOST("accountid"); - $object->paymenttype=GETPOST("paiementtype"); - $object->datev=$datev; - $object->datep=$datep; - $object->amount=price2num(GETPOST("amount")); - $object->label=GETPOST("label"); - $object->ltt=$lttype; + $object->accountid = GETPOST("accountid"); + $object->paymenttype = GETPOST("paiementtype"); + $object->datev = $datev; + $object->datep = $datep; + $object->amount = price2num(GETPOST("amount")); + $object->label = GETPOST("label"); + $object->ltt = $lttype; - $ret=$object->addPayment($user); + $ret = $object->addPayment($user); if ($ret > 0) { $db->commit(); @@ -85,27 +85,27 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) { $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); - $_GET["action"]="create"; + $_GET["action"] = "create"; } } //delete payment of localtax if ($action == 'delete') { - $result=$object->fetch($id); + $result = $object->fetch($id); if ($object->rappro == 0) { $db->begin(); - $ret=$object->delete($user); + $ret = $object->delete($user); if ($ret > 0) { if ($object->fk_bank) { - $accountline=new AccountLine($db); - $result=$accountline->fetch($object->fk_bank); - if ($result > 0) $result=$accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing) + $accountline = new AccountLine($db); + $result = $accountline->fetch($object->fk_bank); + if ($result > 0) $result = $accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing) } if ($result >= 0) @@ -116,7 +116,7 @@ if ($action == 'delete') } else { - $object->error=$accountline->error; + $object->error = $accountline->error; $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } @@ -129,7 +129,7 @@ if ($action == 'delete') } else { - $mesg='Error try do delete a line linked to a conciliated bank transaction'; + $mesg = 'Error try do delete a line linked to a conciliated bank transaction'; setEventMessages($mesg, null, 'errors'); } } @@ -151,13 +151,13 @@ if ($id) $form = new Form($db); -$title=$langs->trans("LT".$object->ltt) . " - " . $langs->trans("Card"); -$help_url=''; +$title = $langs->trans("LT".$object->ltt)." - ".$langs->trans("Card"); +$help_url = ''; llxHeader("", $title, $helpurl); if ($action == 'create') { - print load_fiche_titre($langs->transcountry($lttype==2?"newLT2Payment":"newLT1Payment", $mysoc->country_code)); + print load_fiche_titre($langs->transcountry($lttype == 2 ? "newLT2Payment" : "newLT1Payment", $mysoc->country_code)); print '
'."\n"; print ''; @@ -178,15 +178,15 @@ if ($action == 'create') print ''; // Label - print ''.$langs->trans("Label").'transcountry(($lttype==2?"LT2Payment":"LT1Payment"), $mysoc->country_code)).'">'; + print ''.$langs->trans("Label").'transcountry(($lttype == 2 ? "LT2Payment" : "LT1Payment"), $mysoc->country_code)).'">'; // Amount print ''.$langs->trans("Amount").''; - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { print ''.$langs->trans("Account").''; - $form->select_comptes($_POST["accountid"], "accountid", 0, "courant=1", 1); // Affiche liste des comptes courant + $form->select_comptes($_POST["accountid"], "accountid", 0, "courant=1", 1); // Affiche liste des comptes courant print ''; print ''.$langs->trans("PaymentMode").''; @@ -200,8 +200,8 @@ if ($action == 'create') print ''."\n"; } // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print ''; @@ -254,11 +254,11 @@ if ($id) print ''.$langs->trans("Amount").''.price($object->amount).''; - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { if ($object->fk_account > 0) { - $bankline=new AccountLine($db); + $bankline = new AccountLine($db); $bankline->fetch($object->fk_bank); print ''; @@ -271,8 +271,8 @@ if ($id) } // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print ''; diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php index bb57e796ef6..ebf87b91693 100644 --- a/htdocs/compta/paiement_charge.php +++ b/htdocs/compta/paiement_charge.php @@ -46,9 +46,9 @@ if ($user->socid > 0) * Actions */ -if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes')) +if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'yes')) { - $error=0; + $error = 0; if ($_POST["cancel"]) { @@ -59,7 +59,7 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes $datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - if (! $_POST["paiementtype"] > 0) + if (!$_POST["paiementtype"] > 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")), null, 'errors'); $error++; @@ -71,14 +71,14 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes $error++; $action = 'create'; } - if (! empty($conf->banque->enabled) && ! ($_POST["accountid"] > 0)) + if (!empty($conf->banque->enabled) && !($_POST["accountid"] > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToCredit")), null, 'errors'); $error++; $action = 'create'; } - if (! $error) + if (!$error) { $paymentid = 0; @@ -96,10 +96,10 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes { $error++; setEventMessages($langs->trans("ErrorNoPaymentDefined"), null, 'errors'); - $action='create'; + $action = 'create'; } - if (! $error) + if (!$error) { $db->begin(); @@ -107,34 +107,34 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes $paiement = new PaymentSocialContribution($db); $paiement->chid = $chid; $paiement->datepaye = $datepaye; - $paiement->amounts = $amounts; // Tableau de montant + $paiement->amounts = $amounts; // Tableau de montant $paiement->paiementtype = $_POST["paiementtype"]; $paiement->num_paiement = $_POST["num_paiement"]; $paiement->note = $_POST["note"]; - if (! $error) + if (!$error) { - $paymentid = $paiement->create($user, (GETPOST('closepaidcontrib')=='on'?1:0)); + $paymentid = $paiement->create($user, (GETPOST('closepaidcontrib') == 'on' ? 1 : 0)); if ($paymentid < 0) { $error++; setEventMessages($paiement->error, null, 'errors'); - $action='create'; + $action = 'create'; } } - if (! $error) + if (!$error) { - $result=$paiement->addPaymentToBank($user, 'payment_sc', '(SocialContributionPayment)', GETPOST('accountid', 'int'), '', ''); - if (! ($result > 0)) + $result = $paiement->addPaymentToBank($user, 'payment_sc', '(SocialContributionPayment)', GETPOST('accountid', 'int'), '', ''); + if (!($result > 0)) { $error++; setEventMessages($paiement->error, null, 'errors'); - $action='create'; + $action = 'create'; } } - if (! $error) + if (!$error) { $db->commit(); $loc = DOL_URL_ROOT.'/compta/sociales/card.php?id='.$chid; @@ -156,7 +156,7 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm=='yes llxHeader(); -$form=new Form($db); +$form = new Form($db); // Formulaire de creation d'un paiement de charge @@ -209,12 +209,12 @@ if ($action == 'create') print ''.$langs->trans("Amount")."".price($charge->amount,0,$outputlangs,1,-1,-1,$conf->currency).'';*/ $sql = "SELECT sum(p.amount) as total"; - $sql.= " FROM ".MAIN_DB_PREFIX."paiementcharge as p"; - $sql.= " WHERE p.fk_charge = ".$chid; + $sql .= " FROM ".MAIN_DB_PREFIX."paiementcharge as p"; + $sql .= " WHERE p.fk_charge = ".$chid; $resql = $db->query($sql); if ($resql) { - $obj=$db->fetch_object($resql); + $obj = $db->fetch_object($resql); $sumpaid = $obj->total; $db->free(); } @@ -223,20 +223,20 @@ if ($action == 'create') print ''.$langs->trans("Date").''; $datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - $datepayment=empty($conf->global->MAIN_AUTOFILL_DATE)?(empty($_POST["remonth"])?-1:$datepaye):0; + $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ? (empty($_POST["remonth"]) ?-1 : $datepaye) : 0; print $form->selectDate($datepayment, '', '', '', '', "add_payment", 1, 1); print ""; print ''; print ''.$langs->trans("PaymentMode").''; - $form->select_types_paiements(isset($_POST["paiementtype"])?$_POST["paiementtype"]:$charge->paiementtype, "paiementtype"); + $form->select_types_paiements(isset($_POST["paiementtype"]) ? $_POST["paiementtype"] : $charge->paiementtype, "paiementtype"); print "\n"; print ''; print ''; print ''.$langs->trans('AccountToDebit').''; print ''; - $form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$charge->accountid, "accountid", 0, '', 1); // Show opend bank account list + $form->select_comptes(isset($_POST["accountid"]) ? $_POST["accountid"] : $charge->accountid, "accountid", 0, '', 1); // Show opend bank account list print ''; // Number @@ -270,8 +270,8 @@ if ($action == 'create') print ''.$langs->trans("Amount").''; print "\n"; - $total=0; - $totalrecu=0; + $total = 0; + $totalrecu = 0; while ($i < $num) { @@ -301,7 +301,7 @@ if ($action == 'create') $nameRemain = "remain_".$objp->id; if (!empty($conf->use_javascript_ajax)) print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmount' data-rowid='".$namef."' data-value='".($objp->amount - $sumpaid)."'"); - $remaintopay=$objp->amount - $sumpaid; + $remaintopay = $objp->amount - $sumpaid; print ''; print ''; } @@ -312,9 +312,9 @@ if ($action == 'create') print ""; print "\n"; - $total+=$objp->total; - $total_ttc+=$objp->total_ttc; - $totalrecu+=$objp->am; + $total += $objp->total; + $total_ttc += $objp->total_ttc; + $totalrecu += $objp->am; $i++; } if ($i > 1) diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 4fb2f27b53f..a5279ecbeae 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -34,12 +34,12 @@ class PaymentSocialContribution extends CommonObject /** * @var string ID to identify managed object */ - public $element='paiementcharge'; + public $element = 'paiementcharge'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='paiementcharge'; + public $table_element = 'paiementcharge'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -51,9 +51,9 @@ class PaymentSocialContribution extends CommonObject */ public $fk_charge; - public $datec=''; - public $tms=''; - public $datep=''; + public $datec = ''; + public $tms = ''; + public $datep = ''; /** * @deprecated @@ -61,8 +61,8 @@ class PaymentSocialContribution extends CommonObject */ public $total; - public $amount; // Total amount of payment - public $amounts=array(); // Array of amounts + public $amount; // Total amount of payment + public $amounts = array(); // Array of amounts /** * @var int ID @@ -108,28 +108,28 @@ class PaymentSocialContribution extends CommonObject { global $conf, $langs; - $error=0; + $error = 0; - $now=dol_now(); + $now = dol_now(); dol_syslog(get_class($this)."::create", LOG_DEBUG); // Validate parametres - if (! $this->datepaye) + if (!$this->datepaye) { - $this->error='ErrorBadValueForParameterCreatePaymentSocialContrib'; + $this->error = 'ErrorBadValueForParameterCreatePaymentSocialContrib'; return -1; } // Clean parameters - if (isset($this->fk_charge)) $this->fk_charge= (int) $this->fk_charge; - if (isset($this->amount)) $this->amount=trim($this->amount); - if (isset($this->fk_typepaiement)) $this->fk_typepaiement= (int) $this->fk_typepaiement; - if (isset($this->num_paiement)) $this->num_paiement=trim($this->num_paiement); - if (isset($this->note)) $this->note=trim($this->note); - if (isset($this->fk_bank)) $this->fk_bank= (int) $this->fk_bank; - if (isset($this->fk_user_creat)) $this->fk_user_creat= (int) $this->fk_user_creat; - if (isset($this->fk_user_modif)) $this->fk_user_modif= (int) $this->fk_user_modif; + if (isset($this->fk_charge)) $this->fk_charge = (int) $this->fk_charge; + if (isset($this->amount)) $this->amount = trim($this->amount); + if (isset($this->fk_typepaiement)) $this->fk_typepaiement = (int) $this->fk_typepaiement; + if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement); + if (isset($this->note)) $this->note = trim($this->note); + if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank; + if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat; + if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif; $totalamount = 0; foreach ($this->amounts as $key => $value) // How payment is dispatch @@ -149,14 +149,14 @@ class PaymentSocialContribution extends CommonObject if ($totalamount != 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiementcharge (fk_charge, datec, datep, amount,"; - $sql.= " fk_typepaiement, num_paiement, note, fk_user_creat, fk_bank)"; - $sql.= " VALUES ($this->chid, '".$this->db->idate($now)."',"; - $sql.= " '".$this->db->idate($this->datepaye)."',"; - $sql.= " ".$totalamount.","; - $sql.= " ".$this->paiementtype.", '".$this->db->escape($this->num_paiement)."', '".$this->db->escape($this->note)."', ".$user->id.","; - $sql.= " 0)"; + $sql .= " fk_typepaiement, num_paiement, note, fk_user_creat, fk_bank)"; + $sql .= " VALUES ($this->chid, '".$this->db->idate($now)."',"; + $sql .= " '".$this->db->idate($this->datepaye)."',"; + $sql .= " ".$totalamount.","; + $sql .= " ".$this->paiementtype.", '".$this->db->escape($this->num_paiement)."', '".$this->db->escape($this->note)."', ".$user->id.","; + $sql .= " 0)"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."paiementcharge"); @@ -172,18 +172,18 @@ class PaymentSocialContribution extends CommonObject // If we want to closed payed invoices if ($closepaidcontrib) { - $contrib=new ChargeSociales($this->db); + $contrib = new ChargeSociales($this->db); $contrib->fetch($contribid); $paiement = $contrib->getSommePaiement(); //$creditnotes=$contrib->getSumCreditNotesUsed(); - $creditnotes=0; + $creditnotes = 0; //$deposits=$contrib->getSumDepositsUsed(); - $deposits=0; - $alreadypayed=price2num($paiement + $creditnotes + $deposits, 'MT'); - $remaintopay=price2num($contrib->amount - $paiement - $creditnotes - $deposits, 'MT'); + $deposits = 0; + $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT'); + $remaintopay = price2num($contrib->amount - $paiement - $creditnotes - $deposits, 'MT'); if ($remaintopay == 0) { - $result=$contrib->set_paid($user); + $result = $contrib->set_paid($user); } else dol_syslog("Remain to pay for conrib ".$contribid." not null. We do nothing."); } @@ -197,18 +197,18 @@ class PaymentSocialContribution extends CommonObject } $result = $this->call_trigger('PAYMENTSOCIALCONTRIBUTION_CREATE', $user); - if($result < 0) $error++; + if ($result < 0) $error++; - if ($totalamount != 0 && ! $error) + if ($totalamount != 0 && !$error) { - $this->amount=$totalamount; - $this->total=$totalamount; // deprecated + $this->amount = $totalamount; + $this->total = $totalamount; // deprecated $this->db->commit(); return $this->id; } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -278,7 +278,7 @@ class PaymentSocialContribution extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -294,18 +294,18 @@ class PaymentSocialContribution extends CommonObject public function update($user = null, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters - if (isset($this->fk_charge)) $this->fk_charge= (int) $this->fk_charge; - if (isset($this->amount)) $this->amount=trim($this->amount); - if (isset($this->fk_typepaiement)) $this->fk_typepaiement= (int) $this->fk_typepaiement; - if (isset($this->num_paiement)) $this->num_paiement=trim($this->num_paiement); - if (isset($this->note)) $this->note=trim($this->note); - if (isset($this->fk_bank)) $this->fk_bank= (int) $this->fk_bank; - if (isset($this->fk_user_creat)) $this->fk_user_creat= (int) $this->fk_user_creat; - if (isset($this->fk_user_modif)) $this->fk_user_modif= (int) $this->fk_user_modif; + if (isset($this->fk_charge)) $this->fk_charge = (int) $this->fk_charge; + if (isset($this->amount)) $this->amount = trim($this->amount); + if (isset($this->fk_typepaiement)) $this->fk_typepaiement = (int) $this->fk_typepaiement; + if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement); + if (isset($this->note)) $this->note = trim($this->note); + if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank; + if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat; + if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif; @@ -315,26 +315,26 @@ class PaymentSocialContribution extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."paiementcharge SET"; - $sql.= " fk_charge=".(isset($this->fk_charge)?$this->fk_charge:"null").","; - $sql.= " datec=".(dol_strlen($this->datec)!=0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; - $sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; - $sql.= " datep=".(dol_strlen($this->datep)!=0 ? "'".$this->db->idate($this->datep)."'" : 'null').","; - $sql.= " amount=".(isset($this->amount)?$this->amount:"null").","; - $sql.= " fk_typepaiement=".(isset($this->fk_typepaiement)?$this->fk_typepaiement:"null").","; - $sql.= " num_paiement=".(isset($this->num_paiement)?"'".$this->db->escape($this->num_paiement)."'":"null").","; - $sql.= " note=".(isset($this->note)?"'".$this->db->escape($this->note)."'":"null").","; - $sql.= " fk_bank=".(isset($this->fk_bank)?$this->fk_bank:"null").","; - $sql.= " fk_user_creat=".(isset($this->fk_user_creat)?$this->fk_user_creat:"null").","; - $sql.= " fk_user_modif=".(isset($this->fk_user_modif)?$this->fk_user_modif:"null").""; + $sql .= " fk_charge=".(isset($this->fk_charge) ? $this->fk_charge : "null").","; + $sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; + $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; + $sql .= " datep=".(dol_strlen($this->datep) != 0 ? "'".$this->db->idate($this->datep)."'" : 'null').","; + $sql .= " amount=".(isset($this->amount) ? $this->amount : "null").","; + $sql .= " fk_typepaiement=".(isset($this->fk_typepaiement) ? $this->fk_typepaiement : "null").","; + $sql .= " num_paiement=".(isset($this->num_paiement) ? "'".$this->db->escape($this->num_paiement)."'" : "null").","; + $sql .= " note=".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : "null").","; + $sql .= " fk_bank=".(isset($this->fk_bank) ? $this->fk_bank : "null").","; + $sql .= " fk_user_creat=".(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").","; + $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? $this->fk_user_modif : "null").""; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } //if (! $error) //{ @@ -355,13 +355,13 @@ class PaymentSocialContribution extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -381,7 +381,7 @@ class PaymentSocialContribution extends CommonObject public function delete($user, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; dol_syslog(get_class($this)."::delete"); @@ -392,20 +392,20 @@ class PaymentSocialContribution extends CommonObject $accline = new AccountLine($this->db); $accline->fetch($this->bank_line); $result = $accline->delete(); - if($result < 0) { + if ($result < 0) { $this->errors[] = $accline->error; $error++; } } - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."paiementcharge"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } } //if (! $error) @@ -427,13 +427,13 @@ class PaymentSocialContribution extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$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 { @@ -453,35 +453,35 @@ class PaymentSocialContribution extends CommonObject */ public function createFromClone(User $user, $fromid) { - $error=0; + $error = 0; - $object=new PaymentSocialContribution($this->db); + $object = new PaymentSocialContribution($this->db); $this->db->begin(); // Load source object $object->fetch($fromid); - $object->id=0; - $object->statut=0; + $object->id = 0; + $object->statut = 0; // Clear fields // ... // Create clone $object->context['createfromclone'] = 'createfromclone'; - $result=$object->create($user); + $result = $object->create($user); // Other options if ($result < 0) { - $this->error=$object->error; + $this->error = $object->error; $error++; } unset($object->context['createfromclone']); // End - if (! $error) + if (!$error) { $this->db->commit(); return $object->id; @@ -503,19 +503,19 @@ class PaymentSocialContribution extends CommonObject */ public function initAsSpecimen() { - $this->id=0; + $this->id = 0; - $this->fk_charge=''; - $this->datec=''; - $this->tms=''; - $this->datep=''; - $this->amount=''; - $this->fk_typepaiement=''; - $this->num_paiement=''; - $this->note=''; - $this->fk_bank=''; - $this->fk_user_creat=''; - $this->fk_user_modif=''; + $this->fk_charge = ''; + $this->datec = ''; + $this->tms = ''; + $this->datep = ''; + $this->amount = ''; + $this->fk_typepaiement = ''; + $this->num_paiement = ''; + $this->note = ''; + $this->fk_bank = ''; + $this->fk_user_creat = ''; + $this->fk_user_modif = ''; } @@ -535,22 +535,22 @@ class PaymentSocialContribution extends CommonObject { global $conf; - $error=0; + $error = 0; - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $acc = new Account($this->db); $acc->fetch($accountid); - $total=$this->total; - if ($mode == 'payment_sc') $total=-$total; + $total = $this->total; + if ($mode == 'payment_sc') $total = -$total; // Insert payment into llx_bank $bank_line_id = $acc->addline( $this->datepaye, - $this->paiementtype, // Payment mode id or code ("CHQ or VIR for example") + $this->paiementtype, // Payment mode id or code ("CHQ or VIR for example") $label, $total, $this->num_paiement, @@ -564,7 +564,7 @@ class PaymentSocialContribution extends CommonObject // On connait ainsi le paiement qui a genere l'ecriture bancaire if ($bank_line_id > 0) { - $result=$this->update_fk_bank($bank_line_id); + $result = $this->update_fk_bank($bank_line_id); if ($result <= 0) { $error++; @@ -572,11 +572,11 @@ class PaymentSocialContribution extends CommonObject } // Add link 'payment', 'payment_supplier', 'payment_sc' in bank_url between payment and bank transaction - $url=''; - if ($mode == 'payment_sc') $url=DOL_URL_ROOT.'/compta/payment_sc/card.php?id='; + $url = ''; + if ($mode == 'payment_sc') $url = DOL_URL_ROOT.'/compta/payment_sc/card.php?id='; if ($url) { - $result=$acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode); + $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode); if ($result <= 0) { $error++; @@ -635,7 +635,7 @@ class PaymentSocialContribution extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return 0; } } @@ -663,7 +663,7 @@ class PaymentSocialContribution extends CommonObject public function LibStatut($status, $mode = 0) { // phpcs:enable - global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage + global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage $langs->load('compta'); /*if ($mode == 0) @@ -715,18 +715,18 @@ class PaymentSocialContribution extends CommonObject { global $langs; - $result=''; + $result = ''; - if (empty($this->ref)) $this->ref=$this->lib; + if (empty($this->ref)) $this->ref = $this->lib; $label = $langs->trans("ShowPayment").': '.$this->ref; if (!empty($this->id)) { $link = ''; - $linkend=''; + $linkend = ''; - if ($withpicto) $result.=($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' '); - if ($withpicto && $withpicto != 2) $result.=' '; - if ($withpicto != 2) $result.=$link.($maxlen?dol_trunc($this->ref, $maxlen):$this->ref).$linkend; + if ($withpicto) $result .= ($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' '); + if ($withpicto && $withpicto != 2) $result .= ' '; + if ($withpicto != 2) $result .= $link.($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref).$linkend; } return $result; diff --git a/htdocs/core/boxes/box_goodcustomers.php b/htdocs/core/boxes/box_goodcustomers.php index ee9dc5352c1..79eb6f9ab8e 100644 --- a/htdocs/core/boxes/box_goodcustomers.php +++ b/htdocs/core/boxes/box_goodcustomers.php @@ -33,9 +33,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_goodcustomers extends ModeleBoxes { - public $boxcode="goodcustomers"; - public $boximg="object_company"; - public $boxlabel="BoxGoodCustomers"; + public $boxcode = "goodcustomers"; + public $boximg = "object_company"; + public $boxlabel = "BoxGoodCustomers"; public $depends = array("societe"); /** @@ -62,10 +62,10 @@ class box_goodcustomers extends ModeleBoxes $this->db = $db; // disable box for such cases - if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled=0; // disabled by this option - if (empty($conf->global->MAIN_BOX_ENABLE_BEST_CUSTOMERS)) $this->enabled=0; // not enabled by default. Very slow on large database + if (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled = 0; // disabled by this option + if (empty($conf->global->MAIN_BOX_ENABLE_BEST_CUSTOMERS)) $this->enabled = 0; // not enabled by default. Very slow on large database - $this->hidden = ! ($user->rights->societe->lire); + $this->hidden = !($user->rights->societe->lire); } /** @@ -79,23 +79,23 @@ class box_goodcustomers extends ModeleBoxes global $user, $langs, $conf; $langs->load("boxes"); - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - $thirdpartystatic=new Societe($this->db); + $thirdpartystatic = new Societe($this->db); $this->info_box_head = array('text' => $langs->trans("BoxTitleGoodCustomers", $max)); if ($user->rights->societe->lire) { $sql = "SELECT s.rowid, s.nom as name, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms as datem, s.status as status,"; - $sql.= " count(*) as nbfact, sum(". $this->db->ifsql('f.paye=1', '1', '0').") as nbfactpaye"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; - $sql.= ' WHERE s.entity IN ('.getEntity('societe').')'; - $sql.= ' AND s.rowid = f.fk_soc'; - $sql.= " GROUP BY s.rowid, s.nom, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms, s.status"; - $sql.= $this->db->order("nbfact", "DESC"); - $sql.= $this->db->plimit($max, 0); + $sql .= " count(*) as nbfact, sum(".$this->db->ifsql('f.paye=1', '1', '0').") as nbfactpaye"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; + $sql .= ' WHERE s.entity IN ('.getEntity('societe').')'; + $sql .= ' AND s.rowid = f.fk_soc'; + $sql .= " GROUP BY s.rowid, s.nom, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms, s.status"; + $sql .= $this->db->order("nbfact", "DESC"); + $sql .= $this->db->plimit($max, 0); dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); $result = $this->db->query($sql); @@ -107,7 +107,7 @@ class box_goodcustomers extends ModeleBoxes while ($line < $num) { $objp = $this->db->fetch_object($result); - $datem=$this->db->jdate($objp->tms); + $datem = $this->db->jdate($objp->tms); $thirdpartystatic->id = $objp->rowid; $thirdpartystatic->name = $objp->name; $thirdpartystatic->code_client = $objp->code_client; @@ -131,7 +131,7 @@ class box_goodcustomers extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => $nbfact.( $nbimpaye != 0 ? ' ('.$nbimpaye.')':'') + 'text' => $nbfact.($nbimpaye != 0 ? ' ('.$nbimpaye.')' : '') ); $this->info_box_contents[$line][] = array( @@ -142,7 +142,7 @@ class box_goodcustomers extends ModeleBoxes $line++; } - if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedCustomers")); + if ($num == 0) $this->info_box_contents[$line][0] = array('td' => 'class="center"', 'text'=>$langs->trans("NoRecordedCustomers")); $this->db->free($result); } diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index 1039ea74385..193bcdae2d6 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -31,8 +31,8 @@ require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"; */ class box_task extends ModeleBoxes { - public $boxcode="projettask"; - public $boximg="object_projecttask"; + public $boxcode = "projettask"; + public $boximg = "object_projecttask"; public $boxlabel; public $depends = array("projet"); @@ -42,7 +42,7 @@ class box_task extends ModeleBoxes public $db; public $param; - public $enabled = 1; // enable because fixed ;-). + public $enabled = 1; // enable because fixed ;-). public $info_box_head = array(); public $info_box_contents = array(); @@ -61,10 +61,10 @@ class box_task extends ModeleBoxes // Load translation files required by the page $langs->loadLangs(array('boxes', 'projects')); - $this->boxlabel="Tasks"; + $this->boxlabel = "Tasks"; $this->db = $db; - $this->hidden = ! ($user->rights->projet->lire); + $this->hidden = !($user->rights->projet->lire); } /** @@ -77,32 +77,32 @@ class box_task extends ModeleBoxes { global $conf, $user, $langs; - $this->max=$max; + $this->max = $max; include_once DOL_DOCUMENT_ROOT."/projet/class/task.class.php"; include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT."/core/lib/project.lib.php"; $projectstatic = new Project($this->db); - $taskstatic=new Task($this->db); - $form= new Form($this->db); - $cookie_name='boxfilter_task'; - $boxcontent=''; + $taskstatic = new Task($this->db); + $form = new Form($this->db); + $cookie_name = 'boxfilter_task'; + $boxcontent = ''; $textHead = $langs->trans("CurentlyOpenedTasks"); - $filterValue='all'; - if(in_array(GETPOST($cookie_name), array('all','im_project_contact','im_task_contact'))){ + $filterValue = 'all'; + if (in_array(GETPOST($cookie_name), array('all', 'im_project_contact', 'im_task_contact'))) { $filterValue = GETPOST($cookie_name); } - elseif(!empty($_COOKIE[$cookie_name])){ + elseif (!empty($_COOKIE[$cookie_name])) { $filterValue = $_COOKIE[$cookie_name]; } - if($filterValue == 'im_task_contact'){ - $textHead.= ' : '.$langs->trans("WhichIamLinkedTo"); + if ($filterValue == 'im_task_contact') { + $textHead .= ' : '.$langs->trans("WhichIamLinkedTo"); } - elseif($filterValue == 'im_project_contact'){ - $textHead.= ' : '.$langs->trans("WhichIamLinkedToProject"); + elseif ($filterValue == 'im_project_contact') { + $textHead .= ' : '.$langs->trans("WhichIamLinkedToProject"); } @@ -135,7 +135,7 @@ class box_task extends ModeleBoxes }); '; // set cookie by js - $boxcontent.=''; + $boxcontent .= ''; $this->info_box_contents[0][] = array( 'tr'=>'class="nohover showiffilter'.$this->boxcode.' hideobject"', 'td' => 'class="nohover"', @@ -144,43 +144,43 @@ class box_task extends ModeleBoxes $sql = "SELECT pt.rowid, pt.ref, pt.fk_projet, pt.fk_task_parent, pt.datec, pt.dateo, pt.datee, pt.datev, pt.label, pt.description, pt.duration_effective, pt.planned_workload, pt.progress"; - $sql.= ", p.rowid project_id, p.ref project_ref, p.title project_title"; + $sql .= ", p.rowid project_id, p.ref project_ref, p.title project_title"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet_task as pt"; - $sql.= " JOIN ".MAIN_DB_PREFIX."projet as p ON (pt.fk_projet = p.rowid)"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task as pt"; + $sql .= " JOIN ".MAIN_DB_PREFIX."projet as p ON (pt.fk_projet = p.rowid)"; - if($filterValue === 'im_task_contact') { - $sql .= " JOIN " . MAIN_DB_PREFIX . "element_contact as ec ON (ec.element_id = pt.rowid AND ec.fk_socpeople = '" . $user->id . "' )"; - $sql .= " JOIN " . MAIN_DB_PREFIX . "c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project_task' AND tc.source = 'internal' )"; + if ($filterValue === 'im_task_contact') { + $sql .= " JOIN ".MAIN_DB_PREFIX."element_contact as ec ON (ec.element_id = pt.rowid AND ec.fk_socpeople = '".$user->id."' )"; + $sql .= " JOIN ".MAIN_DB_PREFIX."c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project_task' AND tc.source = 'internal' )"; } - elseif($filterValue === 'im_project_contact') { - $sql .= " JOIN " . MAIN_DB_PREFIX . "element_contact as ec ON (ec.element_id = p.rowid AND ec.fk_socpeople = '" . $user->id . "' )"; - $sql .= " JOIN " . MAIN_DB_PREFIX . "c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project' AND tc.source = 'internal' )"; + elseif ($filterValue === 'im_project_contact') { + $sql .= " JOIN ".MAIN_DB_PREFIX."element_contact as ec ON (ec.element_id = p.rowid AND ec.fk_socpeople = '".$user->id."' )"; + $sql .= " JOIN ".MAIN_DB_PREFIX."c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project' AND tc.source = 'internal' )"; } - $sql.= " WHERE "; - $sql.= " pt.entity = ".$conf->entity; - $sql.= " AND p.fk_statut = ".Project::STATUS_VALIDATED; - $sql.= " AND (pt.progress < 100 OR pt.progress IS NULL ) "; // 100% is done and not displayed - $sql.= " AND p.usage_task = 1 "; + $sql .= " WHERE "; + $sql .= " pt.entity = ".$conf->entity; + $sql .= " AND p.fk_statut = ".Project::STATUS_VALIDATED; + $sql .= " AND (pt.progress < 100 OR pt.progress IS NULL ) "; // 100% is done and not displayed + $sql .= " AND p.usage_task = 1 "; - $sql.= " ORDER BY pt.datee ASC, pt.dateo ASC"; - $sql.= $this->db->plimit($max, 0); + $sql .= " ORDER BY pt.datee ASC, pt.dateo ASC"; + $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); $i = 1; if ($result) { $num = $this->db->num_rows($result); while ($objp = $this->db->fetch_object($result)) { - $taskstatic->id=$objp->rowid; - $taskstatic->ref=$objp->ref; - $taskstatic->label=$objp->label; + $taskstatic->id = $objp->rowid; + $taskstatic->ref = $objp->ref; + $taskstatic->label = $objp->label; $taskstatic->progress = $objp->progress; $taskstatic->fk_statut = $objp->fk_statut; $taskstatic->date_end = $objp->datee; - $taskstatic->planned_workload= $objp->planned_workload; - $taskstatic->duration_effective= $objp->duration_effective; + $taskstatic->planned_workload = $objp->planned_workload; + $taskstatic->duration_effective = $objp->duration_effective; $projectstatic->id = $objp->project_id; $projectstatic->ref = $objp->project_ref; diff --git a/htdocs/core/class/link.class.php b/htdocs/core/class/link.class.php index cdc5b283c44..1a844f86f2b 100644 --- a/htdocs/core/class/link.class.php +++ b/htdocs/core/class/link.class.php @@ -74,9 +74,9 @@ class Link extends CommonObject */ public function create($user = '') { - global $langs,$conf; + global $langs, $conf; - $error=0; + $error = 0; $langs->load("errors"); // Clean parameters if (empty($this->label)) { @@ -99,34 +99,34 @@ class Link extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."links (entity, datea, url, label, objecttype, objectid)"; $sql .= " VALUES ('".$conf->entity."', '".$this->db->idate($this->datea)."'"; - $sql .= ", '" . $this->db->escape($this->url) . "'"; - $sql .= ", '" . $this->db->escape($this->label) . "'"; - $sql .= ", '" . $this->db->escape($this->objecttype) . "'"; - $sql .= ", " . $this->objectid . ")"; + $sql .= ", '".$this->db->escape($this->url)."'"; + $sql .= ", '".$this->db->escape($this->label)."'"; + $sql .= ", '".$this->db->escape($this->objecttype)."'"; + $sql .= ", ".$this->objectid.")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "links"); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."links"); if ($this->id > 0) { // Call trigger - $result=$this->call_trigger('LINK_CREATE', $user); + $result = $this->call_trigger('LINK_CREATE', $user); if ($result < 0) $error++; // End call triggers } else { $error++; } - if (! $error) + if (!$error) { - dol_syslog(get_class($this)."::Create success id=" . $this->id); + dol_syslog(get_class($this)."::Create success id=".$this->id); $this->db->commit(); return $this->id; } else { - dol_syslog(get_class($this)."::Create echec update " . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::Create echec update ".$this->error, LOG_ERR); $this->db->rollback(); return -3; } @@ -135,13 +135,13 @@ class Link extends CommonObject { if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $this->error=$langs->trans("ErrorCompanyNameAlreadyExists", $this->name); - $result=-1; + $this->error = $langs->trans("ErrorCompanyNameAlreadyExists", $this->name); + $result = -1; } else { - $this->error=$this->db->lasterror(); - $result=-2; + $this->error = $this->db->lasterror(); + $result = -2; } $this->db->rollback(); return $result; @@ -157,13 +157,13 @@ class Link extends CommonObject */ public function update($user = '', $call_trigger = 1) { - global $langs,$conf; + global $langs, $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $langs->load("errors"); - $error=0; + $error = 0; - dol_syslog(get_class($this)."::Update id = " . $this->id . " call_trigger = " . $call_trigger); + dol_syslog(get_class($this)."::Update id = ".$this->id." call_trigger = ".$call_trigger); // Check parameters if (empty($this->url)) @@ -180,30 +180,30 @@ class Link extends CommonObject $this->db->begin(); - $sql = "UPDATE " . MAIN_DB_PREFIX . "links SET "; - $sql .= "entity = '" . $conf->entity ."'"; - $sql .= ", datea = '" . $this->db->idate(dol_now()) . "'"; - $sql .= ", url = '" . $this->db->escape($this->url) . "'"; - $sql .= ", label = '" . $this->db->escape($this->label) . "'"; - $sql .= ", objecttype = '" . $this->db->escape($this->objecttype) . "'"; - $sql .= ", objectid = " . $this->objectid; - $sql .= " WHERE rowid = " . $this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."links SET "; + $sql .= "entity = '".$conf->entity."'"; + $sql .= ", datea = '".$this->db->idate(dol_now())."'"; + $sql .= ", url = '".$this->db->escape($this->url)."'"; + $sql .= ", label = '".$this->db->escape($this->label)."'"; + $sql .= ", objecttype = '".$this->db->escape($this->objecttype)."'"; + $sql .= ", objectid = ".$this->objectid; + $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::update sql = " .$sql); + dol_syslog(get_class($this)."::update sql = ".$sql); $resql = $this->db->query($sql); if ($resql) { if ($call_trigger) { // Call trigger - $result=$this->call_trigger('LINK_MODIFY', $user); + $result = $this->call_trigger('LINK_MODIFY', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { - dol_syslog(get_class($this) . "::Update success"); + dol_syslog(get_class($this)."::Update success"); $this->db->commit(); return 1; } else { @@ -218,12 +218,12 @@ class Link extends CommonObject { // Doublon $this->error = $langs->trans("ErrorDuplicateField"); - $result = -1; + $result = -1; } else { - $this->error = $langs->trans("Error sql = " . $sql); - $result = -2; + $this->error = $langs->trans("Error sql = ".$sql); + $result = -2; } $this->db->rollback(); return $result; @@ -244,14 +244,14 @@ class Link extends CommonObject { global $conf; - $sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM " . MAIN_DB_PREFIX . "links"; - $sql .= " WHERE objecttype = '" . $objecttype . "' AND objectid = " . $objectid; - if ($conf->entity != 0) $sql .= " AND entity = " . $conf->entity; + $sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM ".MAIN_DB_PREFIX."links"; + $sql .= " WHERE objecttype = '".$objecttype."' AND objectid = ".$objectid; + if ($conf->entity != 0) $sql .= " AND entity = ".$conf->entity; if ($sortfield) { if (empty($sortorder)) { $sortorder = "ASC"; } - $sql .= " ORDER BY " . $sortfield . " " . $sortorder; + $sql .= " ORDER BY ".$sortfield." ".$sortorder; } dol_syslog(get_class($this)."::fetchAll", LOG_DEBUG); @@ -259,7 +259,7 @@ class Link extends CommonObject if ($resql) { $num = $this->db->num_rows($resql); - dol_syslog(get_class($this)."::fetchAll " . $num . "records", LOG_DEBUG); + dol_syslog(get_class($this)."::fetchAll ".$num."records", LOG_DEBUG); if ($num > 0) { while ($obj = $this->db->fetch_object($resql)) @@ -295,9 +295,9 @@ class Link extends CommonObject { global $conf; - $sql = "SELECT COUNT(rowid) as nb FROM " . MAIN_DB_PREFIX . "links"; - $sql .= " WHERE objecttype = '" . $objecttype . "' AND objectid = " . $objectid; - if ($conf->entity != 0) $sql .= " AND entity = " . $conf->entity; + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."links"; + $sql .= " WHERE objecttype = '".$objecttype."' AND objectid = ".$objectid; + if ($conf->entity != 0) $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); if ($resql) @@ -322,15 +322,15 @@ class Link extends CommonObject $rowid = $this->id; } - $sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM " . MAIN_DB_PREFIX . "links"; - $sql .= " WHERE rowid = " . $rowid; - if($conf->entity != 0) $sql .= " AND entity = " . $conf->entity; + $sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM ".MAIN_DB_PREFIX."links"; + $sql .= " WHERE rowid = ".$rowid; + if ($conf->entity != 0) $sql .= " AND entity = ".$conf->entity; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - if($this->db->num_rows($resql) > 0) + if ($this->db->num_rows($resql) > 0) { $obj = $this->db->fetch_object($resql); @@ -348,7 +348,7 @@ class Link extends CommonObject return 0; } } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -367,7 +367,7 @@ class Link extends CommonObject $this->db->begin(); // Call trigger - $result=$this->call_trigger('LINK_DELETE', $user); + $result = $this->call_trigger('LINK_DELETE', $user); if ($result < 0) { $this->db->rollback(); @@ -376,17 +376,17 @@ class Link extends CommonObject // End call triggers // Remove link - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "links"; - $sql.= " WHERE rowid = " . $this->id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."links"; + $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - if (! $this->db->query($sql)) + if (!$this->db->query($sql)) { $error++; $this->error = $this->db->lasterror(); } - if (! $error) { + if (!$error) { $this->db->commit(); return 1; diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index 53f46ccc861..f2b96b2bea0 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -118,27 +118,27 @@ class pdf_merou extends ModelePdfExpedition */ public function __construct($db = 0) { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; $this->db = $db; $this->name = "merou"; $this->description = $langs->trans("DocumentModelMerou"); $this->type = 'pdf'; - $formatarray=pdf_getFormat(); + $formatarray = pdf_getFormat(); $this->page_largeur = $formatarray['width']; - $this->page_hauteur = round($formatarray['height']/2); - $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->page_hauteur = round($formatarray['height'] / 2); + $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_logo = 1; // Display logo // Get source company - $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 } @@ -157,13 +157,13 @@ class pdf_merou extends ModelePdfExpedition public function write_file(&$object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$conf,$langs,$mysoc,$hookmanager; + global $user, $conf, $langs, $mysoc, $hookmanager; $object->fetch_thirdparty(); - 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", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch")); @@ -180,31 +180,31 @@ class pdf_merou extends ModelePdfExpedition //Create recipient $idcontact = $object->$origin->getIdContact('external', 'SHIPPING'); $this->destinataire = new Contact($this->db); - if (! empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]); + if (!empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]); //Create deliverer $idcontact = $object->$origin->getIdContact('internal', 'LIVREUR'); $this->livreur = new User($this->db); - if (! empty($idcontact[0])) $this->livreur->fetch($idcontact[0]); + if (!empty($idcontact[0])) $this->livreur->fetch($idcontact[0]); // Definition of $dir and $file if ($object->specimen) { $dir = $conf->expedition->dir_output."/sending"; - $file = $dir . "/SPECIMEN.pdf"; + $file = $dir."/SPECIMEN.pdf"; } else { $expref = dol_sanitizeFileName($object->ref); - $dir = $conf->expedition->dir_output . "/sending/" . $expref; - $file = $dir . "/" . $expref . ".pdf"; + $dir = $conf->expedition->dir_output."/sending/".$expref; + $file = $dir."/".$expref.".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; } } @@ -212,24 +212,24 @@ class pdf_merou 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 $nblines = count($object->lines); - $pdf=pdf_getInstance($this->format, 'mm', 'l'); + $pdf = pdf_getInstance($this->format, 'mm', 'l'); $default_font_size = pdf_getPDFFontSize($outputlangs); - $heightforinfotot = 0; // 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 = 0; // 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')) @@ -239,14 +239,14 @@ class pdf_merou extends ModelePdfExpedition } $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); if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); @@ -256,41 +256,41 @@ class pdf_merou extends ModelePdfExpedition $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment")); - 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(); $pagenb++; $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('', '', $default_font_size - 3); - $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); $tab_top = 52; - $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 = $this->page_hauteur - $tab_top - $heightforfooter; $tab_height_newpage = $this->page_hauteur - $tab_top_newpage - $heightforfooter; // Display notes - if (! empty($object->note_public)) + if (!empty($object->note_public)) { $pdf->SetFont('', '', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $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; } @@ -302,7 +302,7 @@ class pdf_merou extends ModelePdfExpedition $curY = $tab_top + 7; $nexY = $tab_top + 7; - $num=count($object->lines); + $num = count($object->lines); // Loop on each lines for ($i = 0; $i < $num; $i++) { @@ -311,17 +311,17 @@ class pdf_merou extends ModelePdfExpedition $pdf->SetTextColor(0, 0, 0); $pdf->setTopMargin($tab_top_newpage); - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - $pageposbefore=$pdf->getPage(); + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + $pageposbefore = $pdf->getPage(); // Description of product line $libelleproduitservice = pdf_writelinedesc($pdf, $object, $i, $outputlangs, 90, 3, 50, $curY, 0, 1); $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) { @@ -332,8 +332,8 @@ class pdf_merou extends ModelePdfExpedition // Check boxes $pdf->SetDrawColor(120, 120, 120); - $pdf->Rect(10+3, $curY, 3, 3); - $pdf->Rect(20+3, $curY, 3, 3); + $pdf->Rect(10 + 3, $curY, 3, 3); + $pdf->Rect(20 + 3, $curY, 3, 3); //Inserting the product reference $pdf->SetXY(30, $curY); @@ -347,16 +347,16 @@ class pdf_merou extends ModelePdfExpedition $pdf->MultiCell(30, 3, $object->lines[$i]->qty_shipped, 0, 'C', 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) @@ -373,9 +373,9 @@ class pdf_merou 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 (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) { @@ -396,12 +396,12 @@ class pdf_merou 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 - 1, $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; } // Pagefoot @@ -413,22 +413,22 @@ class pdf_merou extends ModelePdfExpedition $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); @@ -437,13 +437,13 @@ class pdf_merou extends ModelePdfExpedition } else { - $this->error=$outputlangs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $outputlangs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } else { - $this->error=$outputlangs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR"); + $this->error = $outputlangs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR"); return 0; } } @@ -531,20 +531,20 @@ class pdf_merou extends ModelePdfExpedition */ 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); //Affiche le filigrane brouillon - Print Draft Watermark - if($object->statut==0 && (! empty($conf->global->SENDING_DRAFT_WATERMARK)) ) + if ($object->statut == 0 && (!empty($conf->global->SENDING_DRAFT_WATERMARK))) { pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SENDING_DRAFT_WATERMARK); } - $posy=$this->marge_haute; - $posx=$this->page_largeur-$this->marge_droite-100; + $posy = $this->marge_haute; + $posx = $this->page_largeur - $this->marge_droite - 100; $Xoff = 90; $Yoff = 0; @@ -556,13 +556,13 @@ class pdf_merou extends ModelePdfExpedition //*********************LOGO**************************** $pdf->SetXY(11, 7); - $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, 10, 5, 0, $height); // width=0 (auto) + $height = pdf_getHeightForLogo($logo); + $pdf->Image($logo, 10, 5, 0, $height); // width=0 (auto) } else { @@ -574,7 +574,7 @@ class pdf_merou extends ModelePdfExpedition } else { - $text=$this->emetteur->name; + $text = $this->emetteur->name; $pdf->MultiCell(70, 3, $outputlangs->convToOutputCharset($text), 0, 'L'); } @@ -583,9 +583,9 @@ class pdf_merou extends ModelePdfExpedition $pdf->SetXY($Xoff, 7); $pdf->SetFont('', 'B', $default_font_size + 2); $pdf->SetTextColor(0, 0, 0); - $pdf->MultiCell(0, 3, $outputlangs->transnoentities("SendingSheet"), '', 'L'); // Sending sheet + $pdf->MultiCell(0, 3, $outputlangs->transnoentities("SendingSheet"), '', 'L'); // Sending sheet //Num Expedition - $Yoff = $Yoff+7; + $Yoff = $Yoff + 7; $Xoff = 142; //$pdf->Rect($Xoff, $Yoff, 85, 8); $pdf->SetXY($Xoff, $Yoff); @@ -594,8 +594,8 @@ class pdf_merou extends ModelePdfExpedition $pdf->MultiCell(0, 3, $outputlangs->transnoentities("RefSending").': '.$outputlangs->convToOutputCharset($object->ref), '', 'R'); //$this->Code39($Xoff+43, $Yoff+1, $object->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true); - $origin = $object->origin; - $origin_id = $object->origin_id; + $origin = $object->origin; + $origin_id = $object->origin_id; // Add list of linked elements $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size - 1, $hookmanager); @@ -603,15 +603,15 @@ class pdf_merou extends ModelePdfExpedition //$this->Code39($Xoff+43, $Yoff+1, $object->commande->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true); //Definition Location of the Company block $Xoff = 110; - $blSocX=90; - $blSocY=24; - $blSocW=50; - $blSocX2=$blSocW+$blSocX; + $blSocX = 90; + $blSocY = 24; + $blSocW = 50; + $blSocX2 = $blSocW + $blSocX; // Sender name $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', 'B', $default_font_size - 3); - $pdf->SetXY($blSocX, $blSocY+1); + $pdf->SetXY($blSocX, $blSocY + 1); $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); $pdf->SetTextColor(0, 0, 0); @@ -619,54 +619,54 @@ class pdf_merou extends ModelePdfExpedition $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); $pdf->SetFont('', '', $default_font_size - 3); - $pdf->SetXY($blSocX, $blSocY+4); + $pdf->SetXY($blSocX, $blSocY + 4); $pdf->MultiCell(80, 2, $carac_emetteur, 0, 'L'); if ($object->thirdparty->code_client) { - $Yoff+=3; - $posy=$Yoff; + $Yoff += 3; + $posy = $Yoff; $pdf->SetXY(100, $posy); $pdf->SetTextColor(0, 0, 0); - $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'); } // Date delivery - $Yoff = $Yoff+7; - $pdf->SetXY($blSocX-80, $blSocY+17); + $Yoff = $Yoff + 7; + $pdf->SetXY($blSocX - 80, $blSocY + 17); $pdf->SetFont('', 'B', $default_font_size - 3); $pdf->SetTextColor(0, 0, 0); - $pdf->MultiCell(50, 8, $outputlangs->transnoentities("DateDeliveryPlanned")." : " . dol_print_date($object->date_delivery, 'day', false, $outputlangs, true), '', 'L'); + $pdf->MultiCell(50, 8, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, 'day', false, $outputlangs, true), '', 'L'); - $pdf->SetXY($blSocX-80, $blSocY+20); + $pdf->SetXY($blSocX - 80, $blSocY + 20); $pdf->SetFont('', 'B', $default_font_size - 3); $pdf->SetTextColor(0, 0, 0); - $pdf->MultiCell(50, 8, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, '', 'L'); + $pdf->MultiCell(50, 8, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, '', 'L'); // Deliverer - $pdf->SetXY($blSocX-80, $blSocY+23); + $pdf->SetXY($blSocX - 80, $blSocY + 23); $pdf->SetFont('', '', $default_font_size - 3); $pdf->SetTextColor(0, 0, 0); - 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'); + $code = $outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); - $label=''; - $label.=$outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code)); + $label = ''; + $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 - 3); $pdf->writeHTMLCell(50, 8, '', '', $label, '', 'L'); @@ -681,20 +681,20 @@ class pdf_merou extends ModelePdfExpedition // Shipping company (My Company) $Yoff = $blSocY; - $blExpX=$Xoff-20; - $blW=52; + $blExpX = $Xoff - 20; + $blW = 52; $Ydef = $Yoff; $pdf->Rect($blExpX, $Yoff, $blW, 26); $object->fetch_thirdparty(); // If SHIPPING contact defined on order, 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 @@ -705,19 +705,19 @@ class pdf_merou 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); - $blDestX=$blExpX+55; - $blW=54; - $Yoff = $Ydef +1; + $blDestX = $blExpX + 55; + $blW = 54; + $Yoff = $Ydef + 1; // Show Recipient frame $pdf->SetFont('', 'B', $default_font_size - 3); - $pdf->SetXY($blDestX, $Yoff-4); + $pdf->SetXY($blDestX, $Yoff - 4); $pdf->MultiCell($blW, 3, $outputlangs->transnoentities("Recipient"), 0, 'L'); - $pdf->Rect($blDestX, $Yoff-1, $blW, 26); + $pdf->Rect($blDestX, $Yoff - 1, $blW, 26); // Show recipient name $pdf->SetFont('', 'B', $default_font_size - 3); diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index a79c17b47ca..a398fbf23a4 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -127,7 +127,7 @@ class pdf_azur extends ModelePDFPropales */ public function __construct($db) { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; // Translations $langs->loadLangs(array("main", "bills")); @@ -135,72 +135,72 @@ class pdf_azur extends ModelePDFPropales $this->db = $db; $this->name = "azur"; $this->description = $langs->trans('DocModelAzurDescription'); - $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 - $this->franchise=!$mysoc->tva_assuj; + $this->franchise = !$mysoc->tva_assuj; // 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 @@ -218,11 +218,11 @@ class pdf_azur 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", "propal", "products")); @@ -230,32 +230,32 @@ class pdf_azur extends ModelePDFPropales $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_PROPOSALS_WITH_PICTURE)) + $realpatharray = array(); + 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) { $dir = $conf->product->dir_output.'/'.$midir; @@ -265,16 +265,16 @@ class pdf_azur extends ModelePDFPropales { if ($obj['photo_vignette']) { - $filename= $obj['photo_vignette']; + $filename = $obj['photo_vignette']; } else { - $filename=$obj['photo']; + $filename = $obj['photo']; } } else { - $filename=$obj['photo']; + $filename = $obj['photo']; } $realpath = $dir.$filename; @@ -283,11 +283,11 @@ class pdf_azur extends ModelePDFPropales } } - if ($realpath && $arephoto) $realpatharray[$i]=$realpath; + if ($realpath && $arephoto) $realpatharray[$i] = $realpath; } } - if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva; + if (count($realpatharray) == 0) $this->posxpicture = $this->posxtva; if ($conf->propal->multidir_output[$conf->entity]) { @@ -299,20 +299,20 @@ class pdf_azur extends ModelePDFPropales if ($object->specimen) { $dir = $conf->propal->multidir_output[$conf->entity]; - $file = $dir . "/SPECIMEN.pdf"; + $file = $dir."/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); - $dir = $conf->propal->multidir_output[$object->entity] . "/" . $objectref; - $file = $dir . "/" . $objectref . ".pdf"; + $dir = $conf->propal->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; } } @@ -320,19 +320,19 @@ class pdf_azur extends ModelePDFPropales 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); if (class_exists('TCPDF')) @@ -342,14 +342,14 @@ class pdf_azur 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)); @@ -357,12 +357,12 @@ class pdf_azur extends ModelePDFPropales $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfCommercialProposalTitle")." ".$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) { @@ -372,35 +372,35 @@ class pdf_azur extends ModelePDFPropales 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++; - $heightforinfotot = 40; // Height reserved to output the info and total part - $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE)?(pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature"))+10):0; - $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 + $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE) ? (pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature")) + 10) : 0; + $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; //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit; $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) @@ -411,58 +411,58 @@ class pdf_azur 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; + $notetoshow .= $langs->trans("CaseFollowedBy").' '.$tmpuser->getFullName($langs); + if ($tmpuser->email) $notetoshow .= ', Mail: '.$tmpuser->email; + if ($tmpuser->office_phone) $notetoshow .= ', Tel: '.$tmpuser->office_phone; } 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; @@ -473,183 +473,183 @@ class pdf_azur extends ModelePDFPropales 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; // 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 (isset($imglinesize['width']) && isset($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(); - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture-$curX, 3, $curX, $curY, $hideref, $hidedesc); - $pageposafter=$pdf->getPage(); + pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $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->posxpicture-$curX, 3, $curX, $curY, $hideref, $hidedesc); + $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->posxpicture - $curX, 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+$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 (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); // 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) @@ -666,10 +666,10 @@ class pdf_azur extends ModelePDFPropales $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) { @@ -682,7 +682,7 @@ class pdf_azur extends ModelePDFPropales $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); } @@ -692,19 +692,19 @@ class pdf_azur extends ModelePDFPropales if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1; } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $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); + $posy = $this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs); // Affiche zone versements /* @@ -717,7 +717,7 @@ class pdf_azur extends ModelePDFPropales // Customer signature area if (empty($conf->global->PROPAL_DISABLE_SIGNATURE)) { - $posy=$this->_signature_area($pdf, $object, $posy, $outputlangs); + $posy = $this->_signature_area($pdf, $object, $posy, $outputlangs); } // Pied de page @@ -729,9 +729,9 @@ class pdf_azur extends ModelePDFPropales { require_once DOL_DOCUMENT_ROOT.'/product/class/propalmergepdfproduct.class.php'; - $already_merged = array (); + $already_merged = array(); foreach ($object->lines as $line) { - if (! empty($line->fk_product) && ! (in_array($line->fk_product, $already_merged))) { + if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) { // Find the desire PDF $filetomerge = new Propalmergepdfproduct($this->db); @@ -746,41 +746,41 @@ class pdf_azur 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); @@ -802,31 +802,31 @@ class pdf_azur 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; } } @@ -873,13 +873,13 @@ class pdf_azur extends ModelePDFPropales $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 shipping date - if (! empty($object->date_livraison)) + if (!empty($object->date_livraison)) { $outputlangs->load("sendings"); $pdf->SetFont('', 'B', $default_font_size - 2); @@ -888,10 +888,10 @@ class pdf_azur extends ModelePDFPropales $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 { @@ -902,11 +902,11 @@ class pdf_azur extends ModelePDFPropales $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($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($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 payments conditions @@ -919,11 +919,11 @@ class pdf_azur extends ModelePDFPropales $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; } if (empty($conf->global->PROPALE_PDF_HIDE_PAYMENTTERMMODE)) @@ -955,19 +955,19 @@ class pdf_azur extends ModelePDFPropales $pdf->MultiCell(80, 5, $titre, 0, 'L'); $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)) { - $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) { @@ -977,14 +977,14 @@ class pdf_azur extends ModelePDFPropales $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) @@ -992,14 +992,14 @@ class pdf_azur extends ModelePDFPropales $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; } } } @@ -1008,19 +1008,19 @@ class pdf_azur extends ModelePDFPropales // 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; } } } @@ -1043,7 +1043,7 @@ class pdf_azur extends ModelePDFPropales 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; @@ -1054,32 +1054,32 @@ class pdf_azur extends ModelePDFPropales $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 } @@ -1152,7 +1152,7 @@ class pdf_azur extends ModelePDFPropales } //} // VAT - foreach($this->tva as $tvakey => $tvaval) + foreach ($this->tva as $tvakey => $tvaval) { if ($tvakey != 0) // On affiche pas taux 0 { @@ -1161,15 +1161,15 @@ class pdf_azur 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("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); @@ -1248,7 +1248,7 @@ class pdf_azur extends ModelePDFPropales $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); @@ -1267,7 +1267,7 @@ class pdf_azur extends ModelePDFPropales $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); @@ -1292,7 +1292,7 @@ class pdf_azur extends ModelePDFPropales $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); @@ -1324,8 +1324,8 @@ class pdf_azur extends ModelePDFPropales 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); @@ -1337,30 +1337,30 @@ class pdf_azur 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, 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_PROPOSALS_WITH_PICTURE)) + if (!empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE)) { - $pdf->line($this->posxpicture-1, $tab_top, $this->posxpicture-1, $tab_top + $tab_height); + $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height); if (empty($hidetop)) { //$pdf->SetXY($this->posxpicture-1, $tab_top+1); @@ -1370,30 +1370,30 @@ class pdf_azur extends ModelePDFPropales 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)) { // Not do -3 and +3 instead of -1 -1 to have more space for text 'Sales tax' - $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); @@ -1402,13 +1402,13 @@ class pdf_azur extends ModelePDFPropales } } - $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) @@ -1417,7 +1417,7 @@ class pdf_azur extends ModelePDFPropales } 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'); } } @@ -1434,7 +1434,7 @@ class pdf_azur extends ModelePDFPropales */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { - global $conf,$langs; + global $conf, $langs; // Load traductions files required by page $outputlangs->loadLangs(array("main", "propal", "companies", "bills")); @@ -1444,7 +1444,7 @@ class pdf_azur extends ModelePDFPropales pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); // Show Draft Watermark - if($object->statut==0 && (! empty($conf->global->PROPALE_DRAFT_WATERMARK)) ) + if ($object->statut == 0 && (!empty($conf->global->PROPALE_DRAFT_WATERMARK))) { pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->PROPALE_DRAFT_WATERMARK); } @@ -1452,21 +1452,21 @@ class pdf_azur 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); // Logo if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) { - $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo; + $logo = $conf->mycompany->multidir_output[$object->entity].'/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 { @@ -1478,7 +1478,7 @@ class pdf_azur extends ModelePDFPropales } else { - $text=$this->emetteur->name; + $text = $this->emetteur->name; $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } } @@ -1486,61 +1486,61 @@ class pdf_azur extends ModelePDFPropales $pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $title=$outputlangs->transnoentities("PdfCommercialProposalTitle"); + $title = $outputlangs->transnoentities("PdfCommercialProposalTitle"); $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'); } - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R'); - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal")." : " . dol_print_date($object->fin_validite, "day", false, $outputlangs, true), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal")." : ".dol_print_date($object->fin_validite, "day", false, $outputlangs, true), '', 'R'); if ($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 @@ -1554,28 +1554,28 @@ class pdf_azur extends ModelePDFPropales 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); @@ -1583,24 +1583,24 @@ class pdf_azur extends ModelePDFPropales $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 @@ -1611,26 +1611,26 @@ class pdf_azur extends ModelePDFPropales $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'); @@ -1638,7 +1638,7 @@ class pdf_azur extends ModelePDFPropales // 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'); } @@ -1659,7 +1659,7 @@ class pdf_azur extends ModelePDFPropales 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, 'PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); } @@ -1684,7 +1684,7 @@ class pdf_azur extends ModelePDFPropales $posx = 120; $largcol = ($this->page_largeur - $this->marge_droite - $posx); - $useborder=0; + $useborder = 0; $index = 0; // Total HT $pdf->SetFillColor(255, 255, 255); @@ -1693,11 +1693,11 @@ class pdf_azur extends ModelePDFPropales $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentities("ProposalCustomerSignature"), 0, 'L', 1); $pdf->SetXY($posx, $tab_top + $tab_hl); - $pdf->MultiCell($largcol, $tab_hl*3, '', 1, 'R'); - if (! empty($conf->global->MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING)) { - $pdf->addEmptySignatureAppearance($posx, $tab_top + $tab_hl, $largcol, $tab_hl*3); + $pdf->MultiCell($largcol, $tab_hl * 3, '', 1, 'R'); + if (!empty($conf->global->MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING)) { + $pdf->addEmptySignatureAppearance($posx, $tab_top + $tab_hl, $largcol, $tab_hl * 3); } - return ($tab_hl*7); + return ($tab_hl * 7); } } diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 9dffb0eee69..125c56960ca 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; */ class pdf_squille extends ModelePdfReception { - public $emetteur; // Objet societe qui emet + public $emetteur; // Objet societe qui emet /** @@ -42,54 +42,54 @@ class pdf_squille extends ModelePdfReception */ public function __construct($db = 0) { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; $this->db = $db; $this->name = "squille"; $this->description = $langs->trans("DocumentModelStandardPDF"); $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; // Get source company - $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 // Define position of columns - $this->posxdesc=$this->marge_gauche+1; - $this->posxweightvol=$this->page_largeur - $this->marge_droite - 78; - $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 56; - $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 28; - $this->posxpuht=$this->page_largeur - $this->marge_droite; + $this->posxdesc = $this->marge_gauche + 1; + $this->posxweightvol = $this->page_largeur - $this->marge_droite - 78; + $this->posxqtyordered = $this->page_largeur - $this->marge_droite - 56; + $this->posxqtytoship = $this->page_largeur - $this->marge_droite - 28; + $this->posxpuht = $this->page_largeur - $this->marge_droite; if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { - $this->posxweightvol=$this->page_largeur - $this->marge_droite - 118; - $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 96; - $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 68; - $this->posxpuht=$this->page_largeur - $this->marge_droite - 40; - $this->posxtotalht=$this->page_largeur - $this->marge_droite - 20; + $this->posxweightvol = $this->page_largeur - $this->marge_droite - 118; + $this->posxqtyordered = $this->page_largeur - $this->marge_droite - 96; + $this->posxqtytoship = $this->page_largeur - $this->marge_droite - 68; + $this->posxpuht = $this->page_largeur - $this->marge_droite - 40; + $this->posxtotalht = $this->page_largeur - $this->marge_droite - 20; } - $this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images + $this->posxpicture = $this->posxweightvol - (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->posxweightvol-=20; - $this->posxpicture-=20; - $this->posxqtyordered-=20; - $this->posxqtytoship-=20; + $this->posxweightvol -= 20; + $this->posxpicture -= 20; + $this->posxqtyordered -= 20; + $this->posxqtytoship -= 20; } - if (! empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) + if (!empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) { $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered); $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered); @@ -112,35 +112,35 @@ class pdf_squille extends ModelePdfReception public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$conf,$langs,$hookmanager; + global $user, $conf, $langs, $hookmanager; $object->fetch_thirdparty(); - 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'; - $outputlangs->loadLangs(array("main","dict","companies","bills","products","propal","deliveries","receptions","productbatch","sendings")); + $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "propal", "deliveries", "receptions", "productbatch", "sendings")); $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) { if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) { @@ -175,20 +175,20 @@ class pdf_squille extends ModelePdfReception if ($object->specimen) { $dir = $conf->reception->dir_output; - $file = $dir . "/SPECIMEN.pdf"; + $file = $dir."/SPECIMEN.pdf"; } else { $rcpref = dol_sanitizeFileName($object->ref); - $dir = $conf->reception->dir_output."/" . $rcpref; - $file = $dir . "/" . $rcpref . ".pdf"; + $dir = $conf->reception->dir_output."/".$rcpref; + $file = $dir."/".$rcpref.".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; } } @@ -196,24 +196,24 @@ class pdf_squille extends ModelePdfReception 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) + $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) $pdf->SetAutoPageBreak(1, 0); if (class_exists('TCPDF')) @@ -223,14 +223,14 @@ class pdf_squille extends ModelePdfReception } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (empty($conf->global->MAIN_DISABLE_FPDI) && !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); if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); @@ -240,21 +240,21 @@ class pdf_squille extends ModelePdfReception $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Reception")); - 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; @@ -268,51 +268,51 @@ class pdf_squille extends ModelePdfReception $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->reception_method_id > 0) { // Get code using getLabelFromKey - $code=$outputlangs->getLabelFromKey($this->db, $object->shipment_method_id, 'c_shipment_mode', 'rowid', 'code'); - $label=''; - if ($object->tracking_url != $object->tracking_number) $label.=$outputlangs->trans("LinkToTrackYourPackage")."
"; - $label.=$outputlangs->trans("ReceptionMethod").": ".$outputlangs->trans("ReceptionMethod".strtoupper($code)); + $code = $outputlangs->getLabelFromKey($this->db, $object->shipment_method_id, 'c_shipment_mode', 'rowid', 'code'); + $label = ''; + if ($object->tracking_url != $object->tracking_number) $label .= $outputlangs->trans("LinkToTrackYourPackage")."
"; + $label .= $outputlangs->trans("ReceptionMethod").": ".$outputlangs->trans("ReceptionMethod".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(); } @@ -320,118 +320,118 @@ class pdf_squille extends ModelePdfReception } // Notes - if (! empty($object->note_public)) + if (!empty($object->note_public)) { - $pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer 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); // Dans boucle pour gerer 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; } $iniY = $tab_top + 7; $curY = $tab_top + 7; $nexY = $tab_top + 7; - $fk_commandefourndet=0; - $totalOrdered=0; + $fk_commandefourndet = 0; + $totalOrdered = 0; // Loop on each lines 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 (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); + 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 (isset($imglinesize['width']) && isset($imglinesize['height'])) { - $curX = $this->posxpicture-1; - $pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol-$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->posxweightvol - $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(); - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture-$curX, 3, $curX, $curY, $hideref, $hidedesc); + pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $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->posxpicture-$curX, 3, $curX, $curY, $hideref, $hidedesc); + pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 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)) { @@ -472,25 +472,25 @@ class pdf_squille extends ModelePdfReception $pdf->SetXY($this->posxqtytoship, $curY); $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty, '', 'C'); - if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) + if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { $pdf->SetXY($this->posxpuht, $curY); - $pdf->MultiCell(($this->posxtotalht - $this->posxpuht-1), 3, price($object->lines[$i]->subprice, 0, $outputlangs), '', 'R'); + $pdf->MultiCell(($this->posxtotalht - $this->posxpuht - 1), 3, price($object->lines[$i]->subprice, 0, $outputlangs), '', 'R'); $pdf->SetXY($this->posxtotalht, $curY); $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs), '', 'R'); } - $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)); } @@ -509,9 +509,9 @@ class pdf_squille extends ModelePdfReception $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 (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) { @@ -524,7 +524,7 @@ class pdf_squille extends ModelePdfReception $this->_pagefoot($pdf, $object, $outputlangs, 1); // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; } } @@ -533,16 +533,16 @@ class pdf_squille extends ModelePdfReception 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 totaux - $posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs, $totalOrdered); + $posy = $this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs, $totalOrdered); // Pied de page $this->_pagefoot($pdf, $object, $outputlangs); @@ -554,29 +554,29 @@ class pdf_squille extends ModelePdfReception // 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)); - 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", "EXP_OUTPUTDIR"); + $this->error = $langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR"); return 0; } } @@ -597,9 +597,9 @@ class pdf_squille extends ModelePdfReception protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $totalOrdered) { // phpcs:enable - global $conf,$mysoc; + global $conf, $mysoc; - $sign=1; + $sign = 1; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -608,7 +608,7 @@ class pdf_squille extends ModelePdfReception $pdf->SetFont('', 'B', $default_font_size - 1); // Tableau total - $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; @@ -616,34 +616,34 @@ class pdf_squille extends ModelePdfReception if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol); else $largcol2 = ($this->posxqtytoship - $this->posxweightvol); - $useborder=0; + $useborder = 0; $index = 0; - $totalWeighttoshow=''; - $totalVolumetoshow=''; + $totalWeighttoshow = ''; + $totalVolumetoshow = ''; // Load dim data - $tmparray=$object->getTotalWeightVolume(); - $totalWeight=$tmparray['weight']; - $totalVolume=$tmparray['volume']; - $totalToShip=$tmparray['toship']; + $tmparray = $object->getTotalWeightVolume(); + $totalWeight = $tmparray['weight']; + $totalVolume = $tmparray['volume']; + $totalToShip = $tmparray['toship']; // Set trueVolume and volume_units not currently stored into database if ($object->trueWidth && $object->trueHeight && $object->trueDepth) { - $object->trueVolume= ($object->trueWidth * $object->trueHeight * $object->trueDepth); - $object->volume_units=$object->size_units * 3; + $object->trueVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth); + $object->volume_units = $object->size_units * 3; } - if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); - if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); - if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); - if ($object->trueVolume) $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); + if ($totalWeight != '') $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); + if ($totalVolume != '') $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); + if ($object->trueWeight) $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); + if ($object->trueVolume) $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); $pdf->SetFillColor(255, 255, 255); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1); if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) { @@ -654,7 +654,7 @@ class pdf_squille extends ModelePdfReception $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1); - if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { + if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1); @@ -677,7 +677,7 @@ class pdf_squille extends ModelePdfReception $index++; } - if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++; + if (!$totalWeighttoshow && !$totalVolumetoshow) $index++; $pdf->SetTextColor(0, 0, 0); @@ -702,8 +702,8 @@ class pdf_squille extends ModelePdfReception global $conf; // Force to disable hidetop and hidebottom - $hidebottom=0; - if ($hidetop) $hidetop=-1; + $hidebottom = 0; + if ($hidetop) $hidetop = -1; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -712,55 +712,55 @@ class pdf_squille extends ModelePdfReception $pdf->SetFont('', '', $default_font_size - 2); // 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 $pdf->SetDrawColor(128, 128, 128); $pdf->SetFont('', '', $default_font_size - 1); 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->SetXY($this->posxdesc-1, $tab_top+1); + $pdf->SetXY($this->posxdesc - 1, $tab_top + 1); $pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities("Description"), '', 'L'); } - $pdf->line($this->posxweightvol-1, $tab_top, $this->posxweightvol-1, $tab_top + $tab_height); + $pdf->line($this->posxweightvol - 1, $tab_top, $this->posxweightvol - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxweightvol-1, $tab_top+1); + $pdf->SetXY($this->posxweightvol - 1, $tab_top + 1); $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"), '', 'C'); } if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) { - $pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height); + $pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxqtyordered-1, $tab_top+1); + $pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1); $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"), '', 'C'); } } - $pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height); + $pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxqtytoship, $tab_top+1); + $pdf->SetXY($this->posxqtytoship, $tab_top + 1); $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToReceive"), '', 'C'); } - if(!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { - $pdf->line($this->posxpuht-1, $tab_top, $this->posxpuht-1, $tab_top + $tab_height); + if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { + $pdf->line($this->posxpuht - 1, $tab_top, $this->posxpuht - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxpuht-1, $tab_top+1); + $pdf->SetXY($this->posxpuht - 1, $tab_top + 1); $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"), '', 'C'); } - $pdf->line($this->posxtotalht-1, $tab_top, $this->posxtotalht-1, $tab_top + $tab_height); + $pdf->line($this->posxtotalht - 1, $tab_top, $this->posxtotalht - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxtotalht-1, $tab_top+1); + $pdf->SetXY($this->posxtotalht - 1, $tab_top + 1); $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"), '', 'C'); } } @@ -778,7 +778,7 @@ class pdf_squille extends ModelePdfReception */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; $langs->load("orders"); @@ -787,7 +787,7 @@ class pdf_squille extends ModelePdfReception pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); // Show Draft Watermark - if($object->statut==0 && (! empty($conf->global->RECEPTION_DRAFT_WATERMARK)) ) + if ($object->statut == 0 && (!empty($conf->global->RECEPTION_DRAFT_WATERMARK))) { pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->RECEPTION_DRAFT_WATERMARK); } @@ -798,19 +798,19 @@ class pdf_squille extends ModelePdfReception $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 { @@ -822,21 +822,21 @@ class pdf_squille extends ModelePdfReception } 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 reception ref $object->ref //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); @@ -844,7 +844,7 @@ class pdf_squille extends ModelePdfReception } $pdf->SetDrawColor(128, 128, 128); - if (! empty($conf->barcode->enabled)) + if (!empty($conf->barcode->enabled)) { // TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); @@ -852,67 +852,67 @@ class pdf_squille extends ModelePdfReception } - $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("ReceptionSheet"); + $title = $outputlangs->transnoentities("ReceptionSheet"); $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("RefReception") ." : ".$object->ref, '', 'R'); + $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefReception")." : ".$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_fournisseur)) + if (!empty($object->thirdparty->code_fournisseur)) { - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', '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->fournisseur->enabled)) // commonly $origin='commande' + if (!empty($conf->fournisseur->enabled)) // commonly $origin='commande' { $outputlangs->load('orders'); $classname = 'CommandeFournisseur'; $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'); } @@ -921,31 +921,31 @@ class pdf_squille extends ModelePdfReception if ($showaddress) { // Sender properties - $carac_emetteur=''; + $carac_emetteur = ''; // Add internal contact of origin element if defined - $arrayidcontact=array(); - if (! empty($origin) && is_object($object->$origin)) $arrayidcontact=$object->$origin->getIdContact('internal', 'SALESREPFOLL'); - if(empty($arrayidcontact)) $arrayidcontact=$object->$origin->getIdContact('internal', 'SHIPPING'); + $arrayidcontact = array(); + if (!empty($origin) && is_object($object->$origin)) $arrayidcontact = $object->$origin->getIdContact('internal', 'SALESREPFOLL'); + if (empty($arrayidcontact)) $arrayidcontact = $object->$origin->getIdContact('internal', 'SHIPPING'); if (count($arrayidcontact) > 0) { $object->fetch_user(reset($arrayidcontact)); - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; } $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); // Show sender - $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; - $posx=$this->marge_gauche; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; + $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; + $posx = $this->marge_gauche; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80; - $hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; - $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; + $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; + $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; // 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("Sender").":", 0, 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); @@ -954,13 +954,13 @@ class pdf_squille extends ModelePdfReception $pdf->SetFillColor(255, 255, 255); // If RECEPTION 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 @@ -971,46 +971,46 @@ class pdf_squille extends ModelePdfReception $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 name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); - $pdf->MultiCell($widthrecbox-2, 4, $carac_client_name, 0, 'L'); + $pdf->MultiCell($widthrecbox - 2, 4, $carac_client_name, 0, 'L'); $posy = $pdf->getY(); // Show recipient information $pdf->SetFont('', '', $default_font_size - 1); - $pdf->SetXY($posx+2, $posy); - $pdf->MultiCell($widthrecbox-2, 4, $carac_client, 0, 'L'); + $pdf->SetXY($posx + 2, $posy); + $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, 'L'); // 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 sender name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); $pdf->MultiCell($widthrecbox, 2, $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($widthrecbox, 4, $carac_emetteur, 0, 'L'); } @@ -1031,7 +1031,7 @@ class pdf_squille extends ModelePdfReception 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, 'RECEPTION_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); } } diff --git a/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php b/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php index 1c634023b80..3a1cf3667aa 100644 --- a/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php +++ b/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php @@ -22,7 +22,7 @@ * \brief File to manage password generation according to standard rule */ -require_once DOL_DOCUMENT_ROOT .'/core/modules/security/generate/modules_genpassword.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/security/generate/modules_genpassword.php'; /** @@ -61,10 +61,10 @@ class modGeneratePassStandard extends ModeleGenPassword $this->id = "standard"; $this->length = 8; - $this->db=$db; - $this->conf=$conf; - $this->langs=$langs; - $this->user=$user; + $this->db = $db; + $this->conf = $conf; + $this->langs = $langs; + $this->user = $user; } /** @@ -108,7 +108,7 @@ class modGeneratePassStandard extends ModeleGenPassword while ($i < $this->length) { // pick a random character from the possible ones - $char = substr($possible, mt_rand(0, dol_strlen($possible)-1), 1); + $char = substr($possible, mt_rand(0, dol_strlen($possible) - 1), 1); // we don't want this character if it's already in the password if (!strstr($password, $char)) diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 2f4efae770a..d14503a9039 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -22,7 +22,7 @@ */ // Protection to avoid direct call of template -if (empty($object) || ! is_object($object)) +if (empty($object) || !is_object($object)) { print "Error, template page can't be called as URL"; exit; @@ -35,28 +35,28 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; $module = $object->element; // Special cases -if ($module == 'propal') { $permission=$user->rights->propale->creer; } -elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer; } -elseif ($module == 'order_supplier') { $permission=$user->rights->fournisseur->commande->creer; } -elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer; } -elseif ($module == 'project') { $permission=$user->rights->projet->creer; } -elseif ($module == 'action') { $permission=$user->rights->agenda->myactions->create; } -elseif ($module == 'shipping') { $permission=$user->rights->expedition->creer; } -elseif ($module == 'reception') { $permission=$user->rights->reception->creer; } -elseif ($module == 'project_task') { $permission=$user->rights->projet->creer; } -elseif (! isset($permission) && isset($user->rights->$module->creer)) +if ($module == 'propal') { $permission = $user->rights->propale->creer; } +elseif ($module == 'fichinter') { $permission = $user->rights->ficheinter->creer; } +elseif ($module == 'order_supplier') { $permission = $user->rights->fournisseur->commande->creer; } +elseif ($module == 'invoice_supplier') { $permission = $user->rights->fournisseur->facture->creer; } +elseif ($module == 'project') { $permission = $user->rights->projet->creer; } +elseif ($module == 'action') { $permission = $user->rights->agenda->myactions->create; } +elseif ($module == 'shipping') { $permission = $user->rights->expedition->creer; } +elseif ($module == 'reception') { $permission = $user->rights->reception->creer; } +elseif ($module == 'project_task') { $permission = $user->rights->projet->creer; } +elseif (!isset($permission) && isset($user->rights->$module->creer)) { - $permission=$user->rights->$module->creer; + $permission = $user->rights->$module->creer; } -elseif (! isset($permission) && isset($user->rights->$module->write)) +elseif (!isset($permission) && isset($user->rights->$module->write)) { - $permission=$user->rights->$module->write; + $permission = $user->rights->$module->write; } -$formcompany= new FormCompany($db); -$companystatic=new Societe($db); -$contactstatic=new Contact($db); -$userstatic=new User($db); +$formcompany = new FormCompany($db); +$companystatic = new Societe($db); +$contactstatic = new Contact($db); +$userstatic = new User($db); ?> @@ -90,11 +90,11 @@ if ($permission) { '; ?>
trans("Users"); ?>
global->MAIN_INFO_SOCIETE_NOM; ?>
-
select_dolusers($user->id, 'userid', 0, (! empty($userAlreadySelected)?$userAlreadySelected:null), 0, null, null, 0, 56, '', 0, '', 'minwidth200imp'); ?>
+
select_dolusers($user->id, 'userid', 0, (!empty($userAlreadySelected) ? $userAlreadySelected : null), 0, null, null, 0, 56, '', 0, '', 'minwidth200imp'); ?>
element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) $tmpobject=$objectsrc; + $tmpobject = $object; + if (($object->element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) $tmpobject = $objectsrc; echo $formcompany->selectTypeContact($tmpobject, '', 'type', 'internal'); ?>
 
@@ -116,7 +116,7 @@ if ($permission) { '; ?>
trans("ThirdPartyContacts"); ?>
- socid; ?> + socid; ?> element, array('facture', 'invoice', 'facture_fou $isNewObject = empty($object->id) && empty($object->rowid); // Relative and absolute discounts -$addrelativediscount = '' . $langs->trans("EditRelativeDiscount") . ''; -$addabsolutediscount = '' . $langs->trans("EditGlobalDiscounts") . ''; -$viewabsolutediscount = '' . $langs->trans("ViewAvailableGlobalDiscounts") . ''; +$addrelativediscount = ''.$langs->trans("EditRelativeDiscount").''; +$addabsolutediscount = ''.$langs->trans("EditGlobalDiscounts").''; +$viewabsolutediscount = ''.$langs->trans("ViewAvailableGlobalDiscounts").''; $fixedDiscount = $thirdparty->remise_percent; -if(! empty($discount_type)) { +if (!empty($discount_type)) { $fixedDiscount = $thirdparty->remise_supplier_percent; } if ($fixedDiscount > 0) { - $translationKey = (! empty($discount_type)) ? 'HasRelativeDiscountFromSupplier' : 'CompanyHasRelativeDiscount'; + $translationKey = (!empty($discount_type)) ? 'HasRelativeDiscountFromSupplier' : 'CompanyHasRelativeDiscount'; print $langs->trans($translationKey, $fixedDiscount).'.'; } else { - $translationKey = (! empty($discount_type)) ? 'HasNoRelativeDiscountFromSupplier' : 'CompanyHasNoRelativeDiscount'; + $translationKey = (!empty($discount_type)) ? 'HasNoRelativeDiscountFromSupplier' : 'CompanyHasNoRelativeDiscount'; print $langs->trans($translationKey).'.'; } -if($isNewObject) print ' ('.$addrelativediscount.')'; +if ($isNewObject) print ' ('.$addrelativediscount.')'; // Is there is commercial discount or down payment available ? if ($absolute_discount > 0) { - if ($cannotApplyDiscount || ! $isInvoice || $isNewObject || $object->statut > $objclassname::STATUS_DRAFT || $object->type == $objclassname::TYPE_CREDIT_NOTE || $object->type == $objclassname::TYPE_DEPOSIT) { - $translationKey = ! empty($discount_type) ? 'HasAbsoluteDiscountFromSupplier' : 'CompanyHasAbsoluteDiscount'; - $text = $langs->trans($translationKey, price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency)).'.'; + if ($cannotApplyDiscount || !$isInvoice || $isNewObject || $object->statut > $objclassname::STATUS_DRAFT || $object->type == $objclassname::TYPE_CREDIT_NOTE || $object->type == $objclassname::TYPE_DEPOSIT) { + $translationKey = !empty($discount_type) ? 'HasAbsoluteDiscountFromSupplier' : 'CompanyHasAbsoluteDiscount'; + $text = $langs->trans($translationKey, price($absolute_discount), $langs->transnoentities("Currency".$conf->currency)).'.'; - if ($isInvoice && ! $isNewObject && $object->statut > $objclassname::STATUS_DRAFT && $object->type != $objclassname::TYPE_CREDIT_NOTE && $object->type != $objclassname::TYPE_DEPOSIT) { + if ($isInvoice && !$isNewObject && $object->statut > $objclassname::STATUS_DRAFT && $object->type != $objclassname::TYPE_CREDIT_NOTE && $object->type != $objclassname::TYPE_DEPOSIT) { $text = $form->textwithpicto($text, $langs->trans('AbsoluteDiscountUse')); } if ($isNewObject) { - $text.= ' ('.$addabsolutediscount.')'; + $text .= ' ('.$addabsolutediscount.')'; } print '
'.$text; } else { // Discount available of type fixed amount (not credit note) - $more = '(' . $addabsolutediscount . ')'; - $form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, GETPOST('discountid'), 'remise_id', $thirdparty->id, $absolute_discount, $filterabsolutediscount, $resteapayer, $more, 0, $discount_type); + $more = '('.$addabsolutediscount.')'; + $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, GETPOST('discountid'), 'remise_id', $thirdparty->id, $absolute_discount, $filterabsolutediscount, $resteapayer, $more, 0, $discount_type); } } // Is there credit notes availables ? if ($absolute_creditnote > 0) { // If validated, we show link "add credit note to payment" - if ($cannotApplyDiscount || ! $isInvoice || $isNewObject || $object->statut != $objclassname::STATUS_VALIDATED || $object->type == $objclassname::TYPE_CREDIT_NOTE) { - $translationKey = ! empty($discount_type) ? 'HasCreditNoteFromSupplier' : 'CompanyHasCreditNote'; - $text = $langs->trans($translationKey, price($absolute_creditnote), $langs->transnoentities("Currency" . $conf->currency)) . '.'; + if ($cannotApplyDiscount || !$isInvoice || $isNewObject || $object->statut != $objclassname::STATUS_VALIDATED || $object->type == $objclassname::TYPE_CREDIT_NOTE) { + $translationKey = !empty($discount_type) ? 'HasCreditNoteFromSupplier' : 'CompanyHasCreditNote'; + $text = $langs->trans($translationKey, price($absolute_creditnote), $langs->transnoentities("Currency".$conf->currency)).'.'; - if ($isInvoice && ! $isNewObject && $object->statut == $objclassname::STATUS_DRAFT && $object->type != $objclassname::TYPE_DEPOSIT) { + if ($isInvoice && !$isNewObject && $object->statut == $objclassname::STATUS_DRAFT && $object->type != $objclassname::TYPE_DEPOSIT) { $text = $form->textwithpicto($text, $langs->trans('CreditNoteDepositUse')); } if ($absolute_discount <= 0 || $isNewObject) { - $text.= '('.$addabsolutediscount.')'; + $text .= '('.$addabsolutediscount.')'; } print '
'.$text; } else { // We can add a credit note on a down payment or standard invoice or situation invoice // There is credit notes discounts available - $more = $isInvoice && ! $isNewObject ? ' (' . $viewabsolutediscount . ')' : ''; - $form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, 0, 'remise_id_for_payment', $thirdparty->id, $absolute_creditnote, $filtercreditnote, 0, $more, 0, $discount_type); // We allow credit note even if amount is higher + $more = $isInvoice && !$isNewObject ? ' ('.$viewabsolutediscount.')' : ''; + $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $thirdparty->id, $absolute_creditnote, $filtercreditnote, 0, $more, 0, $discount_type); // We allow credit note even if amount is higher } } -if($absolute_discount <= 0 && $absolute_creditnote <= 0) { - $translationKey = ! empty($discount_type) ? 'HasNoAbsoluteDiscountFromSupplier' : 'CompanyHasNoAbsoluteDiscount'; +if ($absolute_discount <= 0 && $absolute_creditnote <= 0) { + $translationKey = !empty($discount_type) ? 'HasNoAbsoluteDiscountFromSupplier' : 'CompanyHasNoAbsoluteDiscount'; print '
'.$langs->trans($translationKey).'.'; if ($isInvoice && $object->statut == $objclassname::STATUS_DRAFT && $object->type != $objclassname::TYPE_CREDIT_NOTE && $object->type != $objclassname::TYPE_DEPOSIT) { - print ' (' . $addabsolutediscount . ')'; + print ' ('.$addabsolutediscount.')'; } } diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index b2ab12041af..29e983a1d2b 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -33,59 +33,59 @@ */ // Protection to avoid direct call of template -if (empty($object) || ! is_object($object)) { +if (empty($object) || !is_object($object)) { print "Error: this template page cannot be called directly as an URL"; exit; } -$usemargins=0; -if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element, array('facture','facturerec','propal','commande'))) +$usemargins = 0; +if (!empty($conf->margin->enabled) && !empty($object->element) && in_array($object->element, array('facture', 'facturerec', 'propal', 'commande'))) { - $usemargins=1; + $usemargins = 1; } -if (! isset($dateSelector)) global $dateSelector; // Take global var only if not already defined into function calling (for example formAddObjectLine) +if (!isset($dateSelector)) global $dateSelector; // Take global var only if not already defined into function calling (for example formAddObjectLine) global $forceall, $forcetoshowtitlelines, $senderissupplier, $inputalsopricewithtax; -if (! isset($dateSelector)) $dateSelector=1; // For backward compatibility -elseif (empty($dateSelector)) $dateSelector=0; -if (empty($forceall)) $forceall=0; -if (empty($senderissupplier)) $senderissupplier=0; -if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0; +if (!isset($dateSelector)) $dateSelector = 1; // For backward compatibility +elseif (empty($dateSelector)) $dateSelector = 0; +if (empty($forceall)) $forceall = 0; +if (empty($senderissupplier)) $senderissupplier = 0; +if (empty($inputalsopricewithtax)) $inputalsopricewithtax = 0; // Define colspan for the button 'Add' -$colspan = 3; // Columns: total ht + col edit + col delete -if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) $colspan++;//Add column for Total (currency) if required -if (in_array($object->element, array('propal','commande','order','facture','facturerec','invoice','supplier_proposal','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button +$colspan = 3; // Columns: total ht + col edit + col delete +if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) $colspan++; //Add column for Total (currency) if required +if (in_array($object->element, array('propal', 'commande', 'order', 'facture', 'facturerec', 'invoice', 'supplier_proposal', 'order_supplier', 'invoice_supplier'))) $colspan++; // With this, there is a column move button //print $object->element; // Lines for extrafield $objectline = null; if (!empty($extrafields)) { - if ($this->table_element_line=='commandedet') { + if ($this->table_element_line == 'commandedet') { $objectline = new OrderLine($this->db); } - elseif ($this->table_element_line=='propaldet') { + elseif ($this->table_element_line == 'propaldet') { $objectline = new PropaleLigne($this->db); } - elseif ($this->table_element_line=='supplier_proposaldet') { + elseif ($this->table_element_line == 'supplier_proposaldet') { $objectline = new SupplierProposalLine($this->db); } - elseif ($this->table_element_line=='facturedet') { + elseif ($this->table_element_line == 'facturedet') { $objectline = new FactureLigne($this->db); } - elseif ($this->table_element_line=='contratdet') { + elseif ($this->table_element_line == 'contratdet') { $objectline = new ContratLigne($this->db); } - elseif ($this->table_element_line=='commande_fournisseurdet') { + elseif ($this->table_element_line == 'commande_fournisseurdet') { $objectline = new CommandeFournisseurLigne($this->db); } - elseif ($this->table_element_line=='facture_fourn_det') { + elseif ($this->table_element_line == 'facture_fourn_det') { $objectline = new SupplierInvoiceLine($this->db); } - elseif ($this->table_element_line=='facturedet_rec') { + elseif ($this->table_element_line == 'facturedet_rec') { $objectline = new FactureLigneRec($this->db); } } diff --git a/htdocs/expensereport/tpl/linkedobjectblock.tpl.php b/htdocs/expensereport/tpl/linkedobjectblock.tpl.php index 009b1b9ea75..43f612ea3f6 100644 --- a/htdocs/expensereport/tpl/linkedobjectblock.tpl.php +++ b/htdocs/expensereport/tpl/linkedobjectblock.tpl.php @@ -18,7 +18,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 8c750f2f425..c56c2a2cb64 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -46,9 +46,9 @@ class ProductFournisseur extends Product /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; - public $product_fourn_price_id; // id of ligne product-supplier + public $product_fourn_price_id; // id of ligne product-supplier /** * @var int ID @@ -61,18 +61,18 @@ class ProductFournisseur extends Product */ public $fourn_ref; public $delivery_time_days; - public $ref_supplier; // ref supplier (can be set by get_buyprice) + public $ref_supplier; // ref supplier (can be set by get_buyprice) public $desc_supplier; - public $vatrate_supplier; // default vat rate for this supplier/qty/product (can be set by get_buyprice) + public $vatrate_supplier; // default vat rate for this supplier/qty/product (can be set by get_buyprice) - public $fourn_id; //supplier id - public $fourn_qty; // quantity for price (can be set by get_buyprice) - public $fourn_pu; // unit price for quantity (can be set by get_buyprice) + public $fourn_id; //supplier id + public $fourn_qty; // quantity for price (can be set by get_buyprice) + public $fourn_pu; // unit price for quantity (can be set by get_buyprice) - public $fourn_price; // price for quantity - public $fourn_remise_percent; // discount for quantity (percent) - public $fourn_remise; // discount for quantity (amount) - public $product_fourn_id; // product-supplier id + public $fourn_price; // price for quantity + public $fourn_remise_percent; // discount for quantity (percent) + public $fourn_remise; // discount for quantity (amount) + public $product_fourn_id; // product-supplier id /** * @var int ID user_id - user who created/updated supplier price @@ -93,8 +93,8 @@ class ProductFournisseur extends Product */ public $fk_supplier_price_expression; - public $supplier_reputation; // reputation of supplier - public $reputations=array(); // list of available supplier reputations + public $supplier_reputation; // reputation of supplier + public $reputations = array(); // list of available supplier reputations // Multicurreny public $fourn_multicurrency_id; @@ -114,7 +114,7 @@ class ProductFournisseur extends Product $this->db = $db; $langs->load("suppliers"); - $this->reputations= array('-1'=>'', 'FAVORITE'=>$langs->trans('Favorite'),'NOTTHGOOD'=>$langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER'=>$langs->trans('DoNotOrderThisProductToThisSupplier')); + $this->reputations = array('-1'=>'', 'FAVORITE'=>$langs->trans('Favorite'), 'NOTTHGOOD'=>$langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER'=>$langs->trans('DoNotOrderThisProductToThisSupplier')); } @@ -129,19 +129,19 @@ class ProductFournisseur extends Product public function remove_fournisseur($id_fourn) { // phpcs:enable - $ok=1; + $ok = 1; $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql.= " WHERE fk_product = ".$this->id." AND fk_soc = ".$id_fourn; + $sql .= " WHERE fk_product = ".$this->id." AND fk_soc = ".$id_fourn; dol_syslog(get_class($this)."::remove_fournisseur", LOG_DEBUG); - $resql2=$this->db->query($sql); - if (! $resql2) + $resql2 = $this->db->query($sql); + if (!$resql2) { - $this->error=$this->db->lasterror(); - $ok=0; + $this->error = $this->db->lasterror(); + $ok = 0; } if ($ok) @@ -169,25 +169,25 @@ class ProductFournisseur extends Product // phpcs:enable global $conf, $user; - $error=0; + $error = 0; $this->db->begin(); // Call trigger - $result=$this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_DELETE', $user); + $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_DELETE', $user); if ($result < 0) $error++; // End call triggers if (empty($error)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql.= " WHERE rowid = ".$rowid; + $sql .= " WHERE rowid = ".$rowid; dol_syslog(get_class($this)."::remove_product_fournisseur_price", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); $error++; } } @@ -238,66 +238,66 @@ class ProductFournisseur extends Product //global $mysoc; // Clean parameter - if (empty($qty)) $qty=0; - if (empty($buyprice)) $buyprice=0; - if (empty($charges)) $charges=0; - if (empty($availability)) $availability=0; - if (empty($remise_percent)) $remise_percent=0; - if (empty($supplier_reputation) || $supplier_reputation == -1) $supplier_reputation=''; - if ($delivery_time_days != '' && ! is_numeric($delivery_time_days)) $delivery_time_days = ''; + if (empty($qty)) $qty = 0; + if (empty($buyprice)) $buyprice = 0; + if (empty($charges)) $charges = 0; + if (empty($availability)) $availability = 0; + if (empty($remise_percent)) $remise_percent = 0; + if (empty($supplier_reputation) || $supplier_reputation == -1) $supplier_reputation = ''; + if ($delivery_time_days != '' && !is_numeric($delivery_time_days)) $delivery_time_days = ''; if ($price_base_type == 'TTC') { $ttx = $tva_tx; - $buyprice = $buyprice/(1+($ttx/100)); + $buyprice = $buyprice / (1 + ($ttx / 100)); } // Multicurrency if ($conf->multicurrency->enabled) { - if (empty($multicurrency_tx)) $multicurrency_tx=1; - if (empty($multicurrency_buyprice)) $multicurrency_buyprice=0; + if (empty($multicurrency_tx)) $multicurrency_tx = 1; + if (empty($multicurrency_buyprice)) $multicurrency_buyprice = 0; - if (empty($multicurrency_buyprice)) $multicurrency_buyprice=0; + if (empty($multicurrency_buyprice)) $multicurrency_buyprice = 0; if ($multicurrency_price_base_type == 'TTC') { $ttx = $tva_tx; - $multicurrency_buyprice = $multicurrency_buyprice/(1+($ttx/100)); + $multicurrency_buyprice = $multicurrency_buyprice / (1 + ($ttx / 100)); } - $multicurrency_buyprice=price2num($multicurrency_buyprice, 'MU'); - $multicurrency_unitBuyPrice=price2num($multicurrency_buyprice/$qty, 'MU'); + $multicurrency_buyprice = price2num($multicurrency_buyprice, 'MU'); + $multicurrency_unitBuyPrice = price2num($multicurrency_buyprice / $qty, 'MU'); - $buyprice=$multicurrency_buyprice/$multicurrency_tx; + $buyprice = $multicurrency_buyprice / $multicurrency_tx; $fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $multicurrency_code); } - $buyprice=price2num($buyprice, 'MU'); - $charges=price2num($charges, 'MU'); - $qty=price2num($qty, 'MS'); - $unitBuyPrice = price2num($buyprice/$qty, 'MU'); + $buyprice = price2num($buyprice, 'MU'); + $charges = price2num($charges, 'MU'); + $qty = price2num($qty, 'MS'); + $unitBuyPrice = price2num($buyprice / $qty, 'MU'); - $error=0; - $now=dol_now(); + $error = 0; + $now = dol_now(); $newvat = $tva_tx; if (count($localtaxes_array) > 0) { - $localtaxtype1=$localtaxes_array['0']; - $localtax1=$localtaxes_array['1']; - $localtaxtype2=$localtaxes_array['2']; - $localtax2=$localtaxes_array['3']; + $localtaxtype1 = $localtaxes_array['0']; + $localtax1 = $localtaxes_array['1']; + $localtaxtype2 = $localtaxes_array['2']; + $localtax2 = $localtaxes_array['3']; } else // old method. deprecated because ot can't retreive type { - $localtaxtype1='0'; - $localtax1=get_localtax($newvat, 1); - $localtaxtype2='0'; - $localtax2=get_localtax($newvat, 2); + $localtaxtype1 = '0'; + $localtax1 = get_localtax($newvat, 1); + $localtaxtype2 = '0'; + $localtax2 = get_localtax($newvat, 2); } - if (empty($localtax1)) $localtax1=0; // If = '' then = 0 - if (empty($localtax2)) $localtax2=0; // If = '' then = 0 + if (empty($localtax1)) $localtax1 = 0; // If = '' then = 0 + if (empty($localtax2)) $localtax2 = 0; // If = '' then = 0 // Check parameters - if ($buyprice != '' && ! is_numeric($buyprice)) + if ($buyprice != '' && !is_numeric($buyprice)) { } @@ -310,7 +310,7 @@ class ProductFournisseur extends Product if (is_array($logPrices) && count($logPrices) == 0) { $currentPfp = new self($this->db); - $result = $currentPfp->fetch_product_fournisseur_price($this->product_fourn_price_id); + $result = $currentPfp->fetch_product_fournisseur_price($this->product_fourn_price_id); if ($result > 0 && $currentPfp->fourn_price != 0) { $currentPfpUser = new User($this->db); @@ -331,35 +331,35 @@ class ProductFournisseur extends Product } } $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql.= " SET fk_user = " . $user->id." ,"; - $sql.= " ref_fourn = '" . $this->db->escape($ref_fourn) . "',"; - $sql.= " desc_fourn = '" . $this->db->escape($desc_fourn) . "',"; - $sql.= " price = ".$buyprice.","; - $sql.= " quantity = ".$qty.","; - $sql.= " remise_percent = ".$remise_percent.","; - $sql.= " remise = ".$remise.","; - $sql.= " unitprice = ".$unitBuyPrice.","; - $sql.= " fk_availability = ".$availability.","; - $sql.= " multicurrency_price = ".(isset($multicurrency_buyprice)?"'".$this->db->escape(price2num($multicurrency_buyprice))."'":'null').","; - $sql.= " multicurrency_unitprice = ".(isset($multicurrency_unitBuyPrice)?"'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'":'null').","; - $sql.= " multicurrency_tx = ".(isset($multicurrency_tx)?"'".$this->db->escape($multicurrency_tx)."'":'1').","; - $sql.= " fk_multicurrency = ".(isset($fk_multicurrency)?"'".$this->db->escape($fk_multicurrency)."'":'null').","; - $sql.= " multicurrency_code = ".(isset($multicurrency_code)?"'".$this->db->escape($multicurrency_code)."'":'null').","; - $sql.= " entity = ".$conf->entity.","; - $sql.= " tva_tx = ".price2num($tva_tx).","; + $sql .= " SET fk_user = ".$user->id." ,"; + $sql .= " ref_fourn = '".$this->db->escape($ref_fourn)."',"; + $sql .= " desc_fourn = '".$this->db->escape($desc_fourn)."',"; + $sql .= " price = ".$buyprice.","; + $sql .= " quantity = ".$qty.","; + $sql .= " remise_percent = ".$remise_percent.","; + $sql .= " remise = ".$remise.","; + $sql .= " unitprice = ".$unitBuyPrice.","; + $sql .= " fk_availability = ".$availability.","; + $sql .= " multicurrency_price = ".(isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; + $sql .= " multicurrency_unitprice = ".(isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; + $sql .= " multicurrency_tx = ".(isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; + $sql .= " fk_multicurrency = ".(isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; + $sql .= " multicurrency_code = ".(isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; + $sql .= " entity = ".$conf->entity.","; + $sql .= " tva_tx = ".price2num($tva_tx).","; // TODO Add localtax1 and localtax2 //$sql.= " localtax1_tx=".($localtax1>=0?$localtax1:'NULL').","; //$sql.= " localtax2_tx=".($localtax2>=0?$localtax2:'NULL').","; //$sql.= " localtax1_type=".($localtaxtype1!=''?"'".$localtaxtype1."'":"'0'").","; //$sql.= " localtax2_type=".($localtaxtype2!=''?"'".$localtaxtype2."'":"'0'").","; - $sql.= " default_vat_code=".($newdefaultvatcode?"'".$this->db->escape($newdefaultvatcode)."'":"null").","; - $sql.= " info_bits = ".$newnpr.","; - $sql.= " charges = ".$charges.","; // deprecated - $sql.= " delivery_time_days = ".($delivery_time_days != '' ? $delivery_time_days : 'null').","; - $sql.= " supplier_reputation = ".(empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").","; - $sql.= " barcode = ".(empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").","; - $sql.= " fk_barcode_type = ".(empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'"); - $sql.= " WHERE rowid = ".$this->product_fourn_price_id; + $sql .= " default_vat_code=".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").","; + $sql .= " info_bits = ".$newnpr.","; + $sql .= " charges = ".$charges.","; // deprecated + $sql .= " delivery_time_days = ".($delivery_time_days != '' ? $delivery_time_days : 'null').","; + $sql .= " supplier_reputation = ".(empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").","; + $sql .= " barcode = ".(empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").","; + $sql .= " fk_barcode_type = ".(empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'"); + $sql .= " WHERE rowid = ".$this->product_fourn_price_id; // TODO Add price_base_type and price_ttc dol_syslog(get_class($this).'::update_buyprice update knowing id of line = product_fourn_price_id = '.$this->product_fourn_price_id, LOG_DEBUG); @@ -367,10 +367,10 @@ class ProductFournisseur extends Product if ($resql) { // Call trigger - $result=$this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_UPDATE', $user); + $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_UPDATE', $user); if ($result < 0) $error++; // End call triggers - if (! $error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) + if (!$error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) { $result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrency, $multicurrency_code); if ($result < 0) { @@ -390,7 +390,7 @@ class ProductFournisseur extends Product } else { - $this->error=$this->db->error()." sql=".$sql; + $this->error = $this->db->error()." sql=".$sql; $this->db->rollback(); return -2; } @@ -398,57 +398,57 @@ class ProductFournisseur extends Product else { - dol_syslog(get_class($this) . '::update_buyprice without knowing id of line, so we delete from company, quantity and supplier_ref and insert again', LOG_DEBUG); + dol_syslog(get_class($this).'::update_buyprice without knowing id of line, so we delete from company, quantity and supplier_ref and insert again', LOG_DEBUG); // Delete price for this quantity - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "product_fournisseur_price"; - $sql .= " WHERE fk_soc = " . $fourn->id . " AND ref_fourn = '" . $this->db->escape($ref_fourn) . "' AND quantity = " . $qty . " AND entity = " . $conf->entity; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; + $sql .= " WHERE fk_soc = ".$fourn->id." AND ref_fourn = '".$this->db->escape($ref_fourn)."' AND quantity = ".$qty." AND entity = ".$conf->entity; $resql = $this->db->query($sql); if ($resql) { // Add price for this quantity to supplier - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_fournisseur_price("; - $sql.= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price("; + $sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,"; $sql .= "datec, fk_product, fk_soc, ref_fourn, desc_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation, barcode, fk_barcode_type)"; $sql .= " values("; - $sql.= (isset($multicurrency_buyprice)?"'".$this->db->escape(price2num($multicurrency_buyprice))."'":'null').","; - $sql.= (isset($multicurrency_unitBuyPrice)?"'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'":'null').","; - $sql.= (isset($multicurrency_tx)?"'".$this->db->escape($multicurrency_tx)."'":'1').","; - $sql.= (isset($fk_multicurrency)?"'".$this->db->escape($fk_multicurrency)."'":'null').","; - $sql.= (isset($multicurrency_code)?"'".$this->db->escape($multicurrency_code)."'":'null').","; - $sql .= " '" . $this->db->idate($now) . "',"; - $sql .= " " . $this->id . ","; - $sql .= " " . $fourn->id . ","; - $sql .= " '" . $this->db->escape($ref_fourn) . "',"; - $sql .= " '" . $this->db->escape($desc_fourn) . "',"; - $sql .= " " . $user->id . ","; - $sql .= " " . $buyprice . ","; - $sql .= " " . $qty . ","; - $sql .= " " . $remise_percent . ","; - $sql .= " " . $remise . ","; - $sql .= " " . $unitBuyPrice . ","; - $sql .= " " . $tva_tx . ","; - $sql .= " " . $charges . ","; - $sql .= " " . $availability . ","; - $sql .= " ".($newdefaultvatcode?"'".$this->db->escape($newdefaultvatcode)."'":"null").","; - $sql .= " " . $newnpr . ","; - $sql .= $conf->entity . ","; - $sql .= $delivery_time_days . ","; - $sql .= (empty($supplier_reputation) ? 'NULL' : "'" . $this->db->escape($supplier_reputation) . "'") . ","; - $sql .= (empty($barcode) ? 'NULL' : "'" . $this->db->escape($barcode) . "'") . ","; - $sql .= (empty($fk_barcode_type) ? 'NULL' : "'" . $this->db->escape($fk_barcode_type) . "'"); + $sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; + $sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; + $sql .= (isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; + $sql .= (isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; + $sql .= (isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; + $sql .= " '".$this->db->idate($now)."',"; + $sql .= " ".$this->id.","; + $sql .= " ".$fourn->id.","; + $sql .= " '".$this->db->escape($ref_fourn)."',"; + $sql .= " '".$this->db->escape($desc_fourn)."',"; + $sql .= " ".$user->id.","; + $sql .= " ".$buyprice.","; + $sql .= " ".$qty.","; + $sql .= " ".$remise_percent.","; + $sql .= " ".$remise.","; + $sql .= " ".$unitBuyPrice.","; + $sql .= " ".$tva_tx.","; + $sql .= " ".$charges.","; + $sql .= " ".$availability.","; + $sql .= " ".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").","; + $sql .= " ".$newnpr.","; + $sql .= $conf->entity.","; + $sql .= $delivery_time_days.","; + $sql .= (empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").","; + $sql .= (empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").","; + $sql .= (empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'"); $sql .= ")"; $idinserted = 0; $resql = $this->db->query($sql); if ($resql) { - $idinserted = $this->db->last_insert_id(MAIN_DB_PREFIX . "product_fournisseur_price"); + $idinserted = $this->db->last_insert_id(MAIN_DB_PREFIX."product_fournisseur_price"); } else { $error++; } - if (! $error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) { + if (!$error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) { // Add record into log table $result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrenc, $multicurrency_code); if ($result < 0) { @@ -456,7 +456,7 @@ class ProductFournisseur extends Product } } - if (! $error) { + if (!$error) { // Call trigger $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_CREATE', $user); if ($result < 0) @@ -472,14 +472,14 @@ class ProductFournisseur extends Product return -1; } } else { - $this->error = $this->db->lasterror() . " sql=" . $sql; + $this->error = $this->db->lasterror()." sql=".$sql; $this->db->rollback(); return -2; } } else { - $this->error = $this->db->lasterror() . " sql=" . $sql; + $this->error = $this->db->lasterror()." sql=".$sql; $this->db->rollback(); - return - 1; + return -1; } } } @@ -498,12 +498,12 @@ class ProductFournisseur extends Product global $conf; $sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.default_vat_code, pfp.info_bits as fourn_tva_npr, pfp.fk_availability,"; - $sql.= " pfp.fk_soc, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product, pfp.charges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,"; - $sql.= " pfp.supplier_reputation, pfp.fk_user, pfp.datec,"; - $sql.= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,"; - $sql.=" pfp.barcode, pfp.fk_barcode_type"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql.= " WHERE pfp.rowid = ".$rowid; + $sql .= " pfp.fk_soc, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product, pfp.charges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,"; + $sql .= " pfp.supplier_reputation, pfp.fk_user, pfp.datec,"; + $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,"; + $sql .= " pfp.barcode, pfp.fk_barcode_type"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; + $sql .= " WHERE pfp.rowid = ".$rowid; dol_syslog(get_class($this)."::fetch_product_fournisseur_price", LOG_DEBUG); $resql = $this->db->query($sql); @@ -512,16 +512,16 @@ class ProductFournisseur extends Product $obj = $this->db->fetch_object($resql); if ($obj) { - $this->product_fourn_price_id = $rowid; - $this->id = $obj->fk_product; + $this->product_fourn_price_id = $rowid; + $this->id = $obj->fk_product; $this->fk_product = $obj->fk_product; - $this->product_id = $obj->fk_product; // deprecated + $this->product_id = $obj->fk_product; // deprecated $this->fourn_id = $obj->fk_soc; $this->fourn_ref = $obj->ref_fourn; // deprecated $this->ref_supplier = $obj->ref_fourn; $this->desc_supplier = $obj->desc_fourn; - $this->fourn_price = $obj->price; - $this->fourn_charges = $obj->charges; // deprecated + $this->fourn_price = $obj->price; + $this->fourn_charges = $obj->charges; // deprecated $this->fourn_qty = $obj->quantity; $this->fourn_remise_percent = $obj->remise_percent; $this->fourn_remise = $obj->remise; @@ -529,9 +529,9 @@ class ProductFournisseur extends Product $this->fourn_tva_tx = $obj->tva_tx; $this->fourn_tva_npr = $obj->fourn_tva_npr; // Add also localtaxes - $this->fk_availability = $obj->fk_availability; - $this->delivery_time_days = $obj->delivery_time_days; - $this->fk_supplier_price_expression = $obj->fk_supplier_price_expression; + $this->fk_availability = $obj->fk_availability; + $this->delivery_time_days = $obj->delivery_time_days; + $this->fk_supplier_price_expression = $obj->fk_supplier_price_expression; $this->supplier_reputation = $obj->supplier_reputation; $this->default_vat_code = $obj->default_vat_code; $this->user_id = $obj->fk_user; @@ -541,7 +541,7 @@ class ProductFournisseur extends Product $this->fourn_multicurrency_tx = $obj->multicurrency_tx; $this->fourn_multicurrency_id = $obj->fk_multicurrency; $this->fourn_multicurrency_code = $obj->multicurrency_code; - if($conf->barcode->enabled) { + if ($conf->barcode->enabled) { $this->fourn_barcode = $obj->barcode; $this->fourn_fk_barcode_type = $obj->fk_barcode_type; } @@ -552,13 +552,13 @@ class ProductFournisseur extends Product if ($price_result >= 0) { $this->fourn_price = $price_result; //recalculation of unitprice, as probably the price changed... - if ($this->fourn_qty!=0) + if ($this->fourn_qty != 0) { - $this->fourn_unitprice = price2num($this->fourn_price/$this->fourn_qty, 'MU'); + $this->fourn_unitprice = price2num($this->fourn_price / $this->fourn_qty, 'MU'); } else { - $this->fourn_unitprice=""; + $this->fourn_unitprice = ""; } } } @@ -572,7 +572,7 @@ class ProductFournisseur extends Product } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -595,18 +595,18 @@ class ProductFournisseur extends Product global $conf; $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; - $sql.= " pfp.rowid as product_fourn_pri_id, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,"; - $sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation,"; - $sql.= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms,"; - $sql.= " pfp.barcode, pfp.fk_barcode_type"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")"; - $sql.= " AND pfp.fk_soc = s.rowid"; - $sql.= " AND s.status=1"; // only enabled company selected - $sql.= " AND pfp.fk_product = ".$prodid; - if (empty($sortfield)) $sql.= " ORDER BY s.nom, pfp.quantity, pfp.price"; - else $sql.= $this->db->order($sortfield, $sortorder); - $sql.=$this->db->plimit($limit, $offset); + $sql .= " pfp.rowid as product_fourn_pri_id, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,"; + $sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation,"; + $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms,"; + $sql .= " pfp.barcode, pfp.fk_barcode_type"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."societe as s"; + $sql .= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")"; + $sql .= " AND pfp.fk_soc = s.rowid"; + $sql .= " AND s.status=1"; // only enabled company selected + $sql .= " AND pfp.fk_product = ".$prodid; + if (empty($sortfield)) $sql .= " ORDER BY s.nom, pfp.quantity, pfp.price"; + else $sql .= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->plimit($limit, $offset); dol_syslog(get_class($this)."::list_product_fournisseur_price", LOG_DEBUG); $resql = $this->db->query($sql); @@ -619,26 +619,26 @@ class ProductFournisseur extends Product //define base attribute $prodfourn = new ProductFournisseur($this->db); - $prodfourn->product_fourn_price_id = $record["product_fourn_pri_id"]; - $prodfourn->product_fourn_id = $record["product_fourn_id"]; - $prodfourn->fourn_ref = $record["ref_fourn"]; + $prodfourn->product_fourn_price_id = $record["product_fourn_pri_id"]; + $prodfourn->product_fourn_id = $record["product_fourn_id"]; + $prodfourn->fourn_ref = $record["ref_fourn"]; $prodfourn->ref_supplier = $record["ref_fourn"]; - $prodfourn->desc_supplier = $record["desc_fourn"]; + $prodfourn->desc_supplier = $record["desc_fourn"]; $prodfourn->fourn_price = $record["price"]; - $prodfourn->fourn_qty = $record["quantity"]; - $prodfourn->fourn_remise_percent = $record["remise_percent"]; - $prodfourn->fourn_remise = $record["remise"]; - $prodfourn->fourn_unitprice = $record["unitprice"]; - $prodfourn->fourn_charges = $record["charges"]; // deprecated - $prodfourn->fourn_tva_tx = $record["tva_tx"]; + $prodfourn->fourn_qty = $record["quantity"]; + $prodfourn->fourn_remise_percent = $record["remise_percent"]; + $prodfourn->fourn_remise = $record["remise"]; + $prodfourn->fourn_unitprice = $record["unitprice"]; + $prodfourn->fourn_charges = $record["charges"]; // deprecated + $prodfourn->fourn_tva_tx = $record["tva_tx"]; $prodfourn->fourn_id = $record["fourn_id"]; - $prodfourn->fourn_name = $record["supplier_name"]; + $prodfourn->fourn_name = $record["supplier_name"]; $prodfourn->fk_availability = $record["fk_availability"]; $prodfourn->delivery_time_days = $record["delivery_time_days"]; $prodfourn->id = $prodid; $prodfourn->fourn_tva_npr = $record["info_bits"]; - $prodfourn->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; - $prodfourn->supplier_reputation = $record["supplier_reputation"]; + $prodfourn->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; + $prodfourn->supplier_reputation = $record["supplier_reputation"]; $prodfourn->fourn_date_creation = $this->db->jdate($record['datec']); $prodfourn->fourn_date_modification = $this->db->jdate($record['tms']); @@ -648,9 +648,9 @@ class ProductFournisseur extends Product $prodfourn->fourn_multicurrency_id = $record["fk_multicurrency"]; $prodfourn->fourn_multicurrency_code = $record["multicurrency_code"]; - if($conf->barcode->enabled){ - $prodfourn->barcode = $record["barcode"]; - $prodfourn->fk_barcode_type = $record["fk_barcode_type"]; + if ($conf->barcode->enabled) { + $prodfourn->barcode = $record["barcode"]; + $prodfourn->fk_barcode_type = $record["fk_barcode_type"]; } if (!empty($conf->dynamicprices->enabled) && !empty($prodfourn->fk_supplier_price_expression)) { @@ -664,17 +664,17 @@ class ProductFournisseur extends Product if (!isset($prodfourn->fourn_unitprice)) { - if ($prodfourn->fourn_qty!=0) + if ($prodfourn->fourn_qty != 0) { - $prodfourn->fourn_unitprice = price2num($prodfourn->fourn_price/$prodfourn->fourn_qty, 'MU'); + $prodfourn->fourn_unitprice = price2num($prodfourn->fourn_price / $prodfourn->fourn_qty, 'MU'); } else { - $prodfourn->fourn_unitprice=""; + $prodfourn->fourn_unitprice = ""; } } - $retarray[]=$prodfourn; + $retarray[] = $prodfourn; } $this->db->free($resql); @@ -682,7 +682,7 @@ class ProductFournisseur extends Product } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -717,7 +717,7 @@ class ProductFournisseur extends Product $this->fourn_unitprice = ''; $this->fourn_id = ''; $this->fourn_name = ''; - $this->delivery_time_days = ''; + $this->delivery_time_days = ''; $this->id = ''; $this->fourn_multicurrency_price = ''; @@ -727,18 +727,18 @@ class ProductFournisseur extends Product $this->fourn_multicurrency_code = ''; $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; - $sql.= " pfp.rowid as product_fourn_price_id, pfp.ref_fourn,"; - $sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges,"; - $sql.= " pfp.remise, pfp.remise_percent, pfp.fk_supplier_price_expression, pfp.delivery_time_days"; - $sql.= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql.= " WHERE s.entity IN (".getEntity('societe').")"; - $sql.= " AND pfp.entity = ".$conf->entity; // only current entity - $sql.= " AND pfp.fk_product = ".$prodid; - $sql.= " AND pfp.fk_soc = s.rowid"; - $sql.= " AND s.status = 1"; // only enabled society - if ($qty > 0) $sql.= " AND pfp.quantity <= ".$qty; - if ($socid > 0) $sql.= ' AND pfp.fk_soc = '.$socid; + $sql .= " pfp.rowid as product_fourn_price_id, pfp.ref_fourn,"; + $sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges,"; + $sql .= " pfp.remise, pfp.remise_percent, pfp.fk_supplier_price_expression, pfp.delivery_time_days"; + $sql .= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; + $sql .= " WHERE s.entity IN (".getEntity('societe').")"; + $sql .= " AND pfp.entity = ".$conf->entity; // only current entity + $sql .= " AND pfp.fk_product = ".$prodid; + $sql .= " AND pfp.fk_soc = s.rowid"; + $sql .= " AND s.status = 1"; // only enabled society + if ($qty > 0) $sql .= " AND pfp.quantity <= ".$qty; + if ($socid > 0) $sql .= ' AND pfp.fk_soc = '.$socid; dol_syslog(get_class($this)."::find_min_price_product_fournisseur", LOG_DEBUG); @@ -750,7 +750,7 @@ class ProductFournisseur extends Product //Store each record to array for later search of min while ($record = $this->db->fetch_array($resql)) { - $record_array[]=$record; + $record_array[] = $record; } if (count($record_array) == 0) @@ -761,7 +761,7 @@ class ProductFournisseur extends Product else { $min = -1; - foreach($record_array as $record) + foreach ($record_array as $record) { $fourn_price = $record["price"]; // discount calculated buy price @@ -779,7 +779,7 @@ class ProductFournisseur extends Product $fourn_price = price2num($price_result, 'MU'); if ($record["quantity"] != 0) { - $fourn_unitprice = price2num($fourn_price/$record["quantity"], 'MU'); + $fourn_unitprice = price2num($fourn_price / $record["quantity"], 'MU'); } else { @@ -791,19 +791,19 @@ class ProductFournisseur extends Product { $this->product_fourn_price_id = $record["product_fourn_price_id"]; $this->ref_supplier = $record["ref_fourn"]; - $this->ref_fourn = $record["ref_fourn"]; // deprecated - $this->fourn_ref = $record["ref_fourn"]; // deprecated + $this->ref_fourn = $record["ref_fourn"]; // deprecated + $this->fourn_ref = $record["ref_fourn"]; // deprecated $this->fourn_price = $fourn_price; $this->fourn_qty = $record["quantity"]; $this->fourn_remise_percent = $record["remise_percent"]; $this->fourn_remise = $record["remise"]; $this->fourn_unitprice = $record["unitprice"]; - $this->fourn_charges = $record["charges"]; // deprecated + $this->fourn_charges = $record["charges"]; // deprecated $this->fourn_tva_tx = $record["tva_tx"]; $this->fourn_id = $record["fourn_id"]; $this->fourn_name = $record["supplier_name"]; - $this->delivery_time_days = $record["delivery_time_days"]; - $this->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; + $this->delivery_time_days = $record["delivery_time_days"]; + $this->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; $this->id = $prodid; $this->fourn_multicurrency_price = $record["multicurrency_price"]; $this->fourn_multicurrency_unitprice = $record["multicurrency_unitprice"]; @@ -820,7 +820,7 @@ class ProductFournisseur extends Product } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -840,8 +840,8 @@ class ProductFournisseur extends Product $expression_id = $expression_id != 0 ? $expression_id : 'NULL'; $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql.= " SET fk_supplier_price_expression = ".$expression_id; - $sql.= " WHERE rowid = ".$this->product_fourn_price_id; + $sql .= " SET fk_supplier_price_expression = ".$expression_id; + $sql .= " WHERE rowid = ".$this->product_fourn_price_id; dol_syslog(get_class($this)."::setSupplierPriceExpression", LOG_DEBUG); @@ -853,7 +853,7 @@ class ProductFournisseur extends Product } else { - $this->error=$this->db->error()." sql=".$sql; + $this->error = $this->db->error()." sql=".$sql; $this->db->rollback(); return -1; } @@ -898,19 +898,19 @@ class ProductFournisseur extends Product $langs->load("suppliers"); if (count($productFournList) > 0) { $out .= ''; - $out .= ''; - $out .= ''; + $out .= ''; + $out .= ''; $out .= ''; $out .= ''; foreach ($productFournList as $productFourn) { - $out.= ''; - $out.= ''; - $out.= ''; - $out.= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; } $out .= '
'.($showunitprice?$langs->trans("Price").' '.$langs->trans("HT"):'').''.($showunitprice?$langs->trans("QtyMin"):'').'
'.($showunitprice ? $langs->trans("Price").' '.$langs->trans("HT") : '').''.($showunitprice ? $langs->trans("QtyMin") : '').''.$langs->trans("Supplier").''.$langs->trans("SupplierRef").'
'.($showunitprice?price($productFourn->fourn_unitprice * (1 -$productFourn->fourn_remise_percent/100) - $productFourn->fourn_remise):'').''.($showunitprice?$productFourn->fourn_qty:'').''.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).''.$productFourn->fourn_ref.'
'.($showunitprice ?price($productFourn->fourn_unitprice * (1 - $productFourn->fourn_remise_percent / 100) - $productFourn->fourn_remise) : '').''.($showunitprice ? $productFourn->fourn_qty : '').''.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).''.$productFourn->fourn_ref.'
'; } else { - $out=($showunitprice?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent/100) + $this->fourn_remise).' '.$langs->trans("HT").'   (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':''); + $out = ($showunitprice ?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent / 100) + $this->fourn_remise).' '.$langs->trans("HT").'   (' : '').($showsuptitle ? $langs->trans("Supplier").': ' : '').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice ? ')' : ''); } return $out; } @@ -947,18 +947,18 @@ class ProductFournisseur extends Product global $conf; $sql = "SELECT"; - $sql.= " pfpl.rowid, pfp.ref_fourn as supplier_ref, pfpl.datec, u.lastname,"; - $sql.= " pfpl.price, pfpl.quantity"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price_log as pfpl"; - $sql.= ", ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql.= ", ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE pfp.entity IN (".getEntity('productprice').")"; - $sql.= " AND pfpl.fk_user = u.rowid"; - $sql.= " AND pfp.rowid = pfpl.fk_product_fournisseur"; - $sql.= " AND pfpl.fk_product_fournisseur = ".$product_fourn_price_id; - if (empty($sortfield)) $sql.= " ORDER BY pfpl.datec"; - else $sql.= $this->db->order($sortfield, $sortorder); - $sql.=$this->db->plimit($limit, $offset); + $sql .= " pfpl.rowid, pfp.ref_fourn as supplier_ref, pfpl.datec, u.lastname,"; + $sql .= " pfpl.price, pfpl.quantity"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price_log as pfpl"; + $sql .= ", ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; + $sql .= ", ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE pfp.entity IN (".getEntity('productprice').")"; + $sql .= " AND pfpl.fk_user = u.rowid"; + $sql .= " AND pfp.rowid = pfpl.fk_product_fournisseur"; + $sql .= " AND pfpl.fk_product_fournisseur = ".$product_fourn_price_id; + if (empty($sortfield)) $sql .= " ORDER BY pfpl.datec"; + else $sql .= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->plimit($limit, $offset); dol_syslog(get_class($this)."::list_product_fournisseur_price_log", LOG_DEBUG); $resql = $this->db->query($sql); @@ -968,7 +968,7 @@ class ProductFournisseur extends Product while ($record = $this->db->fetch_array($resql)) { - $retarray[]=$record; + $retarray[] = $record; } $this->db->free($resql); @@ -976,7 +976,7 @@ class ProductFournisseur extends Product } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -1001,10 +1001,10 @@ class ProductFournisseur extends Product //$out .= ''.$langs->trans("QtyMin").''; $out .= ''.$langs->trans("User").''; foreach ($productFournLogList as $productFournLog) { - $out.= ''.dol_print_date($this->db->jdate($productFournLog['datec']), 'dayhour', 'tzuser').''; - $out.= ''.price($productFournLog['price']).''; + $out .= ''.dol_print_date($this->db->jdate($productFournLog['datec']), 'dayhour', 'tzuser').''; + $out .= ''.price($productFournLog['price']).''; //$out.= ''.$productFournLog['quantity'].''; - $out.= ''.$productFournLog['lastname'].''; + $out .= ''.$productFournLog['lastname'].''; } $out .= ''; } @@ -1027,19 +1027,19 @@ class ProductFournisseur extends Product { global $db, $conf, $langs; - 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 = ''; - $label = '' . $langs->trans("SupplierRef") . ''; - $label.= '
'; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref_supplier; + $label = ''.$langs->trans("SupplierRef").''; + $label .= '
'; + $label .= ''.$langs->trans('Ref').': '.$this->ref_supplier; $logPrices = $this->listProductFournisseurPriceLog($this->product_fourn_price_id, 'pfpl.datec', 'DESC'); // set sort order here if (is_array($logPrices) && count($logPrices) > 0) { - $label.= '
'; - $label.= '' . $langs->trans("History") . ''; - $label.= $this->displayPriceProductFournisseurLog($logPrices); + $label .= '
'; + $label .= ''.$langs->trans("History").''; + $label .= $this->displayPriceProductFournisseurLog($logPrices); } $url = dol_buildpath('/product/fournisseurs.php', 1).'?id='.$this->id.'&action=add_price&socid='.$this->fourn_id.'&rowid='.$this->product_fourn_price_id; @@ -1047,31 +1047,31 @@ class ProductFournisseur extends Product 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'; } - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("SupplierRef"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("SupplierRef"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $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.= $this->fourn_ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->fourn_ref; $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); @@ -1096,24 +1096,24 @@ class ProductFournisseur extends Product private function logPrice($user, $datec, $buyprice, $qty, $multicurrency_buyprice = null, $multicurrency_unitBuyPrice = null, $multicurrency_tx = null, $fk_multicurrency = null, $multicurrency_code = null) { // Add record into log table - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_fournisseur_price_log("; - $sql.= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_log("; + $sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,"; $sql .= "datec, fk_product_fournisseur,fk_user,price,quantity)"; $sql .= "values("; - $sql.= (isset($multicurrency_buyprice)?"'".$this->db->escape(price2num($multicurrency_buyprice))."'":'null').","; - $sql.= (isset($multicurrency_unitBuyPrice)?"'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'":'null').","; - $sql.= (isset($multicurrency_tx)?"'".$this->db->escape($multicurrency_tx)."'":'1').","; - $sql.= (isset($fk_multicurrency)?"'".$this->db->escape($fk_multicurrency)."'":'null').","; - $sql.= (isset($multicurrency_code)?"'".$this->db->escape($multicurrency_code)."'":'null').","; - $sql .= "'" . $this->db->idate($datec) . "',"; - $sql .= " " . $this->product_fourn_price_id . ","; - $sql .= " " . $user->id . ","; - $sql .= " " . price2num($buyprice) . ","; - $sql .= " " . $qty; + $sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').","; + $sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').","; + $sql .= (isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').","; + $sql .= (isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').","; + $sql .= (isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').","; + $sql .= "'".$this->db->idate($datec)."',"; + $sql .= " ".$this->product_fourn_price_id.","; + $sql .= " ".$user->id.","; + $sql .= " ".price2num($buyprice).","; + $sql .= " ".$qty; $sql .= ")"; $resql = $this->db->query($sql); - if (! $resql) { + if (!$resql) { return -1; } else { return 1; diff --git a/htdocs/fourn/index.php b/htdocs/fourn/index.php index aeb945bc220..207133d9cfa 100644 --- a/htdocs/fourn/index.php +++ b/htdocs/fourn/index.php @@ -40,9 +40,9 @@ $result = restrictedArea($user, 'societe', $socid, ''); * View */ -$commandestatic=new CommandeFournisseur($db); -$facturestatic=new FactureFournisseur($db); -$companystatic=new Societe($db); +$commandestatic = new CommandeFournisseur($db); +$facturestatic = new FactureFournisseur($db); +$companystatic = new Societe($db); llxHeader("", $langs->trans("SuppliersArea")); @@ -56,13 +56,13 @@ print '
'; // Orders $sql = "SELECT count(cf.rowid), cf.fk_statut"; -$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf,"; -$sql.= " ".MAIN_DB_PREFIX."societe as s"; +$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf,"; +$sql .= " ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; -$sql.= " WHERE cf.fk_soc = s.rowid "; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = " .$user->id; -$sql.= " AND cf.entity = ".$conf->entity; -$sql.= " GROUP BY cf.fk_statut"; +$sql .= " WHERE cf.fk_soc = s.rowid "; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id; +$sql .= " AND cf.entity = ".$conf->entity; +$sql .= " GROUP BY cf.fk_statut"; $resql = $db->query($sql); if ($resql) @@ -97,19 +97,19 @@ else // Draft orders -if (! empty($conf->fournisseur->enabled)) +if (!empty($conf->fournisseur->enabled)) { $langs->load("orders"); $sql = "SELECT cf.rowid, cf.ref, cf.total_ttc,"; - $sql.= " s.nom as name, s.rowid as socid"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= " s.nom as name, s.rowid as socid"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; - $sql.= " WHERE cf.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = " .$user->id; - $sql.= " AND cf.entity = ".$conf->entity; - $sql.= " AND cf.fk_statut = 0"; + $sql .= " WHERE cf.fk_soc = s.rowid"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id; + $sql .= " AND cf.entity = ".$conf->entity; + $sql .= " AND cf.fk_statut = 0"; if ($socid) $sql .= " AND cf.fk_soc = ".$socid; $resql = $db->query($sql); @@ -129,21 +129,21 @@ if (! empty($conf->fournisseur->enabled)) $obj = $db->fetch_object($resql); print ''; - $commandestatic->id=$obj->rowid; - $commandestatic->ref=$obj->ref; + $commandestatic->id = $obj->rowid; + $commandestatic->ref = $obj->ref; print $commandestatic->getNomUrl(1, '', 16); print ''; print ''; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=0; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = 0; print $companystatic->getNomUrl(1, '', 16); print ''; print ''.price($obj->total_ttc).''; $i++; $total += $obj->total_ttc; } - if ($total>0) + if ($total > 0) { print ''.$langs->trans("Total").''.price($total).""; } @@ -154,22 +154,22 @@ if (! empty($conf->fournisseur->enabled)) } // Draft invoices -if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) +if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) { $sql = "SELECT ff.ref_supplier, ff.rowid, ff.total_ttc, ff.type"; - $sql.= ", s.nom as name, s.rowid as socid"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as ff"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", s.nom as name, s.rowid as socid"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as ff"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; - $sql.= " WHERE s.rowid = ff.fk_soc"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = " .$user->id; - $sql.= " AND ff.entity = ".$conf->entity; - $sql.= " AND ff.fk_statut = 0"; + $sql .= " WHERE s.rowid = ff.fk_soc"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id; + $sql .= " AND ff.entity = ".$conf->entity; + $sql .= " AND ff.fk_statut = 0"; if ($socid) $sql .= " AND f.fk_soc = ".$socid; $resql = $db->query($sql); - if ( $resql ) + if ($resql) { $num = $db->num_rows($resql); if ($num) @@ -185,20 +185,20 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- $obj = $db->fetch_object($resql); print ''; - $facturestatic->ref=$obj->ref; - $facturestatic->id=$obj->rowid; - $facturestatic->type=$obj->type; + $facturestatic->ref = $obj->ref; + $facturestatic->id = $obj->rowid; + $facturestatic->type = $obj->type; print $facturestatic->getNomUrl(1, ''); print ''; print ''; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->name; - $companystatic->client=0; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->client = 0; print $companystatic->getNomUrl(1, '', 16); print ''; print ''.price($obj->total_ttc).''; print ''; - $tot_ttc+=$obj->total_ttc; + $tot_ttc += $obj->total_ttc; $i++; } @@ -225,18 +225,18 @@ print '
'; /* * List last modified supliers */ -$max=10; +$max = 10; $sql = "SELECT s.rowid as socid, s.nom as name, s.town, s.datec, s.tms, s.prefix_comm, s.code_fournisseur, s.code_compta_fournisseur"; -$sql.= ", st.libelle as stcomm"; -$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; -$sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st"; +$sql .= ", st.libelle as stcomm"; +$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; +$sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= " WHERE s.fk_stcomm = st.id"; -$sql.= " AND s.fournisseur = 1"; -$sql.= " AND s.entity IN (".getEntity('societe').")"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; +$sql .= " WHERE s.fk_stcomm = st.id"; +$sql .= " AND s.fournisseur = 1"; +$sql .= " AND s.entity IN (".getEntity('societe').")"; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($socid) $sql .= " AND s.rowid = ".$socid; -$sql.= " ORDER BY s.tms DESC"; +$sql .= " ORDER BY s.tms DESC"; $sql .= $db->plimit($max, 0); $resql = $db->query($sql); @@ -252,7 +252,7 @@ if ($resql) print ''.$langs->trans("DateModification")."\n"; print "\n"; - while ($obj = $db->fetch_object($resql) ) + while ($obj = $db->fetch_object($resql)) { print ''; print ''.img_object($langs->trans("ShowSupplier"), "company").''; @@ -275,7 +275,7 @@ else * List of suppliers categories */ $companystatic->LoadSupplierCateg(); -$categstatic=new Categorie($db); +$categstatic = new Categorie($db); if (count($companystatic->SupplierCategories)) { @@ -290,9 +290,9 @@ if (count($companystatic->SupplierCategories)) { print ''."\n"; print ''; - $categstatic->id=$rowid; - $categstatic->ref=$label; - $categstatic->label=$label; + $categstatic->id = $rowid; + $categstatic->ref = $label; + $categstatic->label = $label; print $categstatic->getNomUrl(1); print ''."\n"; // TODO this page not exist diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index cac93404a85..c5a88028586 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -911,7 +911,7 @@ if ((empty($id) && empty($ref)) || $action == 'add' || $action == 'request' || $ // Si il y a une erreur if (GETPOST('error')) { - switch(GETPOST('error')) { + switch (GETPOST('error')) { case 'datefin' : $errors[] = $langs->trans('ErrorEndDateCP'); break; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 37d38ea69eb..c44c588b335 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -25,7 +25,7 @@ * \ingroup holiday * \brief Class file of the module paid holiday. */ -require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; /** @@ -36,12 +36,12 @@ class Holiday extends CommonObject /** * @var string ID to identify managed object */ - public $element='holiday'; + public $element = 'holiday'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='holiday'; + public $table_element = 'holiday'; /** * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe @@ -70,47 +70,47 @@ class Holiday extends CommonObject */ public $fk_user; - public $date_create=''; + public $date_create = ''; /** * @var string description */ public $description; - public $date_debut=''; // Date start in PHP server TZ - public $date_fin=''; // Date end in PHP server TZ - public $date_debut_gmt=''; // Date start in GMT - public $date_fin_gmt=''; // Date end in GMT - public $halfday=''; // 0:Full days, 2:Start afternoon end morning, -1:Start afternoon end afternoon, 1:Start morning end morning - public $statut=''; // 1=draft, 2=validated, 3=approved + public $date_debut = ''; // Date start in PHP server TZ + public $date_fin = ''; // Date end in PHP server TZ + public $date_debut_gmt = ''; // Date start in GMT + public $date_fin_gmt = ''; // Date end in GMT + public $halfday = ''; // 0:Full days, 2:Start afternoon end morning, -1:Start afternoon end afternoon, 1:Start morning end morning + public $statut = ''; // 1=draft, 2=validated, 3=approved /** * @var int ID */ public $fk_validator; - public $date_valid=''; + public $date_valid = ''; /** * @var int ID */ public $fk_user_valid; - public $date_refuse=''; + public $date_refuse = ''; /** * @var int ID */ public $fk_user_refuse; - public $date_cancel=''; + public $date_cancel = ''; /** * @var int ID */ public $fk_user_cancel; - public $detail_refuse=''; + public $detail_refuse = ''; /** * @var int ID @@ -175,21 +175,21 @@ class Holiday extends CommonObject $conf->global->HOLIDAY_ADDON = 'mod_holiday_madonna'; } - if (! empty($conf->global->HOLIDAY_ADDON)) + if (!empty($conf->global->HOLIDAY_ADDON)) { - $mybool=false; + $mybool = false; $file = $conf->global->HOLIDAY_ADDON.".php"; $classname = $conf->global->HOLIDAY_ADDON; // Include file with class - $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/holiday/"); // Load file with numbering class (if found) - $mybool|=@include_once $dir.$file; + $mybool |= @include_once $dir.$file; } if ($mybool === false) @@ -207,7 +207,7 @@ class Holiday extends CommonObject } else { - $this->error=$obj->error; + $this->error = $obj->error; //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error); return ""; } @@ -256,58 +256,58 @@ class Holiday extends CommonObject public function create($user, $notrigger = 0) { global $conf; - $error=0; + $error = 0; - $now=dol_now(); + $now = dol_now(); // Check parameters - if (empty($this->fk_user) || ! is_numeric($this->fk_user) || $this->fk_user < 0) { $this->error="ErrorBadParameterFkUser"; return -1; } - if (empty($this->fk_validator) || ! is_numeric($this->fk_validator) || $this->fk_validator < 0) { $this->error="ErrorBadParameterFkValidator"; return -1; } - if (empty($this->fk_type) || ! is_numeric($this->fk_type) || $this->fk_type < 0) { $this->error="ErrorBadParameterFkType"; return -1; } + if (empty($this->fk_user) || !is_numeric($this->fk_user) || $this->fk_user < 0) { $this->error = "ErrorBadParameterFkUser"; return -1; } + if (empty($this->fk_validator) || !is_numeric($this->fk_validator) || $this->fk_validator < 0) { $this->error = "ErrorBadParameterFkValidator"; return -1; } + if (empty($this->fk_type) || !is_numeric($this->fk_type) || $this->fk_type < 0) { $this->error = "ErrorBadParameterFkType"; return -1; } // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday("; - $sql.= "fk_user,"; - $sql.= "date_create,"; - $sql.= "description,"; - $sql.= "date_debut,"; - $sql.= "date_fin,"; - $sql.= "halfday,"; - $sql.= "statut,"; - $sql.= "fk_validator,"; - $sql.= "fk_type,"; - $sql.= "fk_user_create,"; - $sql.= "entity"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->escape($this->fk_user)."',"; - $sql.= " '".$this->db->idate($now)."',"; - $sql.= " '".$this->db->escape($this->description)."',"; - $sql.= " '".$this->db->idate($this->date_debut)."',"; - $sql.= " '".$this->db->idate($this->date_fin)."',"; - $sql.= " ".$this->halfday.","; - $sql.= " '1',"; - $sql.= " '".$this->db->escape($this->fk_validator)."',"; - $sql.= " ".$this->fk_type.","; - $sql.= " ".$user->id.","; - $sql.= " ".$conf->entity; - $sql.= ")"; + $sql .= "fk_user,"; + $sql .= "date_create,"; + $sql .= "description,"; + $sql .= "date_debut,"; + $sql .= "date_fin,"; + $sql .= "halfday,"; + $sql .= "statut,"; + $sql .= "fk_validator,"; + $sql .= "fk_type,"; + $sql .= "fk_user_create,"; + $sql .= "entity"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->escape($this->fk_user)."',"; + $sql .= " '".$this->db->idate($now)."',"; + $sql .= " '".$this->db->escape($this->description)."',"; + $sql .= " '".$this->db->idate($this->date_debut)."',"; + $sql .= " '".$this->db->idate($this->date_fin)."',"; + $sql .= " ".$this->halfday.","; + $sql .= " '1',"; + $sql .= " '".$this->db->escape($this->fk_validator)."',"; + $sql .= " ".$this->fk_type.","; + $sql .= " ".$user->id.","; + $sql .= " ".$conf->entity; + $sql .= ")"; $this->db->begin(); dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) { - $error++; $this->errors[]="Error ".$this->db->lasterror(); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday"); - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('HOLIDAY_CREATE', $user); + $result = $this->call_trigger('HOLIDAY_CREATE', $user); if ($result < 0) { $error++; } // End call triggers } @@ -316,13 +316,13 @@ class Holiday extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::create ".$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 { @@ -344,34 +344,34 @@ class Holiday extends CommonObject global $langs; $sql = "SELECT"; - $sql.= " cp.rowid,"; - $sql.= " cp.ref,"; - $sql.= " cp.fk_user,"; - $sql.= " cp.date_create,"; - $sql.= " cp.description,"; - $sql.= " cp.date_debut,"; - $sql.= " cp.date_fin,"; - $sql.= " cp.halfday,"; - $sql.= " cp.statut,"; - $sql.= " cp.fk_validator,"; - $sql.= " cp.date_valid,"; - $sql.= " cp.fk_user_valid,"; - $sql.= " cp.date_refuse,"; - $sql.= " cp.fk_user_refuse,"; - $sql.= " cp.date_cancel,"; - $sql.= " cp.fk_user_cancel,"; - $sql.= " cp.detail_refuse,"; - $sql.= " cp.note_private,"; - $sql.= " cp.note_public,"; - $sql.= " cp.fk_user_create,"; - $sql.= " cp.fk_type,"; - $sql.= " cp.entity"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp"; - if ($id > 0) $sql.= " WHERE cp.rowid = ".$id; - else $sql.=" WHERE cp.ref = '".$this->db->escape($ref)."'"; + $sql .= " cp.rowid,"; + $sql .= " cp.ref,"; + $sql .= " cp.fk_user,"; + $sql .= " cp.date_create,"; + $sql .= " cp.description,"; + $sql .= " cp.date_debut,"; + $sql .= " cp.date_fin,"; + $sql .= " cp.halfday,"; + $sql .= " cp.statut,"; + $sql .= " cp.fk_validator,"; + $sql .= " cp.date_valid,"; + $sql .= " cp.fk_user_valid,"; + $sql .= " cp.date_refuse,"; + $sql .= " cp.fk_user_refuse,"; + $sql .= " cp.date_cancel,"; + $sql .= " cp.fk_user_cancel,"; + $sql .= " cp.detail_refuse,"; + $sql .= " cp.note_private,"; + $sql .= " cp.note_public,"; + $sql .= " cp.fk_user_create,"; + $sql .= " cp.fk_type,"; + $sql .= " cp.entity"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday as cp"; + if ($id > 0) $sql .= " WHERE cp.rowid = ".$id; + else $sql .= " WHERE cp.ref = '".$this->db->escape($ref)."'"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) @@ -379,7 +379,7 @@ class Holiday extends CommonObject $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; - $this->ref = ($obj->ref?$obj->ref:$obj->rowid); + $this->ref = ($obj->ref ? $obj->ref : $obj->rowid); $this->fk_user = $obj->fk_user; $this->date_create = $this->db->jdate($obj->date_create); $this->description = $obj->description; @@ -411,7 +411,7 @@ class Holiday extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -429,55 +429,55 @@ class Holiday extends CommonObject global $langs, $conf; $sql = "SELECT"; - $sql.= " cp.rowid,"; - $sql.= " cp.ref,"; + $sql .= " cp.rowid,"; + $sql .= " cp.ref,"; - $sql.= " cp.fk_user,"; - $sql.= " cp.fk_type,"; - $sql.= " cp.date_create,"; - $sql.= " cp.description,"; - $sql.= " cp.date_debut,"; - $sql.= " cp.date_fin,"; - $sql.= " cp.halfday,"; - $sql.= " cp.statut,"; - $sql.= " cp.fk_validator,"; - $sql.= " cp.date_valid,"; - $sql.= " cp.fk_user_valid,"; - $sql.= " cp.date_refuse,"; - $sql.= " cp.fk_user_refuse,"; - $sql.= " cp.date_cancel,"; - $sql.= " cp.fk_user_cancel,"; - $sql.= " cp.detail_refuse,"; + $sql .= " cp.fk_user,"; + $sql .= " cp.fk_type,"; + $sql .= " cp.date_create,"; + $sql .= " cp.description,"; + $sql .= " cp.date_debut,"; + $sql .= " cp.date_fin,"; + $sql .= " cp.halfday,"; + $sql .= " cp.statut,"; + $sql .= " cp.fk_validator,"; + $sql .= " cp.date_valid,"; + $sql .= " cp.fk_user_valid,"; + $sql .= " cp.date_refuse,"; + $sql .= " cp.fk_user_refuse,"; + $sql .= " cp.date_cancel,"; + $sql .= " cp.fk_user_cancel,"; + $sql .= " cp.detail_refuse,"; - $sql.= " uu.lastname as user_lastname,"; - $sql.= " uu.firstname as user_firstname,"; - $sql.= " uu.login as user_login,"; - $sql.= " uu.statut as user_statut,"; - $sql.= " uu.photo as user_photo,"; + $sql .= " uu.lastname as user_lastname,"; + $sql .= " uu.firstname as user_firstname,"; + $sql .= " uu.login as user_login,"; + $sql .= " uu.statut as user_statut,"; + $sql .= " uu.photo as user_photo,"; - $sql.= " ua.lastname as validator_lastname,"; - $sql.= " ua.firstname as validator_firstname,"; - $sql.= " ua.login as validator_login,"; - $sql.= " ua.statut as validator_statut,"; - $sql.= " ua.photo as validator_photo"; + $sql .= " ua.lastname as validator_lastname,"; + $sql .= " ua.firstname as validator_firstname,"; + $sql .= " ua.login as validator_login,"; + $sql .= " ua.statut as validator_statut,"; + $sql .= " ua.photo as validator_photo"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp, ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua"; - $sql.= " WHERE cp.entity IN (".getEntity('holiday').")"; - $sql.= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid"; // Hack pour la recherche sur le tableau - $sql.= " AND cp.fk_user IN (".$user_id.")"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday as cp, ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua"; + $sql .= " WHERE cp.entity IN (".getEntity('holiday').")"; + $sql .= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid"; // Hack pour la recherche sur le tableau + $sql .= " AND cp.fk_user IN (".$user_id.")"; // Selection filter - if(!empty($filter)) { - $sql.= $filter; + if (!empty($filter)) { + $sql .= $filter; } // Order of display of the result - if(!empty($order)) { - $sql.= $order; + if (!empty($order)) { + $sql .= $order; } dol_syslog(get_class($this)."::fetchByUser", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); // If no SQL error if ($resql) { @@ -486,16 +486,16 @@ class Holiday extends CommonObject $num = $this->db->num_rows($resql); // If no registration - if(!$num) { + if (!$num) { return 2; } // List the records and add them to the table - while($i < $num) { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $tab_result[$i]['rowid'] = $obj->rowid; - $tab_result[$i]['ref'] = ($obj->ref?$obj->ref:$obj->rowid); + $tab_result[$i]['ref'] = ($obj->ref ? $obj->ref : $obj->rowid); $tab_result[$i]['fk_user'] = $obj->fk_user; $tab_result[$i]['fk_type'] = $obj->fk_type; @@ -538,7 +538,7 @@ class Holiday extends CommonObject else { // SQL Error - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -555,55 +555,55 @@ class Holiday extends CommonObject global $langs; $sql = "SELECT"; - $sql.= " cp.rowid,"; - $sql.= " cp.ref,"; + $sql .= " cp.rowid,"; + $sql .= " cp.ref,"; - $sql.= " cp.fk_user,"; - $sql.= " cp.fk_type,"; - $sql.= " cp.date_create,"; - $sql.= " cp.tms as date_update,"; - $sql.= " cp.description,"; - $sql.= " cp.date_debut,"; - $sql.= " cp.date_fin,"; - $sql.= " cp.halfday,"; - $sql.= " cp.statut,"; - $sql.= " cp.fk_validator,"; - $sql.= " cp.date_valid,"; - $sql.= " cp.fk_user_valid,"; - $sql.= " cp.date_refuse,"; - $sql.= " cp.fk_user_refuse,"; - $sql.= " cp.date_cancel,"; - $sql.= " cp.fk_user_cancel,"; - $sql.= " cp.detail_refuse,"; + $sql .= " cp.fk_user,"; + $sql .= " cp.fk_type,"; + $sql .= " cp.date_create,"; + $sql .= " cp.tms as date_update,"; + $sql .= " cp.description,"; + $sql .= " cp.date_debut,"; + $sql .= " cp.date_fin,"; + $sql .= " cp.halfday,"; + $sql .= " cp.statut,"; + $sql .= " cp.fk_validator,"; + $sql .= " cp.date_valid,"; + $sql .= " cp.fk_user_valid,"; + $sql .= " cp.date_refuse,"; + $sql .= " cp.fk_user_refuse,"; + $sql .= " cp.date_cancel,"; + $sql .= " cp.fk_user_cancel,"; + $sql .= " cp.detail_refuse,"; - $sql.= " uu.lastname as user_lastname,"; - $sql.= " uu.firstname as user_firstname,"; - $sql.= " uu.login as user_login,"; - $sql.= " uu.statut as user_statut,"; - $sql.= " uu.photo as user_photo,"; + $sql .= " uu.lastname as user_lastname,"; + $sql .= " uu.firstname as user_firstname,"; + $sql .= " uu.login as user_login,"; + $sql .= " uu.statut as user_statut,"; + $sql .= " uu.photo as user_photo,"; - $sql.= " ua.lastname as validator_lastname,"; - $sql.= " ua.firstname as validator_firstname,"; - $sql.= " ua.login as validator_login,"; - $sql.= " ua.statut as validator_statut,"; - $sql.= " ua.photo as validator_photo"; + $sql .= " ua.lastname as validator_lastname,"; + $sql .= " ua.firstname as validator_firstname,"; + $sql .= " ua.login as validator_login,"; + $sql .= " ua.statut as validator_statut,"; + $sql .= " ua.photo as validator_photo"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp, ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua"; - $sql.= " WHERE cp.entity IN (".getEntity('holiday').")"; - $sql.= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid "; // Hack pour la recherche sur le tableau + $sql .= " FROM ".MAIN_DB_PREFIX."holiday as cp, ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua"; + $sql .= " WHERE cp.entity IN (".getEntity('holiday').")"; + $sql .= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid "; // Hack pour la recherche sur le tableau // Selection filtering - if(!empty($filter)) { - $sql.= $filter; + if (!empty($filter)) { + $sql .= $filter; } // order of display - if(!empty($order)) { - $sql.= $order; + if (!empty($order)) { + $sql .= $order; } dol_syslog(get_class($this)."::fetchAll", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); // If no SQL error if ($resql) { @@ -612,16 +612,16 @@ class Holiday extends CommonObject $num = $this->db->num_rows($resql); // If no registration - if(!$num) { + if (!$num) { return 2; } // List the records and add them to the table - while($i < $num) { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $tab_result[$i]['rowid'] = $obj->rowid; - $tab_result[$i]['ref'] = ($obj->ref?$obj->ref:$obj->rowid); + $tab_result[$i]['ref'] = ($obj->ref ? $obj->ref : $obj->rowid); $tab_result[$i]['fk_user'] = $obj->fk_user; $tab_result[$i]['fk_type'] = $obj->fk_type; $tab_result[$i]['date_create'] = $this->db->jdate($obj->date_create); @@ -663,7 +663,7 @@ class Holiday extends CommonObject else { // SQL Error - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -679,10 +679,10 @@ class Holiday extends CommonObject public function validate($user = null, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Define new ref - if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref) || $this->ref == $this->id)) + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref) || $this->ref == $this->id)) { $num = $this->getNextNumRef(null); } @@ -694,28 +694,28 @@ class Holiday extends CommonObject // Update status $sql = "UPDATE ".MAIN_DB_PREFIX."holiday SET"; - if(!empty($this->statut) && is_numeric($this->statut)) { - $sql.= " statut = ".$this->statut.","; + if (!empty($this->statut) && is_numeric($this->statut)) { + $sql .= " statut = ".$this->statut.","; } else { $error++; } - $sql.= " ref = '".$this->db->escape($num)."'"; - $sql.= " WHERE rowid= ".$this->id; + $sql .= " ref = '".$this->db->escape($num)."'"; + $sql .= " WHERE rowid= ".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::validate", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $error++; $this->errors[]="Error ".$this->db->lasterror(); + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('HOLIDAY_VALIDATE', $user); + $result = $this->call_trigger('HOLIDAY_VALIDATE', $user); if ($result < 0) { $error++; } // End call triggers } @@ -724,13 +724,13 @@ class Holiday extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::validate ".$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 { @@ -750,86 +750,86 @@ class Holiday extends CommonObject public function approve($user = null, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."holiday SET"; - $sql.= " description= '".$this->db->escape($this->description)."',"; + $sql .= " description= '".$this->db->escape($this->description)."',"; - if(!empty($this->date_debut)) { - $sql.= " date_debut = '".$this->db->idate($this->date_debut)."',"; + if (!empty($this->date_debut)) { + $sql .= " date_debut = '".$this->db->idate($this->date_debut)."',"; } else { $error++; } - if(!empty($this->date_fin)) { - $sql.= " date_fin = '".$this->db->idate($this->date_fin)."',"; + if (!empty($this->date_fin)) { + $sql .= " date_fin = '".$this->db->idate($this->date_fin)."',"; } else { $error++; } - $sql.= " halfday = ".$this->halfday.","; - if(!empty($this->statut) && is_numeric($this->statut)) { - $sql.= " statut = ".$this->statut.","; + $sql .= " halfday = ".$this->halfday.","; + if (!empty($this->statut) && is_numeric($this->statut)) { + $sql .= " statut = ".$this->statut.","; } else { $error++; } - if(!empty($this->fk_validator)) { - $sql.= " fk_validator = '".$this->db->escape($this->fk_validator)."',"; + if (!empty($this->fk_validator)) { + $sql .= " fk_validator = '".$this->db->escape($this->fk_validator)."',"; } else { $error++; } - if(!empty($this->date_valid)) { - $sql.= " date_valid = '".$this->db->idate($this->date_valid)."',"; + if (!empty($this->date_valid)) { + $sql .= " date_valid = '".$this->db->idate($this->date_valid)."',"; } else { - $sql.= " date_valid = NULL,"; + $sql .= " date_valid = NULL,"; } - if(!empty($this->fk_user_valid)) { - $sql.= " fk_user_valid = '".$this->db->escape($this->fk_user_valid)."',"; + if (!empty($this->fk_user_valid)) { + $sql .= " fk_user_valid = '".$this->db->escape($this->fk_user_valid)."',"; } else { - $sql.= " fk_user_valid = NULL,"; + $sql .= " fk_user_valid = NULL,"; } - if(!empty($this->date_refuse)) { - $sql.= " date_refuse = '".$this->db->idate($this->date_refuse)."',"; + if (!empty($this->date_refuse)) { + $sql .= " date_refuse = '".$this->db->idate($this->date_refuse)."',"; } else { - $sql.= " date_refuse = NULL,"; + $sql .= " date_refuse = NULL,"; } - if(!empty($this->fk_user_refuse)) { - $sql.= " fk_user_refuse = '".$this->db->escape($this->fk_user_refuse)."',"; + if (!empty($this->fk_user_refuse)) { + $sql .= " fk_user_refuse = '".$this->db->escape($this->fk_user_refuse)."',"; } else { - $sql.= " fk_user_refuse = NULL,"; + $sql .= " fk_user_refuse = NULL,"; } - if(!empty($this->date_cancel)) { - $sql.= " date_cancel = '".$this->db->idate($this->date_cancel)."',"; + if (!empty($this->date_cancel)) { + $sql .= " date_cancel = '".$this->db->idate($this->date_cancel)."',"; } else { - $sql.= " date_cancel = NULL,"; + $sql .= " date_cancel = NULL,"; } - if(!empty($this->fk_user_cancel)) { - $sql.= " fk_user_cancel = '".$this->db->escape($this->fk_user_cancel)."',"; + if (!empty($this->fk_user_cancel)) { + $sql .= " fk_user_cancel = '".$this->db->escape($this->fk_user_cancel)."',"; } else { - $sql.= " fk_user_cancel = NULL,"; + $sql .= " fk_user_cancel = NULL,"; } - if(!empty($this->detail_refuse)) { - $sql.= " detail_refuse = '".$this->db->escape($this->detail_refuse)."'"; + if (!empty($this->detail_refuse)) { + $sql .= " detail_refuse = '".$this->db->escape($this->detail_refuse)."'"; } else { - $sql.= " detail_refuse = NULL"; + $sql .= " detail_refuse = NULL"; } - $sql.= " WHERE rowid= ".$this->id; + $sql .= " WHERE rowid= ".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::approve", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $error++; $this->errors[]="Error ".$this->db->lasterror(); + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('HOLIDAY_APPROVE', $user); + $result = $this->call_trigger('HOLIDAY_APPROVE', $user); if ($result < 0) { $error++; } // End call triggers } @@ -838,13 +838,13 @@ class Holiday extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::approve ".$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 { @@ -863,86 +863,86 @@ class Holiday extends CommonObject public function update($user = null, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."holiday SET"; - $sql.= " description= '".$this->db->escape($this->description)."',"; + $sql .= " description= '".$this->db->escape($this->description)."',"; - if(!empty($this->date_debut)) { - $sql.= " date_debut = '".$this->db->idate($this->date_debut)."',"; + if (!empty($this->date_debut)) { + $sql .= " date_debut = '".$this->db->idate($this->date_debut)."',"; } else { $error++; } - if(!empty($this->date_fin)) { - $sql.= " date_fin = '".$this->db->idate($this->date_fin)."',"; + if (!empty($this->date_fin)) { + $sql .= " date_fin = '".$this->db->idate($this->date_fin)."',"; } else { $error++; } - $sql.= " halfday = ".$this->halfday.","; - if(!empty($this->statut) && is_numeric($this->statut)) { - $sql.= " statut = ".$this->statut.","; + $sql .= " halfday = ".$this->halfday.","; + if (!empty($this->statut) && is_numeric($this->statut)) { + $sql .= " statut = ".$this->statut.","; } else { $error++; } - if(!empty($this->fk_validator)) { - $sql.= " fk_validator = '".$this->db->escape($this->fk_validator)."',"; + if (!empty($this->fk_validator)) { + $sql .= " fk_validator = '".$this->db->escape($this->fk_validator)."',"; } else { $error++; } - if(!empty($this->date_valid)) { - $sql.= " date_valid = '".$this->db->idate($this->date_valid)."',"; + if (!empty($this->date_valid)) { + $sql .= " date_valid = '".$this->db->idate($this->date_valid)."',"; } else { - $sql.= " date_valid = NULL,"; + $sql .= " date_valid = NULL,"; } - if(!empty($this->fk_user_valid)) { - $sql.= " fk_user_valid = '".$this->db->escape($this->fk_user_valid)."',"; + if (!empty($this->fk_user_valid)) { + $sql .= " fk_user_valid = '".$this->db->escape($this->fk_user_valid)."',"; } else { - $sql.= " fk_user_valid = NULL,"; + $sql .= " fk_user_valid = NULL,"; } - if(!empty($this->date_refuse)) { - $sql.= " date_refuse = '".$this->db->idate($this->date_refuse)."',"; + if (!empty($this->date_refuse)) { + $sql .= " date_refuse = '".$this->db->idate($this->date_refuse)."',"; } else { - $sql.= " date_refuse = NULL,"; + $sql .= " date_refuse = NULL,"; } - if(!empty($this->fk_user_refuse)) { - $sql.= " fk_user_refuse = '".$this->db->escape($this->fk_user_refuse)."',"; + if (!empty($this->fk_user_refuse)) { + $sql .= " fk_user_refuse = '".$this->db->escape($this->fk_user_refuse)."',"; } else { - $sql.= " fk_user_refuse = NULL,"; + $sql .= " fk_user_refuse = NULL,"; } - if(!empty($this->date_cancel)) { - $sql.= " date_cancel = '".$this->db->idate($this->date_cancel)."',"; + if (!empty($this->date_cancel)) { + $sql .= " date_cancel = '".$this->db->idate($this->date_cancel)."',"; } else { - $sql.= " date_cancel = NULL,"; + $sql .= " date_cancel = NULL,"; } - if(!empty($this->fk_user_cancel)) { - $sql.= " fk_user_cancel = '".$this->db->escape($this->fk_user_cancel)."',"; + if (!empty($this->fk_user_cancel)) { + $sql .= " fk_user_cancel = '".$this->db->escape($this->fk_user_cancel)."',"; } else { - $sql.= " fk_user_cancel = NULL,"; + $sql .= " fk_user_cancel = NULL,"; } - if(!empty($this->detail_refuse)) { - $sql.= " detail_refuse = '".$this->db->escape($this->detail_refuse)."'"; + if (!empty($this->detail_refuse)) { + $sql .= " detail_refuse = '".$this->db->escape($this->detail_refuse)."'"; } else { - $sql.= " detail_refuse = NULL"; + $sql .= " detail_refuse = NULL"; } - $sql.= " WHERE rowid= ".$this->id; + $sql .= " WHERE rowid= ".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $error++; $this->errors[]="Error ".$this->db->lasterror(); + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('HOLIDAY_MODIFY', $user); + $result = $this->call_trigger('HOLIDAY_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } @@ -951,13 +951,13 @@ class Holiday extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -977,25 +977,25 @@ class Holiday extends CommonObject public function delete($user, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; $sql = "DELETE FROM ".MAIN_DB_PREFIX."holiday"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; $this->db->begin(); dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $error++; $this->errors[]="Error ".$this->db->lasterror(); + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('HOLIDAY_DELETE', $user); + $result = $this->call_trigger('HOLIDAY_DELETE', $user); if ($result < 0) { $error++; } // End call triggers } @@ -1004,13 +1004,13 @@ class Holiday extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$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 { @@ -1036,10 +1036,10 @@ class Holiday extends CommonObject { $this->fetchByUser($fk_user, '', ''); - foreach($this->holiday as $infos_CP) + foreach ($this->holiday as $infos_CP) { - if ($infos_CP['statut'] == 4) continue; // ignore not validated holidays - if ($infos_CP['statut'] == 5) continue; // ignore not validated holidays + if ($infos_CP['statut'] == 4) continue; // ignore not validated holidays + if ($infos_CP['statut'] == 5) continue; // ignore not validated holidays /* var_dump("--"); var_dump("old: ".dol_print_date($infos_CP['date_debut'],'dayhour').' '.dol_print_date($infos_CP['date_fin'],'dayhour').' '.$infos_CP['halfday']); @@ -1118,36 +1118,36 @@ class Holiday extends CommonObject { global $langs, $conf; - $isavailablemorning=true; - $isavailableafternoon=true; + $isavailablemorning = true; + $isavailableafternoon = true; $sql = "SELECT cp.rowid, cp.date_debut as date_start, cp.date_fin as date_end, cp.halfday, cp.statut"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp"; - $sql.= " WHERE cp.entity IN (".getEntity('holiday').")"; - $sql.= " AND cp.fk_user = ".(int) $fk_user; - $sql.= " AND cp.date_debut <= '".$this->db->idate($timestamp)."' AND cp.date_fin >= '".$this->db->idate($timestamp)."'"; - if ($status != '-1') $sql.=" AND cp.statut IN (".$this->db->escape($status).")"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday as cp"; + $sql .= " WHERE cp.entity IN (".getEntity('holiday').")"; + $sql .= " AND cp.fk_user = ".(int) $fk_user; + $sql .= " AND cp.date_debut <= '".$this->db->idate($timestamp)."' AND cp.date_fin >= '".$this->db->idate($timestamp)."'"; + if ($status != '-1') $sql .= " AND cp.statut IN (".$this->db->escape($status).")"; $resql = $this->db->query($sql); if ($resql) { - $num_rows = $this->db->num_rows($resql); // Note, we can have 2 records if on is morning and the other one is afternoon + $num_rows = $this->db->num_rows($resql); // Note, we can have 2 records if on is morning and the other one is afternoon if ($num_rows > 0) { - $arrayofrecord=array(); - $i=0; + $arrayofrecord = array(); + $i = 0; while ($i < $num_rows) { $obj = $this->db->fetch_object($resql); // Note: $obj->halfday is 0:Full days, 2:Sart afternoon end morning, -1:Start afternoon, 1:End morning - $arrayofrecord[$obj->rowid]=array('date_start'=>$this->db->jdate($obj->date_start), 'date_end'=>$this->db->jdate($obj->date_end), 'halfday'=>$obj->halfday); + $arrayofrecord[$obj->rowid] = array('date_start'=>$this->db->jdate($obj->date_start), 'date_end'=>$this->db->jdate($obj->date_end), 'halfday'=>$obj->halfday); $i++; } // We found a record, user is on holiday by default, so is not available is true. $isavailablemorning = true; - foreach($arrayofrecord as $record) + foreach ($arrayofrecord as $record) { if ($timestamp == $record['date_start'] && $record['halfday'] == 2) continue; if ($timestamp == $record['date_start'] && $record['halfday'] == -1) continue; @@ -1155,7 +1155,7 @@ class Holiday extends CommonObject break; } $isavailableafternoon = true; - foreach($arrayofrecord as $record) + foreach ($arrayofrecord as $record) { if ($timestamp == $record['date_end'] && $record['halfday'] == 2) continue; if ($timestamp == $record['date_end'] && $record['halfday'] == 1) continue; @@ -1181,26 +1181,26 @@ class Holiday extends CommonObject { global $langs; - $result=''; + $result = ''; - $label=$langs->trans("Show").': '.$this->ref; + $label = $langs->trans("Show").': '.$this->ref; $url = DOL_URL_ROOT.'/holiday/card.php?id='.$this->id; //if ($option != 'nolink') //{ // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; //} $linkstart = ''; - $linkend=''; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), $this->picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; return $result; @@ -1270,24 +1270,24 @@ class Holiday extends CommonObject global $langs; // Liste des statuts - $name = array('DraftCP','ToReviewCP','ApprovedCP','CancelCP','RefuseCP'); - $nb = count($name)+1; + $name = array('DraftCP', 'ToReviewCP', 'ApprovedCP', 'CancelCP', 'RefuseCP'); + $nb = count($name) + 1; // Select HTML $statut = ''."\n"; + $statut .= ''."\n"; print $statut; } @@ -1302,12 +1302,12 @@ class Holiday extends CommonObject { $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET"; - $sql.= " value = '".$value."'"; - $sql.= " WHERE name = '".$name."'"; + $sql .= " value = '".$value."'"; + $sql .= " WHERE name = '".$name."'"; dol_syslog(get_class($this).'::updateConfCP name='.$name.'', LOG_DEBUG); $result = $this->db->query($sql); - if($result) { + if ($result) { return true; } @@ -1325,13 +1325,13 @@ class Holiday extends CommonObject public function getConfCP($name, $createifnotfound = '') { $sql = "SELECT value"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday_config"; - $sql.= " WHERE name = '".$this->db->escape($name)."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday_config"; + $sql .= " WHERE name = '".$this->db->escape($name)."'"; dol_syslog(get_class($this).'::getConfCP name='.$name.' createifnotfound='.$createifnotfound, LOG_DEBUG); $result = $this->db->query($sql); - if($result) { + if ($result) { $obj = $this->db->fetch_object($result); // Return value if (empty($obj)) @@ -1339,7 +1339,7 @@ class Holiday extends CommonObject if ($createifnotfound) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_config(name, value)"; - $sql.= " VALUES('".$this->db->escape($name)."', '".$this->db->escape($createifnotfound)."')"; + $sql .= " VALUES('".$this->db->escape($name)."', '".$this->db->escape($createifnotfound)."')"; $result = $this->db->query($sql); if ($result) { @@ -1347,7 +1347,7 @@ class Holiday extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -2; } } @@ -1362,7 +1362,7 @@ class Holiday extends CommonObject } } else { // Erreur SQL - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -1386,7 +1386,7 @@ class Holiday extends CommonObject $langs->load("holiday"); // Si mise à jour pour tout le monde en début de mois - $now=dol_now(); + $now = dol_now(); $month = date('m', $now); $newdateforlastupdate = dol_print_date($now, '%Y%m%d%H%M%S'); @@ -1405,16 +1405,16 @@ class Holiday extends CommonObject $nbUser = count($users); $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET"; - $sql.= " value = '".$this->db->escape($newdateforlastupdate)."'"; - $sql.= " WHERE name = 'lastUpdate'"; + $sql .= " value = '".$this->db->escape($newdateforlastupdate)."'"; + $sql .= " WHERE name = 'lastUpdate'"; $result = $this->db->query($sql); - $typeleaves=$this->getTypes(1, 1); + $typeleaves = $this->getTypes(1, 1); // Update each user counter foreach ($users as $userCounter) { $nbDaysToAdd = $typeleaves[$userCounter['type']]['newByMonth']; - if(empty($nbDaysToAdd)) continue; + if (empty($nbDaysToAdd)) continue; dol_syslog("We update leave type id ".$userCounter['type']." for user id ".$userCounter['rowid'], LOG_DEBUG); @@ -1433,7 +1433,7 @@ class Holiday extends CommonObject } } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -1453,7 +1453,7 @@ class Holiday extends CommonObject $nbHoliday = price2num($nbHoliday, 5); $sql = "SELECT nb_holiday FROM ".MAIN_DB_PREFIX."holiday_users"; - $sql.= " WHERE fk_user = ".(int) $userID." AND fk_type = ".(int) $fk_type; + $sql .= " WHERE fk_user = ".(int) $userID." AND fk_type = ".(int) $fk_type; $resql = $this->db->query($sql); if ($resql) { @@ -1463,36 +1463,36 @@ class Holiday extends CommonObject { // Update for user $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_users SET"; - $sql.= " nb_holiday = ".$nbHoliday; - $sql.= " WHERE fk_user = ".(int) $userID." AND fk_type = ".(int) $fk_type; + $sql .= " nb_holiday = ".$nbHoliday; + $sql .= " WHERE fk_user = ".(int) $userID." AND fk_type = ".(int) $fk_type; $result = $this->db->query($sql); - if (! $result) + if (!$result) { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); } } else { // Insert for user $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_users(nb_holiday, fk_user, fk_type) VALUES ("; - $sql.= $nbHoliday; - $sql.= ", ".(int) $userID.", ".(int) $fk_type.")"; + $sql .= $nbHoliday; + $sql .= ", ".(int) $userID.", ".(int) $fk_type.")"; $result = $this->db->query($sql); - if (! $result) + if (!$result) { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); } } } else { - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); $error++; } - if (! $error) + if (!$error) { return 1; } @@ -1513,16 +1513,16 @@ class Holiday extends CommonObject { $sql = "SELECT value"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday_config"; - $sql.= " WHERE name = '".$name."'"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday_config"; + $sql .= " WHERE name = '".$name."'"; $result = $this->db->query($sql); - if($result) { + if ($result) { $obj = $this->db->fetch_object($result); // Si la valeur est 1 on retourne checked - if($obj->value) { + if ($obj->value) { return 'checked'; } } @@ -1539,29 +1539,29 @@ class Holiday extends CommonObject public function createCPusers($single = false, $userid = '') { // Si c'est l'ensemble des utilisateurs à ajouter - if (! $single) + if (!$single) { dol_syslog(get_class($this).'::createCPusers'); $arrayofusers = $this->fetchUsers(false, true); - foreach($arrayofusers as $users) + foreach ($arrayofusers as $users) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_users"; - $sql.= " (fk_user, nb_holiday)"; - $sql.= " VALUES ('".$users['rowid']."','0')"; + $sql .= " (fk_user, nb_holiday)"; + $sql .= " VALUES ('".$users['rowid']."','0')"; - $resql=$this->db->query($sql); - if (! $resql) dol_print_error($this->db); + $resql = $this->db->query($sql); + if (!$resql) dol_print_error($this->db); } } else { $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_users"; - $sql.= " (fk_user, nb_holiday)"; - $sql.= " VALUES ('".$userid."','0')"; + $sql .= " (fk_user, nb_holiday)"; + $sql .= " VALUES ('".$userid."','0')"; - $resql=$this->db->query($sql); - if (! $resql) dol_print_error($this->db); + $resql = $this->db->query($sql); + if (!$resql) dol_print_error($this->db); } } @@ -1575,7 +1575,7 @@ class Holiday extends CommonObject { $sql = "DELETE FROM ".MAIN_DB_PREFIX."holiday_users"; - $sql.= " WHERE fk_user = '".$user_id."'"; + $sql .= " WHERE fk_user = '".$user_id."'"; $this->db->query($sql); } @@ -1591,13 +1591,13 @@ class Holiday extends CommonObject public function getCPforUser($user_id, $fk_type = 0) { $sql = "SELECT nb_holiday"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users"; - $sql.= " WHERE fk_user = ".(int) $user_id; - if ($fk_type > 0) $sql.=" AND fk_type = ".(int) $fk_type; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday_users"; + $sql .= " WHERE fk_user = ".(int) $user_id; + if ($fk_type > 0) $sql .= " AND fk_type = ".(int) $fk_type; dol_syslog(get_class($this).'::getCPforUser user_id='.$user_id.' type_id='.$fk_type, LOG_DEBUG); $result = $this->db->query($sql); - if($result) + if ($result) { $obj = $this->db->fetch_object($result); //return number_format($obj->nb_holiday,2); @@ -1631,23 +1631,23 @@ class Holiday extends CommonObject // Si utilisateur de Dolibarr $sql = "SELECT u.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; - if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { - $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; - $sql.= " WHERE (ug.fk_user = u.rowid"; - $sql.= " AND ug.entity = ".$conf->entity.")"; - $sql.= " OR u.admin = 1"; + $sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; + $sql .= " WHERE (ug.fk_user = u.rowid"; + $sql .= " AND ug.entity = ".$conf->entity.")"; + $sql .= " OR u.admin = 1"; } else { - $sql.= " WHERE u.entity IN (0,".$conf->entity.")"; + $sql .= " WHERE u.entity IN (0,".$conf->entity.")"; } - $sql.= " AND u.statut > 0"; - if ($filters) $sql.=$filters; + $sql .= " AND u.statut > 0"; + if ($filters) $sql .= $filters; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); // Si pas d'erreur SQL if ($resql) { @@ -1656,14 +1656,14 @@ class Holiday extends CommonObject $stringlist = ''; // Boucles du listage des utilisateurs - while($i < $num) + while ($i < $num) { $obj = $this->db->fetch_object($resql); if ($i == 0) { - $stringlist.= $obj->rowid; + $stringlist .= $obj->rowid; } else { - $stringlist.= ', '.$obj->rowid; + $stringlist .= ', '.$obj->rowid; } $i++; @@ -1674,7 +1674,7 @@ class Holiday extends CommonObject else { // Erreur SQL - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -1682,11 +1682,11 @@ class Holiday extends CommonObject { // We want only list of vacation balance for user ids $sql = "SELECT DISTINCT cpu.fk_user"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE cpu.fk_user = u.user"; - if ($filters) $sql.=$filters; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE cpu.fk_user = u.user"; + if ($filters) $sql .= $filters; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); // Si pas d'erreur SQL if ($resql) { @@ -1695,14 +1695,14 @@ class Holiday extends CommonObject $stringlist = ''; // Boucles du listage des utilisateurs - while($i < $num) + while ($i < $num) { $obj = $this->db->fetch_object($resql); - if($i == 0) { - $stringlist.= $obj->fk_user; + if ($i == 0) { + $stringlist .= $obj->fk_user; } else { - $stringlist.= ', '.$obj->fk_user; + $stringlist .= ', '.$obj->fk_user; } $i++; @@ -1713,7 +1713,7 @@ class Holiday extends CommonObject else { // Erreur SQL - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -1779,11 +1779,11 @@ class Holiday extends CommonObject { // List of vacation balance users $sql = "SELECT cpu.fk_type, cpu.nb_holiday, u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE cpu.fk_user = u.rowid"; - if ($filters) $sql.=$filters; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE cpu.fk_user = u.rowid"; + if ($filters) $sql .= $filters; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); // Si pas d'erreur SQL if ($resql) @@ -1793,19 +1793,19 @@ class Holiday extends CommonObject $num = $this->db->num_rows($resql); // Boucles du listage des utilisateurs - while($i < $num) + while ($i < $num) { $obj = $this->db->fetch_object($resql); - $tab_result[$i]['rowid'] = $obj->rowid; // rowid of user - $tab_result[$i]['name'] = $obj->lastname; // deprecated + $tab_result[$i]['rowid'] = $obj->rowid; // rowid of user + $tab_result[$i]['name'] = $obj->lastname; // deprecated $tab_result[$i]['lastname'] = $obj->lastname; $tab_result[$i]['firstname'] = $obj->firstname; $tab_result[$i]['gender'] = $obj->gender; $tab_result[$i]['status'] = $obj->statut; $tab_result[$i]['employee'] = $obj->employee; $tab_result[$i]['photo'] = $obj->photo; - $tab_result[$i]['fk_user'] = $obj->fk_user; // rowid of manager + $tab_result[$i]['fk_user'] = $obj->fk_user; // rowid of manager $tab_result[$i]['type'] = $obj->fk_type; $tab_result[$i]['nb_holiday'] = $obj->nb_holiday; @@ -1818,7 +1818,7 @@ class Holiday extends CommonObject else { // Erreur SQL - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -1836,20 +1836,20 @@ class Holiday extends CommonObject public function fetch_users_approver_holiday() { // phpcs:enable - $users_validator=array(); + $users_validator = array(); $sql = "SELECT DISTINCT ur.fk_user"; - $sql.= " FROM ".MAIN_DB_PREFIX."user_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd"; - $sql.= " WHERE ur.fk_id = rd.id and rd.module = 'holiday' AND rd.perms = 'approve'"; // Permission 'Approve'; - $sql.= "UNION"; - $sql.= " SELECT DISTINCT ugu.fk_user"; - $sql.= " FROM ".MAIN_DB_PREFIX."usergroup_user as ugu, ".MAIN_DB_PREFIX."usergroup_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd"; - $sql.= " WHERE ugu.fk_usergroup = ur.fk_usergroup AND ur.fk_id = rd.id and rd.module = 'holiday' AND rd.perms = 'approve'"; // Permission 'Approve'; + $sql .= " FROM ".MAIN_DB_PREFIX."user_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd"; + $sql .= " WHERE ur.fk_id = rd.id and rd.module = 'holiday' AND rd.perms = 'approve'"; // Permission 'Approve'; + $sql .= "UNION"; + $sql .= " SELECT DISTINCT ugu.fk_user"; + $sql .= " FROM ".MAIN_DB_PREFIX."usergroup_user as ugu, ".MAIN_DB_PREFIX."usergroup_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd"; + $sql .= " WHERE ugu.fk_usergroup = ur.fk_usergroup AND ur.fk_id = rd.id and rd.module = 'holiday' AND rd.perms = 'approve'"; // Permission 'Approve'; //print $sql; dol_syslog(get_class($this)."::fetch_users_approver_holiday sql=".$sql); $result = $this->db->query($sql); - if($result) + if ($result) { $num_rows = $this->db->num_rows($result); $i = 0; while ($i < $num_rows) @@ -1862,7 +1862,7 @@ class Holiday extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); dol_syslog(get_class($this)."::fetch_users_approver_holiday Error ".$this->error, LOG_ERR); return -1; } @@ -1877,8 +1877,8 @@ class Holiday extends CommonObject public function countActiveUsers() { $sql = "SELECT count(u.rowid) as compteur"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE u.statut > 0"; + $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE u.statut > 0"; $result = $this->db->query($sql); $objet = $this->db->fetch_object($result); @@ -1894,8 +1894,8 @@ class Holiday extends CommonObject { $sql = "SELECT count(u.rowid) as compteur"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u LEFT OUTER JOIN ".MAIN_DB_PREFIX."holiday_users hu ON (hu.fk_user=u.rowid)"; - $sql.= " WHERE u.statut > 0 AND hu.fk_user IS NULL"; + $sql .= " FROM ".MAIN_DB_PREFIX."user as u LEFT OUTER JOIN ".MAIN_DB_PREFIX."holiday_users hu ON (hu.fk_user=u.rowid)"; + $sql .= " WHERE u.statut > 0 AND hu.fk_user IS NULL"; $result = $this->db->query($sql); $objet = $this->db->fetch_object($result); @@ -1912,7 +1912,7 @@ class Holiday extends CommonObject */ public function verifNbUsers($userDolibarrWithoutCP, $userCP) { - if (empty($userCP)) $userCP=0; + if (empty($userCP)) $userCP = 0; dol_syslog(get_class($this).'::verifNbUsers userDolibarr='.$userDolibarrWithoutCP.' userCP='.$userCP); return 1; } @@ -1932,7 +1932,7 @@ class Holiday extends CommonObject { global $conf, $langs; - $error=0; + $error = 0; $prev_solde = price2num($this->getCPforUser($fk_user_update, $fk_type), 5); $new_solde = price2num($new_solde, 5); @@ -1944,30 +1944,30 @@ class Holiday extends CommonObject // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_logs ("; - $sql.= "date_action,"; - $sql.= "fk_user_action,"; - $sql.= "fk_user_update,"; - $sql.= "type_action,"; - $sql.= "prev_solde,"; - $sql.= "new_solde,"; - $sql.= "fk_type"; - $sql.= ") VALUES ("; - $sql.= " '".$this->db->idate(dol_now())."',"; - $sql.= " '".$fk_user_action."',"; - $sql.= " '".$fk_user_update."',"; - $sql.= " '".$this->db->escape($label)."',"; - $sql.= " '".$prev_solde."',"; - $sql.= " '".$new_solde."',"; - $sql.= " ".$fk_type; - $sql.= ")"; + $sql .= "date_action,"; + $sql .= "fk_user_action,"; + $sql .= "fk_user_update,"; + $sql .= "type_action,"; + $sql .= "prev_solde,"; + $sql .= "new_solde,"; + $sql .= "fk_type"; + $sql .= ") VALUES ("; + $sql .= " '".$this->db->idate(dol_now())."',"; + $sql .= " '".$fk_user_action."',"; + $sql .= " '".$fk_user_update."',"; + $sql .= " '".$this->db->escape($label)."',"; + $sql .= " '".$prev_solde."',"; + $sql .= " '".$new_solde."',"; + $sql .= " ".$fk_type; + $sql .= ")"; - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { - $error++; $this->errors[]="Error ".$this->db->lasterror(); + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { $this->optRowid = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday_logs"); } @@ -1975,13 +1975,13 @@ class Holiday extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::addLogCP ".$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 { @@ -2002,29 +2002,29 @@ class Holiday extends CommonObject global $langs; $sql = "SELECT"; - $sql.= " cpl.rowid,"; - $sql.= " cpl.date_action,"; - $sql.= " cpl.fk_user_action,"; - $sql.= " cpl.fk_user_update,"; - $sql.= " cpl.type_action,"; - $sql.= " cpl.prev_solde,"; - $sql.= " cpl.new_solde,"; - $sql.= " cpl.fk_type"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday_logs as cpl"; - $sql.= " WHERE cpl.rowid > 0"; // To avoid error with other search and criteria + $sql .= " cpl.rowid,"; + $sql .= " cpl.date_action,"; + $sql .= " cpl.fk_user_action,"; + $sql .= " cpl.fk_user_update,"; + $sql .= " cpl.type_action,"; + $sql .= " cpl.prev_solde,"; + $sql .= " cpl.new_solde,"; + $sql .= " cpl.fk_type"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday_logs as cpl"; + $sql .= " WHERE cpl.rowid > 0"; // To avoid error with other search and criteria // Filtrage de séléction - if(!empty($filter)) { - $sql.= " ".$filter; + if (!empty($filter)) { + $sql .= " ".$filter; } // Ordre d'affichage - if(!empty($order)) { - $sql.= " ".$order; + if (!empty($order)) { + $sql .= " ".$order; } dol_syslog(get_class($this)."::fetchLog", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); // Si pas d'erreur SQL if ($resql) { @@ -2033,12 +2033,12 @@ class Holiday extends CommonObject $num = $this->db->num_rows($resql); // Si pas d'enregistrement - if(!$num) { + if (!$num) { return 2; } // On liste les résultats et on les ajoutent dans le tableau - while($i < $num) { + while ($i < $num) { $obj = $this->db->fetch_object($resql); $tab_result[$i]['rowid'] = $obj->rowid; @@ -2059,7 +2059,7 @@ class Holiday extends CommonObject else { // Erreur SQL - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -2077,10 +2077,10 @@ class Holiday extends CommonObject global $mysoc; $sql = "SELECT rowid, code, label, affect, delay, newByMonth"; - $sql.= " FROM " . MAIN_DB_PREFIX . "c_holiday_types"; - $sql.= " WHERE (fk_country IS NULL OR fk_country = ".$mysoc->country_id.')'; - if ($active >= 0) $sql.=" AND active = ".((int) $active); - if ($affect >= 0) $sql.=" AND affect = ".((int) $affect); + $sql .= " FROM ".MAIN_DB_PREFIX."c_holiday_types"; + $sql .= " WHERE (fk_country IS NULL OR fk_country = ".$mysoc->country_id.')'; + if ($active >= 0) $sql .= " AND active = ".((int) $active); + if ($affect >= 0) $sql .= " AND affect = ".((int) $affect); $result = $this->db->query($sql); if ($result) @@ -2111,21 +2111,21 @@ class Holiday extends CommonObject */ public function initAsSpecimen() { - global $user,$langs; + global $user, $langs; // Initialise parameters - $this->id=0; - $this->specimen=1; + $this->id = 0; + $this->specimen = 1; - $this->fk_user=1; - $this->description='SPECIMEN description'; - $this->date_debut=dol_now(); - $this->date_fin=dol_now()+(24*3600); - $this->date_valid=dol_now(); - $this->fk_validator=1; - $this->halfday=0; - $this->fk_type=1; - $this->statut=Holiday::STATUS_VALIDATED; + $this->fk_user = 1; + $this->description = 'SPECIMEN description'; + $this->date_debut = dol_now(); + $this->date_fin = dol_now() + (24 * 3600); + $this->date_valid = dol_now(); + $this->fk_validator = 1; + $this->halfday = 0; + $this->fk_type = 1; + $this->statut = Holiday::STATUS_VALIDATED; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -2137,17 +2137,17 @@ class Holiday extends CommonObject public function load_state_board() { // phpcs:enable - $this->nb=array(); + $this->nb = array(); $sql = "SELECT count(h.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday as h"; - $sql.= " WHERE h.statut > 1"; - $sql.= " AND h.entity IN (".getEntity('holiday').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."holiday as h"; + $sql .= " WHERE h.statut > 1"; + $sql .= " AND h.entity IN (".getEntity('holiday').")"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - while ($obj=$this->db->fetch_object($resql)) { - $this->nb["holidays"]=$obj->nb; + while ($obj = $this->db->fetch_object($resql)) { + $this->nb["holidays"] = $obj->nb; } $this->db->free($resql); return 1; @@ -2155,7 +2155,7 @@ class Holiday extends CommonObject else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2211,7 +2211,7 @@ class Holiday extends CommonObject else { dol_print_error($this->db); - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 0efb8dfde59..d4fd5a20caf 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -92,14 +92,14 @@ if (! is_object($conf)) dolibarr_install_syslog("upgrade2: conf file not initial * View */ -if ((! $versionfrom || preg_match('/version/', $versionfrom)) && (! $versionto || preg_match('/version/', $versionto))) +if ((!$versionfrom || preg_match('/version/', $versionfrom)) && (!$versionto || preg_match('/version/', $versionto))) { print 'Error: Parameter versionfrom or versionto missing or having a bad format.'."\n"; print 'Upgrade must be ran from command line with parameters or called from page install/index.php (like a first install)'."\n"; // Test if batch mode $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); - $path=__DIR__.'/'; + $path = __DIR__.'/'; if (substr($sapi_type, 0, 3) == 'cli') { print 'Syntax from command line: '.$script_file." x.y.z a.b.c [MAIN_MODULE_NAME1_TO_ENABLE,MAIN_MODULE_NAME2_TO_ENABLE...]\n"; @@ -107,24 +107,24 @@ if ((! $versionfrom || preg_match('/version/', $versionfrom)) && (! $versionto | exit; } -pHeader('', 'step5', GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'upgrade', 'versionfrom='.$versionfrom.'&versionto='.$versionto); +pHeader('', 'step5', GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'upgrade', 'versionfrom='.$versionfrom.'&versionto='.$versionto); -if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ09'))) +if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ09'))) { print '

Database '.$langs->trans('DataMigration').'

'; print ''; // If password is encoded, we decode it - if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass)) + if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) { require_once $dolibarr_main_document_root.'/core/lib/security.lib.php'; if (preg_match('/crypted:/i', $dolibarr_main_db_pass)) { $dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass); $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass); - $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted + $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted } else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); } @@ -137,25 +137,25 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a $conf->db->user = $dolibarr_main_db_user; $conf->db->pass = $dolibarr_main_db_pass; - $db=getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port); + $db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port); // Create the global $hookmanager object include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($db); + $hookmanager = new HookManager($db); $hookmanager->initHooks(array('upgrade')); if (!$db->connected) { print ''; - dolibarr_install_syslog('upgrade2: failed to connect to database :' . $conf->db->name . ' on ' . $conf->db->host . ' for user ' . $conf->db->user, LOG_ERR); + dolibarr_install_syslog('upgrade2: failed to connect to database :'.$conf->db->name.' on '.$conf->db->host.' for user '.$conf->db->user, LOG_ERR); $error++; } - if (! $error) + if (!$error) { - if($db->database_selected) + if ($db->database_selected) { - dolibarr_install_syslog('upgrade2: database connection successful :' . $dolibarr_main_db_name); + dolibarr_install_syslog('upgrade2: database connection successful :'.$dolibarr_main_db_name); } else { @@ -163,17 +163,17 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a } } - if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption=0; + if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption = 0; $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption; - if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey=''; + if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey = ''; $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey; // Chargement config - if (! $error) + if (!$error) { $conf->setValues($db); // Reset forced setup after the setValues - if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE=constant('SYSLOG_FILE'); + if (defined('SYSLOG_FILE')) $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1; } @@ -185,18 +185,18 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a ***************************************************************************************/ $db->begin(); - if (! $error) + if (!$error) { // Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE // Version to install is DOL_VERSION - $dolibarrlastupgradeversionarray=preg_split('/[\.-]/', isset($conf->global->MAIN_VERSION_LAST_UPGRADE)?$conf->global->MAIN_VERSION_LAST_UPGRADE:(isset($conf->global->MAIN_VERSION_LAST_INSTALL)?$conf->global->MAIN_VERSION_LAST_INSTALL:'')); + $dolibarrlastupgradeversionarray = preg_split('/[\.-]/', isset($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_UPGRADE : (isset($conf->global->MAIN_VERSION_LAST_INSTALL) ? $conf->global->MAIN_VERSION_LAST_INSTALL : '')); // Chaque action de migration doit renvoyer une ligne sur 4 colonnes avec // dans la 1ere colonne, la description de l'action a faire // dans la 4eme colonne, le texte 'OK' si fait ou 'AlreadyDone' si rien n'est fait ou 'Error' - $versiontoarray=explode('.', $versionto); - $versionranarray=explode('.', DOL_VERSION); + $versiontoarray = explode('.', $versionto); + $versionranarray = explode('.', DOL_VERSION); // Force to execute this at begin to avoid the new core code into Dolibarr to be broken. @@ -224,8 +224,8 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a $db->query($sql, 1); - $afterversionarray=explode('.', '2.0.0'); - $beforeversionarray=explode('.', '2.7.9'); + $afterversionarray = explode('.', '2.0.0'); + $beforeversionarray = explode('.', '2.7.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { // Script pour V2 -> V2.1 @@ -287,12 +287,12 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a } // Script for 2.8 - $afterversionarray=explode('.', '2.7.9'); - $beforeversionarray=explode('.', '2.8.9'); + $afterversionarray = explode('.', '2.7.9'); + $beforeversionarray = explode('.', '2.8.9'); //print $versionto.' '.versioncompare($versiontoarray,$afterversionarray).' '.versioncompare($versiontoarray,$beforeversionarray); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { - migrate_price_facture($db, $langs, $conf); // Code of this function works for 2.8+ because need a field tva_tx + migrate_price_facture($db, $langs, $conf); // Code of this function works for 2.8+ because need a field tva_tx migrate_relationship_tables($db, $langs, $conf, 'co_exp', 'fk_commande', 'commande', 'fk_expedition', 'shipping'); @@ -314,8 +314,8 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a } // Script for 2.9 - $afterversionarray=explode('.', '2.8.9'); - $beforeversionarray=explode('.', '2.9.9'); + $afterversionarray = explode('.', '2.8.9'); + $beforeversionarray = explode('.', '2.9.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_project_task_time($db, $langs, $conf); @@ -328,16 +328,16 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a } // Script for 3.0 - $afterversionarray=explode('.', '2.9.9'); - $beforeversionarray=explode('.', '3.0.9'); + $afterversionarray = explode('.', '2.9.9'); + $beforeversionarray = explode('.', '3.0.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { // No particular code } // Script for 3.1 - $afterversionarray=explode('.', '3.0.9'); - $beforeversionarray=explode('.', '3.1.9'); + $afterversionarray = explode('.', '3.0.9'); + $beforeversionarray = explode('.', '3.1.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_rename_directories($db, $langs, $conf, '/rss', '/externalrss'); @@ -346,8 +346,8 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a } // Script for 3.2 - $afterversionarray=explode('.', '3.1.9'); - $beforeversionarray=explode('.', '3.2.9'); + $afterversionarray = explode('.', '3.1.9'); + $beforeversionarray = explode('.', '3.2.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_price_contrat($db, $langs, $conf); @@ -358,8 +358,8 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a } // Script for 3.3 - $afterversionarray=explode('.', '3.2.9'); - $beforeversionarray=explode('.', '3.3.9'); + $afterversionarray = explode('.', '3.2.9'); + $beforeversionarray = explode('.', '3.3.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_categorie_association($db, $langs, $conf); @@ -369,32 +369,32 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a // No specific scripts // Tasks to do always and only into last targeted version - $afterversionarray=explode('.', '3.6.9'); // target is after this - $beforeversionarray=explode('.', '3.7.9'); // target is before this + $afterversionarray = explode('.', '3.6.9'); // target is after this + $beforeversionarray = explode('.', '3.7.9'); // target is before this if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_event_assignement($db, $langs, $conf); } // Scripts for 3.9 - $afterversionarray=explode('.', '3.7.9'); - $beforeversionarray=explode('.', '3.8.9'); + $afterversionarray = explode('.', '3.7.9'); + $beforeversionarray = explode('.', '3.8.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { // No particular code } // Scripts for 4.0 - $afterversionarray=explode('.', '3.9.9'); - $beforeversionarray=explode('.', '4.0.9'); + $afterversionarray = explode('.', '3.9.9'); + $beforeversionarray = explode('.', '4.0.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_rename_directories($db, $langs, $conf, '/fckeditor', '/medias'); } // Scripts for 5.0 - $afterversionarray=explode('.', '4.0.9'); - $beforeversionarray=explode('.', '5.0.9'); + $afterversionarray = explode('.', '4.0.9'); + $beforeversionarray = explode('.', '5.0.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { // Migrate to add entity value into llx_societe_remise @@ -405,11 +405,11 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a } // Scripts for 6.0 - $afterversionarray=explode('.', '5.0.9'); - $beforeversionarray=explode('.', '6.0.9'); + $afterversionarray = explode('.', '5.0.9'); + $beforeversionarray = explode('.', '6.0.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { - if (! empty($conf->multicompany->enabled)) + if (!empty($conf->multicompany->enabled)) { global $multicompany_transverse_mode; @@ -426,8 +426,8 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a } // Scripts for 7.0 - $afterversionarray=explode('.', '6.0.9'); - $beforeversionarray=explode('.', '7.0.9'); + $afterversionarray = explode('.', '6.0.9'); + $beforeversionarray = explode('.', '7.0.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { // Migrate contact association @@ -437,16 +437,16 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a } // Scripts for 8.0 - $afterversionarray=explode('.', '7.0.9'); - $beforeversionarray=explode('.', '8.0.9'); + $afterversionarray = explode('.', '7.0.9'); + $beforeversionarray = explode('.', '8.0.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_rename_directories($db, $langs, $conf, '/contracts', '/contract'); } // Scripts for 9.0 - $afterversionarray=explode('.', '8.0.9'); - $beforeversionarray=explode('.', '9.0.9'); + $afterversionarray = explode('.', '8.0.9'); + $beforeversionarray = explode('.', '9.0.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { migrate_user_photospath(); @@ -467,7 +467,7 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a if (versioncompare($versiontoarray, $versionranarray) >= 0 || versioncompare($versiontoarray, $versionranarray) <= -3) { // Reload modules (this must be always done and only into last targeted version, because code to reload module may need table structure of last version) - $listofmodule=array( + $listofmodule = array( 'MAIN_MODULE_ACCOUNTING'=>'newboxdefonly', 'MAIN_MODULE_AGENDA'=>'newboxdefonly', 'MAIN_MODULE_BARCODE'=>'newboxdefonly', @@ -488,7 +488,7 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a 'MAIN_MODULE_SYSLOG'=>'newboxdefonly', 'MAIN_MODULE_SOCIETE'=>'newboxdefonly', 'MAIN_MODULE_SERVICE'=>'newboxdefonly', - 'MAIN_MODULE_USER'=>'newboxdefonly', //This one must be always done and only into last targeted version) + 'MAIN_MODULE_USER'=>'newboxdefonly', //This one must be always done and only into last targeted version) 'MAIN_MODULE_VARIANTS'=>'newboxdefonly', 'MAIN_MODULE_WEBSITE'=>'newboxdefonly', ); @@ -500,27 +500,27 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a // Can force activation of some module during migration with parameter 'enablemodules=MAIN_MODULE_XXX,MAIN_MODULE_YYY,...' // In most cases (online install or upgrade) $enablemodules is empty. Can be forced when ran from command line. - if (! $error && $enablemodules) + if (!$error && $enablemodules) { // Reload modules (this must be always done and only into last targeted version) - $listofmodules=array(); - $enablemodules=preg_replace('/enablemodules=/', '', $enablemodules); - $tmplistofmodules=explode(',', $enablemodules); - foreach($tmplistofmodules as $value) + $listofmodules = array(); + $enablemodules = preg_replace('/enablemodules=/', '', $enablemodules); + $tmplistofmodules = explode(',', $enablemodules); + foreach ($tmplistofmodules as $value) { - $listofmodules[$value]='forceactivate'; + $listofmodules[$value] = 'forceactivate'; } migrate_reload_modules($db, $langs, $conf, $listofmodules, 1); } // Can call a dedicated external upgrade process - if (! $error) + if (!$error) { - $parameters=array('versionfrom'=>$versionfrom, 'versionto='.$versionto); - $object=new stdClass(); - $action="upgrade"; - $reshook=$hookmanager->executeHooks('doUpgrade2', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('versionfrom'=>$versionfrom, 'versionto='.$versionto); + $object = new stdClass(); + $action = "upgrade"; + $reshook = $hookmanager->executeHooks('doUpgrade2', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($hookmanager->resNbOfHooks > 0) { if ($reshook < 0) @@ -542,7 +542,7 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a else { //if (! empty($conf->modules)) - if (! empty($conf->modules_parts['hooks'])) // If there is at least one module with one hook, we show message to say nothing was done + if (!empty($conf->modules_parts['hooks'])) // If there is at least one module with one hook, we show message to say nothing was done { print ''; $insert_sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn_facturefourn SET '; - $insert_sql.= ' fk_paiementfourn = \''.$select_obj->rowid.'\','; - $insert_sql.= ' fk_facturefourn = \''.$select_obj->fk_facture_fourn.'\','; - $insert_sql.= ' amount = \''.$select_obj->amount.'\''; + $insert_sql .= ' fk_paiementfourn = \''.$select_obj->rowid.'\','; + $insert_sql .= ' fk_facturefourn = \''.$select_obj->fk_facture_fourn.'\','; + $insert_sql .= ' amount = \''.$select_obj->amount.'\''; $insert_resql = $db->query($insert_sql); if ($insert_resql) @@ -1454,9 +1454,9 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf) */ function migrate_price_facture($db, $langs, $conf) { - $err=0; + $err = 0; - $tmpmysoc=new Societe($db); + $tmpmysoc = new Societe($db); $tmpmysoc->setMysoc($conf); $db->begin(); @@ -1468,14 +1468,14 @@ function migrate_price_facture($db, $langs, $conf) // List of invoice lines not up to date $sql = "SELECT fd.rowid, fd.qty, fd.subprice, fd.remise_percent, fd.tva_tx as vatrate, fd.total_ttc, fd.info_bits,"; - $sql.= " f.rowid as facid, f.remise_percent as remise_percent_global, f.total_ttc as total_ttc_f"; - $sql.= " FROM ".MAIN_DB_PREFIX."facturedet as fd, ".MAIN_DB_PREFIX."facture as f"; - $sql.= " WHERE fd.fk_facture = f.rowid"; - $sql.= " AND (((fd.total_ttc = 0 AND fd.remise_percent != 100) or fd.total_ttc IS NULL) or f.total_ttc IS NULL)"; + $sql .= " f.rowid as facid, f.remise_percent as remise_percent_global, f.total_ttc as total_ttc_f"; + $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd, ".MAIN_DB_PREFIX."facture as f"; + $sql .= " WHERE fd.fk_facture = f.rowid"; + $sql .= " AND (((fd.total_ttc = 0 AND fd.remise_percent != 100) or fd.total_ttc IS NULL) or f.total_ttc IS NULL)"; //print $sql; dolibarr_install_syslog("upgrade2::migrate_price_facture"); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -1496,10 +1496,10 @@ function migrate_price_facture($db, $langs, $conf) $info_bits = $obj->info_bits; // On met a jour les 3 nouveaux champs - $facligne= new FactureLigne($db); + $facligne = new FactureLigne($db); $facligne->fetch($rowid); - $result=calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $facligne->product_type, $tmpmysoc); + $result = calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $facligne->product_type, $tmpmysoc); $total_ht = $result[0]; $total_tva = $result[1]; $total_ttc = $result[2]; @@ -1508,20 +1508,20 @@ function migrate_price_facture($db, $langs, $conf) $facligne->total_tva = $total_tva; $facligne->total_ttc = $total_ttc; - dolibarr_install_syslog("upgrade2: line " . $rowid . ": facid=" . $obj->facid . " pu=" . $pu ." qty=" . $qty . " vatrate=" . $vatrate . " remise_percent=" . $remise_percent . " remise_global=" . $remise_percent_global . " -> " . $total_ht . ", " . $total_tva . ", " . $total_ttc); + dolibarr_install_syslog("upgrade2: line ".$rowid.": facid=".$obj->facid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." remise_global=".$remise_percent_global." -> ".$total_ht.", ".$total_tva.", ".$total_ttc); print ". "; $facligne->update_total(); /* On touche a facture mere uniquement si total_ttc = 0 */ - if (! $total_ttc_f) + if (!$total_ttc_f) { $facture = new Facture($db); - $facture->id=$obj->facid; + $facture->id = $obj->facid; - if ( $facture->fetch($facture->id) >= 0) + if ($facture->fetch($facture->id) >= 0) { - if ( $facture->update_price() > 0 ) + if ($facture->update_price() > 0) { //print $facture->id; } @@ -1573,7 +1573,7 @@ function migrate_price_facture($db, $langs, $conf) */ function migrate_price_propal($db, $langs, $conf) { - $tmpmysoc=new Societe($db); + $tmpmysoc = new Societe($db); $tmpmysoc->setMysoc($conf); $db->begin(); @@ -1585,13 +1585,13 @@ function migrate_price_propal($db, $langs, $conf) // List of proposal lines not up to date $sql = "SELECT pd.rowid, pd.qty, pd.subprice, pd.remise_percent, pd.tva_tx as vatrate, pd.info_bits,"; - $sql.= " p.rowid as propalid, p.remise_percent as remise_percent_global"; - $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as pd, ".MAIN_DB_PREFIX."propal as p"; - $sql.= " WHERE pd.fk_propal = p.rowid"; - $sql.= " AND ((pd.total_ttc = 0 AND pd.remise_percent != 100) or pd.total_ttc IS NULL)"; + $sql .= " p.rowid as propalid, p.remise_percent as remise_percent_global"; + $sql .= " FROM ".MAIN_DB_PREFIX."propaldet as pd, ".MAIN_DB_PREFIX."propal as p"; + $sql .= " WHERE pd.fk_propal = p.rowid"; + $sql .= " AND ((pd.total_ttc = 0 AND pd.remise_percent != 100) or pd.total_ttc IS NULL)"; dolibarr_install_syslog("upgrade2::migrate_price_propal"); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -1611,10 +1611,10 @@ function migrate_price_propal($db, $langs, $conf) $info_bits = $obj->info_bits; // On met a jour les 3 nouveaux champs - $propalligne= new PropaleLigne($db); + $propalligne = new PropaleLigne($db); $propalligne->fetch($rowid); - $result=calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $propalligne->product_type, $tmpmysoc); + $result = calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $propalligne->product_type, $tmpmysoc); $total_ht = $result[0]; $total_tva = $result[1]; $total_ttc = $result[2]; @@ -1623,7 +1623,7 @@ function migrate_price_propal($db, $langs, $conf) $propalligne->total_tva = $total_tva; $propalligne->total_ttc = $total_ttc; - dolibarr_install_syslog("upgrade2: Line " . $rowid . ": propalid=" . $obj->rowid . " pu=" . $pu . " qty=" . $qty . " vatrate=" . $vatrate . " remise_percent=" . $remise_percent . " remise_global=" . $remise_percent_global . " -> " . $total_ht . ", " . $total_tva. ", " . $total_ttc); + dolibarr_install_syslog("upgrade2: Line ".$rowid.": propalid=".$obj->rowid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." remise_global=".$remise_percent_global." -> ".$total_ht.", ".$total_tva.", ".$total_ttc); print ". "; $propalligne->update_total(); @@ -1683,9 +1683,9 @@ function migrate_price_contrat($db, $langs, $conf) { $db->begin(); - $tmpmysoc=new Societe($db); + $tmpmysoc = new Societe($db); $tmpmysoc->setMysoc($conf); - if (empty($tmpmysoc->country_id)) $tmpmysoc->country_id=0; // Ti not have this set to '' or will make sql syntax error. + if (empty($tmpmysoc->country_id)) $tmpmysoc->country_id = 0; // Ti not have this set to '' or will make sql syntax error. print ''; print ''; @@ -3722,7 +3722,7 @@ function migrate_categorie_association($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT fk_categorie_mere, fk_categorie_fille"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."categorie_association"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."categorie_association"; $resql = $db->query($sqlSelect); if ($resql) @@ -3737,11 +3737,11 @@ function migrate_categorie_association($db, $langs, $conf) $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."categorie SET "; - $sqlUpdate.= "fk_parent = ".$obj->fk_categorie_mere; - $sqlUpdate.= " WHERE rowid = ".$obj->fk_categorie_fille; + $sqlUpdate .= "fk_parent = ".$obj->fk_categorie_mere; + $sqlUpdate .= " WHERE rowid = ".$obj->fk_categorie_fille; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -3755,7 +3755,7 @@ function migrate_categorie_association($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if (! $error) + if (!$error) { // TODO DROP table in the next release /* @@ -3813,10 +3813,10 @@ function migrate_event_assignement($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT a.id, a.fk_user_action"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; - $sqlSelect.= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_resources as ar ON ar.fk_actioncomm = a.id AND ar.element_type = 'user' AND ar.fk_element = a.fk_user_action"; - $sqlSelect.= " WHERE fk_user_action > 0 AND fk_user_action NOT IN (SELECT fk_element FROM ".MAIN_DB_PREFIX."actioncomm_resources as ar WHERE ar.fk_actioncomm = a.id AND ar.element_type = 'user')"; - $sqlSelect.= " ORDER BY a.id"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; + $sqlSelect .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_resources as ar ON ar.fk_actioncomm = a.id AND ar.element_type = 'user' AND ar.fk_element = a.fk_user_action"; + $sqlSelect .= " WHERE fk_user_action > 0 AND fk_user_action NOT IN (SELECT fk_element FROM ".MAIN_DB_PREFIX."actioncomm_resources as ar WHERE ar.fk_actioncomm = a.id AND ar.element_type = 'user')"; + $sqlSelect .= " ORDER BY a.id"; //print $sqlSelect; $resql = $db->query($sqlSelect); @@ -3832,10 +3832,10 @@ function migrate_event_assignement($db, $langs, $conf) $obj = $db->fetch_object($resql); $sqlUpdate = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element) "; - $sqlUpdate.= "VALUES(".$obj->id.", 'user', ".$obj->fk_user_action.")"; + $sqlUpdate .= "VALUES(".$obj->id.", 'user', ".$obj->fk_user_action.")"; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -3849,7 +3849,7 @@ function migrate_event_assignement($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if (! $error) + if (!$error) { $db->commit(); } @@ -3890,10 +3890,10 @@ function migrate_event_assignement_contact($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT a.id, a.fk_contact"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; - $sqlSelect.= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_resources as ar ON ar.fk_actioncomm = a.id AND ar.element_type = 'socpeople' AND ar.fk_element = a.fk_contact"; - $sqlSelect.= " WHERE fk_contact > 0 AND fk_contact NOT IN (SELECT fk_element FROM ".MAIN_DB_PREFIX."actioncomm_resources as ar WHERE ar.fk_actioncomm = a.id AND ar.element_type = 'socpeople')"; - $sqlSelect.= " ORDER BY a.id"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; + $sqlSelect .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_resources as ar ON ar.fk_actioncomm = a.id AND ar.element_type = 'socpeople' AND ar.fk_element = a.fk_contact"; + $sqlSelect .= " WHERE fk_contact > 0 AND fk_contact NOT IN (SELECT fk_element FROM ".MAIN_DB_PREFIX."actioncomm_resources as ar WHERE ar.fk_actioncomm = a.id AND ar.element_type = 'socpeople')"; + $sqlSelect .= " ORDER BY a.id"; //print $sqlSelect; $resql = $db->query($sqlSelect); @@ -3909,10 +3909,10 @@ function migrate_event_assignement_contact($db, $langs, $conf) $obj = $db->fetch_object($resql); $sqlUpdate = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element) "; - $sqlUpdate.= "VALUES(".$obj->id.", 'socpeople', ".$obj->fk_contact.")"; + $sqlUpdate .= "VALUES(".$obj->id.", 'socpeople', ".$obj->fk_contact.")"; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -3926,7 +3926,7 @@ function migrate_event_assignement_contact($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if (! $error) + if (!$error) { $db->commit(); } @@ -3972,7 +3972,7 @@ function migrate_reset_blocked_log($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT DISTINCT entity"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."blockedlog"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."blockedlog"; //print $sqlSelect; @@ -4001,9 +4001,9 @@ function migrate_reset_blocked_log($db, $langs, $conf) print ' - Record for entity must be reset...'; $sqlUpdate = "DELETE FROM ".MAIN_DB_PREFIX."blockedlog"; - $sqlUpdate.= " WHERE entity = " . $obj->entity; - $resqlUpdate=$db->query($sqlUpdate); - if (! $resqlUpdate) + $sqlUpdate .= " WHERE entity = ".$obj->entity; + $resqlUpdate = $db->query($sqlUpdate); + if (!$resqlUpdate) { $error++; dol_print_error($db); @@ -4011,18 +4011,18 @@ function migrate_reset_blocked_log($db, $langs, $conf) else { // Add set line - $object=new stdClass(); + $object = new stdClass(); $object->id = 1; $object->element = 'module'; $object->ref = 'systemevent'; $object->entity = $obj->entity; $object->date = dol_now(); - $b=new BlockedLog($db); + $b = new BlockedLog($db); $b->setObjectData($object, 'MODULE_SET', 0); $res = $b->create($user); - if ($res<=0) { + if ($res <= 0) { $error++; } } @@ -4045,7 +4045,7 @@ function migrate_reset_blocked_log($db, $langs, $conf) print $langs->trans('NothingToDo')."
\n"; } - if (! $error) + if (!$error) { $db->commit(); } @@ -4086,8 +4086,8 @@ function migrate_remise_entity($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT sr.rowid, s.entity"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."societe_remise as sr, ".MAIN_DB_PREFIX."societe as s"; - $sqlSelect.= " WHERE sr.fk_soc = s.rowid and sr.entity != s.entity"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."societe_remise as sr, ".MAIN_DB_PREFIX."societe as s"; + $sqlSelect .= " WHERE sr.fk_soc = s.rowid and sr.entity != s.entity"; //print $sqlSelect; @@ -4104,11 +4104,11 @@ function migrate_remise_entity($db, $langs, $conf) $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."societe_remise SET"; - $sqlUpdate.= " entity = " . $obj->entity; - $sqlUpdate.= " WHERE rowid = " . $obj->rowid; + $sqlUpdate .= " entity = ".$obj->entity; + $sqlUpdate .= " WHERE rowid = ".$obj->rowid; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -4123,7 +4123,7 @@ function migrate_remise_entity($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if (! $error) + if (!$error) { $db->commit(); } @@ -4163,7 +4163,7 @@ function migrate_remise_except_entity($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT sr.rowid, sr.fk_soc, sr.fk_facture_source, sr.fk_facture, sr.fk_facture_line"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as sr"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as sr"; //print $sqlSelect; $resql = $db->query($sqlSelect); @@ -4183,21 +4183,21 @@ function migrate_remise_except_entity($db, $langs, $conf) $fk_facture = (!empty($obj->fk_facture_source) ? $obj->fk_facture_source : $obj->fk_facture); $sqlSelect2 = "SELECT f.entity"; - $sqlSelect2.= " FROM ".MAIN_DB_PREFIX."facture as f"; - $sqlSelect2.= " WHERE f.rowid = " . $fk_facture; + $sqlSelect2 .= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sqlSelect2 .= " WHERE f.rowid = ".$fk_facture; } elseif (!empty($obj->fk_facture_line)) { $sqlSelect2 = "SELECT f.entity"; - $sqlSelect2.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as fd"; - $sqlSelect2.= " WHERE fd.rowid = " . $obj->fk_facture_line; - $sqlSelect2.= " AND fd.fk_facture = f.rowid"; + $sqlSelect2 .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as fd"; + $sqlSelect2 .= " WHERE fd.rowid = ".$obj->fk_facture_line; + $sqlSelect2 .= " AND fd.fk_facture = f.rowid"; } else { $sqlSelect2 = "SELECT s.entity"; - $sqlSelect2.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sqlSelect2.= " WHERE s.rowid = " . $obj->fk_soc; + $sqlSelect2 .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sqlSelect2 .= " WHERE s.rowid = ".$obj->fk_soc; } $resql2 = $db->query($sqlSelect2); @@ -4208,11 +4208,11 @@ function migrate_remise_except_entity($db, $langs, $conf) $obj2 = $db->fetch_object($resql2); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."societe_remise_except SET"; - $sqlUpdate.= " entity = " . $obj2->entity; - $sqlUpdate.= " WHERE rowid = " . $obj->rowid; + $sqlUpdate .= " entity = ".$obj2->entity; + $sqlUpdate .= " WHERE rowid = ".$obj->rowid; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -4234,7 +4234,7 @@ function migrate_remise_except_entity($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if (! $error) + if (!$error) { $db->commit(); } @@ -4274,8 +4274,8 @@ function migrate_user_rights_entity($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT u.rowid, u.entity"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."user as u"; - $sqlSelect.= " WHERE u.entity > 1"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."user as u"; + $sqlSelect .= " WHERE u.entity > 1"; //print $sqlSelect; $resql = $db->query($sqlSelect); @@ -4291,11 +4291,11 @@ function migrate_user_rights_entity($db, $langs, $conf) $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."user_rights SET"; - $sqlUpdate.= " entity = " . $obj->entity; - $sqlUpdate.= " WHERE fk_user = " . $obj->rowid; + $sqlUpdate .= " entity = ".$obj->entity; + $sqlUpdate .= " WHERE fk_user = ".$obj->rowid; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -4310,7 +4310,7 @@ function migrate_user_rights_entity($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if (! $error) + if (!$error) { $db->commit(); } @@ -4350,8 +4350,8 @@ function migrate_usergroup_rights_entity($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT u.rowid, u.entity"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."usergroup as u"; - $sqlSelect.= " WHERE u.entity > 1"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."usergroup as u"; + $sqlSelect .= " WHERE u.entity > 1"; //print $sqlSelect; $resql = $db->query($sqlSelect); @@ -4367,11 +4367,11 @@ function migrate_usergroup_rights_entity($db, $langs, $conf) $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."usergroup_rights SET"; - $sqlUpdate.= " entity = " . $obj->entity; - $sqlUpdate.= " WHERE fk_usergroup = " . $obj->rowid; + $sqlUpdate .= " entity = ".$obj->entity; + $sqlUpdate .= " WHERE fk_usergroup = ".$obj->rowid; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -4386,7 +4386,7 @@ function migrate_usergroup_rights_entity($db, $langs, $conf) print $langs->trans('AlreadyDone')."
\n"; } - if (! $error) + if (!$error) { $db->commit(); } @@ -4419,9 +4419,9 @@ function migrate_rename_directories($db, $langs, $conf, $oldname, $newname) { dolibarr_install_syslog("upgrade2::migrate_rename_directories"); - if (is_dir(DOL_DATA_ROOT.$oldname) && ! file_exists(DOL_DATA_ROOT.$newname)) + if (is_dir(DOL_DATA_ROOT.$oldname) && !file_exists(DOL_DATA_ROOT.$newname)) { - dolibarr_install_syslog("upgrade2::migrate_rename_directories move " . DOL_DATA_ROOT . $oldname . ' into ' . DOL_DATA_ROOT . $newname); + dolibarr_install_syslog("upgrade2::migrate_rename_directories move ".DOL_DATA_ROOT.$oldname.' into '.DOL_DATA_ROOT.$newname); @rename(DOL_DATA_ROOT.$oldname, DOL_DATA_ROOT.$newname); } } @@ -4496,9 +4496,9 @@ function migrate_delete_old_files($db, $langs, $conf) $result = 1; if (file_exists(DOL_DOCUMENT_ROOT.$filetodelete)) { $result = dol_delete_file(DOL_DOCUMENT_ROOT.$filetodelete, 0, 0, 0, null, true, false); - if (! $result) { + if (!$result) { $langs->load("errors"); - print '
'.$langs->trans("Error").': '.$langs->trans("ErrorFailToDeleteFile", DOL_DOCUMENT_ROOT . $filetodelete); + print '
'.$langs->trans("Error").': '.$langs->trans("ErrorFailToDeleteFile", DOL_DOCUMENT_ROOT.$filetodelete); print ' '.$langs->trans("RemoveItManuallyAndPressF5ToContinue").'
'; } else { //print $langs->trans("FileWasRemoved", $filetodelete).'
'; @@ -4523,7 +4523,7 @@ function migrate_delete_old_dir($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_delete_old_dir"); // List of files to delete - $filetodeletearray=array( + $filetodeletearray = array( DOL_DOCUMENT_ROOT.'/core/modules/facture/terre', DOL_DOCUMENT_ROOT.'/core/modules/facture/mercure', ); @@ -4533,7 +4533,7 @@ function migrate_delete_old_dir($db, $langs, $conf) if (file_exists($filetodelete)) { $result = dol_delete_dir_recursive($filetodelete); } - if (! $result) { + if (!$result) { $langs->load("errors"); print '
'.$langs->trans("Error").': '.$langs->trans("ErrorFailToDeleteDir", $filetodelete); print ' '.$langs->trans("RemoveItManuallyAndPressF5ToContinue").'
'; @@ -4561,18 +4561,18 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo dolibarr_install_syslog("upgrade2::migrate_reload_modules force=".$force.", listofmodule=".join(',', array_keys($listofmodule))); - foreach($listofmodule as $moduletoreload => $reloadmode) // reloadmodule can be 'noboxes', 'newboxdefonly', 'forceactivate' + foreach ($listofmodule as $moduletoreload => $reloadmode) // reloadmodule can be 'noboxes', 'newboxdefonly', 'forceactivate' { - if (empty($moduletoreload) || (empty($conf->global->$moduletoreload) && ! $force)) continue; // Discard reload if module not enabled + if (empty($moduletoreload) || (empty($conf->global->$moduletoreload) && !$force)) continue; // Discard reload if module not enabled - $mod=null; + $mod = null; if ($moduletoreload == 'MAIN_MODULE_AGENDA') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Agenda module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modAgenda.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modAgenda.class.php'; if ($res) { - $mod=new modAgenda($db); + $mod = new modAgenda($db); $mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4580,9 +4580,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_API') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Rest API module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modApi.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modApi.class.php'; if ($res) { - $mod=new modApi($db); + $mod = new modApi($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4590,9 +4590,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_BARCODE') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Barcode module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modBarcode.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modBarcode.class.php'; if ($res) { - $mod=new modBarcode($db); + $mod = new modBarcode($db); $mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4600,9 +4600,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_CRON') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Cron module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modCron.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modCron.class.php'; if ($res) { - $mod=new modCron($db); + $mod = new modCron($db); $mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4610,9 +4610,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_SOCIETE') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Societe module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modSociete.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modSociete.class.php'; if ($res) { - $mod=new modSociete($db); + $mod = new modSociete($db); $mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4620,9 +4620,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_PRODUIT') // Permission has changed into 2.7 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Produit module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modProduct.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modProduct.class.php'; if ($res) { - $mod=new modProduct($db); + $mod = new modProduct($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4630,9 +4630,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_SERVICE') // Permission has changed into 2.7 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Service module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modService.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modService.class.php'; if ($res) { - $mod=new modService($db); + $mod = new modService($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4640,9 +4640,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_COMMANDE') // Permission has changed into 2.9 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Commande module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modCommande.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modCommande.class.php'; if ($res) { - $mod=new modCommande($db); + $mod = new modCommande($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4650,9 +4650,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_FACTURE') // Permission has changed into 2.9 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Facture module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modFacture.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modFacture.class.php'; if ($res) { - $mod=new modFacture($db); + $mod = new modFacture($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4660,9 +4660,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_FOURNISSEUR') // Permission has changed into 2.9 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Fournisseur module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modFournisseur.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modFournisseur.class.php'; if ($res) { - $mod=new modFournisseur($db); + $mod = new modFournisseur($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4670,9 +4670,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_HOLIDAY') // Permission and tabs has changed into 3.8 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Leave Request module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modHoliday.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modHoliday.class.php'; if ($res) { - $mod=new modHoliday($db); + $mod = new modHoliday($db); $mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4680,9 +4680,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_DEPLACEMENT') // Permission has changed into 3.0 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Deplacement module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modDeplacement.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modDeplacement.class.php'; if ($res) { - $mod=new modDeplacement($db); + $mod = new modDeplacement($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4690,9 +4690,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_DON') // Permission has changed into 3.0 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Don module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modDon.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modDon.class.php'; if ($res) { - $mod=new modDon($db); + $mod = new modDon($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4700,47 +4700,47 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo elseif ($moduletoreload == 'MAIN_MODULE_ECM') // Permission has changed into 3.0 and 3.1 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate ECM module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modECM.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modECM.class.php'; if ($res) { - $mod=new modECM($db); - $mod->remove('noboxes'); // We need to remove because a permission id has been removed + $mod = new modECM($db); + $mod->remove('noboxes'); // We need to remove because a permission id has been removed $mod->init($reloadmode); } } elseif ($moduletoreload == 'MAIN_MODULE_PAYBOX') // Permission has changed into 3.0 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Paybox module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modPaybox.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modPaybox.class.php'; if ($res) { - $mod=new modPaybox($db); - $mod->remove('noboxes'); // We need to remove because id of module has changed + $mod = new modPaybox($db); + $mod->remove('noboxes'); // We need to remove because id of module has changed $mod->init($reloadmode); } } elseif ($moduletoreload == 'MAIN_MODULE_SUPPLIERPROPOSAL') // Module after 3.5 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Supplier Proposal module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modSupplierProposal.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modSupplierProposal.class.php'; if ($res) { - $mod=new modSupplierProposal($db); - $mod->remove('noboxes'); // We need to remove because id of module has changed + $mod = new modSupplierProposal($db); + $mod->remove('noboxes'); // We need to remove because id of module has changed $mod->init($reloadmode); } } elseif ($moduletoreload == 'MAIN_MODULE_OPENSURVEY') // Permission has changed into 3.0 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Opensurvey module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modOpenSurvey.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modOpenSurvey.class.php'; if ($res) { - $mod=new modOpenSurvey($db); - $mod->remove('noboxes'); // We need to remove because menu entries has changed + $mod = new modOpenSurvey($db); + $mod->remove('noboxes'); // We need to remove because menu entries has changed $mod->init($reloadmode); } } else { $tmp = preg_match('/MAIN_MODULE_([a-zA-Z0-9]+)/', $moduletoreload, $reg); - if (! empty($reg[1])) + if (!empty($reg[1])) { if (strtoupper($moduletoreload) == $moduletoreload) // If key is un uppercase { @@ -4751,10 +4751,10 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo $moduletoreloadshort = $reg[1]; } dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module ".$moduletoreloadshort." with mode ".$reloadmode); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/mod'.$moduletoreloadshort.'.class.php'; + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/mod'.$moduletoreloadshort.'.class.php'; if ($res) { $classname = 'mod'.$moduletoreloadshort; - $mod=new $classname($db); + $mod = new $classname($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4762,10 +4762,10 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo { dolibarr_install_syslog('Failed to include '.DOL_DOCUMENT_ROOT.'/core/modules/mod'.$moduletoreloadshort.'.class.php'); - $res=@dol_include_once(strtolower($moduletoreloadshort).'/core/modules/mod'.$moduletoreloadshort.'.class.php'); + $res = @dol_include_once(strtolower($moduletoreloadshort).'/core/modules/mod'.$moduletoreloadshort.'.class.php'); if ($res) { $classname = 'mod'.$moduletoreloadshort; - $mod=new $classname($db); + $mod = new $classname($db); //$mod->remove('noboxes'); $mod->init($reloadmode); } @@ -4782,11 +4782,11 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo } } - if (! empty($mod) && is_object($mod)) + if (!empty($mod) && is_object($mod)) { print '
'; @@ -4811,11 +4811,11 @@ function migrate_reload_menu($db, $langs, $conf, $versionto) dolibarr_install_syslog("upgrade2::migrate_reload_menu"); // Define list of menu handlers to initialize - $listofmenuhandler=array(); + $listofmenuhandler = array(); if ($conf->global->MAIN_MENU_STANDARD == 'auguria_menu' || $conf->global->MAIN_MENU_SMARTPHONE == 'auguria_menu' || $conf->global->MAIN_MENUFRONT_STANDARD == 'auguria_menu' || $conf->global->MAIN_MENUFRONT_SMARTPHONE == 'auguria_menu') { - $listofmenuhandler['auguria']=1; // We set here only dynamic menu handlers + $listofmenuhandler['auguria'] = 1; // We set here only dynamic menu handlers } foreach ($listofmenuhandler as $key => $val) @@ -4828,10 +4828,10 @@ function migrate_reload_menu($db, $langs, $conf, $versionto) // Load sql ini_menu_handler.sql file $dir = DOL_DOCUMENT_ROOT."/core/menus/"; - $file='init_menu_'.$key.'.sql'; + $file = 'init_menu_'.$key.'.sql'; if (file_exists($dir.$file)) { - $result=run_sql($dir.$file, 1, '', 1, $key); + $result = run_sql($dir.$file, 1, '', 1, $key); } print ''; @@ -4854,9 +4854,9 @@ function migrate_user_photospath() include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; $fuser = new User($db); - if (! is_object($user)) $user = $fuser; // To avoid error during migration + if (!is_object($user)) $user = $fuser; // To avoid error during migration - $sql = "SELECT rowid as uid from ".MAIN_DB_PREFIX."user"; // Get list of all users + $sql = "SELECT rowid as uid from ".MAIN_DB_PREFIX."user"; // Get list of all users $resql = $db->query($sql); if ($resql) { @@ -4866,25 +4866,25 @@ function migrate_user_photospath() //echo '
'.$fuser->id.' -> '.$fuser->entity; $entity = (empty($fuser->entity) ? 1 : $fuser->entity); if ($entity > 1) { - $dir = DOL_DATA_ROOT . '/' . $entity . '/users'; + $dir = DOL_DATA_ROOT.'/'.$entity.'/users'; } else { - $dir = $conf->user->multidir_output[$entity]; // $conf->user->multidir_output[] for each entity is construct by the multicompany module + $dir = $conf->user->multidir_output[$entity]; // $conf->user->multidir_output[] for each entity is construct by the multicompany module } if ($dir) { //print "Process user id ".$fuser->id."
\n"; - $origin = $dir .'/'. get_exdir($fuser->id, 2, 0, 1, $fuser, 'user'); // Use old behaviour to get x/y path - $destin = $dir .'/'. $fuser->id; + $origin = $dir.'/'.get_exdir($fuser->id, 2, 0, 1, $fuser, 'user'); // Use old behaviour to get x/y path + $destin = $dir.'/'.$fuser->id; - $origin_osencoded=dol_osencode($origin); + $origin_osencoded = dol_osencode($origin); dol_mkdir($destin); //echo '
'.$origin.' -> '.$destin; if (dol_is_dir($origin)) { - $handle=opendir($origin_osencoded); + $handle = opendir($origin_osencoded); if (is_resource($handle)) { while (($file = readdir($handle)) !== false) @@ -4899,7 +4899,7 @@ function migrate_user_photospath() dol_mkdir($destin.'/'.$file); while (($thumb = readdir($thumbs)) !== false) { - if (! dol_is_file($destin.'/'.$file.'/'.$thumb)) + if (!dol_is_file($destin.'/'.$file.'/'.$thumb)) { if ($thumb == '.' || $thumb == '..') continue; @@ -4914,7 +4914,7 @@ function migrate_user_photospath() } else // it is a file { - if (! dol_is_file($destin.'/'.$file)) + if (!dol_is_file($destin.'/'.$file)) { //print $origin.'/'.$file.' -> '.$destin.'/'.$file.'
'."\n"; print '.'; diff --git a/htdocs/loan/calcmens.php b/htdocs/loan/calcmens.php index 5cde353105f..9a95ec9d438 100644 --- a/htdocs/loan/calcmens.php +++ b/htdocs/loan/calcmens.php @@ -22,42 +22,42 @@ * \brief File to return datables output */ -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); require '../main.inc.php'; require DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php'; -$mens=GETPOST('mens'); -$capital=GETPOST('capital'); -$rate=GETPOST('rate'); -$echance=GETPOST('echeance'); -$nbterm=GETPOST('nbterm'); +$mens = GETPOST('mens'); +$capital = GETPOST('capital'); +$rate = GETPOST('rate'); +$echance = GETPOST('echeance'); +$nbterm = GETPOST('nbterm'); top_httphead(); -$output=array(); +$output = array(); $object = new LoanSchedule($db); -$int = ($capital*($rate/12)); +$int = ($capital * ($rate / 12)); $int = round($int, 2, PHP_ROUND_HALF_UP); -$cap_rest = round($capital - ($mens-$int), 2, PHP_ROUND_HALF_UP); -$output[$echance]=array('cap_rest'=>$cap_rest,'cap_rest_str'=>price($cap_rest),'interet'=>$int,'interet_str'=>price($int, 0, '', 1),'mens'=>$mens); +$cap_rest = round($capital - ($mens - $int), 2, PHP_ROUND_HALF_UP); +$output[$echance] = array('cap_rest'=>$cap_rest, 'cap_rest_str'=>price($cap_rest), 'interet'=>$int, 'interet_str'=>price($int, 0, '', 1), 'mens'=>$mens); $echance++; -$capital=$cap_rest; -while ($echance<=$nbterm) { - $mens = round($object->calcMonthlyPayments($capital, $rate, $nbterm-$echance+1), 2, PHP_ROUND_HALF_UP); +$capital = $cap_rest; +while ($echance <= $nbterm) { + $mens = round($object->calcMonthlyPayments($capital, $rate, $nbterm - $echance + 1), 2, PHP_ROUND_HALF_UP); - $int = ($capital*($rate/12)); + $int = ($capital * ($rate / 12)); $int = round($int, 2, PHP_ROUND_HALF_UP); - $cap_rest = round($capital - ($mens-$int), 2, PHP_ROUND_HALF_UP); + $cap_rest = round($capital - ($mens - $int), 2, PHP_ROUND_HALF_UP); - $output[$echance]=array('cap_rest'=>$cap_rest,'cap_rest_str'=>price($cap_rest),'interet'=>$int,'interet_str'=>price($int, 0, '', 1),'mens'=>$mens); + $output[$echance] = array('cap_rest'=>$cap_rest, 'cap_rest_str'=>price($cap_rest), 'interet'=>$int, 'interet_str'=>price($int, 0, '', 1), 'mens'=>$mens); - $capital=$cap_rest; + $capital = $cap_rest; $echance++; } diff --git a/htdocs/opensurvey/wizard/choix_autre.php b/htdocs/opensurvey/wizard/choix_autre.php index a8a1f8248d1..f8a3e13b80a 100644 --- a/htdocs/opensurvey/wizard/choix_autre.php +++ b/htdocs/opensurvey/wizard/choix_autre.php @@ -40,19 +40,19 @@ if (!$user->rights->opensurvey->write) accessforbidden(); if (isset($_SESSION["nbrecases"])) { for ($i = 0; $i < $_SESSION["nbrecases"]; $i++) { if (isset($_POST["choix"][$i])) { - $_SESSION["choix$i"]=$_POST["choix"][$i]; + $_SESSION["choix$i"] = $_POST["choix"][$i]; } if (isset($_POST["typecolonne"][$i])) { - $_SESSION["typecolonne$i"]=$_POST["typecolonne"][$i]; + $_SESSION["typecolonne$i"] = $_POST["typecolonne"][$i]; } } } else { //nombre de cases par défaut - $_SESSION["nbrecases"]=5; + $_SESSION["nbrecases"] = 5; } if (GETPOST("ajoutcases") || GETPOST("ajoutcases_x")) { - $_SESSION["nbrecases"]=$_SESSION["nbrecases"]+5; + $_SESSION["nbrecases"] = $_SESSION["nbrecases"] + 5; } // Create survey into database @@ -62,23 +62,23 @@ if (isset($_POST["confirmecreation"])) $toutchoix = ''; for ($i = 0; $i < $_SESSION["nbrecases"] + 1; $i++) { - if (! empty($_POST["choix"][$i])) + if (!empty($_POST["choix"][$i])) { - $toutchoix.=','; - $toutchoix.=str_replace(array(",","@"), " ", $_POST["choix"][$i]).(empty($_POST["typecolonne"][$i])?'':'@'.$_POST["typecolonne"][$i]); + $toutchoix .= ','; + $toutchoix .= str_replace(array(",", "@"), " ", $_POST["choix"][$i]).(empty($_POST["typecolonne"][$i]) ? '' : '@'.$_POST["typecolonne"][$i]); } } - $toutchoix=substr("$toutchoix", 1); - $_SESSION["toutchoix"]=$toutchoix; + $toutchoix = substr("$toutchoix", 1); + $_SESSION["toutchoix"] = $toutchoix; //test de remplissage des cases $testremplissage = ''; - for ($i=0;$i<$_SESSION["nbrecases"];$i++) + for ($i = 0; $i < $_SESSION["nbrecases"]; $i++) { if (isset($_POST["choix"][$i])) { - $testremplissage="ok"; + $testremplissage = "ok"; } } @@ -87,7 +87,7 @@ if (isset($_POST["confirmecreation"])) setEventMessages($langs->trans("ErrorOpenSurveyOneChoice"), null, 'errors'); } else { //format du sondage AUTRE - $_SESSION["formatsondage"]="A"; + $_SESSION["formatsondage"] = "A"; // Add into database ajouter_sondage(); @@ -101,10 +101,10 @@ if (isset($_POST["confirmecreation"])) * View */ -$form=new Form($db); +$form = new Form($db); -$arrayofjs=array(); -$arrayofcss=array('/opensurvey/css/style.css'); +$arrayofjs = array(); +$arrayofcss = array('/opensurvey/css/style.css'); llxHeader('', $langs->trans("OpenSurvey"), "", '', 0, 0, $arrayofjs, $arrayofcss); if (empty($_SESSION['titre'])) @@ -123,7 +123,7 @@ print ''."\n"; print load_fiche_titre($langs->trans("CreatePoll").' (2 / 2)'); -print '
'. $langs->trans("PollOnChoice") .'

'."\n"; +print '
'.$langs->trans("PollOnChoice").'

'."\n"; print '
'."\n"; print '
'.$langs->trans("ErrorFailedToConnectToDatabase", $conf->db->name).''.$langs->trans('Error').'
'; print ''.$langs->trans('UpgradeExternalModule').': '.$langs->trans("None"); @@ -560,8 +560,8 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a // Copy directory medias - $srcroot=DOL_DOCUMENT_ROOT.'/install/medias'; - $destroot=DOL_DATA_ROOT.'/medias'; + $srcroot = DOL_DOCUMENT_ROOT.'/install/medias'; + $destroot = DOL_DATA_ROOT.'/medias'; dolCopyDir($srcroot, $destroot, 0, 0); @@ -581,12 +581,12 @@ else $error++; } -$ret=0; -if ($error && isset($argv[1])) $ret=1; +$ret = 0; +if ($error && isset($argv[1])) $ret = 1; dolibarr_install_syslog("Exit ".$ret); dolibarr_install_syslog("--- upgrade2: end"); -pFooter($error?2:0, $setuplang); +pFooter($error ? 2 : 0, $setuplang); if ($db->connected) $db->close(); @@ -630,7 +630,7 @@ function migrate_paiements($db, $langs, $conf) while ($i < $num) { $obj = $db->fetch_object($resql); - $row[$i][0] = $obj->rowid ; + $row[$i][0] = $obj->rowid; $row[$i][1] = $obj->fk_facture; $row[$i][2] = $obj->amount; $i++; @@ -647,11 +647,11 @@ function migrate_paiements($db, $langs, $conf) if ($db->begin()) { $res = 0; - $num=count($row); + $num = count($row); for ($i = 0; $i < $num; $i++) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount)"; - $sql.= " VALUES (".$row[$i][1].",".$row[$i][0].",".$row[$i][2].")"; + $sql .= " VALUES (".$row[$i][1].",".$row[$i][0].",".$row[$i][2].")"; $res += $db->query($sql); @@ -710,13 +710,13 @@ function migrate_paiements_orphelins_1($db, $langs, $conf) { // Tous les enregistrements qui sortent de cette requete devrait avoir un pere dans llx_paiement_facture $sql = "SELECT distinct p.rowid, p.datec, p.amount as pamount, bu.fk_bank, b.amount as bamount,"; - $sql.= " bu2.url_id as socid"; - $sql.= " FROM (".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."bank_url as bu, ".MAIN_DB_PREFIX."bank as b)"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON pf.fk_paiement = p.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON (bu.fk_bank=bu2.fk_bank AND bu2.type = 'company')"; - $sql.= " WHERE pf.rowid IS NULL AND (p.rowid=bu.url_id AND bu.type='payment') AND bu.fk_bank = b.rowid"; - $sql.= " AND b.rappro = 1"; - $sql.= " AND (p.fk_facture = 0 OR p.fk_facture IS NULL)"; + $sql .= " bu2.url_id as socid"; + $sql .= " FROM (".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."bank_url as bu, ".MAIN_DB_PREFIX."bank as b)"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON pf.fk_paiement = p.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON (bu.fk_bank=bu2.fk_bank AND bu2.type = 'company')"; + $sql .= " WHERE pf.rowid IS NULL AND (p.rowid=bu.url_id AND bu.type='payment') AND bu.fk_bank = b.rowid"; + $sql .= " AND b.rappro = 1"; + $sql .= " AND (p.fk_facture = 0 OR p.fk_facture IS NULL)"; $resql = $db->query($sql); @@ -732,7 +732,7 @@ function migrate_paiements_orphelins_1($db, $langs, $conf) $obj = $db->fetch_object($resql); if ($obj->pamount == $obj->bamount && $obj->socid) // Pour etre sur d'avoir bon cas { - $row[$j]['paymentid'] = $obj->rowid ; // paymentid + $row[$j]['paymentid'] = $obj->rowid; // paymentid $row[$j]['pamount'] = $obj->pamount; $row[$j]['fk_bank'] = $obj->fk_bank; $row[$j]['bamount'] = $obj->bamount; @@ -754,30 +754,30 @@ function migrate_paiements_orphelins_1($db, $langs, $conf) $db->begin(); $res = 0; - $num=count($row); + $num = count($row); for ($i = 0; $i < $num; $i++) { if ($conf->global->MAIN_FEATURES_LEVEL == 2) print '* '.$row[$i]['datec'].' paymentid='.$row[$i]['paymentid'].' pamount='.$row[$i]['pamount'].' fk_bank='.$row[$i]['fk_bank'].' bamount='.$row[$i]['bamount'].' socid='.$row[$i]['socid'].'
'; // On cherche facture sans lien paiement et du meme montant et pour meme societe. - $sql=" SELECT distinct f.rowid from ".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_statut in (2,3) AND fk_soc = ".$row[$i]['socid']." AND total_ttc = ".$row[$i]['pamount']; - $sql.=" AND pf.fk_facture IS NULL"; - $sql.=" ORDER BY f.fk_statut"; + $sql = " SELECT distinct f.rowid from ".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_statut in (2,3) AND fk_soc = ".$row[$i]['socid']." AND total_ttc = ".$row[$i]['pamount']; + $sql .= " AND pf.fk_facture IS NULL"; + $sql .= " ORDER BY f.fk_statut"; //print $sql.'
'; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); //print 'Nb of invoice found for this amount and company :'.$num.'
'; if ($num >= 1) { - $obj=$db->fetch_object($resql); - $facid=$obj->rowid; + $obj = $db->fetch_object($resql); + $facid = $obj->rowid; $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount)"; - $sql.= " VALUES (".$facid.",".$row[$i]['paymentid'].",".$row[$i]['pamount'].")"; + $sql .= " VALUES (".$facid.",".$row[$i]['paymentid'].",".$row[$i]['pamount'].")"; $res += $db->query($sql); @@ -837,12 +837,12 @@ function migrate_paiements_orphelins_2($db, $langs, $conf) { // Tous les enregistrements qui sortent de cette requete devrait avoir un pere dans llx_paiement_facture $sql = "SELECT distinct p.rowid, p.datec, p.amount as pamount, bu.fk_bank, b.amount as bamount,"; - $sql.= " bu2.url_id as socid"; - $sql.= " FROM (".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."bank_url as bu, ".MAIN_DB_PREFIX."bank as b)"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON pf.fk_paiement = p.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON (bu.fk_bank = bu2.fk_bank AND bu2.type = 'company')"; - $sql.= " WHERE pf.rowid IS NULL AND (p.fk_bank = bu.fk_bank AND bu.type = 'payment') AND bu.fk_bank = b.rowid"; - $sql.= " AND (p.fk_facture = 0 OR p.fk_facture IS NULL)"; + $sql .= " bu2.url_id as socid"; + $sql .= " FROM (".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."bank_url as bu, ".MAIN_DB_PREFIX."bank as b)"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON pf.fk_paiement = p.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON (bu.fk_bank = bu2.fk_bank AND bu2.type = 'company')"; + $sql .= " WHERE pf.rowid IS NULL AND (p.fk_bank = bu.fk_bank AND bu.type = 'payment') AND bu.fk_bank = b.rowid"; + $sql .= " AND (p.fk_facture = 0 OR p.fk_facture IS NULL)"; $resql = $db->query($sql); @@ -858,7 +858,7 @@ function migrate_paiements_orphelins_2($db, $langs, $conf) $obj = $db->fetch_object($resql); if ($obj->pamount == $obj->bamount && $obj->socid) // Pour etre sur d'avoir bon cas { - $row[$j]['paymentid'] = $obj->rowid ; // paymentid + $row[$j]['paymentid'] = $obj->rowid; // paymentid $row[$j]['pamount'] = $obj->pamount; $row[$j]['fk_bank'] = $obj->fk_bank; $row[$j]['bamount'] = $obj->bamount; @@ -874,9 +874,9 @@ function migrate_paiements_orphelins_2($db, $langs, $conf) dol_print_error($db); } - $nberr=0; + $nberr = 0; - $num=count($row); + $num = count($row); if ($num) { print $langs->trans('OrphelinsPaymentsDetectedByMethod', 2).': '.count($row)."
\n"; @@ -888,24 +888,24 @@ function migrate_paiements_orphelins_2($db, $langs, $conf) if ($conf->global->MAIN_FEATURES_LEVEL == 2) print '* '.$row[$i]['datec'].' paymentid='.$row[$i]['paymentid'].' '.$row[$i]['pamount'].' fk_bank='.$row[$i]['fk_bank'].' '.$row[$i]['bamount'].' socid='.$row[$i]['socid'].'
'; // On cherche facture sans lien paiement et du meme montant et pour meme societe. - $sql=" SELECT distinct f.rowid from ".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_statut in (2,3) AND fk_soc = ".$row[$i]['socid']." AND total_ttc = ".$row[$i]['pamount']; - $sql.=" AND pf.fk_facture IS NULL"; - $sql.=" ORDER BY f.fk_statut"; + $sql = " SELECT distinct f.rowid from ".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_statut in (2,3) AND fk_soc = ".$row[$i]['socid']." AND total_ttc = ".$row[$i]['pamount']; + $sql .= " AND pf.fk_facture IS NULL"; + $sql .= " ORDER BY f.fk_statut"; //print $sql.'
'; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); //print 'Nb of invoice found for this amount and company :'.$num.'
'; if ($num >= 1) { - $obj=$db->fetch_object($resql); - $facid=$obj->rowid; + $obj = $db->fetch_object($resql); + $facid = $obj->rowid; $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement_facture (fk_facture, fk_paiement, amount)"; - $sql.= " VALUES (".$facid.",".$row[$i]['paymentid'].",".$row[$i]['pamount'].")"; + $sql .= " VALUES (".$facid.",".$row[$i]['paymentid'].",".$row[$i]['pamount'].")"; $res += $db->query($sql); print $langs->trans('MigrationProcessPaymentUpdate', 'facid='.$facid.'-paymentid='.$row[$i]['paymentid'].'-amount='.$row[$i]['pamount'])."
\n"; @@ -971,19 +971,19 @@ function migrate_contracts_det($db, $langs, $conf) { print '
'; - $nberr=0; + $nberr = 0; print '
'; print ''.$langs->trans('MigrationContractsUpdate')."
\n"; $sql = "SELECT c.rowid as cref, c.date_contrat, c.statut, c.mise_en_service, c.fin_validite, c.date_cloture, c.fk_product, c.fk_facture, c.fk_user_author,"; - $sql.= " p.ref, p.label, p.description, p.price, p.tva_tx, p.duration, cd.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p"; - $sql.= " ON c.fk_product = p.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd"; - $sql.= " ON c.rowid=cd.fk_contrat"; - $sql.= " WHERE cd.rowid IS NULL AND p.rowid IS NOT NULL"; + $sql .= " p.ref, p.label, p.description, p.price, p.tva_tx, p.duration, cd.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p"; + $sql .= " ON c.fk_product = p.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd"; + $sql .= " ON c.rowid=cd.fk_contrat"; + $sql .= " WHERE cd.rowid IS NULL AND p.rowid IS NOT NULL"; $resql = $db->query($sql); dolibarr_install_syslog("upgrade2::migrate_contracts_det"); @@ -1003,20 +1003,20 @@ function migrate_contracts_det($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."contratdet ("; - $sql.= "fk_contrat, fk_product, statut, label, description,"; - $sql.= "date_ouverture_prevue, date_ouverture, date_fin_validite, tva_tx, qty,"; - $sql.= "subprice, price_ht, fk_user_author, fk_user_ouverture)"; - $sql.= " VALUES ("; - $sql.= $obj->cref.",".($obj->fk_product?$obj->fk_product:0).","; - $sql.= ($obj->mise_en_service?"4":"0").","; - $sql.= "'".$db->escape($obj->label)."', null,"; - $sql.= ($obj->mise_en_service?"'".$obj->mise_en_service."'":($obj->date_contrat?"'".$obj->date_contrat."'":"null")).","; - $sql.= ($obj->mise_en_service?"'".$obj->mise_en_service."'":"null").","; - $sql.= ($obj->fin_validite?"'".$obj->fin_validite."'":"null").","; - $sql.= "'".$obj->tva_tx."', 1,"; - $sql.= "'".$obj->price."', '".$obj->price."',".$obj->fk_user_author.","; - $sql.= ($obj->mise_en_service?$obj->fk_user_author:"null"); - $sql.= ")"; + $sql .= "fk_contrat, fk_product, statut, label, description,"; + $sql .= "date_ouverture_prevue, date_ouverture, date_fin_validite, tva_tx, qty,"; + $sql .= "subprice, price_ht, fk_user_author, fk_user_ouverture)"; + $sql .= " VALUES ("; + $sql .= $obj->cref.",".($obj->fk_product ? $obj->fk_product : 0).","; + $sql .= ($obj->mise_en_service ? "4" : "0").","; + $sql .= "'".$db->escape($obj->label)."', null,"; + $sql .= ($obj->mise_en_service ? "'".$obj->mise_en_service."'" : ($obj->date_contrat ? "'".$obj->date_contrat."'" : "null")).","; + $sql .= ($obj->mise_en_service ? "'".$obj->mise_en_service."'" : "null").","; + $sql .= ($obj->fin_validite ? "'".$obj->fin_validite."'" : "null").","; + $sql .= "'".$obj->tva_tx."', 1,"; + $sql .= "'".$obj->price."', '".$obj->price."',".$obj->fk_user_author.","; + $sql .= ($obj->mise_en_service ? $obj->fk_user_author : "null"); + $sql .= ")"; if ($db->query($sql)) { @@ -1031,7 +1031,7 @@ function migrate_contracts_det($db, $langs, $conf) $i++; } - if (! $nberr) + if (!$nberr) { // $db->rollback(); $db->commit(); @@ -1069,17 +1069,17 @@ function migrate_links_transfert($db, $langs, $conf) { print '
'; - $nberr=0; + $nberr = 0; print '
'; print ''.$langs->trans('MigrationBankTransfertsUpdate')."
\n"; $sql = "SELECT ba.rowid as barowid, bb.rowid as bbrowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as bb, ".MAIN_DB_PREFIX."bank as ba"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = ba.rowid"; - $sql.= " WHERE ba.amount = -bb.amount AND ba.fk_account <> bb.fk_account"; - $sql.= " AND ba.datev = bb.datev AND ba.datec = bb.datec"; - $sql.= " AND bu.fk_bank IS NULL"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as bb, ".MAIN_DB_PREFIX."bank as ba"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = ba.rowid"; + $sql .= " WHERE ba.amount = -bb.amount AND ba.fk_account <> bb.fk_account"; + $sql .= " AND ba.datev = bb.datev AND ba.datec = bb.datec"; + $sql .= " AND bu.fk_bank IS NULL"; $resql = $db->query($sql); dolibarr_install_syslog("upgrade2::migrate_links_transfert"); @@ -1099,16 +1099,16 @@ function migrate_links_transfert($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_url ("; - $sql.= "fk_bank, url_id, url, label, type"; - $sql.= ")"; - $sql.= " VALUES ("; - $sql.= $obj->barowid.",".$obj->bbrowid.", '/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'"; - $sql.= ")"; + $sql .= "fk_bank, url_id, url, label, type"; + $sql .= ")"; + $sql .= " VALUES ("; + $sql .= $obj->barowid.",".$obj->bbrowid.", '/compta/bank/line.php?rowid=', '(banktransfert)', 'banktransfert'"; + $sql .= ")"; print $sql.'
'; dolibarr_install_syslog("migrate_links_transfert"); - if (! $db->query($sql)) + if (!$db->query($sql)) { dol_print_error($db); $nberr++; @@ -1117,7 +1117,7 @@ function migrate_links_transfert($db, $langs, $conf) $i++; } - if (! $nberr) + if (!$nberr) { // $db->rollback(); $db->commit(); @@ -1156,19 +1156,19 @@ function migrate_contracts_date1($db, $langs, $conf) print '
'; print ''.$langs->trans('MigrationContractsEmptyDatesUpdate')."
\n"; - $sql="update ".MAIN_DB_PREFIX."contrat set date_contrat=tms where date_contrat is null"; + $sql = "update ".MAIN_DB_PREFIX."contrat set date_contrat=tms where date_contrat is null"; dolibarr_install_syslog("upgrade2::migrate_contracts_date1"); $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); if ($db->affected_rows($resql) > 0) print $langs->trans('MigrationContractsEmptyDatesUpdateSuccess')."
\n"; else print $langs->trans('MigrationContractsEmptyDatesNothingToUpdate')."
\n"; - $sql="update ".MAIN_DB_PREFIX."contrat set datec=tms where datec is null"; + $sql = "update ".MAIN_DB_PREFIX."contrat set datec=tms where datec is null"; dolibarr_install_syslog("upgrade2::migrate_contracts_date1"); $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); if ($db->affected_rows($resql) > 0) print $langs->trans('MigrationContractsEmptyCreationDatesUpdateSuccess')."
\n"; else @@ -1184,16 +1184,16 @@ function migrate_contracts_date2($db, $langs, $conf) { print '
'; - $nberr=0; + $nberr = 0; print '
'; print ''.$langs->trans('MigrationContractsInvalidDatesUpdate')."
\n"; $sql = "SELECT c.rowid as cref, c.datec, c.date_contrat, MIN(cd.date_ouverture) as datemin"; - $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c,"; - $sql.= " ".MAIN_DB_PREFIX."contratdet as cd"; - $sql.= " WHERE c.rowid=cd.fk_contrat AND cd.date_ouverture IS NOT NULL"; - $sql.= " GROUP BY c.rowid, c.date_contrat"; + $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c,"; + $sql .= " ".MAIN_DB_PREFIX."contratdet as cd"; + $sql .= " WHERE c.rowid=cd.fk_contrat AND cd.date_ouverture IS NOT NULL"; + $sql .= " GROUP BY c.rowid, c.date_contrat"; $resql = $db->query($sql); dolibarr_install_syslog("upgrade2::migrate_contracts_date2"); @@ -1205,7 +1205,7 @@ function migrate_contracts_date2($db, $langs, $conf) if ($num) { - $nbcontratsmodifie=0; + $nbcontratsmodifie = 0; $db->begin(); while ($i < $num) @@ -1214,11 +1214,11 @@ function migrate_contracts_date2($db, $langs, $conf) if ($obj->date_contrat > $obj->datemin) { print $langs->trans('MigrationContractsInvalidDateFix', $obj->cref, $obj->date_contrat, $obj->datemin)."
\n"; - $sql ="UPDATE ".MAIN_DB_PREFIX."contrat"; - $sql.=" SET date_contrat='".$obj->datemin."'"; - $sql.=" WHERE rowid=".$obj->cref; - $resql2=$db->query($sql); - if (! $resql2) dol_print_error($db); + $sql = "UPDATE ".MAIN_DB_PREFIX."contrat"; + $sql .= " SET date_contrat='".$obj->datemin."'"; + $sql .= " WHERE rowid=".$obj->cref; + $resql2 = $db->query($sql); + if (!$resql2) dol_print_error($db); $nbcontratsmodifie++; } @@ -1256,10 +1256,10 @@ function migrate_contracts_date3($db, $langs, $conf) print '
'; print ''.$langs->trans('MigrationContractsIncoherentCreationDateUpdate')."
\n"; - $sql="update ".MAIN_DB_PREFIX."contrat set datec=date_contrat where datec is null or datec > date_contrat"; + $sql = "update ".MAIN_DB_PREFIX."contrat set datec=date_contrat where datec is null or datec > date_contrat"; dolibarr_install_syslog("upgrade2::migrate_contracts_date3"); $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); if ($db->affected_rows($resql) > 0) print $langs->trans('MigrationContractsIncoherentCreationDateUpdateSuccess')."
\n"; else @@ -1284,10 +1284,10 @@ function migrate_contracts_open($db, $langs, $conf) print ''.$langs->trans('MigrationReopeningContracts')."
\n"; $sql = "SELECT c.rowid as cref FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."contratdet as cd"; - $sql.= " WHERE cd.statut = 4 AND c.statut=2 AND c.rowid=cd.fk_contrat"; + $sql .= " WHERE cd.statut = 4 AND c.statut=2 AND c.rowid=cd.fk_contrat"; dolibarr_install_syslog("upgrade2::migrate_contracts_open"); $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); if ($db->affected_rows($resql) > 0) { $i = 0; $row = array(); @@ -1295,7 +1295,7 @@ function migrate_contracts_open($db, $langs, $conf) if ($num) { - $nbcontratsmodifie=0; + $nbcontratsmodifie = 0; $db->begin(); while ($i < $num) @@ -1303,11 +1303,11 @@ function migrate_contracts_open($db, $langs, $conf) $obj = $db->fetch_object($resql); print $langs->trans('MigrationReopenThisContract', $obj->cref)."
\n"; - $sql ="UPDATE ".MAIN_DB_PREFIX."contrat"; - $sql.=" SET statut=1"; - $sql.=" WHERE rowid=".$obj->cref; - $resql2=$db->query($sql); - if (! $resql2) dol_print_error($db); + $sql = "UPDATE ".MAIN_DB_PREFIX."contrat"; + $sql .= " SET statut=1"; + $sql .= " WHERE rowid=".$obj->cref; + $resql2 = $db->query($sql); + if (!$resql2) dol_print_error($db); $nbcontratsmodifie++; @@ -1348,31 +1348,31 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf) $obj = $db->fetch_object($result); if ($obj) { - $error=0; - $nb=0; + $error = 0; + $nb = 0; $select_sql = 'SELECT rowid, fk_facture_fourn, amount'; - $select_sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn'; - $select_sql.= ' WHERE fk_facture_fourn IS NOT NULL'; + $select_sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn'; + $select_sql .= ' WHERE fk_facture_fourn IS NOT NULL'; dolibarr_install_syslog("upgrade2::migrate_paiementfourn_facturefourn"); $select_resql = $db->query($select_sql); if ($select_resql) { $select_num = $db->num_rows($select_resql); - $i=0; + $i = 0; $var = true; // Pour chaque paiement fournisseur, on insere une ligne dans paiementfourn_facturefourn - while (($i < $select_num) && (! $error)) + while (($i < $select_num) && (!$error)) { $var = !$var; $select_obj = $db->fetch_object($select_resql); // Verifier si la ligne est deja dans la nouvelle table. On ne veut pas inserer de doublons. $check_sql = 'SELECT fk_paiementfourn, fk_facturefourn'; - $check_sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn'; - $check_sql.= ' WHERE fk_paiementfourn = '.$select_obj->rowid.' AND fk_facturefourn = '.$select_obj->fk_facture_fourn; + $check_sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn'; + $check_sql .= ' WHERE fk_paiementfourn = '.$select_obj->rowid.' AND fk_facturefourn = '.$select_obj->fk_facture_fourn; $check_resql = $db->query($check_sql); if ($check_resql) { @@ -1391,9 +1391,9 @@ function migrate_paiementfourn_facturefourn($db, $langs, $conf) print '
'.$select_obj->rowid.''.$select_obj->fk_facture_fourn.''.$select_obj->amount.'
'; @@ -1694,13 +1694,13 @@ function migrate_price_contrat($db, $langs, $conf) // List of contract lines not up to date $sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as vatrate, cd.info_bits,"; - $sql.= " c.rowid as contratid"; - $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c"; - $sql.= " WHERE cd.fk_contrat = c.rowid"; - $sql.= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100 AND cd.subprice > 0) or cd.total_ttc IS NULL)"; + $sql .= " c.rowid as contratid"; + $sql .= " FROM ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c"; + $sql .= " WHERE cd.fk_contrat = c.rowid"; + $sql .= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100 AND cd.subprice > 0) or cd.total_ttc IS NULL)"; dolibarr_install_syslog("upgrade2::migrate_price_contrat"); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -1719,11 +1719,11 @@ function migrate_price_contrat($db, $langs, $conf) $info_bits = $obj->info_bits; // On met a jour les 3 nouveaux champs - $contratligne= new ContratLigne($db); + $contratligne = new ContratLigne($db); //$contratligne->fetch($rowid); Non requis car le update_total ne met a jour que chp redefinis $contratligne->fetch($rowid); - $result=calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, 0, 'HT', $info_bits, $contratligne->product_type, $tmpmysoc); + $result = calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, 0, 'HT', $info_bits, $contratligne->product_type, $tmpmysoc); $total_ht = $result[0]; $total_tva = $result[1]; $total_ttc = $result[2]; @@ -1732,7 +1732,7 @@ function migrate_price_contrat($db, $langs, $conf) $contratligne->total_tva = $total_tva; $contratligne->total_ttc = $total_ttc; - dolibarr_install_syslog("upgrade2: Line " . $rowid . ": contratdetid=" . $obj->rowid . " pu=" . $pu . " qty=" . $qty . " vatrate=" . $vatrate . " remise_percent=" . $remise_percent. " -> " . $total_ht . ", " . $total_tva. " , " . $total_ttc); + dolibarr_install_syslog("upgrade2: Line ".$rowid.": contratdetid=".$obj->rowid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." -> ".$total_ht.", ".$total_tva." , ".$total_ttc); print ". "; $contratligne->update_total(); @@ -1772,7 +1772,7 @@ function migrate_price_commande($db, $langs, $conf) { $db->begin(); - $tmpmysoc=new Societe($db); + $tmpmysoc = new Societe($db); $tmpmysoc->setMysoc($conf); print '
'; @@ -1782,13 +1782,13 @@ function migrate_price_commande($db, $langs, $conf) // List of sales orders lines not up to date $sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as vatrate, cd.info_bits,"; - $sql.= " c.rowid as commandeid, c.remise_percent as remise_percent_global"; - $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."commande as c"; - $sql.= " WHERE cd.fk_commande = c.rowid"; - $sql.= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100) or cd.total_ttc IS NULL)"; + $sql .= " c.rowid as commandeid, c.remise_percent as remise_percent_global"; + $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."commande as c"; + $sql .= " WHERE cd.fk_commande = c.rowid"; + $sql .= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100) or cd.total_ttc IS NULL)"; dolibarr_install_syslog("upgrade2::migrate_price_commande"); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -1808,10 +1808,10 @@ function migrate_price_commande($db, $langs, $conf) $info_bits = $obj->info_bits; // On met a jour les 3 nouveaux champs - $commandeligne= new OrderLine($db); + $commandeligne = new OrderLine($db); $commandeligne->fetch($rowid); - $result=calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $commandeligne->product_type, $tmpmysoc); + $result = calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $commandeligne->product_type, $tmpmysoc); $total_ht = $result[0]; $total_tva = $result[1]; $total_ttc = $result[2]; @@ -1820,7 +1820,7 @@ function migrate_price_commande($db, $langs, $conf) $commandeligne->total_tva = $total_tva; $commandeligne->total_ttc = $total_ttc; - dolibarr_install_syslog("upgrade2: Line " . $rowid . " : commandeid=" . $obj->rowid . " pu=" . $pu . " qty=" . $qty . " vatrate=" . $vatrate . " remise_percent=" . $remise_percent . " remise_global=" . $remise_percent_global. " -> " . $total_ht . ", " . $total_tva . ", " . $total_ttc); + dolibarr_install_syslog("upgrade2: Line ".$rowid." : commandeid=".$obj->rowid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." remise_global=".$remise_percent_global." -> ".$total_ht.", ".$total_tva.", ".$total_ttc); print ". "; $commandeligne->update_total(); @@ -1889,7 +1889,7 @@ function migrate_price_commande_fournisseur($db, $langs, $conf) { $db->begin(); - $tmpmysoc=new Societe($db); + $tmpmysoc = new Societe($db); $tmpmysoc->setMysoc($conf); print '
'; @@ -1899,13 +1899,13 @@ function migrate_price_commande_fournisseur($db, $langs, $conf) // List of purchase order lines not up to date $sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as vatrate, cd.info_bits,"; - $sql.= " c.rowid as commandeid, c.remise_percent as remise_percent_global"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd, ".MAIN_DB_PREFIX."commande_fournisseur as c"; - $sql.= " WHERE cd.fk_commande = c.rowid"; - $sql.= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100) or cd.total_ttc IS NULL)"; + $sql .= " c.rowid as commandeid, c.remise_percent as remise_percent_global"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd, ".MAIN_DB_PREFIX."commande_fournisseur as c"; + $sql .= " WHERE cd.fk_commande = c.rowid"; + $sql .= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100) or cd.total_ttc IS NULL)"; dolibarr_install_syslog("upgrade2::migrate_price_commande_fournisseur"); - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -1925,10 +1925,10 @@ function migrate_price_commande_fournisseur($db, $langs, $conf) $info_bits = $obj->info_bits; // On met a jour les 3 nouveaux champs - $commandeligne= new CommandeFournisseurLigne($db); + $commandeligne = new CommandeFournisseurLigne($db); $commandeligne->fetch($rowid); - $result=calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $commandeligne->product_type, $tmpsoc); + $result = calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $commandeligne->product_type, $tmpsoc); $total_ht = $result[0]; $total_tva = $result[1]; $total_ttc = $result[2]; @@ -1937,7 +1937,7 @@ function migrate_price_commande_fournisseur($db, $langs, $conf) $commandeligne->total_tva = $total_tva; $commandeligne->total_ttc = $total_ttc; - dolibarr_install_syslog("upgrade2: Line " . $rowid . ": commandeid=" . $obj->rowid . " pu=" . $pu . " qty=" . $qty . " vatrate=" . $vatrate . " remise_percent=" . $remise_percent . " remise_global=" . $remise_percent_global . " -> " . $total_ht . ", " . $total_tva . ", " . $total_ttc); + dolibarr_install_syslog("upgrade2: Line ".$rowid.": commandeid=".$obj->rowid." pu=".$pu." qty=".$qty." vatrate=".$vatrate." remise_percent=".$remise_percent." remise_global=".$remise_percent_global." -> ".$total_ht.", ".$total_tva.", ".$total_ttc); print ". "; $commandeligne->update_total(); @@ -2009,42 +2009,42 @@ function migrate_modeles($db, $langs, $conf) dolibarr_install_syslog("upgrade2::migrate_modeles"); - if (! empty($conf->facture->enabled)) + if (!empty($conf->facture->enabled)) { include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; - $modellist=ModelePDFFactures::liste_modeles($db); - if (count($modellist)==0) + $modellist = ModelePDFFactures::liste_modeles($db); + if (count($modellist) == 0) { // Aucun model par defaut. - $sql=" insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('crabe','invoice')"; + $sql = " insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('crabe','invoice')"; $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); } } - if (! empty($conf->commande->enabled)) + if (!empty($conf->commande->enabled)) { include_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php'; - $modellist=ModelePDFCommandes::liste_modeles($db); - if (count($modellist)==0) + $modellist = ModelePDFCommandes::liste_modeles($db); + if (count($modellist) == 0) { // Aucun model par defaut. - $sql=" insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('einstein','order')"; + $sql = " insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('einstein','order')"; $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); } } - if (! empty($conf->expedition->enabled)) + if (!empty($conf->expedition->enabled)) { include_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php'; - $modellist=ModelePDFExpedition::liste_modeles($db); - if (count($modellist)==0) + $modellist = ModelePDFExpedition::liste_modeles($db); + if (count($modellist) == 0) { // Aucun model par defaut. - $sql=" insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('rouget','shipping')"; + $sql = " insert into ".MAIN_DB_PREFIX."document_model(nom,type) values('rouget','shipping')"; $resql = $db->query($sql); - if (! $resql) dol_print_error($db); + if (!$resql) dol_print_error($db); } } @@ -2091,8 +2091,8 @@ function migrate_commande_expedition($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."co_exp (fk_expedition,fk_commande)"; - $sql.= " VALUES (".$obj->rowid.",".$obj->fk_commande.")"; - $resql2=$db->query($sql); + $sql .= " VALUES (".$obj->rowid.",".$obj->fk_commande.")"; + $resql2 = $db->query($sql); if (!$resql2) { @@ -2155,9 +2155,9 @@ function migrate_commande_livraison($db, $langs, $conf) $db->begin(); $sql = "SELECT l.rowid, l.fk_commande"; - $sql.= ", c.ref_client, c.date_livraison"; - $sql.= " FROM ".MAIN_DB_PREFIX."livraison as l, ".MAIN_DB_PREFIX."commande as c"; - $sql.= " WHERE c.rowid = l.fk_commande"; + $sql .= ", c.ref_client, c.date_livraison"; + $sql .= " FROM ".MAIN_DB_PREFIX."livraison as l, ".MAIN_DB_PREFIX."commande as c"; + $sql .= " WHERE c.rowid = l.fk_commande"; $resql = $db->query($sql); if ($resql) { @@ -2171,16 +2171,16 @@ function migrate_commande_livraison($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."co_liv (fk_livraison,fk_commande)"; - $sql.= " VALUES (".$obj->rowid.",".$obj->fk_commande.")"; - $resql2=$db->query($sql); + $sql .= " VALUES (".$obj->rowid.",".$obj->fk_commande.")"; + $resql2 = $db->query($sql); if ($resql2) { $sqlu = "UPDATE ".MAIN_DB_PREFIX."livraison SET"; - $sqlu.= " ref_client='".$obj->ref_client."'"; - $sqlu.= ", date_livraison='".$obj->date_livraison."'"; - $sqlu.= " WHERE rowid = ".$obj->rowid; - $resql3=$db->query($sqlu); + $sqlu .= " ref_client='".$obj->ref_client."'"; + $sqlu .= ", date_livraison='".$obj->date_livraison."'"; + $sqlu .= " WHERE rowid = ".$obj->rowid; + $resql3 = $db->query($sqlu); if (!$resql3) { $error++; @@ -2250,9 +2250,9 @@ function migrate_detail_livraison($db, $langs, $conf) $db->begin(); $sql = "SELECT cd.rowid, cd.fk_product, cd.description, cd.subprice, cd.total_ht"; - $sql.= ", ld.fk_livraison"; - $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."livraisondet as ld"; - $sql.= " WHERE ld.fk_commande_ligne = cd.rowid"; + $sql .= ", ld.fk_livraison"; + $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."livraisondet as ld"; + $sql .= " WHERE ld.fk_commande_ligne = cd.rowid"; $resql = $db->query($sql); if ($resql) { @@ -2266,19 +2266,19 @@ function migrate_detail_livraison($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql = "UPDATE ".MAIN_DB_PREFIX."livraisondet SET"; - $sql.= " fk_product=".$obj->fk_product; - $sql.= ",description='".$db->escape($obj->description)."'"; - $sql.= ",subprice='".$obj->subprice."'"; - $sql.= ",total_ht='".$obj->total_ht."'"; - $sql.= " WHERE fk_commande_ligne = ".$obj->rowid; - $resql2=$db->query($sql); + $sql .= " fk_product=".$obj->fk_product; + $sql .= ",description='".$db->escape($obj->description)."'"; + $sql .= ",subprice='".$obj->subprice."'"; + $sql .= ",total_ht='".$obj->total_ht."'"; + $sql .= " WHERE fk_commande_ligne = ".$obj->rowid; + $resql2 = $db->query($sql); if ($resql2) { $sql = "SELECT total_ht"; - $sql.= " FROM ".MAIN_DB_PREFIX."livraison"; - $sql.= " WHERE rowid = ".$obj->fk_livraison; - $resql3=$db->query($sql); + $sql .= " FROM ".MAIN_DB_PREFIX."livraison"; + $sql .= " WHERE rowid = ".$obj->fk_livraison; + $resql3 = $db->query($sql); if ($resql3) { @@ -2286,9 +2286,9 @@ function migrate_detail_livraison($db, $langs, $conf) $total_ht = $obju->total_ht + $obj->total_ht; $sqlu = "UPDATE ".MAIN_DB_PREFIX."livraison SET"; - $sqlu.= " total_ht='".$total_ht."'"; - $sqlu.= " WHERE rowid=".$obj->fk_livraison; - $resql4=$db->query($sqlu); + $sqlu .= " total_ht='".$total_ht."'"; + $sqlu .= " WHERE rowid=".$obj->fk_livraison; + $resql4 = $db->query($sqlu); if (!$resql4) { $error++; @@ -2365,8 +2365,8 @@ function migrate_stocks($db, $langs, $conf) $db->begin(); $sql = "SELECT SUM(reel) as total, fk_product"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; - $sql.= " GROUP BY fk_product"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; + $sql .= " GROUP BY fk_product"; $resql = $db->query($sql); if ($resql) { @@ -2380,10 +2380,10 @@ function migrate_stocks($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql = "UPDATE ".MAIN_DB_PREFIX."product SET"; - $sql.= " stock = '".$obj->total."'"; - $sql.= " WHERE rowid=".$obj->fk_product; + $sql .= " stock = '".$obj->total."'"; + $sql .= " WHERE rowid=".$obj->fk_product; - $resql2=$db->query($sql); + $resql2 = $db->query($sql); if ($resql2) { } @@ -2440,9 +2440,9 @@ function migrate_menus($db, $langs, $conf) $db->begin(); $sql = "SELECT m.rowid, mc.action"; - $sql.= " FROM ".MAIN_DB_PREFIX."menu_constraint as mc, ".MAIN_DB_PREFIX."menu_const as md, ".MAIN_DB_PREFIX."menu as m"; - $sql.= " WHERE md.fk_menu = m.rowid AND md.fk_constraint = mc.rowid"; - $sql.= " AND m.enabled = '1'"; + $sql .= " FROM ".MAIN_DB_PREFIX."menu_constraint as mc, ".MAIN_DB_PREFIX."menu_const as md, ".MAIN_DB_PREFIX."menu as m"; + $sql .= " WHERE md.fk_menu = m.rowid AND md.fk_constraint = mc.rowid"; + $sql .= " AND m.enabled = '1'"; $resql = $db->query($sql); if ($resql) { @@ -2455,11 +2455,11 @@ function migrate_menus($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql = "UPDATE ".MAIN_DB_PREFIX."menu SET"; - $sql.= " enabled = '".$obj->action."'"; - $sql.= " WHERE rowid=".$obj->rowid; - $sql.= " AND enabled = '1'"; + $sql .= " enabled = '".$obj->action."'"; + $sql .= " WHERE rowid=".$obj->rowid; + $sql .= " AND enabled = '1'"; - $resql2=$db->query($sql); + $resql2 = $db->query($sql); if ($resql2) { } @@ -2521,10 +2521,10 @@ function migrate_commande_deliveryaddress($db, $langs, $conf) $db->begin(); $sql = "SELECT c.fk_adresse_livraison, ce.fk_expedition"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; - $sql.= ", ".MAIN_DB_PREFIX."co_exp as ce"; - $sql.= " WHERE c.rowid = ce.fk_commande"; - $sql.= " AND c.fk_adresse_livraison IS NOT NULL AND c.fk_adresse_livraison != 0"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande as c"; + $sql .= ", ".MAIN_DB_PREFIX."co_exp as ce"; + $sql .= " WHERE c.rowid = ce.fk_commande"; + $sql .= " AND c.fk_adresse_livraison IS NOT NULL AND c.fk_adresse_livraison != 0"; $resql = $db->query($sql); if ($resql) @@ -2539,10 +2539,10 @@ function migrate_commande_deliveryaddress($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET"; - $sql.= " fk_adresse_livraison = '".$obj->fk_adresse_livraison."'"; - $sql.= " WHERE rowid=".$obj->fk_expedition; + $sql .= " fk_adresse_livraison = '".$obj->fk_adresse_livraison."'"; + $sql .= " WHERE rowid=".$obj->fk_expedition; - $resql2=$db->query($sql); + $resql2 = $db->query($sql); if (!$resql2) { $error++; @@ -2595,7 +2595,7 @@ function migrate_restore_missing_links($db, $langs, $conf) if (($db->type == 'mysql' || $db->type == 'mysqli')) { - if (versioncompare($db->getVersionArray(), array(4,0)) < 0) + if (versioncompare($db->getVersionArray(), array(4, 0)) < 0) { dolibarr_install_syslog("upgrade2::migrate_restore_missing_links Version of database too old to make this migrate action"); return 0; @@ -2610,16 +2610,16 @@ function migrate_restore_missing_links($db, $langs, $conf) // Restore missing link for this cross foreign key (link 1 <=> 1). Direction 1. - $table1='facturedet'; $field1='fk_remise_except'; - $table2='societe_remise_except'; $field2='fk_facture_line'; + $table1 = 'facturedet'; $field1 = 'fk_remise_except'; + $table2 = 'societe_remise_except'; $field2 = 'fk_facture_line'; $db->begin(); $sql = "SELECT t1.rowid, t1.".$field1." as field"; - $sql.= " FROM ".MAIN_DB_PREFIX.$table1." as t1"; - $sql.= " WHERE t1.".$field1." IS NOT NULL AND t1.".$field1." NOT IN"; - $sql.= " (SELECT t2.rowid FROM ".MAIN_DB_PREFIX.$table2." as t2"; - $sql.= " WHERE t1.rowid = t2.".$field2.")"; + $sql .= " FROM ".MAIN_DB_PREFIX.$table1." as t1"; + $sql .= " WHERE t1.".$field1." IS NOT NULL AND t1.".$field1." NOT IN"; + $sql .= " (SELECT t2.rowid FROM ".MAIN_DB_PREFIX.$table2." as t2"; + $sql .= " WHERE t1.rowid = t2.".$field2.")"; dolibarr_install_syslog("upgrade2::migrate_restore_missing_links DIRECTION 1"); $resql = $db->query($sql); @@ -2636,11 +2636,11 @@ function migrate_restore_missing_links($db, $langs, $conf) print 'Line '.$obj->rowid.' in '.$table1.' is linked to record '.$obj->field.' in '.$table2.' that has no link to '.$table1.'. We fix this.
'; $sql = "UPDATE ".MAIN_DB_PREFIX.$table2." SET"; - $sql.= " ".$field2." = '".$obj->rowid."'"; - $sql.= " WHERE rowid=".$obj->field; + $sql .= " ".$field2." = '".$obj->rowid."'"; + $sql .= " WHERE rowid=".$obj->field; - $resql2=$db->query($sql); - if (! $resql2) + $resql2 = $db->query($sql); + if (!$resql2) { $error++; dol_print_error($db); @@ -2675,16 +2675,16 @@ function migrate_restore_missing_links($db, $langs, $conf) print ''.$langs->trans('MigrationFixData')." (2)
\n"; // Restore missing link for this cross foreign key (link 1 <=> 1). Direction 2. - $table2='facturedet'; $field2='fk_remise_except'; - $table1='societe_remise_except'; $field1='fk_facture_line'; + $table2 = 'facturedet'; $field2 = 'fk_remise_except'; + $table1 = 'societe_remise_except'; $field1 = 'fk_facture_line'; $db->begin(); $sql = "SELECT t1.rowid, t1.".$field1." as field"; - $sql.= " FROM ".MAIN_DB_PREFIX.$table1." as t1"; - $sql.= " WHERE t1.".$field1." IS NOT NULL AND t1.".$field1." NOT IN"; - $sql.= " (SELECT t2.rowid FROM ".MAIN_DB_PREFIX.$table2." as t2"; - $sql.= " WHERE t1.rowid = t2.".$field2.")"; + $sql .= " FROM ".MAIN_DB_PREFIX.$table1." as t1"; + $sql .= " WHERE t1.".$field1." IS NOT NULL AND t1.".$field1." NOT IN"; + $sql .= " (SELECT t2.rowid FROM ".MAIN_DB_PREFIX.$table2." as t2"; + $sql .= " WHERE t1.rowid = t2.".$field2.")"; dolibarr_install_syslog("upgrade2::migrate_restore_missing_links DIRECTION 2"); $resql = $db->query($sql); @@ -2701,11 +2701,11 @@ function migrate_restore_missing_links($db, $langs, $conf) print 'Line '.$obj->rowid.' in '.$table1.' is linked to record '.$obj->field.' in '.$table2.' that has no link to '.$table1.'. We fix this.
'; $sql = "UPDATE ".MAIN_DB_PREFIX.$table2." SET"; - $sql.= " ".$field2." = '".$obj->rowid."'"; - $sql.= " WHERE rowid=".$obj->field; + $sql .= " ".$field2." = '".$obj->rowid."'"; + $sql .= " WHERE rowid=".$obj->field; - $resql2=$db->query($sql); - if (! $resql2) + $resql2 = $db->query($sql); + if (!$resql2) { $error++; dol_print_error($db); @@ -2776,22 +2776,22 @@ function migrate_project_user_resp($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."element_contact ("; - $sql2.= "datecreate"; - $sql2.= ", statut"; - $sql2.= ", element_id"; - $sql2.= ", fk_c_type_contact"; - $sql2.= ", fk_socpeople"; - $sql2.= ") VALUES ("; - $sql2.= "'".$db->idate(dol_now())."'"; - $sql2.= ", '4'"; - $sql2.= ", ".$obj->rowid; - $sql2.= ", '160'"; - $sql2.= ", ".$obj->fk_user_resp; - $sql2.= ")"; + $sql2 .= "datecreate"; + $sql2 .= ", statut"; + $sql2 .= ", element_id"; + $sql2 .= ", fk_c_type_contact"; + $sql2 .= ", fk_socpeople"; + $sql2 .= ") VALUES ("; + $sql2 .= "'".$db->idate(dol_now())."'"; + $sql2 .= ", '4'"; + $sql2 .= ", ".$obj->rowid; + $sql2 .= ", '160'"; + $sql2 .= ", ".$obj->fk_user_resp; + $sql2 .= ")"; if ($obj->fk_user_resp > 0) { - $resql2=$db->query($sql2); + $resql2 = $db->query($sql2); if (!$resql2) { $error++; @@ -2871,20 +2871,20 @@ function migrate_project_task_actors($db, $langs, $conf) $obj = $db->fetch_object($resql); $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."element_contact ("; - $sql2.= "datecreate"; - $sql2.= ", statut"; - $sql2.= ", element_id"; - $sql2.= ", fk_c_type_contact"; - $sql2.= ", fk_socpeople"; - $sql2.= ") VALUES ("; - $sql2.= "'".$db->idate(dol_now())."'"; - $sql2.= ", '4'"; - $sql2.= ", ".$obj->fk_project_task; - $sql2.= ", '180'"; - $sql2.= ", ".$obj->fk_user; - $sql2.= ")"; + $sql2 .= "datecreate"; + $sql2 .= ", statut"; + $sql2 .= ", element_id"; + $sql2 .= ", fk_c_type_contact"; + $sql2 .= ", fk_socpeople"; + $sql2 .= ") VALUES ("; + $sql2 .= "'".$db->idate(dol_now())."'"; + $sql2 .= ", '4'"; + $sql2 .= ", ".$obj->fk_project_task; + $sql2 .= ", '180'"; + $sql2 .= ", ".$obj->fk_user; + $sql2 .= ")"; - $resql2=$db->query($sql2); + $resql2 = $db->query($sql2); if (!$resql2) { @@ -2950,12 +2950,12 @@ function migrate_relationship_tables($db, $langs, $conf, $table, $fk_source, $so if ($db->DDLInfoTable(MAIN_DB_PREFIX.$table)) { - dolibarr_install_syslog("upgrade2::migrate_relationship_tables table = " . MAIN_DB_PREFIX . $table); + dolibarr_install_syslog("upgrade2::migrate_relationship_tables table = ".MAIN_DB_PREFIX.$table); $db->begin(); $sqlSelect = "SELECT ".$fk_source.", ".$fk_target; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX.$table; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX.$table; $resql = $db->query($sqlSelect); if ($resql) @@ -2970,19 +2970,19 @@ function migrate_relationship_tables($db, $langs, $conf, $table, $fk_source, $so $obj = $db->fetch_object($resql); $sqlInsert = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; - $sqlInsert.= "fk_source"; - $sqlInsert.= ", sourcetype"; - $sqlInsert.= ", fk_target"; - $sqlInsert.= ", targettype"; - $sqlInsert.= ") VALUES ("; - $sqlInsert.= $obj->$fk_source; - $sqlInsert.= ", '".$sourcetype."'"; - $sqlInsert.= ", ".$obj->$fk_target; - $sqlInsert.= ", '".$targettype."'"; - $sqlInsert.= ")"; + $sqlInsert .= "fk_source"; + $sqlInsert .= ", sourcetype"; + $sqlInsert .= ", fk_target"; + $sqlInsert .= ", targettype"; + $sqlInsert .= ") VALUES ("; + $sqlInsert .= $obj->$fk_source; + $sqlInsert .= ", '".$sourcetype."'"; + $sqlInsert .= ", ".$obj->$fk_target; + $sqlInsert .= ", '".$targettype."'"; + $sqlInsert .= ")"; - $result=$db->query($sqlInsert); - if (! $result) + $result = $db->query($sqlInsert); + if (!$result) { $error++; dol_print_error($db); @@ -3049,7 +3049,7 @@ function migrate_project_task_time($db, $langs, $conf) $db->begin(); $sql = "SELECT rowid, fk_task, task_duration"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time"; $resql = $db->query($sql); if ($resql) { @@ -3069,16 +3069,16 @@ function migrate_project_task_time($db, $langs, $conf) { // convert to second // only for int time and float time ex: 1,75 for 1h45 - list($hour,$min) = explode('.', $obj->task_duration); - $hour = $hour*60*60; - $min = ($min/100)*60*60; - $newtime = $hour+$min; + list($hour, $min) = explode('.', $obj->task_duration); + $hour = $hour * 60 * 60; + $min = ($min / 100) * 60 * 60; + $newtime = $hour + $min; $sql2 = "UPDATE ".MAIN_DB_PREFIX."projet_task_time SET"; - $sql2.= " task_duration = ".$newtime; - $sql2.= " WHERE rowid = ".$obj->rowid; + $sql2 .= " task_duration = ".$newtime; + $sql2 .= " WHERE rowid = ".$obj->rowid; - $resql2=$db->query($sql2); + $resql2 = $db->query($sql2); if (!$resql2) { $error++; @@ -3086,12 +3086,12 @@ function migrate_project_task_time($db, $langs, $conf) } print ". "; $oldtime++; - if (! empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $newtime; + if (!empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $newtime; else $totaltime[$obj->fk_task] = $newtime; } else { - if (! empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $obj->task_duration; + if (!empty($totaltime[$obj->fk_task])) $totaltime[$obj->fk_task] += $obj->task_duration; else $totaltime[$obj->fk_task] = $obj->task_duration; } @@ -3102,13 +3102,13 @@ function migrate_project_task_time($db, $langs, $conf) { if ($oldtime > 0) { - foreach($totaltime as $taskid => $total_duration) + foreach ($totaltime as $taskid => $total_duration) { $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET"; - $sql.= " duration_effective = ".$total_duration; - $sql.= " WHERE rowid = ".$taskid; + $sql .= " duration_effective = ".$total_duration; + $sql .= " WHERE rowid = ".$taskid; - $resql=$db->query($sql); + $resql = $db->query($sql); if (!$resql) { $error++; @@ -3181,11 +3181,11 @@ function migrate_customerorder_shipping($db, $langs, $conf) if ($db->query($sqlAdd1) && $db->query($sqlAdd2)) { $sqlSelect = "SELECT e.rowid as shipping_id, c.ref_client, c.date_livraison"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."expedition as e"; - $sqlSelect.= ", ".MAIN_DB_PREFIX."element_element as el"; - $sqlSelect.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON c.rowid = el.fk_source AND el.sourcetype = 'commande'"; - $sqlSelect.= " WHERE e.rowid = el.fk_target"; - $sqlSelect.= " AND el.targettype = 'shipping'"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."expedition as e"; + $sqlSelect .= ", ".MAIN_DB_PREFIX."element_element as el"; + $sqlSelect .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON c.rowid = el.fk_source AND el.sourcetype = 'commande'"; + $sqlSelect .= " WHERE e.rowid = el.fk_target"; + $sqlSelect .= " AND el.targettype = 'shipping'"; $resql = $db->query($sqlSelect); if ($resql) @@ -3200,12 +3200,12 @@ function migrate_customerorder_shipping($db, $langs, $conf) $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."expedition SET"; - $sqlUpdate.= " ref_customer = '".$obj->ref_client."'"; - $sqlUpdate.= ", date_delivery = '".($obj->date_livraison?$obj->date_livraison:'null')."'"; - $sqlUpdate.= " WHERE rowid = ".$obj->shipping_id; + $sqlUpdate .= " ref_customer = '".$obj->ref_client."'"; + $sqlUpdate .= ", date_delivery = '".($obj->date_livraison ? $obj->date_livraison : 'null')."'"; + $sqlUpdate .= " WHERE rowid = ".$obj->shipping_id; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -3275,8 +3275,8 @@ function migrate_shipping_delivery($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT rowid, fk_expedition"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."livraison"; - $sqlSelect.= " WHERE fk_expedition is not null"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."livraison"; + $sqlSelect .= " WHERE fk_expedition is not null"; $resql = $db->query($sqlSelect); if ($resql) @@ -3291,25 +3291,25 @@ function migrate_shipping_delivery($db, $langs, $conf) $obj = $db->fetch_object($resql); $sqlInsert = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; - $sqlInsert.= "fk_source"; - $sqlInsert.= ", sourcetype"; - $sqlInsert.= ", fk_target"; - $sqlInsert.= ", targettype"; - $sqlInsert.= ") VALUES ("; - $sqlInsert.= $obj->fk_expedition; - $sqlInsert.= ", 'shipping'"; - $sqlInsert.= ", ".$obj->rowid; - $sqlInsert.= ", 'delivery'"; - $sqlInsert.= ")"; + $sqlInsert .= "fk_source"; + $sqlInsert .= ", sourcetype"; + $sqlInsert .= ", fk_target"; + $sqlInsert .= ", targettype"; + $sqlInsert .= ") VALUES ("; + $sqlInsert .= $obj->fk_expedition; + $sqlInsert .= ", 'shipping'"; + $sqlInsert .= ", ".$obj->rowid; + $sqlInsert .= ", 'delivery'"; + $sqlInsert .= ")"; - $result=$db->query($sqlInsert); + $result = $db->query($sqlInsert); if ($result) { $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."livraison SET fk_expedition = NULL"; - $sqlUpdate.= " WHERE rowid = ".$obj->rowid; + $sqlUpdate .= " WHERE rowid = ".$obj->rowid; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -3383,16 +3383,16 @@ function migrate_shipping_delivery2($db, $langs, $conf) $db->begin(); $sqlSelect = "SELECT l.rowid as delivery_id, e.ref_customer, e.date_delivery"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."livraison as l,"; - $sqlSelect.= " ".MAIN_DB_PREFIX."element_element as el,"; - $sqlSelect.= " ".MAIN_DB_PREFIX."expedition as e"; - $sqlSelect.= " WHERE l.rowid = el.fk_target"; - $sqlSelect.= " AND el.targettype = 'delivery'"; - $sqlSelect.= " AND e.rowid = el.fk_source AND el.sourcetype = 'shipping'"; - $sqlSelect.= " AND (e.ref_customer IS NOT NULL OR e.date_delivery IS NOT NULL)"; // Useless to process this record if both are null + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."livraison as l,"; + $sqlSelect .= " ".MAIN_DB_PREFIX."element_element as el,"; + $sqlSelect .= " ".MAIN_DB_PREFIX."expedition as e"; + $sqlSelect .= " WHERE l.rowid = el.fk_target"; + $sqlSelect .= " AND el.targettype = 'delivery'"; + $sqlSelect .= " AND e.rowid = el.fk_source AND el.sourcetype = 'shipping'"; + $sqlSelect .= " AND (e.ref_customer IS NOT NULL OR e.date_delivery IS NOT NULL)"; // Useless to process this record if both are null // Add condition to know if we never migrate this record - $sqlSelect.= " AND (l.ref_customer IS NULL".($db->type!='pgsql'?" or l.ref_customer = ''":"").")"; - $sqlSelect.= " AND (l.date_delivery IS NULL".($db->type!='pgsql'?" or l.date_delivery = ''":"").")"; + $sqlSelect .= " AND (l.ref_customer IS NULL".($db->type != 'pgsql' ? " or l.ref_customer = ''" : "").")"; + $sqlSelect .= " AND (l.date_delivery IS NULL".($db->type != 'pgsql' ? " or l.date_delivery = ''" : "").")"; $resql = $db->query($sqlSelect); if ($resql) @@ -3407,12 +3407,12 @@ function migrate_shipping_delivery2($db, $langs, $conf) $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."livraison SET"; - $sqlUpdate.= " ref_customer = '".$obj->ref_customer."',"; - $sqlUpdate.= " date_delivery = ".($obj->date_delivery?"'".$obj->date_delivery."'":'null'); - $sqlUpdate.= " WHERE rowid = ".$obj->delivery_id; + $sqlUpdate .= " ref_customer = '".$obj->ref_customer."',"; + $sqlUpdate .= " date_delivery = ".($obj->date_delivery ? "'".$obj->date_delivery."'" : 'null'); + $sqlUpdate .= " WHERE rowid = ".$obj->delivery_id; - $result=$db->query($sqlUpdate); - if (! $result) + $result = $db->query($sqlUpdate); + if (!$result) { $error++; dol_print_error($db); @@ -3469,21 +3469,21 @@ function migrate_actioncomm_element($db, $langs, $conf) 'invoice_supplier' => 'fk_supplier_invoice' ); - foreach($elements as $type => $field) + foreach ($elements as $type => $field) { $result = $db->DDLDescTable(MAIN_DB_PREFIX."actioncomm", $field); $obj = $db->fetch_object($result); if ($obj) { - dolibarr_install_syslog("upgrade2::migrate_actioncomm_element field=" . $field); + dolibarr_install_syslog("upgrade2::migrate_actioncomm_element field=".$field); $db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm SET "; - $sql.= "fk_element = ".$field.", elementtype = '".$type."'"; - $sql.= " WHERE ".$field." IS NOT NULL"; - $sql.= " AND fk_element IS NULL"; - $sql.= " AND elementtype IS NULL"; + $sql .= "fk_element = ".$field.", elementtype = '".$type."'"; + $sql .= " WHERE ".$field." IS NOT NULL"; + $sql .= " AND fk_element IS NULL"; + $sql .= " AND elementtype IS NULL"; $resql = $db->query($sql); if ($resql) @@ -3527,23 +3527,23 @@ function migrate_mode_reglement($db, $langs, $conf) print ''.$langs->trans('MigrationPaymentMode')."
\n"; $elements = array( - 'old_id' => array(5,8,9,10,11), - 'new_id' => array(50,51,52,53,54), - 'code' => array('VAD','TRA','LCR','FAC','PRO'), - 'tables' => array('commande_fournisseur','commande','facture_rec','facture','propal') + 'old_id' => array(5, 8, 9, 10, 11), + 'new_id' => array(50, 51, 52, 53, 54), + 'code' => array('VAD', 'TRA', 'LCR', 'FAC', 'PRO'), + 'tables' => array('commande_fournisseur', 'commande', 'facture_rec', 'facture', 'propal') ); - $count=0; + $count = 0; - foreach($elements['old_id'] as $key => $old_id) + foreach ($elements['old_id'] as $key => $old_id) { - $error=0; + $error = 0; - dolibarr_install_syslog("upgrade2::migrate_mode_reglement code=" . $elements['code'][$key]); + dolibarr_install_syslog("upgrade2::migrate_mode_reglement code=".$elements['code'][$key]); $sqlSelect = "SELECT id"; - $sqlSelect.= " FROM ".MAIN_DB_PREFIX."c_paiement"; - $sqlSelect.= " WHERE id = ".$old_id; - $sqlSelect.= " AND code = '".$elements['code'][$key]."'"; + $sqlSelect .= " FROM ".MAIN_DB_PREFIX."c_paiement"; + $sqlSelect .= " WHERE id = ".$old_id; + $sqlSelect .= " AND code = '".$elements['code'][$key]."'"; $resql = $db->query($sqlSelect); if ($resql) @@ -3556,27 +3556,27 @@ function migrate_mode_reglement($db, $langs, $conf) $db->begin(); $sqla = "UPDATE ".MAIN_DB_PREFIX."paiement SET "; - $sqla.= "fk_paiement = ".$elements['new_id'][$key]; - $sqla.= " WHERE fk_paiement = ".$old_id; - $sqla.= " AND fk_paiement IN (SELECT id FROM ".MAIN_DB_PREFIX."c_paiement WHERE id = ".$old_id." AND code = '".$elements['code'][$key]."')"; + $sqla .= "fk_paiement = ".$elements['new_id'][$key]; + $sqla .= " WHERE fk_paiement = ".$old_id; + $sqla .= " AND fk_paiement IN (SELECT id FROM ".MAIN_DB_PREFIX."c_paiement WHERE id = ".$old_id." AND code = '".$elements['code'][$key]."')"; $resqla = $db->query($sqla); $sql = "UPDATE ".MAIN_DB_PREFIX."c_paiement SET "; - $sql.= "id = ".$elements['new_id'][$key]; - $sql.= " WHERE id = ".$old_id; - $sql.= " AND code = '".$elements['code'][$key]."'"; + $sql .= "id = ".$elements['new_id'][$key]; + $sql .= " WHERE id = ".$old_id; + $sql .= " AND code = '".$elements['code'][$key]."'"; $resql = $db->query($sql); if ($resqla && $resql) { - foreach($elements['tables'] as $table) + foreach ($elements['tables'] as $table) { $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET "; - $sql.= "fk_mode_reglement = ".$elements['new_id'][$key]; - $sql.= " WHERE fk_mode_reglement = ".$old_id; + $sql .= "fk_mode_reglement = ".$elements['new_id'][$key]; + $sql .= " WHERE fk_mode_reglement = ".$old_id; $resql = $db->query($sql); - if (! $resql) + if (!$resql) { dol_print_error($db); $error++; @@ -3584,7 +3584,7 @@ function migrate_mode_reglement($db, $langs, $conf) print ". "; } - if (! $error) + if (!$error) { $db->commit(); } @@ -3627,54 +3627,54 @@ function migrate_clean_association($db, $langs, $conf, $versionto) $obj = $db->fetch_object($result); if ($obj) // It table categorie_association exists { - $couples=array(); - $filles=array(); + $couples = array(); + $filles = array(); $sql = "SELECT fk_categorie_mere, fk_categorie_fille"; - $sql.= " FROM ".MAIN_DB_PREFIX."categorie_association"; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie_association"; dolibarr_install_syslog("upgrade: search duplicate"); $resql = $db->query($sql); if ($resql) { - $num=$db->num_rows($resql); - while ($obj=$db->fetch_object($resql)) + $num = $db->num_rows($resql); + while ($obj = $db->fetch_object($resql)) { - if (! isset($filles[$obj->fk_categorie_fille])) // Only one record as child (a child has only on parent). + if (!isset($filles[$obj->fk_categorie_fille])) // Only one record as child (a child has only on parent). { if ($obj->fk_categorie_mere != $obj->fk_categorie_fille) { - $filles[$obj->fk_categorie_fille]=1; // Set record for this child - $couples[$obj->fk_categorie_mere.'_'.$obj->fk_categorie_fille]=array('mere'=>$obj->fk_categorie_mere, 'fille'=>$obj->fk_categorie_fille); + $filles[$obj->fk_categorie_fille] = 1; // Set record for this child + $couples[$obj->fk_categorie_mere.'_'.$obj->fk_categorie_fille] = array('mere'=>$obj->fk_categorie_mere, 'fille'=>$obj->fk_categorie_fille); } } } - dolibarr_install_syslog("upgrade: result is num=" . $num . " count(couples)=" . count($couples)); + dolibarr_install_syslog("upgrade: result is num=".$num." count(couples)=".count($couples)); // If there is duplicates couples or child with two parents if (count($couples) > 0 && $num > count($couples)) { - $error=0; + $error = 0; $db->begin(); // We delete all - $sql="DELETE FROM ".MAIN_DB_PREFIX."categorie_association"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_association"; dolibarr_install_syslog("upgrade: delete association"); - $resqld=$db->query($sql); + $resqld = $db->query($sql); if ($resqld) { // And we insert only each record once - foreach($couples as $key => $val) + foreach ($couples as $key => $val) { - $sql ="INSERT INTO ".MAIN_DB_PREFIX."categorie_association(fk_categorie_mere,fk_categorie_fille)"; - $sql.=" VALUES(".$val['mere'].", ".$val['fille'].")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_association(fk_categorie_mere,fk_categorie_fille)"; + $sql .= " VALUES(".$val['mere'].", ".$val['fille'].")"; dolibarr_install_syslog("upgrade: insert association"); - $resqli=$db->query($sql); - if (! $resqli) $error++; + $resqli = $db->query($sql); + if (!$resqli) $error++; } } - if (! $error) + if (!$error) { print '
'.$langs->trans("MigrationCategorieAssociation").''.$langs->trans("RemoveDuplicates").' '.$langs->trans("Success").' ('.$num.'=>'.count($couples).')
'; print ''.$langs->trans('Upgrade').': '; - print $langs->trans('MigrationReloadModule').' '.$mod->getName(); // We keep getName outside of trans because getName is already encoded/translated + print $langs->trans('MigrationReloadModule').' '.$mod->getName(); // We keep getName outside of trans because getName is already encoded/translated print ""; print "
\n"; print '
'."\n"; @@ -134,8 +134,8 @@ for ($i = 0; $i < $_SESSION["nbrecases"]; $i++) { if (isset($_SESSION["choix$i"]) === false) { $_SESSION["choix$i"] = ''; } - print ''."\n"; } @@ -144,7 +144,7 @@ print '
'. $langs->trans("TitleChoice") .' '.$j.': '; - $tmparray=array('checkbox'=>$langs->trans("CheckBox"),'yesno'=>$langs->trans("YesNoList"),'foragainst'=>$langs->trans("PourContreList")); + print '
'.$langs->trans("TitleChoice").' '.$j.': '; + $tmparray = array('checkbox'=>$langs->trans("CheckBox"), 'yesno'=>$langs->trans("YesNoList"), 'foragainst'=>$langs->trans("PourContreList")); print '   '.$langs->trans("Type").' '.$form->selectarray("typecolonne[]", $tmparray, $_SESSION["typecolonne$i"]); print '
'."\n"; //ajout de cases supplementaires print ''."\n"; -print ''."\n"; +print ''."\n"; print '
'. $langs->trans("5MoreChoices") .''.$langs->trans("5MoreChoices").'
'."\n"; print'
'."\n"; diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index 4f6eea5b903..8a2d643189b 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -22,13 +22,13 @@ * \brief File to return Ajax response on product list request */ -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); -if (empty($_GET['keysearch']) && ! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (empty($_GET['keysearch']) && !defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); require '../../main.inc.php'; @@ -57,9 +57,9 @@ $hidepriceinlabel = GETPOST('hidepriceinlabel', 'int'); dol_syslog(join(',', $_GET)); // print_r($_GET); -if (! empty($action) && $action == 'fetch' && ! empty($id)) +if (!empty($action) && $action == 'fetch' && !empty($id)) { - require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $outjson = array(); @@ -77,11 +77,11 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) $found = false; // Price by qty - if (! empty($price_by_qty_rowid) && $price_by_qty_rowid >= 1 && (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))) // If we need a particular price related to qty + if (!empty($price_by_qty_rowid) && $price_by_qty_rowid >= 1 && (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))) // If we need a particular price related to qty { $sql = "SELECT price, unitprice, quantity, remise_percent"; - $sql .= " FROM " . MAIN_DB_PREFIX . "product_price_by_qty "; - $sql .= " WHERE rowid=" . $price_by_qty_rowid . ""; + $sql .= " FROM ".MAIN_DB_PREFIX."product_price_by_qty "; + $sql .= " WHERE rowid=".$price_by_qty_rowid.""; $result = $db->query($sql); if ($result) { @@ -99,14 +99,14 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) } // Multiprice - if (! $found && isset($price_level) && $price_level >= 1 && (! empty($conf->global->PRODUIT_MULTIPRICES))) // If we need a particular price + if (!$found && isset($price_level) && $price_level >= 1 && (!empty($conf->global->PRODUIT_MULTIPRICES))) // If we need a particular price // level (from 1 to 6) { $sql = "SELECT price, price_ttc, price_base_type, tva_tx"; - $sql .= " FROM " . MAIN_DB_PREFIX . "product_price "; - $sql .= " WHERE fk_product='" . $id . "'"; - $sql .= " AND entity IN (" . getEntity('productprice') . ")"; - $sql .= " AND price_level=" . $price_level; + $sql .= " FROM ".MAIN_DB_PREFIX."product_price "; + $sql .= " WHERE fk_product='".$id."'"; + $sql .= " AND entity IN (".getEntity('productprice').")"; + $sql .= " AND price_level=".$price_level; $sql .= " ORDER BY date_price"; $sql .= " DESC LIMIT 1"; @@ -124,12 +124,12 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) } // Price by customer - if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES) && ! empty($socid)) { - require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) { + require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; $prodcustprice = new Productcustomerprice($db); - $filter = array('t.fk_product' => $object->id,'t.fk_soc' => $socid); + $filter = array('t.fk_product' => $object->id, 't.fk_soc' => $socid); $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); if ($result) { @@ -143,21 +143,21 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) } } - if (! $found) { + if (!$found) { $outprice_ht = price($object->price); $outprice_ttc = price($object->price_ttc); $outpricebasetype = $object->price_base_type; $outtva_tx = $object->tva_tx; } - $outjson = array('ref' => $outref,'label' => $outlabel,'desc' => $outdesc,'type' => $outtype,'price_ht' => $outprice_ht,'price_ttc' => $outprice_ttc,'pricebasetype' => $outpricebasetype,'tva_tx' => $outtva_tx,'qty' => $outqty,'discount' => $outdiscount); + $outjson = array('ref' => $outref, 'label' => $outlabel, 'desc' => $outdesc, 'type' => $outtype, 'price_ht' => $outprice_ht, 'price_ttc' => $outprice_ttc, 'pricebasetype' => $outpricebasetype, 'tva_tx' => $outtva_tx, 'qty' => $outqty, 'discount' => $outdiscount); } echo json_encode($outjson); } else { - require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; $langs->load("products"); $langs->load("main"); @@ -170,19 +170,19 @@ else return; } - $match = preg_grep('/(' . $htmlname . '[0-9]+)/', array_keys($_GET)); + $match = preg_grep('/('.$htmlname.'[0-9]+)/', array_keys($_GET)); sort($match); - $idprod = (! empty($match[0]) ? $match[0] : ''); + $idprod = (!empty($match[0]) ? $match[0] : ''); - if (GETPOST($htmlname, 'alpha') == '' && (! $idprod || ! GETPOST($idprod, 'alpha'))) + if (GETPOST($htmlname, 'alpha') == '' && (!$idprod || !GETPOST($idprod, 'alpha'))) { print json_encode(array()); return; } // When used from jQuery, the search term is added as GET param "term". - $searchkey = (($idprod && GETPOST($idprod, 'alpha')) ? GETPOST($idprod, 'alpha') : (GETPOST($htmlname, 'alpha') ? GETPOST($htmlname, 'alpha') : '')); + $searchkey = (($idprod && GETPOST($idprod, 'alpha')) ? GETPOST($idprod, 'alpha') : (GETPOST($htmlname, 'alpha') ? GETPOST($htmlname, 'alpha') : '')); $form = new Form($db); if (empty($mode) || $mode == 1) { // mode=1: customer diff --git a/htdocs/product/canvas/product/tpl/card_create.tpl.php b/htdocs/product/canvas/product/tpl/card_create.tpl.php index b12a0d41370..99ddd39d49b 100644 --- a/htdocs/product/canvas/product/tpl/card_create.tpl.php +++ b/htdocs/product/canvas/product/tpl/card_create.tpl.php @@ -16,16 +16,16 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; } -$object=$GLOBALS['object']; +$object = $GLOBALS['object']; -$statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); +$statutarray = array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); ?> @@ -35,7 +35,7 @@ print load_fiche_titre($langs->trans("NewProduct"), '', 'products'); dol_fiche_head(''); ?> -error)?'':$object->error), $object->errors); ?> +error) ? '' : $object->error), $object->errors); ?> @@ -71,7 +71,7 @@ dol_fiche_head(''); selectarray('statut_buy', $statutarray, $object->status_buy); ?> -stock->enabled)) { ?> +stock->enabled)) { ?> trans("StockLimit"); ?> @@ -108,7 +108,7 @@ dol_fiche_head('');
-global->PRODUIT_MULTIPRICES) { ?> +global->PRODUIT_MULTIPRICES) { ?> diff --git a/htdocs/product/canvas/service/tpl/card_create.tpl.php b/htdocs/product/canvas/service/tpl/card_create.tpl.php index d51e1541278..26daca173a4 100644 --- a/htdocs/product/canvas/service/tpl/card_create.tpl.php +++ b/htdocs/product/canvas/service/tpl/card_create.tpl.php @@ -16,16 +16,16 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; } -$object=$GLOBALS['object']; +$object = $GLOBALS['object']; -$statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); +$statutarray = array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); ?> @@ -80,7 +80,7 @@ dol_fiche_head('');
-global->PRODUIT_MULTIPRICES) { ?> +global->PRODUIT_MULTIPRICES) { ?>
trans("SellingPrice"); ?>
diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 8117d8fb6aa..dd542b71f8d 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -21,7 +21,7 @@ * \ingroup produit * \brief File of class to manage predefined price products or services by customer */ -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; /** * File of class to manage predefined price products or services by customer @@ -73,7 +73,7 @@ class Productcustomerprice extends CommonObject */ public $fk_user; - public $lines = array (); + public $lines = array(); /** @@ -166,7 +166,7 @@ class Productcustomerprice extends CommonObject } // Insert request - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_customer_price("; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_customer_price("; $sql .= "entity,"; $sql .= "datec,"; $sql .= "fk_product,"; @@ -186,39 +186,39 @@ class Productcustomerprice extends CommonObject $sql .= "fk_user,"; $sql .= "import_key"; $sql .= ") VALUES ("; - $sql .= " " . $conf->entity . ","; - $sql .= " '" . $this->db->idate(dol_now()) . "',"; - $sql .= " " . (! isset($this->fk_product) ? 'NULL' : "'" . $this->db->escape($this->fk_product) . "'") . ","; - $sql .= " " . (! isset($this->fk_soc) ? 'NULL' : "'" . $this->db->escape($this->fk_soc) . "'") . ","; - $sql .= " " . (empty($this->price) ? '0' : "'" . $this->db->escape($this->price) . "'") . ","; - $sql .= " " . (empty($this->price_ttc) ? '0' : "'" . $this->db->escape($this->price_ttc) . "'") . ","; - $sql .= " " . (empty($this->price_min) ? '0' : "'" . $this->db->escape($this->price_min) . "'") . ","; - $sql .= " " . (empty($this->price_min_ttc) ? '0' : "'" . $this->db->escape($this->price_min_ttc) . "'") . ","; - $sql .= " " . (! isset($this->price_base_type) ? 'NULL' : "'" . $this->db->escape($this->price_base_type) . "'") . ","; + $sql .= " ".$conf->entity.","; + $sql .= " '".$this->db->idate(dol_now())."',"; + $sql .= " ".(!isset($this->fk_product) ? 'NULL' : "'".$this->db->escape($this->fk_product)."'").","; + $sql .= " ".(!isset($this->fk_soc) ? 'NULL' : "'".$this->db->escape($this->fk_soc)."'").","; + $sql .= " ".(empty($this->price) ? '0' : "'".$this->db->escape($this->price)."'").","; + $sql .= " ".(empty($this->price_ttc) ? '0' : "'".$this->db->escape($this->price_ttc)."'").","; + $sql .= " ".(empty($this->price_min) ? '0' : "'".$this->db->escape($this->price_min)."'").","; + $sql .= " ".(empty($this->price_min_ttc) ? '0' : "'".$this->db->escape($this->price_min_ttc)."'").","; + $sql .= " ".(!isset($this->price_base_type) ? 'NULL' : "'".$this->db->escape($this->price_base_type)."'").","; $sql .= " ".($this->default_vat_code ? "'".$this->db->escape($this->default_vat_code)."'" : "null").","; - $sql .= " " . (! isset($this->tva_tx) ? 'NULL' : (empty($this->tva_tx)?0:$this->tva_tx)) . ","; - $sql .= " " . (! isset($this->recuperableonly) ? 'NULL' : "'" . $this->db->escape($this->recuperableonly) . "'") . ","; - $sql .= " " . (empty($this->localtax1_type) ? "'0'" : "'" . $this->db->escape($this->localtax1_type) . "'") . ","; - $sql .= " " . (! isset($this->localtax1_tx) ? 'NULL' : (empty($this->localtax1_tx)?0:$this->localtax1_tx)) . ","; - $sql .= " " . (empty($this->localtax2_type) ? "'0'" : "'" . $this->db->escape($this->localtax2_type) . "'") . ","; - $sql .= " " . (! isset($this->localtax2_tx) ? 'NULL' : (empty($this->localtax2_tx)?0:$this->localtax2_tx)) . ","; - $sql .= " " . $user->id . ","; - $sql .= " " . (! isset($this->import_key) ? 'NULL' : "'" . $this->db->escape($this->import_key) . "'") . ""; + $sql .= " ".(!isset($this->tva_tx) ? 'NULL' : (empty($this->tva_tx) ? 0 : $this->tva_tx)).","; + $sql .= " ".(!isset($this->recuperableonly) ? 'NULL' : "'".$this->db->escape($this->recuperableonly)."'").","; + $sql .= " ".(empty($this->localtax1_type) ? "'0'" : "'".$this->db->escape($this->localtax1_type)."'").","; + $sql .= " ".(!isset($this->localtax1_tx) ? 'NULL' : (empty($this->localtax1_tx) ? 0 : $this->localtax1_tx)).","; + $sql .= " ".(empty($this->localtax2_type) ? "'0'" : "'".$this->db->escape($this->localtax2_type)."'").","; + $sql .= " ".(!isset($this->localtax2_tx) ? 'NULL' : (empty($this->localtax2_tx) ? 0 : $this->localtax2_tx)).","; + $sql .= " ".$user->id.","; + $sql .= " ".(!isset($this->import_key) ? 'NULL' : "'".$this->db->escape($this->import_key)."'").""; $sql .= ")"; $this->db->begin(); - dol_syslog(get_class($this) . "::create", LOG_DEBUG); + dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors [] = "Error " . $this->db->lasterror(); + if (!$resql) { + $error++; + $this->errors [] = "Error ".$this->db->lasterror(); } - if (! $error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "product_customer_price"); + if (!$error) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_customer_price"); - if (! $notrigger) { + if (!$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. @@ -231,21 +231,21 @@ class Productcustomerprice extends CommonObject } } - if (! $error) { + if (!$error) { $result = $this->setPriceOnAffiliateThirdparty($user, $forceupdateaffiliate); if ($result < 0) { - $error ++; + $error++; } } // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this) . "::create " . $errmsg, LOG_ERR); - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); return $this->id; @@ -283,10 +283,10 @@ class Productcustomerprice extends CommonObject $sql .= " t.fk_user,"; $sql .= " t.import_key"; - $sql .= " FROM " . MAIN_DB_PREFIX . "product_customer_price as t"; - $sql .= " WHERE t.rowid = " . $id; + $sql .= " FROM ".MAIN_DB_PREFIX."product_customer_price as t"; + $sql .= " WHERE t.rowid = ".$id; - dol_syslog(get_class($this) . "::fetch", LOG_DEBUG); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { @@ -316,8 +316,8 @@ class Productcustomerprice extends CommonObject return 1; } else { - $this->error = "Error " . $this->db->lasterror(); - return - 1; + $this->error = "Error ".$this->db->lasterror(); + return -1; } } @@ -337,8 +337,8 @@ class Productcustomerprice extends CommonObject // phpcs:enable global $langs; - if ( empty($sortfield)) $sortfield = "t.rowid"; - if ( empty($sortorder)) $sortorder = "DESC"; + if (empty($sortfield)) $sortfield = "t.rowid"; + if (empty($sortorder)) $sortorder = "DESC"; $sql = "SELECT"; $sql .= " t.rowid,"; @@ -364,39 +364,39 @@ class Productcustomerprice extends CommonObject $sql .= " t.import_key,"; $sql .= " soc.nom as socname,"; $sql .= " prod.ref as prodref"; - $sql .= " FROM " . MAIN_DB_PREFIX . "product_customer_price as t "; - $sql .= " ," . MAIN_DB_PREFIX . "product as prod "; - $sql .= " ," . MAIN_DB_PREFIX . "societe as soc "; + $sql .= " FROM ".MAIN_DB_PREFIX."product_customer_price as t "; + $sql .= " ,".MAIN_DB_PREFIX."product as prod "; + $sql .= " ,".MAIN_DB_PREFIX."societe as soc "; $sql .= " WHERE soc.rowid=t.fk_soc "; $sql .= " AND prod.rowid=t.fk_product "; - $sql .= " AND prod.entity IN (" . getEntity('product') . ")"; - $sql .= " AND t.entity IN (" . getEntity('productprice') . ")"; + $sql .= " AND prod.entity IN (".getEntity('product').")"; + $sql .= " AND t.entity IN (".getEntity('productprice').")"; // Manage filter if (count($filter) > 0) { foreach ($filter as $key => $value) { if (strpos($key, 'date')) // To allow $filter['YEAR(s.dated)']=>$year { - $sql .= ' AND ' . $key . ' = \'' . $value . '\''; + $sql .= ' AND '.$key.' = \''.$value.'\''; } elseif ($key == 'soc.nom') { - $sql .= ' AND ' . $key . ' LIKE \'%' . $value . '%\''; + $sql .= ' AND '.$key.' LIKE \'%'.$value.'%\''; } elseif ($key == 'prod.ref') { - $sql .= ' AND ' . $key . ' LIKE \'%' . $value . '%\''; + $sql .= ' AND '.$key.' LIKE \'%'.$value.'%\''; } else { - $sql .= ' AND ' . $key . ' = ' . $value; + $sql .= ' AND '.$key.' = '.$value; } } } - $sql.= $this->db->order($sortfield, $sortorder); - if (! empty($limit)) $sql .= ' ' . $this->db->plimit($limit + 1, $offset); + $sql .= $this->db->order($sortfield, $sortorder); + if (!empty($limit)) $sql .= ' '.$this->db->plimit($limit + 1, $offset); - dol_syslog(get_class($this) . "::fetch_all", LOG_DEBUG); + dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $this->lines = array (); + $this->lines = array(); $num = $this->db->num_rows($resql); - while ( $obj = $this->db->fetch_object($resql) ) { + while ($obj = $this->db->fetch_object($resql)) { $line = new PriceByCustomerLine(); $line->id = $obj->rowid; @@ -429,8 +429,8 @@ class Productcustomerprice extends CommonObject return $num; } else { - $this->error = "Error " . $this->db->lasterror(); - return - 1; + $this->error = "Error ".$this->db->lasterror(); + return -1; } } @@ -450,8 +450,8 @@ class Productcustomerprice extends CommonObject // phpcs:enable global $langs; - if (! empty($sortfield)) $sortfield = "t.rowid"; - if (! empty($sortorder)) $sortorder = "DESC"; + if (!empty($sortfield)) $sortfield = "t.rowid"; + if (!empty($sortorder)) $sortorder = "DESC"; $sql = "SELECT"; $sql .= " t.rowid,"; @@ -474,38 +474,38 @@ class Productcustomerprice extends CommonObject $sql .= " t.import_key,"; $sql .= " soc.nom as socname,"; $sql .= " prod.ref as prodref"; - $sql .= " FROM " . MAIN_DB_PREFIX . "product_customer_price_log as t "; - $sql .= " ," . MAIN_DB_PREFIX . "product as prod "; - $sql .= " ," . MAIN_DB_PREFIX . "societe as soc "; + $sql .= " FROM ".MAIN_DB_PREFIX."product_customer_price_log as t "; + $sql .= " ,".MAIN_DB_PREFIX."product as prod "; + $sql .= " ,".MAIN_DB_PREFIX."societe as soc "; $sql .= " WHERE soc.rowid=t.fk_soc "; $sql .= " AND prod.rowid=t.fk_product "; - $sql .= " AND prod.entity IN (" . getEntity('product') . ")"; - $sql .= " AND t.entity IN (" . getEntity('productprice') . ")"; + $sql .= " AND prod.entity IN (".getEntity('product').")"; + $sql .= " AND t.entity IN (".getEntity('productprice').")"; // Manage filter if (count($filter) > 0) { foreach ($filter as $key => $value) { if (strpos($key, 'date')) // To allow $filter['YEAR(s.dated)']=>$year { - $sql .= ' AND ' . $key . ' = \'' . $value . '\''; + $sql .= ' AND '.$key.' = \''.$value.'\''; } elseif ($key == 'soc.nom') { - $sql .= ' AND ' . $key . ' LIKE \'%' . $value . '%\''; + $sql .= ' AND '.$key.' LIKE \'%'.$value.'%\''; } else { - $sql .= ' AND ' . $key . ' = ' . $value; + $sql .= ' AND '.$key.' = '.$value; } } } - $sql.= $this->db->order($sortfield, $sortorder); - if (! empty($limit)) $sql .= ' ' . $this->db->plimit($limit + 1, $offset); + $sql .= $this->db->order($sortfield, $sortorder); + if (!empty($limit)) $sql .= ' '.$this->db->plimit($limit + 1, $offset); - dol_syslog(get_class($this) . "::fetch_all_log", LOG_DEBUG); + dol_syslog(get_class($this)."::fetch_all_log", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $this->lines = array (); + $this->lines = array(); $num = $this->db->num_rows($resql); - while ( $obj = $this->db->fetch_object($resql) ) { + while ($obj = $this->db->fetch_object($resql)) { $line = new PriceByCustomerLine(); $line->id = $obj->rowid; @@ -536,8 +536,8 @@ class Productcustomerprice extends CommonObject return $num; } else { - $this->error = "Error " . $this->db->lasterror(); - return - 1; + $this->error = "Error ".$this->db->lasterror(); + return -1; } } @@ -622,7 +622,7 @@ class Productcustomerprice extends CommonObject // Do a copy of current record into log table // Insert request - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_customer_price_log("; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_customer_price_log("; $sql .= "entity,"; $sql .= "datec,"; @@ -665,75 +665,75 @@ class Productcustomerprice extends CommonObject $sql .= " t.fk_user,"; $sql .= " t.import_key"; - $sql .= " FROM " . MAIN_DB_PREFIX . "product_customer_price as t"; - $sql .= " WHERE t.rowid = " . $this->id; + $sql .= " FROM ".MAIN_DB_PREFIX."product_customer_price as t"; + $sql .= " WHERE t.rowid = ".$this->id; $this->db->begin(); - dol_syslog(get_class($this) . "::update", LOG_DEBUG); + dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors [] = "Error " . $this->db->lasterror(); + if (!$resql) { + $error++; + $this->errors [] = "Error ".$this->db->lasterror(); } // Update request - $sql = "UPDATE " . MAIN_DB_PREFIX . "product_customer_price SET"; + $sql = "UPDATE ".MAIN_DB_PREFIX."product_customer_price SET"; - $sql .= " entity=" . $conf->entity . ","; - $sql .= " datec='" . $this->db->idate(dol_now()) . "',"; - $sql .= " tms=" . (dol_strlen($this->tms) != 0 ? "'" . $this->db->idate($this->tms) . "'" : 'null') . ","; - $sql .= " fk_product=" . (isset($this->fk_product) ? $this->fk_product : "null") . ","; - $sql .= " fk_soc=" . (isset($this->fk_soc) ? $this->fk_soc : "null") . ","; - $sql .= " price=" . (isset($this->price) ? $this->price : "null") . ","; - $sql .= " price_ttc=" . (isset($this->price_ttc) ? $this->price_ttc : "null") . ","; - $sql .= " price_min=" . (isset($this->price_min) ? $this->price_min : "null") . ","; - $sql .= " price_min_ttc=" . (isset($this->price_min_ttc) ? $this->price_min_ttc : "null") . ","; - $sql .= " price_base_type=" . (isset($this->price_base_type) ? "'" . $this->db->escape($this->price_base_type) . "'" : "null") . ","; + $sql .= " entity=".$conf->entity.","; + $sql .= " datec='".$this->db->idate(dol_now())."',"; + $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; + $sql .= " fk_product=".(isset($this->fk_product) ? $this->fk_product : "null").","; + $sql .= " fk_soc=".(isset($this->fk_soc) ? $this->fk_soc : "null").","; + $sql .= " price=".(isset($this->price) ? $this->price : "null").","; + $sql .= " price_ttc=".(isset($this->price_ttc) ? $this->price_ttc : "null").","; + $sql .= " price_min=".(isset($this->price_min) ? $this->price_min : "null").","; + $sql .= " price_min_ttc=".(isset($this->price_min_ttc) ? $this->price_min_ttc : "null").","; + $sql .= " price_base_type=".(isset($this->price_base_type) ? "'".$this->db->escape($this->price_base_type)."'" : "null").","; $sql .= " default_vat_code = ".($this->default_vat_code ? "'".$this->db->escape($this->default_vat_code)."'" : "null").","; - $sql .= " tva_tx=" . (isset($this->tva_tx) ? (empty($this->tva_tx)?0:$this->tva_tx) : "null") . ","; - $sql .= " recuperableonly=" . (isset($this->recuperableonly) ? $this->recuperableonly : "null") . ","; - $sql .= " localtax1_tx=" . (isset($this->localtax1_tx) ? (empty($this->localtax1_tx)?0:$this->localtax1_tx) : "null") . ","; - $sql .= " localtax2_tx=" . (isset($this->localtax2_tx) ? (empty($this->localtax2_tx)?0:$this->localtax2_tx) : "null") . ","; - $sql .= " localtax1_type=" . (! empty($this->localtax1_type) ? "'".$this->db->escape($this->localtax1_type)."'": "'0'") . ","; - $sql .= " localtax2_type=" . (! empty($this->localtax2_type) ? "'".$this->db->escape($this->localtax2_type)."'": "'0'") . ","; - $sql .= " fk_user=" . $user->id . ","; - $sql .= " import_key=" . (isset($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null") . ""; + $sql .= " tva_tx=".(isset($this->tva_tx) ? (empty($this->tva_tx) ? 0 : $this->tva_tx) : "null").","; + $sql .= " recuperableonly=".(isset($this->recuperableonly) ? $this->recuperableonly : "null").","; + $sql .= " localtax1_tx=".(isset($this->localtax1_tx) ? (empty($this->localtax1_tx) ? 0 : $this->localtax1_tx) : "null").","; + $sql .= " localtax2_tx=".(isset($this->localtax2_tx) ? (empty($this->localtax2_tx) ? 0 : $this->localtax2_tx) : "null").","; + $sql .= " localtax1_type=".(!empty($this->localtax1_type) ? "'".$this->db->escape($this->localtax1_type)."'" : "'0'").","; + $sql .= " localtax2_type=".(!empty($this->localtax2_type) ? "'".$this->db->escape($this->localtax2_type)."'" : "'0'").","; + $sql .= " fk_user=".$user->id.","; + $sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null").""; - $sql .= " WHERE rowid=" . $this->id; + $sql .= " WHERE rowid=".$this->id; - dol_syslog(get_class($this) . "::update", LOG_DEBUG); + dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors [] = "Error " . $this->db->lasterror(); + if (!$resql) { + $error++; + $this->errors [] = "Error ".$this->db->lasterror(); } - if (! $error) { - if (! $notrigger) { + if (!$error) { + if (!$notrigger) { // Call triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('PRODUCT_CUSTOMER_PRICE_UPDATE', $this, $user, $langs, $conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } + include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; + $interface = new Interfaces($this->db); + $result = $interface->run_triggers('PRODUCT_CUSTOMER_PRICE_UPDATE', $this, $user, $langs, $conf); + if ($result < 0) { $error++; $this->errors = $interface->errors; } // End call triggers } } - if (! $error) { + if (!$error) { $result = $this->setPriceOnAffiliateThirdparty($user, $forceupdateaffiliate); if ($result < 0) { - $error ++; + $error++; } } // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this) . "::update " . $errmsg, LOG_ERR); - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); return 1; @@ -754,34 +754,34 @@ class Productcustomerprice extends CommonObject // Find all susidiaries $sql = "SELECT s.rowid"; - $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; - $sql .= " WHERE s.parent = " . $this->fk_soc; - $sql .= " AND s.entity IN (" . getEntity('societe') . ")"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= " WHERE s.parent = ".$this->fk_soc; + $sql .= " AND s.entity IN (".getEntity('societe').")"; - dol_syslog(get_class($this) . "::setPriceOnAffiliateThirdparty", LOG_DEBUG); + dol_syslog(get_class($this)."::setPriceOnAffiliateThirdparty", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - $this->lines = array (); + $this->lines = array(); $num = $this->db->num_rows($resql); - while ( ($obj = $this->db->fetch_object($resql)) && (empty($error)) ) { + while (($obj = $this->db->fetch_object($resql)) && (empty($error))) { // find if there is an existing line for the product and the subsidiaries $prodsocprice = new Productcustomerprice($this->db); - $filter = array ( - 't.fk_product' => $this->fk_product,'t.fk_soc' => $obj->rowid + $filter = array( + 't.fk_product' => $this->fk_product, 't.fk_soc' => $obj->rowid ); $result = $prodsocprice->fetch_all('', '', 0, 0, $filter); if ($result < 0) { - $error ++; + $error++; $this->error = $prodsocprice->error; } else { // There is one line if (count($prodsocprice->lines) > 0) { // If force update => Update - if (! empty($forceupdateaffiliate)) { + if (!empty($forceupdateaffiliate)) { $prodsocpriceupd = new Productcustomerprice($this->db); $prodsocpriceupd->fetch($prodsocprice->lines [0]->id); @@ -793,7 +793,7 @@ class Productcustomerprice extends CommonObject $resultupd = $prodsocpriceupd->update($user, 0, $forceupdateaffiliate); if ($result < 0) { - $error ++; + $error++; $this->error = $prodsocpriceupd->error; } } @@ -810,7 +810,7 @@ class Productcustomerprice extends CommonObject $resultupd = $prodsocpricenew->create($user, 0, $forceupdateaffiliate); if ($result < 0) { - $error ++; + $error++; $this->error = $prodsocpriceupd->error; } } @@ -821,11 +821,11 @@ class Productcustomerprice extends CommonObject if (empty($error)) { return 1; } else { - return - 1; + return -1; } } else { - $this->error = "Error " . $this->db->lasterror(); - return - 1; + $this->error = "Error ".$this->db->lasterror(); + return -1; } } @@ -844,8 +844,8 @@ class Productcustomerprice extends CommonObject $this->db->begin(); - if (! $error) { - if (! $notrigger) { + if (!$error) { + if (!$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. @@ -858,26 +858,26 @@ class Productcustomerprice extends CommonObject } } - if (! $error) { - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "product_customer_price"; - $sql .= " WHERE rowid=" . $this->id; + if (!$error) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_customer_price"; + $sql .= " WHERE rowid=".$this->id; - dol_syslog(get_class($this) . "::delete", LOG_DEBUG); + dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { - $error ++; - $this->errors [] = "Error " . $this->db->lasterror(); + if (!$resql) { + $error++; + $this->errors [] = "Error ".$this->db->lasterror(); } } // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { - dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR); - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); return 1; @@ -908,28 +908,28 @@ class Productcustomerprice extends CommonObject // ... // Create clone - $object->context['createfromclone']='createfromclone'; + $object->context['createfromclone'] = 'createfromclone'; $result = $object->create($user); // Other options if ($result < 0) { $this->error = $object->error; - $this->errors=array_merge($this->errors, $object->errors); + $this->errors = array_merge($this->errors, $object->errors); $error++; } - if (! $error) { + if (!$error) { } unset($object->context['createfromclone']); // End - if (! $error) { + if (!$error) { $this->db->commit(); return $object->id; } else { $this->db->rollback(); - return - 1; + return -1; } } diff --git a/htdocs/product/document.php b/htdocs/product/document.php index ef508c9a200..f12b20b7921 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -62,33 +62,33 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="position_name"; +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "position_name"; $object = new Product($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); - if (! empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); - elseif (! empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); + if (!empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); + elseif (!empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs { - if (! empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos"; + if (!empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos"; else $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos"; } } -$modulepart='produit'; +$modulepart = 'produit'; /* * Actions */ -$parameters=array('id'=>$id); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$id); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) @@ -102,10 +102,10 @@ if (empty($reshook)) $urlfile = GETPOST('urlfile', 'alpha'); $filename = basename($urlfile); $filetomerge = new Propalmergepdfproduct($db); - $filetomerge->fk_product=$object->id; - $filetomerge->file_name=$filename; - $result=$filetomerge->delete_by_file($user); - if ($result<0) { + $filetomerge->fk_product = $object->id; + $filetomerge->file_name = $filename; + $result = $filetomerge->delete_by_file($user); + if ($result < 0) { setEventMessages($filetomerge->error, $filetomerge->errors, 'errors'); } } @@ -115,7 +115,7 @@ if (empty($reshook)) include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; } -if ($action=='filemerge') +if ($action == 'filemerge') { $is_refresh = GETPOST('refresh'); if (empty($is_refresh)) { @@ -131,11 +131,11 @@ if ($action=='filemerge') $filetomerge = new Propalmergepdfproduct($db); if ($conf->global->MAIN_MULTILANGS) { - $result=$filetomerge->delete_by_product($user, $object->id, $lang_id); + $result = $filetomerge->delete_by_product($user, $object->id, $lang_id); } else { - $result=$filetomerge->delete_by_product($user, $object->id); + $result = $filetomerge->delete_by_product($user, $object->id); } - if ($result<0) { + if ($result < 0) { setEventMessages($filetomerge->error, $filetomerge->errors, 'errors'); } @@ -149,8 +149,8 @@ if ($action=='filemerge') $filetomerge->lang = $lang_id; } - $result=$filetomerge->create($user); - if ($result<0) { + $result = $filetomerge->create($user); + if ($result < 0) { setEventMessages($filetomerge->error, $filetomerge->errors, 'errors'); } } @@ -170,13 +170,13 @@ $helpurl = ''; $shortlabel = dol_trunc($object->label, 16); if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { - $title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('Documents'); - $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Documents'); + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; } if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { - $title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('Documents'); - $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Documents'); + $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; } llxHeader('', $title, $helpurl); @@ -234,8 +234,8 @@ if ($object->id) dol_fiche_end(); $permission = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->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'; // Merge propal PDF document PDF files @@ -255,7 +255,7 @@ if ($object->id) $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', 'name', SORT_ASC, 1); - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs { $filearray = array_merge($filearray, dol_dir_list($upload_dirold, "files", 0, '', '\.meta$', 'name', SORT_ASC, 1)); } @@ -269,8 +269,8 @@ if ($object->id) print $langs->trans('PropalMergePdfProductActualFile'); } - print ''; - print ''; + print ''; + print ''; print ''; if (count($filetomerge->lines) == 0) { print $langs->trans('PropalMergePdfProductChooseFile'); @@ -291,7 +291,7 @@ if ($object->id) print Form::selectarray('lang_id', $langs_available, $default_lang, 0, 0, 0, '', 0, 0, 0, 'ASC'); if ($conf->global->MAIN_MULTILANGS) { - print ''; + print ''; } print ''; @@ -306,9 +306,9 @@ if ($object->id) if ($conf->global->MAIN_MULTILANGS) { - if (array_key_exists($filetoadd['name'] . '_' . $default_lang, $filetomerge->lines)) + if (array_key_exists($filetoadd['name'].'_'.$default_lang, $filetomerge->lines)) { - $filename = $filetoadd['name'] . ' - ' . $langs->trans('Language_' . $default_lang); + $filename = $filetoadd['name'].' - '.$langs->trans('Language_'.$default_lang); $checked = ' checked '; } } @@ -321,13 +321,13 @@ if ($object->id) } print ''; } } print ''; print '
trans("SellingPrice"); ?>
'; - print '' . $filename . ''; + print ''.$filename.''; print '
'; - print ''; + print ''; print '
'; diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index 3054aebfa9d..12c9163cf92 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -56,20 +56,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); @@ -77,10 +77,10 @@ if (! empty($canvas)) } // Define virtualdiffersfromphysical -$virtualdiffersfromphysical=0; -if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)|| ! empty($conf->global->STOCK_CALCULATE_ON_RECEPTION)) +$virtualdiffersfromphysical = 0; +if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION)) { - $virtualdiffersfromphysical=1; // According to increase/decrease stock options, virtual and physical stock may differs. + $virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs. } @@ -91,18 +91,18 @@ if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || ! empty($conf->global 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=''; - $fourn_id=''; - $sbarcode=''; + $sref = ""; + $snom = ""; + $sall = ""; + $tosell = ""; + $tobuy = ""; + $search_sale = ""; + $search_categ = ""; + $type = ""; + $catid = ''; + $toolowstock = ''; + $fourn_id = ''; + $sbarcode = ''; } @@ -111,50 +111,50 @@ 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); $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,'; -$sql.= ' SUM(s.reel) as stock_physique'; -if (! empty($conf->global->PRODUCT_USE_UNITS)) $sql.= ', u.short_label as unit_short'; -$sql.= ' FROM '.MAIN_DB_PREFIX.'product as p'; -$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s on p.rowid = s.fk_product'; -if (! empty($conf->global->PRODUCT_USE_UNITS)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_units as u on p.fk_unit = u.rowid'; +$sql .= ' p.fk_product_type, p.tms as datem,'; +$sql .= ' p.duration, p.tosell as statut, p.tobuy, p.seuil_stock_alerte, p.desiredstock,'; +$sql .= ' SUM(s.reel) as stock_physique'; +if (!empty($conf->global->PRODUCT_USE_UNITS)) $sql .= ', u.short_label as unit_short'; +$sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s on p.rowid = s.fk_product'; +if (!empty($conf->global->PRODUCT_USE_UNITS)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_units as u on p.fk_unit = u.rowid'; // 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); -$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, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock"; -if ($toolowstock) $sql.= " HAVING SUM(".$db->ifsql('s.reel IS NULL', '0', 's.reel').") < p.seuil_stock_alerte"; -$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, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock"; +if ($toolowstock) $sql .= " HAVING SUM(".$db->ifsql('s.reel IS NULL', '0', 's.reel').") < p.seuil_stock_alerte"; +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -169,7 +169,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) @@ -187,31 +187,31 @@ 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("MenuStocks").')'; + $texte .= ' ('.$langs->trans("MenuStocks").')'; - $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_sale) $param.="&search_sale=".urlencode($search_sale); - if ($search_categ) $param.="&search_categ=".urlencode($search_categ); - if ($toolowstock) $param.="&toolowstock=".urlencode($toolowstock); - if ($sbarcode) $param.="&sbarcode=".urlencode($sbarcode); - if ($catid) $param.="&catid=".urlencode($catid); + $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_sale) $param .= "&search_sale=".urlencode($search_sale); + if ($search_categ) $param .= "&search_categ=".urlencode($search_categ); + if ($toolowstock) $param .= "&toolowstock=".urlencode($toolowstock); + if ($sbarcode) $param .= "&sbarcode=".urlencode($sbarcode); + if ($catid) $param .= "&catid=".urlencode($catid); llxHeader("", $texte, $helpurl); - print ''; + print ''; print ''; print ''; print ''; @@ -220,7 +220,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); @@ -231,48 +231,48 @@ 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.='
'; - $moreforfilter.=$langs->trans("StockTooLow").' '; - $moreforfilter.='
'; + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans("StockTooLow").' '; + $moreforfilter .= '
'; - if (! empty($moreforfilter)) + if (!empty($moreforfilter)) { print '
'; print $moreforfilter; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; } - $param=''; - if ($tosell) $param.="&tosell=".$tosell; - if ($tobuy) $param.="&tobuy=".$tobuy; - if ($type) $param.="&type=".$type; - if ($fourn_id) $param.="&fourn_id=".$fourn_id; - if ($snom) $param.="&snom=".$snom; - if ($sref) $param.="&sref=".$sref; - if ($toolowstock) $param.="&toolowstock=".$toolowstock; - if ($search_categ) $param.="&search_categ=".$search_categ; + $param = ''; + if ($tosell) $param .= "&tosell=".$tosell; + if ($tobuy) $param .= "&tobuy=".$tobuy; + if ($type) $param .= "&type=".$type; + if ($fourn_id) $param .= "&fourn_id=".$fourn_id; + if ($snom) $param .= "&snom=".$snom; + if ($sref) $param .= "&sref=".$sref; + if ($toolowstock) $param .= "&toolowstock=".$toolowstock; + if ($search_categ) $param .= "&search_categ=".$search_categ; $formProduct = new FormProduct($db); $formProduct->loadWarehouses(); $warehouses_list = $formProduct->cache_warehouses; $nb_warehouse = count($warehouses_list); $colspan_warehouse = 1; - if (! empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) { $colspan_warehouse = $nb_warehouse > 1 ? $nb_warehouse+1 : 1; } + if (!empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) { $colspan_warehouse = $nb_warehouse > 1 ? $nb_warehouse + 1 : 1; } print '
'; - print ''; + print '
'; // Fields title search print ''; @@ -283,7 +283,7 @@ if ($resql) print ''; print ''; // Duration - if (! empty($conf->service->enabled) && $type == 1) + if (!empty($conf->service->enabled) && $type == 1) { print ''; print ''; print ''; print ''; @@ -307,14 +307,14 @@ 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("StockLimit", $_SERVER["PHP_SELF"], "p.seuil_stock_alerte", $param, "", '', $sortfield, $sortorder, 'right '); print_liste_field_titre("DesiredStock", $_SERVER["PHP_SELF"], "p.desiredstock", $param, "", '', $sortfield, $sortorder, 'right '); print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stock_physique", $param, "", '', $sortfield, $sortorder, 'right '); // Details per warehouse - if (! empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) // TODO This should be moved into the selection of fields on page product/list (page product/stock will be removed and replaced with product/list with its own context) + if (!empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) // TODO This should be moved into the selection of fields on page product/list (page product/stock will be removed and replaced with product/list with its own context) { - if ($nb_warehouse>1) { + if ($nb_warehouse > 1) { foreach ($warehouses_list as &$wh) { print_liste_field_titre($wh['label'], '', '', '', '', '', '', '', 'right '); } @@ -322,7 +322,7 @@ if ($resql) } if ($virtualdiffersfromphysical) print_liste_field_titre("VirtualStock", $_SERVER["PHP_SELF"], "", $param, "", '', $sortfield, $sortorder, 'right '); // Units - if (! empty($conf->global->PRODUCT_USE_UNITS)) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { print_liste_field_titre("Unit", $_SERVER["PHP_SELF"], "unit_short", $param, "", 'align="right"', $sortfield, $sortorder); } print_liste_field_titre(''); @@ -335,7 +335,7 @@ if ($resql) { $objp = $db->fetch_object($resql); - $product=new Product($db); + $product = new Product($db); $product->fetch($objp->rowid); $product->load_stock(); @@ -346,7 +346,7 @@ if ($resql) print ''; print ''; - if (! empty($conf->service->enabled) && $type == 1) + if (!empty($conf->service->enabled) && $type == 1) { print ''; // Details per warehouse - if (! empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) // TODO This should be moved into the selection of fields on page product/list (page product/stock will be removed and replaced with product/list with its own context) + if (!empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) // TODO This should be moved into the selection of fields on page product/list (page product/stock will be removed and replaced with product/list with its own context) { - if($nb_warehouse>1) { - foreach($warehouses_list as &$wh) { + if ($nb_warehouse > 1) { + foreach ($warehouses_list as &$wh) { print ''; @@ -385,8 +385,8 @@ if ($resql) print ''; } // Units - if (! empty($conf->global->PRODUCT_USE_UNITS)) { - print ''; + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + print ''; } print ''; print ''; diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index 6a0748f8f84..7ffc0908c4e 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -26,13 +26,13 @@ * \brief File to offer a way to make an online signature for a particular Dolibarr entity */ -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. // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php // TODO This should be useless. Because entity must be retreive from object ref and not from url. -$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) define("DOLENTITY", $entity); require '../../main.inc.php'; @@ -46,7 +46,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $langs->loadLangs(array("main", "other", "dict", "bills", "companies", "errors", "paybox")); -$action=GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); // Input are: // type ('invoice','order','contractline'), @@ -55,15 +55,15 @@ $action=GETPOST('action', 'alpha'); // tag (a free text, required if type is empty) // currency (iso code) -$suffix=GETPOST("suffix", 'alpha'); -$source=GETPOST("source", 'alpha'); -$ref=$REF=GETPOST("ref", 'alpha'); +$suffix = GETPOST("suffix", 'alpha'); +$source = GETPOST("source", 'alpha'); +$ref = $REF = GETPOST("ref", 'alpha'); -if (empty($source)) $source='proposal'; +if (empty($source)) $source = 'proposal'; -if (! $action) +if (!$action) { - if ($source && ! $ref) + if ($source && !$ref) { print $langs->trans('ErrorBadParameters')." - ref missing"; exit; @@ -71,8 +71,8 @@ if (! $action) } -$paymentmethod=''; -$validpaymentmethod=array(); +$paymentmethod = ''; +$validpaymentmethod = array(); @@ -80,34 +80,34 @@ $validpaymentmethod=array(); // 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 -$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost. +$urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost. // Complete urls for post treatment -$SECUREKEY=GETPOST("securekey"); // Secure key +$SECUREKEY = GETPOST("securekey"); // Secure key -if (! empty($source)) +if (!empty($source)) { - $urlok.='source='.urlencode($source).'&'; - $urlko.='source='.urlencode($source).'&'; + $urlok .= 'source='.urlencode($source).'&'; + $urlko .= 'source='.urlencode($source).'&'; } -if (! empty($REF)) +if (!empty($REF)) { - $urlok.='ref='.urlencode($REF).'&'; - $urlko.='ref='.urlencode($REF).'&'; + $urlok .= 'ref='.urlencode($REF).'&'; + $urlko .= 'ref='.urlencode($REF).'&'; } -if (! empty($SECUREKEY)) +if (!empty($SECUREKEY)) { - $urlok.='securekey='.urlencode($SECUREKEY).'&'; - $urlko.='securekey='.urlencode($SECUREKEY).'&'; + $urlok .= 'securekey='.urlencode($SECUREKEY).'&'; + $urlko .= 'securekey='.urlencode($SECUREKEY).'&'; } -if (! empty($entity)) +if (!empty($entity)) { - $urlok.='entity='.urlencode($entity).'&'; - $urlko.='entity='.urlencode($entity).'&'; + $urlok .= 'entity='.urlencode($entity).'&'; + $urlko .= 'entity='.urlencode($entity).'&'; } -$urlok=preg_replace('/&$/', '', $urlok); // Remove last & -$urlko=preg_replace('/&$/', '', $urlko); // Remove last & +$urlok = preg_replace('/&$/', '', $urlok); // Remove last & +$urlko = preg_replace('/&$/', '', $urlko); // Remove last & $creditor = $mysoc->name; @@ -127,16 +127,16 @@ if ($action == 'dosign') * View */ -$head=''; -if (! empty($conf->global->MAIN_SIGN_CSS_URL)) $head=''."\n"; +$head = ''; +if (!empty($conf->global->MAIN_SIGN_CSS_URL)) $head = ''."\n"; -$conf->dol_hide_topmenu=1; -$conf->dol_hide_leftmenu=1; +$conf->dol_hide_topmenu = 1; +$conf->dol_hide_leftmenu = 1; llxHeader($head, $langs->trans("OnlineSignature"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'); // Check link validity -if (! empty($source) && in_array($ref, array('member_ref', 'contractline_ref', 'invoice_ref', 'order_ref', ''))) +if (!empty($source) && in_array($ref, array('member_ref', 'contractline_ref', 'invoice_ref', 'order_ref', ''))) { $langs->load("errors"); dol_print_error_email('BADREFINONLINESIGNFORM', $langs->trans("ErrorBadLinkSourceSetButBadValueForRef", $source, $ref)); @@ -161,24 +161,24 @@ print ''."\n"; print '
'; print ' '; @@ -298,7 +298,7 @@ if ($resql) print ' '; - $searchpicto=$form->showFilterAndCheckAddButtons(0); + $searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
'.$product->label.''; if (preg_match('/([0-9]+)y/i', $objp->duration, $regs)) print $regs[1].' '.$langs->trans("DurationYear"); @@ -361,14 +361,14 @@ if ($resql) // Real stock print ''; if ($objp->seuil_stock_alerte != '' && ($objp->stock_physique < $objp->seuil_stock_alerte)) print img_warning($langs->trans("StockTooLow")).' '; - print $objp->stock_physique|0; + print $objp->stock_physique | 0; print ''; print empty($product->stock_warehouse[$wh['id']]->real) ? '0' : $product->stock_warehouse[$wh['id']]->real; print '' . $objp->unit_short . ''.$objp->unit_short.''.$langs->trans("Movements").''.$product->LibStatut($objp->statut, 5, 0).'
'."\n"; // Show logo (search order: logo defined by ONLINE_SIGN_LOGO_suffix, then ONLINE_SIGN_LOGO_, then small company logo, large company logo, theme logo, common logo) -$width=0; +$width = 0; // Define logo and logosmall -$logosmall=$mysoc->logo_small; -$logo=$mysoc->logo; -$paramlogo='ONLINE_SIGN_LOGO_'.$suffix; -if (! empty($conf->global->$paramlogo)) $logosmall=$conf->global->$paramlogo; -elseif (! empty($conf->global->ONLINE_SIGN_LOGO)) $logosmall=$conf->global->ONLINE_SIGN_LOGO; +$logosmall = $mysoc->logo_small; +$logo = $mysoc->logo; +$paramlogo = 'ONLINE_SIGN_LOGO_'.$suffix; +if (!empty($conf->global->$paramlogo)) $logosmall = $conf->global->$paramlogo; +elseif (!empty($conf->global->ONLINE_SIGN_LOGO)) $logosmall = $conf->global->ONLINE_SIGN_LOGO; //print ''."\n"; // Define urllogo -$urllogo=''; -if (! empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) +$urllogo = ''; +if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) { - $urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); } -elseif (! empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) +elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) { - $urllogo=DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); - $width=96; + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); + $width = 96; } // Output html code for logo if ($urllogo) @@ -191,18 +191,18 @@ if ($urllogo) } // Output introduction text -$text=''; -if (! empty($conf->global->ONLINE_SIGN_NEWFORM_TEXT)) +$text = ''; +if (!empty($conf->global->ONLINE_SIGN_NEWFORM_TEXT)) { $langs->load("members"); - if (preg_match('/^\((.*)\)$/', $conf->global->ONLINE_SIGN_NEWFORM_TEXT, $reg)) $text.=$langs->trans($reg[1])."
\n"; - else $text.=$conf->global->ONLINE_SIGN_NEWFORM_TEXT."
\n"; - $text=''."\n"; + if (preg_match('/^\((.*)\)$/', $conf->global->ONLINE_SIGN_NEWFORM_TEXT, $reg)) $text .= $langs->trans($reg[1])."
\n"; + else $text .= $conf->global->ONLINE_SIGN_NEWFORM_TEXT."
\n"; + $text = ''."\n"; } if (empty($text)) { - $text.=''."\n"; - $text.=''."\n"; + $text .= ''."\n"; + $text .= ''."\n"; } print $text; @@ -211,47 +211,47 @@ print '

'.$text.'

'.$text.'

'.$langs->trans("WelcomeOnOnlineSignaturePage", $mysoc->name).'
'.$langs->trans("ThisScreenAllowsYouToSignDocFrom", $creditor).'


'.$langs->trans("WelcomeOnOnlineSignaturePage", $mysoc->name).'
'.$langs->trans("ThisScreenAllowsYouToSignDocFrom", $creditor).'

'; print ''; print ''."\n"; -$found=false; -$error=0; -$var=false; +$found = false; +$error = 0; +$var = false; // Payment on customer order if ($source == 'proposal') { - $found=true; + $found = true; $langs->load("proposal"); require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - $proposal=new Propal($db); - $result=$proposal->fetch('', $ref); + $proposal = new Propal($db); + $result = $proposal->fetch('', $ref); if ($result <= 0) { - $mesg=$proposal->error; + $mesg = $proposal->error; $error++; } else { - $result=$proposal->fetch_thirdparty($proposal->socid); + $result = $proposal->fetch_thirdparty($proposal->socid); } // Creditor - print ''."\n"; // Debitor - print ''."\n"; @@ -259,7 +259,7 @@ if ($source == 'proposal') -if (! $found && ! $mesg) $mesg=$langs->trans("ErrorBadParameters"); +if (!$found && !$mesg) $mesg = $langs->trans("ErrorBadParameters"); if ($mesg) print ''."\n"; @@ -268,7 +268,7 @@ print "\n"; if ($action != 'dosign') { - if ($found && ! $error) // We are in a management option and no error + if ($found && !$error) // We are in a management option and no error { } else diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index 00a92ecc115..9b3dd7dea03 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -22,8 +22,8 @@ * \ingroup core * \brief Class file to manage forms into resource module */ -require_once DOL_DOCUMENT_ROOT ."/core/class/html.form.class.php"; -require_once DOL_DOCUMENT_ROOT ."/resource/class/dolresource.class.php"; +require_once DOL_DOCUMENT_ROOT."/core/class/html.form.class.php"; +require_once DOL_DOCUMENT_ROOT."/resource/class/dolresource.class.php"; /** @@ -39,14 +39,14 @@ class FormResource */ public $db; - public $substit=array(); + public $substit = array(); - public $param=array(); + public $param = array(); /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** @@ -79,10 +79,10 @@ class FormResource public function select_resource_list($selected = '', $htmlname = 'fk_resource', $filter = '', $showempty = 0, $showtype = 0, $forcecombo = 0, $event = array(), $filterkey = '', $outputmode = 0, $limit = 20) { // phpcs:enable - global $conf,$user,$langs; + global $conf, $user, $langs; - $out=''; - $outarray=array(); + $out = ''; + $outarray = array(); $resourcestat = new Dolresource($this->db); @@ -91,20 +91,20 @@ class FormResource if ($outputmode != 2) { $out = ''; - $out.= ''; + $out .= ''; } if ($resourcestat) { - if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->RESOURCE_USE_SEARCH_TO_SELECT) && ! $forcecombo) + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->RESOURCE_USE_SEARCH_TO_SELECT) && !$forcecombo) { //$minLength = (is_numeric($conf->global->RESOURCE_USE_SEARCH_TO_SELECT)?$conf->global->RESOURCE_USE_SEARCH_TO_SELECT:2); - $out.= ajax_combobox($htmlname, $event, $conf->global->RESOURCE_USE_SEARCH_TO_SELECT); + $out .= ajax_combobox($htmlname, $event, $conf->global->RESOURCE_USE_SEARCH_TO_SELECT); } // Construct $out and $outarray - $out.= ''."\n"; + if ($showempty) $out .= ''."\n"; $num = 0; if (is_array($resourcestat->lines)) $num = count($resourcestat->lines); @@ -115,34 +115,34 @@ class FormResource { while ($i < $num) { - $resourceclass=ucfirst($resourcestat->lines[$i]->element); + $resourceclass = ucfirst($resourcestat->lines[$i]->element); - $label=$resourcestat->lines[$i]->ref?$resourcestat->lines[$i]->ref:''.$resourcestat->lines[$i]->label; - if ($resourceclass != 'Dolresource') $label.=' ('.$langs->trans($resourceclass).')'; + $label = $resourcestat->lines[$i]->ref ? $resourcestat->lines[$i]->ref : ''.$resourcestat->lines[$i]->label; + if ($resourceclass != 'Dolresource') $label .= ' ('.$langs->trans($resourceclass).')'; if ($selected > 0 && $selected == $resourcestat->lines[$i]->id) { - $out.= ''; + $out .= ''; } else { - $out.= ''; + $out .= ''; } array_push($outarray, array('key'=>$resourcestat->lines[$i]->id, 'value'=>$resourcestat->lines[$i]->label, 'label'=>$resourcestat->lines[$i]->label)); $i++; - if (($i % 10) == 0) $out.="\n"; + if (($i % 10) == 0) $out .= "\n"; } } - $out.= ''."\n"; - $out.= ajax_combobox($htmlname); + $out .= ''."\n"; + $out .= ajax_combobox($htmlname); if ($outputmode != 2) { - $out.= '     '; + $out .= '     '; - $out.= ''; + $out .= ''; } } else @@ -170,22 +170,22 @@ class FormResource public function select_types_resource($selected = '', $htmlname = 'type_resource', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0) { // phpcs:enable - global $langs,$user; + global $langs, $user; $resourcestat = new Dolresource($this->db); dol_syslog(get_class($this)."::select_types_resource ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG); - $filterarray=array(); + $filterarray = array(); - if ($filtertype != '' && $filtertype != '-1') $filterarray=explode(',', $filtertype); + if ($filtertype != '' && $filtertype != '-1') $filterarray = explode(',', $filtertype); $resourcestat->load_cache_code_type_resource(); print ''; - if ($user->admin && ! $noadmininfo) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + if ($user->admin && !$noadmininfo) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } } diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 42fae860666..b8fbb099fb3 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -57,7 +57,7 @@ class Thirdparties extends DolibarrApi $this->company = new Societe($this->db); - if (! empty($conf->global->SOCIETE_EMAIL_MANDATORY)) { + if (!empty($conf->global->SOCIETE_EMAIL_MANDATORY)) { static::$FIELDS[] = 'email'; } } @@ -121,24 +121,24 @@ class Thirdparties extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; + if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; $sql = "SELECT t.rowid"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - $sql.= " FROM ".MAIN_DB_PREFIX."societe as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as t"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale - $sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st"; - $sql.= " WHERE t.fk_stcomm = st.id"; - if ($mode == 1) $sql.= " AND t.client IN (1, 3)"; - if ($mode == 2) $sql.= " AND t.client IN (2, 3)"; - if ($mode == 3) $sql.= " AND t.client IN (0)"; - if ($mode == 4) $sql.= " AND t.fournisseur IN (1)"; - $sql.= ' AND t.entity IN ('.getEntity('societe').')'; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + $sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st"; + $sql .= " WHERE t.fk_stcomm = st.id"; + if ($mode == 1) $sql .= " AND t.client IN (1, 3)"; + if ($mode == 2) $sql .= " AND t.client IN (2, 3)"; + if ($mode == 3) $sql .= " AND t.client IN (0)"; + if ($mode == 4) $sql .= " AND t.fournisseur IN (1)"; + $sql .= ' AND t.entity IN ('.getEntity('societe').')'; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; //if ($email != NULL) $sql.= " AND s.email = \"".$email."\""; - if ($socid) $sql.= " AND t.rowid IN (".$socids.")"; - if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + if ($socid) $sql .= " AND t.rowid IN (".$socids.")"; + if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale // Insert sale filter if ($search_sale > 0) { @@ -147,15 +147,15 @@ class Thirdparties extends DolibarrApi // 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); + $sql .= $db->order($sortfield, $sortorder); if ($limit) { if ($page < 0) @@ -164,7 +164,7 @@ class Thirdparties extends DolibarrApi } $offset = $limit * $page; - $sql.= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); } $result = $db->query($sql); @@ -176,7 +176,7 @@ class Thirdparties extends DolibarrApi { $obj = $db->fetch_object($result); $soc_static = new Societe($db); - if($soc_static->fetch($obj->rowid)) { + if ($soc_static->fetch($obj->rowid)) { $obj_ret[] = $this->_cleanObjectDatas($soc_static); } $i++; @@ -185,7 +185,7 @@ class Thirdparties extends DolibarrApi else { throw new RestException(503, 'Error when retrieve thirdparties : '.$db->lasterror()); } - if( ! count($obj_ret)) { + if (!count($obj_ret)) { throw new RestException(404, 'Thirdparties not found'); } return $obj_ret; @@ -199,13 +199,13 @@ class Thirdparties extends DolibarrApi */ public function post($request_data = null) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } // Check mandatory fields $result = $this->_validate($request_data); - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $this->company->$field = $value; } if ($this->company->create(DolibarrApiAccess::$user) < 0) @@ -223,25 +223,25 @@ class Thirdparties extends DolibarrApi */ public function put($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { if ($field == 'id') continue; $this->company->$field = $value; } - if($this->company->update($id, DolibarrApiAccess::$user, 1, '', '', 'update')) + if ($this->company->update($id, DolibarrApiAccess::$user, 1, '', '', 'update')) return $this->get($id); return false; @@ -272,27 +272,27 @@ class Thirdparties extends DolibarrApi throw new RestException(400, 'Try to merge a thirdparty into itself'); } - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } - $result = $this->company->fetch($id); // include the fetch of extra fields - if( ! $result ) { + $result = $this->company->fetch($id); // include the fetch of extra fields + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->companytoremove = new Societe($db); - $result = $this->companytoremove->fetch($idtodelete); // include the fetch of extra fields - if( ! $result ) { + $result = $this->companytoremove->fetch($idtodelete); // include the fetch of extra fields + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $this->companytoremove->id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $this->companytoremove->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -309,7 +309,7 @@ class Thirdparties extends DolibarrApi // Recopy some data $object->client = $object->client | $soc_origin->client; $object->fournisseur = $object->fournisseur | $soc_origin->fournisseur; - $listofproperties=array( + $listofproperties = array( 'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'url', 'barcode', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', 'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'remise_supplier_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis', @@ -323,7 +323,7 @@ class Thirdparties extends DolibarrApi } // Concat some data - $listofproperties=array( + $listofproperties = array( 'note_public', 'note_private' ); foreach ($listofproperties as $property) @@ -367,7 +367,7 @@ class Thirdparties extends DolibarrApi } // Move links - if (! $error) + if (!$error) { $objects = array( 'Adherent' => '/adherents/class/adherent.class.php', @@ -422,12 +422,12 @@ class Thirdparties extends DolibarrApi } - if (! $error) + if (!$error) { - $object->context=array('merge'=>1, 'mergefromid'=>$soc_origin->id); + $object->context = array('merge'=>1, 'mergefromid'=>$soc_origin->id); // Call trigger - $result=$object->call_trigger('COMPANY_MODIFY', $user); + $result = $object->call_trigger('COMPANY_MODIFY', $user); if ($result < 0) { //setEventMessages($object->error, $object->errors, 'errors'); @@ -436,7 +436,7 @@ class Thirdparties extends DolibarrApi // End call triggers } - if (! $error) + if (!$error) { //We finally remove the old thirdparty if ($soc_origin->delete($soc_origin->id, $user) < 1) @@ -469,14 +469,14 @@ class Thirdparties extends DolibarrApi */ public function delete($id) { - if(! DolibarrApiAccess::$user->rights->societe->supprimer) { + if (!DolibarrApiAccess::$user->rights->societe->supprimer) { throw new RestException(401); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->company->oldcopy = clone $this->company; @@ -498,12 +498,12 @@ class Thirdparties extends DolibarrApi */ public function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { - if (! DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); } $result = $this->company->fetch($id); - if( ! $result ) + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } @@ -537,24 +537,24 @@ class Thirdparties extends DolibarrApi */ public function addCategory($id, $category_id) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } $category = new Categorie($this->db); $result = $category->fetch($category_id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'category not found'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( ! DolibarrApi::_checkAccessToResource('category', $category->id)) { + if (!DolibarrApi::_checkAccessToResource('category', $category->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -575,24 +575,24 @@ class Thirdparties extends DolibarrApi */ public function deleteCategory($id, $category_id) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } $category = new Categorie($this->db); $result = $category->fetch($category_id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'category not found'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( ! DolibarrApi::_checkAccessToResource('category', $category->id)) { + if (!DolibarrApi::_checkAccessToResource('category', $category->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -616,12 +616,12 @@ class Thirdparties extends DolibarrApi */ public function getSupplierCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { - if (! DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); } $result = $this->company->fetch($id); - if( ! $result ) + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } @@ -655,24 +655,24 @@ class Thirdparties extends DolibarrApi */ public function addSupplierCategory($id, $category_id) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } $category = new Categorie($this->db); $result = $category->fetch($category_id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'category not found'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( ! DolibarrApi::_checkAccessToResource('category', $category->id)) { + if (!DolibarrApi::_checkAccessToResource('category', $category->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -693,24 +693,24 @@ class Thirdparties extends DolibarrApi */ public function deleteSupplierCategory($id, $category_id) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } $category = new Categorie($this->db); $result = $category->fetch($category_id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'category not found'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( ! DolibarrApi::_checkAccessToResource('category', $category->id)) { + if (!DolibarrApi::_checkAccessToResource('category', $category->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -738,20 +738,20 @@ class Thirdparties extends DolibarrApi { $obj_ret = array(); - if(! DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->rights->societe->lire) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Thirdparty ID is mandatory'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } @@ -782,20 +782,20 @@ class Thirdparties extends DolibarrApi { $obj_ret = array(); - if(! DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->rights->societe->lire) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Thirdparty ID is mandatory'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } @@ -825,20 +825,20 @@ class Thirdparties extends DolibarrApi { $obj_ret = array(); - if(! DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->rights->societe->lire) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Thirdparty ID is mandatory'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } @@ -868,20 +868,20 @@ class Thirdparties extends DolibarrApi { $obj_ret = array(); - if(! DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->rights->societe->lire) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Thirdparty ID is mandatory'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $result = $this->company->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } @@ -935,14 +935,14 @@ class Thirdparties extends DolibarrApi if ($filter == "available") $sql .= " AND re.fk_facture IS NULL AND re.fk_facture_line IS NULL"; if ($filter == "used") $sql .= " AND (re.fk_facture IS NOT NULL OR re.fk_facture_line IS NOT NULL)"; - $sql.= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->order($sortfield, $sortorder); $result = $this->db->query($sql); - if( ! $result ) { + if (!$result) { throw new RestException(503, $this->db->lasterror()); } else { $num = $this->db->num_rows($result); - while ( $obj = $this->db->fetch_object($result) ) { + while ($obj = $this->db->fetch_object($result)) { $obj_ret[] = $obj; } } @@ -967,14 +967,14 @@ class Thirdparties extends DolibarrApi */ public function getInvoicesQualifiedForReplacement($id) { - if(! DolibarrApiAccess::$user->rights->facture->lire) { + if (!DolibarrApiAccess::$user->rights->facture->lire) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Thirdparty ID is mandatory'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -985,7 +985,7 @@ class Thirdparties extends DolibarrApi $invoice = new Facture($this->db); $result = $invoice->list_replacable_invoices($id); - if( $result < 0) { + if ($result < 0) { throw new RestException(405, $this->thirdparty->error); } @@ -1009,14 +1009,14 @@ class Thirdparties extends DolibarrApi */ public function getInvoicesQualifiedForCreditNote($id) { - if(! DolibarrApiAccess::$user->rights->facture->lire) { + if (!DolibarrApiAccess::$user->rights->facture->lire) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Thirdparty ID is mandatory'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -1027,7 +1027,7 @@ class Thirdparties extends DolibarrApi $invoice = new Facture($this->db); $result = $invoice->list_qualified_avoir_invoices($id); - if( $result < 0) { + if ($result < 0) { throw new RestException(405, $this->thirdparty->error); } @@ -1047,14 +1047,14 @@ class Thirdparties extends DolibarrApi { global $db, $conf; - if(! DolibarrApiAccess::$user->rights->facture->lire) { + if (!DolibarrApiAccess::$user->rights->facture->lire) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Thirdparty ID is mandatory'); } - if( ! DolibarrApi::_checkAccessToResource('societe', $id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -1063,18 +1063,18 @@ class Thirdparties extends DolibarrApi */ $sql = "SELECT rowid, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,"; - $sql.= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib"; - if ($id) $sql.= " WHERE fk_soc = ".$id." "; + $sql .= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib"; + if ($id) $sql .= " WHERE fk_soc = ".$id." "; $result = $db->query($sql); - if($result->num_rows == 0 ){ + if ($result->num_rows == 0) { throw new RestException(404, 'Account not found'); } - $i=0; + $i = 0; $accounts = array(); @@ -1085,13 +1085,13 @@ class Thirdparties extends DolibarrApi { $obj = $db->fetch_object($result); $account = new CompanyBankAccount($db); - if($account->fetch($obj->rowid)) { + if ($account->fetch($obj->rowid)) { $accounts[] = $account; } $i++; } } - else{ + else { throw new RestException(404, 'Account not found'); } @@ -1124,7 +1124,7 @@ class Thirdparties extends DolibarrApi */ public function createCompanyBankAccount($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } @@ -1132,7 +1132,7 @@ class Thirdparties extends DolibarrApi $account->socid = $id; - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $account->$field = $value; } @@ -1159,7 +1159,7 @@ class Thirdparties extends DolibarrApi */ public function updateCompanyBankAccount($id, $bankaccount_id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } @@ -1167,12 +1167,12 @@ class Thirdparties extends DolibarrApi $account->fetch($bankaccount_id, $id, -1, ''); - if($account->socid != $id){ + if ($account->socid != $id) { throw new RestException(401); } - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $account->$field = $value; } @@ -1194,7 +1194,7 @@ class Thirdparties extends DolibarrApi */ public function deleteCompanyBankAccount($id, $bankaccount_id) { - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } @@ -1202,7 +1202,7 @@ class Thirdparties extends DolibarrApi $account->fetch($bankaccount_id); - if(!$account->socid == $id) + if (!$account->socid == $id) throw new RestException(401); return $account->delete(DolibarrApiAccess::$user); @@ -1222,12 +1222,12 @@ class Thirdparties extends DolibarrApi { global $conf; - $this->langs->loadLangs(array("main","dict","commercial","products","companies","banks","bills","withdrawals")); + $this->langs->loadLangs(array("main", "dict", "commercial", "products", "companies", "banks", "bills", "withdrawals")); $this->company->fetch($id); $action = 'builddoc'; - if(! DolibarrApiAccess::$user->rights->societe->creer) + if (!DolibarrApiAccess::$user->rights->societe->creer) throw new RestException(401); $this->company->setDocModel(DolibarrApiAccess::$user, $model); @@ -1235,32 +1235,32 @@ class Thirdparties extends DolibarrApi $this->company->fk_bank = $this->company->fk_account; $outputlangs = $this->langs; - $newlang=''; + $newlang = ''; - if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang=GETPOST('lang_id', 'aZ09'); - if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->thirdparty->default_lang)) $newlang=$this->company->thirdparty->default_lang; // for proposal, order, invoice, ... - if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->default_lang)) $newlang=$this->company->default_lang; // for thirdparty - if (! empty($newlang)) { + if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->thirdparty->default_lang)) $newlang = $this->company->thirdparty->default_lang; // for proposal, order, invoice, ... + if ($this->conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->company->default_lang)) $newlang = $this->company->default_lang; // for thirdparty + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } // To be sure vars is defined $hidedetails = $hidedesc = $hideref = 0; - $moreparams=null; - if (empty($hidedetails)) $hidedetails=0; - if (empty($hidedesc)) $hidedesc=0; - if (empty($hideref)) $hideref=0; - if (empty($moreparams)) $moreparams=null; + $moreparams = null; + if (empty($hidedetails)) $hidedetails = 0; + if (empty($hidedesc)) $hidedesc = 0; + if (empty($hideref)) $hideref = 0; + if (empty($moreparams)) $moreparams = null; $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib"; - if ($id) $sql.= " WHERE fk_soc = ".$id." "; - if ($companybankid) $sql.= " AND id = ".$companybankid.""; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib"; + if ($id) $sql .= " WHERE fk_soc = ".$id." "; + if ($companybankid) $sql .= " AND id = ".$companybankid.""; - $i=0; - $accounts=array(); + $i = 0; + $accounts = array(); $result = $this->db->query($sql); if ($result) @@ -1321,11 +1321,11 @@ class Thirdparties extends DolibarrApi { global $db, $conf; - if(!DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->rights->societe->lire) { throw new RestException(401); } - if(!DolibarrApi::_checkAccessToResource('societe', $id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -1333,16 +1333,16 @@ class Thirdparties extends DolibarrApi * We select all the records that match the socid */ $sql = "SELECT rowid, fk_soc, key_account, site, date_creation, tms FROM ".MAIN_DB_PREFIX."societe_account"; - $sql.= " WHERE fk_soc = $id"; - if($site) $sql .= " AND site ='$site'"; + $sql .= " WHERE fk_soc = $id"; + if ($site) $sql .= " AND site ='$site'"; $result = $db->query($sql); - if($result->num_rows == 0){ + if ($result->num_rows == 0) { throw new RestException(404, 'This thirdparty does not have any gateway attached or does not exist.'); } - $i=0; + $i = 0; $accounts = array(); @@ -1352,7 +1352,7 @@ class Thirdparties extends DolibarrApi $obj = $db->fetch_object($result); $account = new SocieteAccount($db); - if($account->fetch($obj->rowid)) { + if ($account->fetch($obj->rowid)) { $accounts[] = $account; } $i++; @@ -1398,25 +1398,25 @@ class Thirdparties extends DolibarrApi { global $db; - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } - if(!isset($request_data['site'])) { + if (!isset($request_data['site'])) { throw new RestException(422, 'Unprocessable Entity: You must pass the site attribute in your request data !'); } - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '". $request_data['site']."' "; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '".$request_data['site']."' "; $result = $db->query($sql); - if($result->num_rows == 0 ){ + if ($result->num_rows == 0) { $account = new SocieteAccount($this->db); - if(!isset($request_data['login'])) { + if (!isset($request_data['login'])) { $account->login = ""; } $account->fk_soc = $id; - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $account->$field = $value; } @@ -1457,7 +1457,7 @@ class Thirdparties extends DolibarrApi { global $db; - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } @@ -1465,16 +1465,16 @@ class Thirdparties extends DolibarrApi $result = $db->query($sql); // We do not found an existing SocieteAccount entity for this fk_soc and site ; we then create a new one. - if($result->num_rows == 0 ){ - if(!isset($request_data['key_account'])) { + if ($result->num_rows == 0) { + if (!isset($request_data['key_account'])) { throw new RestException(422, 'Unprocessable Entity: You must pass the key_account attribute in your request data !'); } $account = new SocieteAccount($this->db); - if(!isset($request_data['login'])) { + if (!isset($request_data['login'])) { $account->login = ""; } - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $account->$field = $value; } @@ -1501,13 +1501,13 @@ class Thirdparties extends DolibarrApi $account->id = $obj->rowid; $account->fk_soc = $id; $account->site = $site; - if(!isset($request_data['login'])) { + if (!isset($request_data['login'])) { $account->login = ""; } $account->fk_user_creat = $obj->fk_user_creat; $account->date_creation = $obj->date_creation; - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $account->$field = $value; } @@ -1539,30 +1539,30 @@ class Thirdparties extends DolibarrApi { global $db; - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = $id AND site = '$site' "; $result = $db->query($sql); - if($result->num_rows == 0 ){ + if ($result->num_rows == 0) { throw new RestException(404, "This thirdparty does not have $site gateway attached or does not exist."); } else { // If the user tries to edit the site member, we check first if - if(isset($request_data['site']) && $request_data['site'] !== $site) { - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '". $request_data['site']."' "; + if (isset($request_data['site']) && $request_data['site'] !== $site) { + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '".$request_data['site']."' "; $result = $db->query($sql); - if($result->num_rows !== 0) - throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) site member from $site to ".$request_data['site'] . " but another SocieteAccount entity already exists for this thirdparty with this site key."); + if ($result->num_rows !== 0) + throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) site member from $site to ".$request_data['site']." but another SocieteAccount entity already exists for this thirdparty with this site key."); } $obj = $db->fetch_object($result); $account = new SocieteAccount($this->db); $account->fetch($obj->rowid); - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $account->$field = $value; } @@ -1593,21 +1593,21 @@ class Thirdparties extends DolibarrApi global /** @var Database $db */ $db; - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = $id AND site = '$site' "; $result = $db->query($sql); - if($result->num_rows == 0 ){ + if ($result->num_rows == 0) { throw new RestException(404); } else { $obj = $db->fetch_object($result); $account = new SocieteAccount($this->db); $account->fetch($obj->rowid); - if($account->delete(DolibarrApiAccess::$user) < 0) { + if ($account->delete(DolibarrApiAccess::$user) < 0) { throw new RestException(500, "Error while deleting $site gateway attached to this third party"); } } @@ -1630,7 +1630,7 @@ class Thirdparties extends DolibarrApi global /** @var Database $db */ $db; - if(! DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->rights->societe->creer) { throw new RestException(401); } @@ -1639,14 +1639,14 @@ class Thirdparties extends DolibarrApi */ $sql = "SELECT rowid, fk_soc, key_account, site, date_creation, tms"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = $id "; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = $id "; $result = $db->query($sql); - if($result->num_rows == 0 ){ + if ($result->num_rows == 0) { throw new RestException(404, 'This third party does not have any gateway attached or does not exist.'); } else { - $i=0; + $i = 0; $num = $db->num_rows($result); while ($i < $num) @@ -1655,7 +1655,7 @@ class Thirdparties extends DolibarrApi $account = new SocieteAccount($db); $account->fetch($obj->rowid); - if($account->delete(DolibarrApiAccess::$user) < 0) { + if ($account->delete(DolibarrApiAccess::$user) < 0) { throw new RestException(500, 'Error while deleting gateways attached to this third party'); } $i++; diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index d403499a79e..5cfe6fa3709 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -25,7 +25,7 @@ * \brief File of class to manage bank accounts description of third parties */ -require_once DOL_DOCUMENT_ROOT .'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; /** @@ -81,34 +81,34 @@ class CompanyBankAccount extends Account public function create(User $user = null, $notrigger = 0) { $now = dol_now(); - $error = 0; + $error = 0; // Correct default_rib to be sure to have always one default $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib where fk_soc = ".$this->socid." AND default_rib = 1 AND type = 'ban'"; $result = $this->db->query($sql); if ($result) { - $numrows=$this->db->num_rows($result); + $numrows = $this->db->num_rows($result); if ($this->default_rib && $numrows > 0) $this->default_rib = 0; if (empty($this->default_rib) && $numrows == 0) $this->default_rib = 1; } $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, type, datec)"; - $sql.= " VALUES (".$this->socid.", 'ban', '".$this->db->idate($now)."')"; - $resql=$this->db->query($sql); + $sql .= " VALUES (".$this->socid.", 'ban', '".$this->db->idate($now)."')"; + $resql = $this->db->query($sql); if ($resql) { if ($this->db->affected_rows($resql)) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_rib"); - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('COMPANY_RIB_CREATE', $user); + $result = $this->call_trigger('COMPANY_RIB_CREATE', $user); if ($result < 0) $error++; // End call triggers - if (! $error) + if (!$error) { return 1; } @@ -215,14 +215,14 @@ class CompanyBankAccount extends Account if (empty($id) && empty($socid)) return -1; $sql = "SELECT rowid, type, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,"; - $sql.= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur, date_rum"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_rib"; - if ($id) $sql.= " WHERE rowid = ".$id; + $sql .= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur, date_rum"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib"; + if ($id) $sql .= " WHERE rowid = ".$id; if ($socid) { - $sql.= " WHERE fk_soc = ".$socid; - if ($default > -1) $sql.=" AND default_rib = ".$this->db->escape($default); - if ($type) $sql.= " AND type ='".$this->db->escape($type)."'"; + $sql .= " WHERE fk_soc = ".$socid; + if ($default > -1) $sql .= " AND default_rib = ".$this->db->escape($default); + if ($type) $sql .= " AND type ='".$this->db->escape($type)."'"; } $resql = $this->db->query($sql); @@ -232,10 +232,10 @@ class CompanyBankAccount extends Account { $obj = $this->db->fetch_object($resql); - $this->ref = $obj->fk_soc.'-'.$obj->label; // Generate an artificial ref + $this->ref = $obj->fk_soc.'-'.$obj->label; // Generate an artificial ref - $this->id = $obj->rowid; - $this->type = $obj->type; + $this->id = $obj->rowid; + $this->type = $obj->type; $this->socid = $obj->fk_soc; $this->bank = $obj->bank; $this->code_banque = $obj->code_banque; @@ -243,7 +243,7 @@ class CompanyBankAccount extends Account $this->number = $obj->number; $this->cle_rib = $obj->cle_rib; $this->bic = $obj->bic; - $this->iban = $obj->iban; + $this->iban = $obj->iban; $this->domiciliation = $obj->domiciliation; $this->proprio = $obj->proprio; $this->owner_address = $obj->owner_address; @@ -279,31 +279,31 @@ class CompanyBankAccount extends Account $error = 0; - dol_syslog(get_class($this) . "::delete ".$this->id, LOG_DEBUG); + dol_syslog(get_class($this)."::delete ".$this->id, LOG_DEBUG); $this->db->begin(); - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('COMPANY_RIB_DELETE', $user); + $result = $this->call_trigger('COMPANY_RIB_DELETE', $user); if ($result < 0) $error++; // End call triggers } - if (! $error) + if (!$error) { - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "societe_rib"; - $sql .= " WHERE rowid = " . $this->id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_rib"; + $sql .= " 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) { $this->db->commit(); return 1; @@ -311,7 +311,7 @@ class CompanyBankAccount extends Account else { $this->db->rollback(); - return -1*$error; + return -1 * $error; } } @@ -325,7 +325,7 @@ class CompanyBankAccount extends Account { $rib = ''; - if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib || $this->iban || $this->bic ) { + if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib || $this->iban || $this->bic) { if ($this->label && $displayriblabel) { $rib = $this->label." : "; } @@ -345,7 +345,7 @@ class CompanyBankAccount extends Account public function setAsDefault($rib = 0) { $sql1 = "SELECT rowid as id, fk_soc FROM ".MAIN_DB_PREFIX."societe_rib"; - $sql1.= " WHERE rowid = ".($rib?$rib:$this->id); + $sql1 .= " WHERE rowid = ".($rib ? $rib : $this->id); dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG); $result1 = $this->db->query($sql1); @@ -362,12 +362,12 @@ class CompanyBankAccount extends Account $this->db->begin(); $sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0"; - $sql2.= " WHERE type = 'ban' AND fk_soc = ".$obj->fk_soc; + $sql2 .= " WHERE type = 'ban' AND fk_soc = ".$obj->fk_soc; dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG); $result2 = $this->db->query($sql2); $sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1"; - $sql3.= " WHERE rowid = ".$obj->id; + $sql3 .= " WHERE rowid = ".$obj->id; dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG); $result3 = $this->db->query($sql3); diff --git a/htdocs/stripe/payment.php b/htdocs/stripe/payment.php index 0fe4c450fad..4692687220a 100644 --- a/htdocs/stripe/payment.php +++ b/htdocs/stripe/payment.php @@ -102,19 +102,19 @@ $stripeacc = $stripe->getStripeAccount($service); }*/ // Initialize technical object to manage hooks of paiements. Note that conf->hooks_modules contains array array -$hookmanager->initHooks(array('paiementcard','globalcard')); +$hookmanager->initHooks(array('paiementcard', 'globalcard')); /* * Actions */ -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('socid'=>$socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { - if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm=='yes')) + if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm == 'yes')) { $error = 0; @@ -125,7 +125,7 @@ if (empty($reshook)) $atleastonepaymentnotnull = 0; // Generate payment array and check if there is payment higher than invoice and payment date before invoice date - $tmpinvoice=new Facture($db); + $tmpinvoice = new Facture($db); foreach ($_POST as $key => $value) { if (substr($key, 0, 7) == 'amount_') @@ -133,16 +133,16 @@ if (empty($reshook)) $cursorfacid = substr($key, 7); $amounts[$cursorfacid] = price2num(trim(GETPOST($key))); $totalpayment = $totalpayment + $amounts[$cursorfacid]; - if (! empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++; - $result=$tmpinvoice->fetch($cursorfacid); + if (!empty($amounts[$cursorfacid])) $atleastonepaymentnotnull++; + $result = $tmpinvoice->fetch($cursorfacid); if ($result <= 0) dol_print_error($db); - $amountsresttopay[$cursorfacid]=price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement()); + $amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement()); if ($amounts[$cursorfacid]) { // Check amount if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid]))) { - $addwarning=1; + $addwarning = 1; $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay"); } // Check date @@ -154,23 +154,23 @@ if (empty($reshook)) } } - $formquestion[$i++]=array('type' => 'hidden','name' => $key, 'value' => $_POST[$key]); + $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => $_POST[$key]); } elseif (substr($key, 0, 21) == 'multicurrency_amount_') { $cursorfacid = substr($key, 21); $multicurrency_amounts[$cursorfacid] = price2num(trim(GETPOST($key))); $multicurrency_totalpayment += $multicurrency_amounts[$cursorfacid]; - if (! empty($multicurrency_amounts[$cursorfacid])) $atleastonepaymentnotnull++; - $result=$tmpinvoice->fetch($cursorfacid); + if (!empty($multicurrency_amounts[$cursorfacid])) $atleastonepaymentnotnull++; + $result = $tmpinvoice->fetch($cursorfacid); if ($result <= 0) dol_print_error($db); - $multicurrency_amountsresttopay[$cursorfacid]=price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1)); + $multicurrency_amountsresttopay[$cursorfacid] = price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1)); if ($multicurrency_amounts[$cursorfacid]) { // Check amount if ($multicurrency_amounts[$cursorfacid] && (abs($multicurrency_amounts[$cursorfacid]) > abs($multicurrency_amountsresttopay[$cursorfacid]))) { - $addwarning=1; + $addwarning = 1; $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay"); } // Check date @@ -182,7 +182,7 @@ if (empty($reshook)) } } - $formquestion[$i++]=array('type' => 'hidden','name' => $key, 'value' => GETPOST($key, 'int')); + $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => GETPOST($key, 'int')); } } @@ -193,7 +193,7 @@ if (empty($reshook)) $error++; }*/ - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { // If bank module is on, account is required to enter a payment if (GETPOST('accountid') <= 0) @@ -242,7 +242,7 @@ if (empty($reshook)) */ if ($action == 'confirm_paiement' && $confirm == 'yes') { - $error=0; + $error = 0; $datepaye = dol_now(); @@ -264,7 +264,7 @@ if (empty($reshook)) } } - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { // Si module bank actif, un compte est obligatoire lors de la saisie d'un paiement if (GETPOST('accountid') <= 0) @@ -282,34 +282,34 @@ if (empty($reshook)) if (is_object($stripe) && $stripeacc) { - $customerstripe=$stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus); + $customerstripe = $stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus); if ($customerstripe->id) { - $listofsources=$customerstripe->sources->data; + $listofsources = $customerstripe->sources->data; } } - $stripeamount=0; + $stripeamount = 0; foreach ($amounts as $key => $value) // How payment is dispatch { - $stripeamount+=price2num($value, 'MT'); + $stripeamount += price2num($value, 'MT'); } if (preg_match('/acct_/i', $source)) { - $paiementcode ="VIR"; + $paiementcode = "VIR"; } elseif (preg_match('/card_/i', $source)) { - $paiementcode ="CB"; + $paiementcode = "CB"; } elseif (preg_match('/src_/i', $source)) { - $customer2 = $customerstripe=$stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus); + $customer2 = $customerstripe = $stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus); $src = $customer2->sources->retrieve("$source"); - if ($src->type=='card') + if ($src->type == 'card') { - $paiementcode ="CB"; + $paiementcode = "CB"; } } @@ -319,17 +319,17 @@ if (empty($reshook)) $societe->fetch($facture->socid); dol_syslog("Create charge", LOG_DEBUG, 0, '_stripe'); - $stripecu = $stripe->getStripeCustomerAccount($societe->id, $servicestatus); // Get thirdparty cu_... + $stripecu = $stripe->getStripeCustomerAccount($societe->id, $servicestatus); // Get thirdparty cu_... - $charge=$stripe->createPaymentStripe($stripeamount, $facture->multicurrency_code, "invoice", $facid, $source, $stripecu, $stripeacc, $servicestatus); + $charge = $stripe->createPaymentStripe($stripeamount, $facture->multicurrency_code, "invoice", $facid, $source, $stripecu, $stripeacc, $servicestatus); if (!$error) { // Creation of payment line $paiement = new Paiement($db); $paiement->datepaye = $datepaye; - $paiement->amounts = $amounts; // Array with all payments dispatching - $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching + $paiement->amounts = $amounts; // Array with all payments dispatching + $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching $paiement->paiementid = dol_getIdFromCode($db, $paiementcode, 'c_paiement'); $paiement->num_paiement = $charge->message; $paiement->note = GETPOST('comment'); @@ -337,7 +337,7 @@ if (empty($reshook)) $paiement->ext_payment_site = $service; } - if (! $error) + if (!$error) { $paiement_id = $paiement->create($user, 0); if ($paiement_id < 0) @@ -351,45 +351,45 @@ if (empty($reshook)) $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $facture->thirdparty->default_lang; - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - $model=$facture->modelpdf; + $model = $facture->modelpdf; $ret = $facture->fetch($facid); // Reload to get new records $facture->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } } - if (! $error) + if (!$error) { - $label='(CustomerInvoicePayment)'; - if (GETPOST('type') == 2) $label='(CustomerInvoicePaymentBack)'; - $result=$paiement->addPaymentToBank($user, 'payment', $label, GETPOST('accountid'), '', ''); + $label = '(CustomerInvoicePayment)'; + if (GETPOST('type') == 2) $label = '(CustomerInvoicePaymentBack)'; + $result = $paiement->addPaymentToBank($user, 'payment', $label, GETPOST('accountid'), '', ''); if ($result < 0) { setEventMessages($paiement->error, $paiement->errors, 'errors'); $error++; } - elseif (GETPOST('closepaidinvoices')=='on') { + elseif (GETPOST('closepaidinvoices') == 'on') { $facture->set_paid($user); } } - if (! $error) + if (!$error) { $db->commit(); // If payment dispatching on more than one invoice, we keep on summary page, otherwise go on invoice card - $invoiceid=0; + $invoiceid = 0; foreach ($paiement->amounts as $key => $amount) { $facid = $key; if (is_numeric($amount) && $amount <> 0) { - if ($invoiceid != 0) $invoiceid=-1; // There is more than one invoice payed by this payment - else $invoiceid=$facid; + if ($invoiceid != 0) $invoiceid = -1; // There is more than one invoice payed by this payment + else $invoiceid = $facid; } } if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$invoiceid; @@ -417,39 +417,39 @@ $form = new Form($db); llxHeader(); -if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox', 'alpha')) { +if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) { $service = 'StripeLive'; $servicestatus = 0; } else { dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); } -if (GETPOST('error')){ +if (GETPOST('error')) { setEventMessages(GETPOST('error'), null, 'errors'); } if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement') { $facture = new Facture($db); - $result=$facture->fetch($facid); + $result = $facture->fetch($facid); if ($result >= 0) { $facture->fetch_thirdparty(); - $title=''; - if ($facture->type != 2) $title.=$langs->trans("EnterPaymentReceivedFromCustomer"); - if ($facture->type == 2) $title.=$langs->trans("EnterPaymentDueToCustomer"); + $title = ''; + if ($facture->type != 2) $title .= $langs->trans("EnterPaymentReceivedFromCustomer"); + if ($facture->type == 2) $title .= $langs->trans("EnterPaymentDueToCustomer"); print load_fiche_titre($title); // Initialize data for confirmation (this is used because data can be change during confirmation) if ($action == 'add_paiement') { - $i=0; + $i = 0; - $formquestion[$i++]=array('type' => 'hidden','name' => 'facid', 'value' => $facture->id); - $formquestion[$i++]=array('type' => 'hidden','name' => 'socid', 'value' => $facture->socid); - $formquestion[$i++]=array('type' => 'hidden','name' => 'type', 'value' => $facture->type); + $formquestion[$i++] = array('type' => 'hidden', 'name' => 'facid', 'value' => $facture->id); + $formquestion[$i++] = array('type' => 'hidden', 'name' => 'socid', 'value' => $facture->socid); + $formquestion[$i++] = array('type' => 'hidden', 'name' => 'type', 'value' => $facture->type); } @@ -544,7 +544,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie '; print ' });'."\n"; - if (!empty($conf->use_javascript_ajax)){ + if (!empty($conf->use_javascript_ajax)) { //Add js for AutoFill print ' $(document).ready(function () {'; print ' $(".AutoFillAmout").on(\'click touchstart\', function(){ @@ -577,7 +577,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print '\n"; // Bank account - if (! empty($conf->banque->enabled)) + if (!empty($conf->banque->enabled)) { //$form->select_comptes($accountid,'accountid',0,'',2); print ''; @@ -615,7 +615,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie dol_fiche_end(); - $customerstripe=$stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus); + $customerstripe = $stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus); print '
'; print_barre_liste($langs->trans('StripeSourceList').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', ''); @@ -632,62 +632,62 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''; print ''; print ''; // Default print ''; @@ -711,32 +711,32 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie // $account=\Stripe\Account::retrieve("".$stripe->getStripeCustomerAccount($facture->socid).""); //} - if (($account->type=='custom' or $account->type=='express') && $entity==1) { + if (($account->type == 'custom' or $account->type == 'express') && $entity == 1) { print ''; print ''; print ''; // Default print ''; print ''; } - if (empty($input)&&!$stripe->getStripeCustomerAccount($facture->socid)) { + if (empty($input) && !$stripe->getStripeCustomerAccount($facture->socid)) { print ''; } @@ -768,33 +768,33 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie */ $sql = 'SELECT f.rowid as facid, f.ref, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ttc, f.type, '; - $sql.= ' f.datef as df, f.fk_soc as socid'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; + $sql .= ' f.datef as df, f.fk_soc as socid'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facture as f'; if (!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS)) { - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON (f.fk_soc = s.rowid)'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON (f.fk_soc = s.rowid)'; } - $sql.= ' WHERE f.entity IN ('.getEntity('invoice').")"; - $sql.= ' AND (f.fk_soc = '.$facture->socid; + $sql .= ' WHERE f.entity IN ('.getEntity('invoice').")"; + $sql .= ' AND (f.fk_soc = '.$facture->socid; if (!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS) && !empty($facture->thirdparty->parent)) { - $sql.= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.$facture->thirdparty->parent.')'; + $sql .= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.$facture->thirdparty->parent.')'; } - $sql.= ') AND f.paye = 0'; - $sql.= ' AND f.fk_statut = 1'; // Statut=0 => not validated, Statut=2 => canceled + $sql .= ') AND f.paye = 0'; + $sql .= ' AND f.fk_statut = 1'; // Statut=0 => not validated, Statut=2 => canceled if ($facture->type != 2) { - $sql .= ' AND type IN (0,1,3,5)'; // Standard invoice, replacement, deposit, situation + $sql .= ' AND type IN (0,1,3,5)'; // Standard invoice, replacement, deposit, situation } else { - $sql .= ' AND type = 2'; // If paying back a credit note, we show all credit notes + $sql .= ' AND type = 2'; // If paying back a credit note, we show all credit notes } // Sort invoices by date and serial number: the older one comes first - $sql.=' ORDER BY f.datef ASC, f.ref ASC'; + $sql .= ' ORDER BY f.datef ASC, f.ref ASC'; $resql = $db->query($sql); if ($resql) @@ -802,17 +802,17 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $num = $db->num_rows($resql); if ($num > 0) { - $sign=1; - if ($facture->type == 2) $sign=-1; + $sign = 1; + if ($facture->type == 2) $sign = -1; - $arraytitle=$langs->trans('Invoice'); - if ($facture->type == 2) $arraytitle=$langs->trans("CreditNotes"); - $alreadypayedlabel=$langs->trans('Received'); - $multicurrencyalreadypayedlabel=$langs->trans('MulticurrencyReceived'); - if ($facture->type == 2) { $alreadypayedlabel=$langs->trans("PaidBack"); $multicurrencyalreadypayedlabel=$langs->trans("MulticurrencyPaidBack"); } - $remaindertopay=$langs->trans('RemainderToTake'); - $multicurrencyremaindertopay=$langs->trans('MulticurrencyRemainderToTake'); - if ($facture->type == 2) { $remaindertopay=$langs->trans("RemainderToPayBack"); $multicurrencyremaindertopay=$langs->trans("MulticurrencyRemainderToPayBack"); } + $arraytitle = $langs->trans('Invoice'); + if ($facture->type == 2) $arraytitle = $langs->trans("CreditNotes"); + $alreadypayedlabel = $langs->trans('Received'); + $multicurrencyalreadypayedlabel = $langs->trans('MulticurrencyReceived'); + if ($facture->type == 2) { $alreadypayedlabel = $langs->trans("PaidBack"); $multicurrencyalreadypayedlabel = $langs->trans("MulticurrencyPaidBack"); } + $remaindertopay = $langs->trans('RemainderToTake'); + $multicurrencyremaindertopay = $langs->trans('MulticurrencyRemainderToTake'); + if ($facture->type == 2) { $remaindertopay = $langs->trans("RemainderToPayBack"); $multicurrencyremaindertopay = $langs->trans("MulticurrencyRemainderToPayBack"); } $i = 0; @@ -838,17 +838,17 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; } - $tmpinvoice =new Facture($db); - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $tmpinvoice, $action); // Note that $action and $object may have been modified by hook + $tmpinvoice = new Facture($db); + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $tmpinvoice, $action); // Note that $action and $object may have been modified by hook print ''; print "\n"; - $total=0; - $totalrecu=0; - $totalrecucreditnote=0; - $totalrecudeposits=0; + $total = 0; + $totalrecu = 0; + $totalrecucreditnote = 0; + $totalrecudeposits = 0; while ($i < $num) { @@ -857,29 +857,29 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $soc = new Societe($db); $soc->fetch($objp->socid); - $invoice=new Facture($db); + $invoice = new Facture($db); $invoice->fetch($objp->facid); $paiement = $invoice->getSommePaiement(); - $creditnotes=$invoice->getSumCreditNotesUsed(); - $deposits=$invoice->getSumDepositsUsed(); - $alreadypayed=price2num($paiement + $creditnotes + $deposits, 'MT'); - $remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT'); + $creditnotes = $invoice->getSumCreditNotesUsed(); + $deposits = $invoice->getSumDepositsUsed(); + $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT'); + $remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT'); // Multicurrency Price if (!empty($conf->multicurrency->enabled)) { $multicurrency_payment = $invoice->getSommePaiement(1); - $multicurrency_creditnotes=$invoice->getSumCreditNotesUsed(1); - $multicurrency_deposits=$invoice->getSumDepositsUsed(1); - $multicurrency_alreadypayed=price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits, 'MT'); - $multicurrency_remaintopay=price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits, 'MT'); + $multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1); + $multicurrency_deposits = $invoice->getSumDepositsUsed(1); + $multicurrency_alreadypayed = price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits, 'MT'); + $multicurrency_remaintopay = price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits, 'MT'); } print ''; print '\n"; // Date @@ -946,7 +946,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ""; // Multicurrency Price - if (! empty($conf->multicurrency->enabled)) + if (!empty($conf->multicurrency->enabled)) { print '"; } - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook // Warning print '\n"; - $total+=$objp->total; - $total_ttc+=$objp->total_ttc; - $totalrecu+=$paiement; - $totalrecucreditnote+=$creditnotes; - $totalrecudeposits+=$deposits; + $total += $objp->total; + $total_ttc += $objp->total_ttc; + $totalrecu += $paiement; + $totalrecucreditnote += $creditnotes; + $totalrecudeposits += $deposits; $i++; } if ($i > 1) { - $amount=round(price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT'))*100); + $amount = round(price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT')) * 100); // Print total print ''; @@ -1033,10 +1033,10 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie // Bouton Enregistrer if ($action != 'add_paiement') { - $checkboxlabel=$langs->trans("ClosePaidInvoicesAutomatically"); - if ($facture->type == 2) $checkboxlabel=$langs->trans("ClosePaidCreditNotesAutomatically"); - $buttontitle=$langs->trans('ToMakePayment'); - if ($facture->type == 2) $buttontitle=$langs->trans('ToMakePaymentBack'); + $checkboxlabel = $langs->trans("ClosePaidInvoicesAutomatically"); + if ($facture->type == 2) $checkboxlabel = $langs->trans("ClosePaidCreditNotesAutomatically"); + $buttontitle = $langs->trans('ToMakePayment'); + if ($facture->type == 2) $buttontitle = $langs->trans('ToMakePaymentBack'); print '
'; print ' '.$checkboxlabel; @@ -1052,18 +1052,18 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie // Form to confirm payment if ($action == 'add_paiement') { - $preselectedchoice=$addwarning?'no':'yes'; + $preselectedchoice = $addwarning ? 'no' : 'yes'; print '
'; if (!empty($totalpayment)) { $text = $langs->trans('ConfirmCustomerPayment', $totalpayment, $langs->trans("Currency".$conf->currency)); } if (!empty($multicurrency_totalpayment)) { - $text.='
'.$langs->trans('ConfirmCustomerPayment', $multicurrency_totalpayment, $langs->trans("paymentInInvoiceCurrency")); + $text .= '
'.$langs->trans('ConfirmCustomerPayment', $multicurrency_totalpayment, $langs->trans("paymentInInvoiceCurrency")); } if (GETPOST('closepaidinvoices')) { - $text.='
'.$langs->trans("AllCompletelyPayedInvoiceWillBeClosed"); + $text .= '
'.$langs->trans("AllCompletelyPayedInvoiceWillBeClosed"); print ''; } print $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$facture->id.'&socid='.$facture->socid.'&type='.$facture->type, $langs->trans('ReceivedCustomersPayments'), $text, 'confirm_paiement', $formquestion, $preselectedchoice); @@ -1078,27 +1078,27 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie * Show list of payments */ -if (! GETPOST('action')) +if (!GETPOST('action')) { - if ($page == -1 || empty($page)) $page = 0 ; - $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; - $offset = $limit * $page ; + if ($page == -1 || empty($page)) $page = 0; + $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; + $offset = $limit * $page; - if (! $sortorder) $sortorder='DESC'; - if (! $sortfield) $sortfield='p.datep'; + if (!$sortorder) $sortorder = 'DESC'; + if (!$sortfield) $sortfield = 'p.datep'; $sql = 'SELECT p.datep as dp, p.amount, f.amount as fa_amount, f.ref'; - $sql.=', f.rowid as facid, c.libelle as paiement_type, p.num_paiement'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement as p, '.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'c_paiement as c'; - $sql.= ' WHERE p.fk_facture = f.rowid AND p.fk_paiement = c.id'; - $sql.= ' AND f.entity IN ('.getEntity('invoice').")"; + $sql .= ', f.rowid as facid, c.libelle as paiement_type, p.num_paiement'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement as p, '.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'c_paiement as c'; + $sql .= ' WHERE p.fk_facture = f.rowid AND p.fk_paiement = c.id'; + $sql .= ' AND f.entity IN ('.getEntity('invoice').")"; if ($socid) { - $sql.= ' AND f.fk_soc = '.$socid; + $sql .= ' AND f.fk_soc = '.$socid; } - $sql.= ' ORDER BY '.$sortfield.' '.$sortorder; - $sql.= $db->plimit($limit+1, $offset); + $sql .= ' ORDER BY '.$sortfield.' '.$sortorder; + $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); if ($resql) @@ -1115,8 +1115,8 @@ if (! GETPOST('action')) print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], 'fa_amount', '', '', '', $sortfield, $sortorder, 'right '); $tmpobject = new Paiement($db); - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $tmpobject, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $tmpobject, $action); // Note that $action and $object may have been modified by hook print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); print "
\n"; @@ -1131,8 +1131,8 @@ if (! GETPOST('action')) print '\n"; print ''; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook print ''; print ''; diff --git a/htdocs/stripe/payout.php b/htdocs/stripe/payout.php index 791ceda79eb..2815b1ac5a9 100644 --- a/htdocs/stripe/payout.php +++ b/htdocs/stripe/payout.php @@ -77,25 +77,25 @@ $stripeacc = $stripe->getStripeAccount($service); print $langs->trans('ErrorStripeAccountNotDefined'); }*/ -if (! $rowid) { - print ''; +if (!$rowid) { + print ''; if ($optioncss != '') { - print ''; + print ''; } - print ''; + print ''; print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - $title=$langs->trans("StripePayoutList"); - $title.=($stripeaccount?' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')':' (Stripe connection with keys from Stripe module setup)'); + $title = $langs->trans("StripePayoutList"); + $title .= ($stripeaccount ? ' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)'); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_accountancy.png', 0, '', '', $limit); print '
'; - print '
'.$langs->trans("ThisIsInformationOnDocumentToSign").' :
'.$langs->trans("Creditor"); - print ''.$creditor.''; + print '
'.$langs->trans("Creditor"); + print ''.$creditor.''; print ''; print '
'.$langs->trans("ThirdParty"); - print ''.$proposal->thirdparty->name.''; + print '
'.$langs->trans("ThirdParty"); + print ''.$proposal->thirdparty->name.''; // Object - $text=''.$langs->trans("SignatureProposalRef", $proposal->ref).''; - print '
'.$langs->trans("Designation"); - print ''.$text; + $text = ''.$langs->trans("SignatureProposalRef", $proposal->ref).''; + print '
'.$langs->trans("Designation"); + print ''.$text; print ''; print ''; print '

'.$mesg.'
'.$langs->trans('Company').''.$facture->thirdparty->getNomUrl(4)."
id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { + if (($action == 'add_paiement' && $src->id != $source) or ($src->object == 'source' && $src->card->three_d_secure == 'required')) { print'class="opacitymedium"'; } print '>id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { + if (($action == 'add_paiement' && $src->id != $source) or ($src->object == 'source' && $src->card->three_d_secure == 'required')) { print ' disabled'; - } elseif (($customerstripe->default_source==$src->id && $action != 'add_paiement') or ($source==$src->id && $action == 'add_paiement')) { + } elseif (($customerstripe->default_source == $src->id && $action != 'add_paiement') or ($source == $src->id && $action == 'add_paiement')) { print ' checked'; } print '>id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { + if (($action == 'add_paiement' && $src->id != $source) or ($src->object == 'source' && $src->card->three_d_secure == 'required')) { print'class="opacitymedium"'; } print' >'; - if ($src->object=='card') { + if ($src->object == 'card') { print img_credit_card($src->brand); - } elseif ($src->object=='source' && $src->type=='card') { + } elseif ($src->object == 'source' && $src->type == 'card') { print img_credit_card($src->card->brand); - } elseif ($src->object=='source' && $src->type=='sepa_debit') { + } elseif ($src->object == 'source' && $src->type == 'sepa_debit') { print ''; } print 'id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { + if (($action == 'add_paiement' && $src->id != $source) or ($src->object == 'source' && $src->card->three_d_secure == 'required')) { print'class="opacitymedium"'; } print' >'; - if ($src->object=='card') { + if ($src->object == 'card') { print '....'.$src->last4.' - '.$src->exp_month.'/'.$src->exp_year.''; print ''; if ($src->country) { $img = picto_from_langcode($src->country); - print $img?$img.' ':''; + print $img ? $img.' ' : ''; print getCountry($src->country, 1); } else { print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; } - } elseif ($src->object=='source' && $src->type=='card') { + } elseif ($src->object == 'source' && $src->type == 'card') { print $src->owner->name.'
....'.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year.''; print '
'; if ($src->card->country) { $img = picto_from_langcode($src->card->country); - print $img?$img.' ':''; + print $img ? $img.' ' : ''; print getCountry($src->card->country, 1); } else { print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; } - } elseif ($src->object=='source' && $src->type=='sepa_debit') { + } elseif ($src->object == 'source' && $src->type == 'sepa_debit') { print 'info sepa'; print ''; if ($src->sepa_debit->country) { $img = picto_from_langcode($src->sepa_debit->country); - print $img?$img.' ':''; + print $img ? $img.' ' : ''; print getCountry($src->sepa_debit->country, 1); } else { print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; @@ -696,11 +696,11 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print 'id!=$source) or ($src->object=='source' && $src->card->three_d_secure=='required')) { + if (($action == 'add_paiement' && $src->id != $source) or ($src->object == 'source' && $src->card->three_d_secure == 'required')) { print'class="opacitymedium"'; } print'>'; - if (($customerstripe->default_source==$src->id)) { + if (($customerstripe->default_source == $src->id)) { print ""; } print '
getStripeCustomerAccount($facture->socid)!=$source) { + if ($action == 'add_paiement' && $stripe->getStripeCustomerAccount($facture->socid) != $source) { print'class="opacitymedium"'; } print'>global->STRIPE_EXTERNAL_ACCOUNT && $action == 'add_paiement')) { + if ((empty($input) && $action != 'add_paiement') or ($source == $conf->global->STRIPE_EXTERNAL_ACCOUNT && $action == 'add_paiement')) { print ' checked'; - } elseif ($action == 'add_paiement' && $conf->global->STRIPE_EXTERNAL_ACCOUNT!=$source) { + } elseif ($action == 'add_paiement' && $conf->global->STRIPE_EXTERNAL_ACCOUNT != $source) { print ' disabled'; } print '>getStripeCustomerAccount($facture->socid)!=$source) { + if ($action == 'add_paiement' && $stripe->getStripeCustomerAccount($facture->socid) != $source) { print'class="opacitymedium"'; } print '>getStripeCustomerAccount($facture->socid)!=$source) { + if ($action == 'add_paiement' && $stripe->getStripeCustomerAccount($facture->socid) != $source) { print'class="opacitymedium"'; } print'>'.$langs->trans('sold'); print'id!=$source) { + if ($action == 'add_paiement' && $src->id != $source) { print'class="opacitymedium"'; } print'>'; @@ -744,7 +744,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print 'id!=$source) { + if ($action == 'add_paiement' && $src->id != $source) { print'class="opacitymedium"'; } print'>'; @@ -756,7 +756,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print '
'.$langs->trans("None").'
'.$langs->trans('MulticurrencyPaymentAmount').' 
'; print $invoice->getNomUrl(1, ''); - if($objp->socid != $facture->thirdparty->id) print ' - '.$soc->getNomUrl(1).' '; + if ($objp->socid != $facture->thirdparty->id) print ' - '.$soc->getNomUrl(1).' '; print "'; @@ -972,8 +972,8 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print "'; @@ -987,16 +987,16 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print "
'.$objp->paiement_type.' '.$objp->num_paiement."'.price($objp->amount).' 
' . "\n"; + print '
'."\n"; print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); diff --git a/htdocs/stripe/transaction.php b/htdocs/stripe/transaction.php index 906d7768bd4..6a0067bf220 100644 --- a/htdocs/stripe/transaction.php +++ b/htdocs/stripe/transaction.php @@ -77,24 +77,24 @@ $stripeacc = $stripe->getStripeAccount($service); print $langs->trans('ErrorStripeAccountNotDefined'); }*/ -if (! $rowid) { - print ''; +if (!$rowid) { + print ''; if ($optioncss != '') - print ''; - print ''; + print ''; + print ''; print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - $title=$langs->trans("StripeTransactionList"); - $title.=($stripeaccount?' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')':' (Stripe connection with keys from Stripe module setup)'); + $title = $langs->trans("StripeTransactionList"); + $title .= ($stripeaccount ? ' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)'); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_accountancy.png', 0, '', '', $limit); print '
'; - print '
' . "\n"; + print '
'."\n"; print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); diff --git a/htdocs/takepos/phone.php b/htdocs/takepos/phone.php index 2bd21626f34..5d0346a495c 100644 --- a/htdocs/takepos/phone.php +++ b/htdocs/takepos/phone.php @@ -25,37 +25,37 @@ //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); -require '../main.inc.php'; // Load $user and permissions +require '../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; -$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 $action = GETPOST('action', 'alpha'); $setterminal = GETPOST('setterminal', 'int'); -if ($setterminal>0) +if ($setterminal > 0) { - $_SESSION["takeposterminal"]=$setterminal; + $_SESSION["takeposterminal"] = $setterminal; } -$langs->loadLangs(array("bills","orders","commercial","cashdesk","receiptprinter")); +$langs->loadLangs(array("bills", "orders", "commercial", "cashdesk", "receiptprinter")); /* * View */ // Title -$title='TakePOS - Dolibarr '.DOL_VERSION; -if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title='TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE; -$head=' +$title = 'TakePOS - Dolibarr '.DOL_VERSION; +if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $title = 'TakePOS - '.$conf->global->MAIN_APPLICATION_TITLE; +$head = ''; @@ -66,14 +66,14 @@ top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); '; } - $out.= ''; + $out.= ''; } else // In most cases, this is not used. We used instead function with no specific list of colors { diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 90cc0a142cb..34802a57a5d 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -788,12 +788,12 @@ if ($action == 'create' || $action == 'adduserldap') print ''; @@ -802,12 +802,12 @@ if ($action == 'create' || $action == 'adduserldap') print ''; @@ -816,17 +816,17 @@ if ($action == 'create' || $action == 'adduserldap') print ''; @@ -836,7 +836,7 @@ if ($action == 'create' || $action == 'adduserldap') require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $generated_password=getRandomPassword(false); } - $password=$generated_password; + $password=(GETPOSTISSET('password')?GETPOST('password'):$generated_password); // Password print ''; @@ -1004,12 +1004,12 @@ if ($action == 'create' || $action == 'adduserldap') print ''; @@ -1018,12 +1018,12 @@ if ($action == 'create' || $action == 'adduserldap') print ''; @@ -1032,12 +1032,12 @@ if ($action == 'create' || $action == 'adduserldap') print ''; @@ -1114,12 +1114,12 @@ if ($action == 'create' || $action == 'adduserldap') print ''; @@ -1128,7 +1128,7 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; print ''; } @@ -1137,7 +1137,7 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; print ''; } @@ -1183,7 +1183,7 @@ if ($action == 'create' || $action == 'adduserldap') print $langs->trans("Note"); print '\n"; @@ -1204,7 +1204,7 @@ if ($action == 'create' || $action == 'adduserldap') // Position/Job print ''; print ''; // Default warehouse @@ -1226,7 +1226,7 @@ if ($action == 'create' || $action == 'adduserldap') print $form->textwithpicto($text, $langs->trans("THMDescription"), 1, 'help', 'classthm'); print ''; print ''; print "\n"; @@ -1236,14 +1236,14 @@ if ($action == 'create' || $action == 'adduserldap') print $form->textwithpicto($text, $langs->trans("TJMDescription"), 1, 'help', 'classtjm'); print ''; print ''; print "\n"; // Salary print ''; print ''; print "\n"; } @@ -1251,7 +1251,7 @@ if ($action == 'create' || $action == 'adduserldap') // Weeklyhours print ''; print ''; print "\n"; @@ -2446,7 +2446,7 @@ else print ''; print '
'; if (! empty($ldap_lastname)) { - print ''; + print ''; print $ldap_lastname; } else { - print ''; + print ''; } print '
'; if (! empty($ldap_firstname)) { - print ''; + print ''; print $ldap_firstname; } else { - print ''; + print ''; } print '
'; if (! empty($ldap_login)) { - print ''; + print ''; print $ldap_login; } elseif (! empty($ldap_loginsmb)) { - print ''; + print ''; print $ldap_loginsmb; } else { - print ''; + print ''; } print '
'.$langs->trans("Password").''; if (! empty($ldap_phone)) { - print ''; + print ''; print $ldap_phone; } else { - print ''; + print ''; } print '
'; if (! empty($ldap_mobile)) { - print ''; + print ''; print $ldap_mobile; } else { - print ''; + print ''; } print '
'; if (! empty($ldap_fax)) { - print ''; + print ''; print $ldap_fax; } else { - print ''; + print ''; } print '
'; if (! empty($ldap_mail)) { - print ''; + print ''; print $ldap_mail; } else { - print ''; + print ''; } print '
'.$langs->trans("AccountancyCode").''; - print ''; + print ''; print '
'.$langs->trans("ColorUser").''; - print $formother->selectColor(GETPOST('color')?GETPOST('color'):$object->color, 'color', null, 1, '', 'hideifnotset'); + print $formother->selectColor(GETPOSTISSET('color')?GETPOST('color', 'alphanohtml'):$object->color, 'color', null, 1, '', 'hideifnotset'); print '
'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('note', '', '', 120, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_3, '90%'); + $doleditor=new DolEditor('note', GETPOSTISSET('note')?GETPOST('note', 'none'):'', '', 120, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_3, '90%'); $doleditor->Create(); print "
'.$langs->trans("PostOrFunction").''; - print ''; + print ''; print '
'; - print ''; + print ''; print '
'; - print ''; + print ''; print '
'.$langs->trans("Salary").''; - print ''; + print ''; print '
'.$langs->trans("WeeklyHours").''; - print ''; + print ''; print '
'; if ($caneditfield) { - print $formother->selectColor(GETPOST('color')?GETPOST('color'):$object->color, 'color', null, 1, '', 'hideifnotset'); + print $formother->selectColor(GETPOSTISSET('color')?GETPOST('color', 'alphanohtml'):$object->color, 'color', null, 1, '', 'hideifnotset'); }else{ print $formother->showColor($object->color, ''); } From 07880dd835521f4d856b476de60b498b90c2e4a5 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 14 Nov 2019 16:00:08 +0000 Subject: [PATCH 20/47] Fixing style errors. --- htdocs/adherents/type.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index f49dd73874a..b1b18e3ed31 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -280,8 +280,8 @@ if (!$rowid && $action != 'create' && $action != 'edit') $membertype->id = $objp->rowid; $membertype->ref = $objp->rowid; $membertype->label = $objp->rowid; - $membertype->status = $objp->status; - + $membertype->status = $objp->status; + print '
'; print $membertype->getNomUrl(1); @@ -427,7 +427,7 @@ if ($rowid > 0) print ''; - // Morphy + // Morphy print ''; print ''; From 8ef9728470f23bfd61f97db1c767ca90a0a80335 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Nov 2019 17:28:23 +0100 Subject: [PATCH 21/47] Fix permission on file --- htdocs/install/mysql/tables/llx_c_holiday_types.sql | 0 htdocs/install/mysql/tables/llx_c_price_expression.sql | 0 htdocs/install/mysql/tables/llx_c_ticket_category.sql | 0 htdocs/install/mysql/tables/llx_c_ticket_severity.sql | 0 htdocs/install/mysql/tables/llx_c_ticket_type.sql | 0 htdocs/install/mysql/tables/llx_expensereport.sql | 0 htdocs/install/mysql/tables/llx_product.sql | 0 htdocs/install/mysql/tables/llx_product_fournisseur_price.sql | 0 htdocs/install/mysql/tables/llx_product_price.sql | 0 htdocs/install/mysql/tables/llx_ticket.key.sql | 0 10 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 htdocs/install/mysql/tables/llx_c_holiday_types.sql mode change 100755 => 100644 htdocs/install/mysql/tables/llx_c_price_expression.sql mode change 100755 => 100644 htdocs/install/mysql/tables/llx_c_ticket_category.sql mode change 100755 => 100644 htdocs/install/mysql/tables/llx_c_ticket_severity.sql mode change 100755 => 100644 htdocs/install/mysql/tables/llx_c_ticket_type.sql mode change 100755 => 100644 htdocs/install/mysql/tables/llx_expensereport.sql mode change 100755 => 100644 htdocs/install/mysql/tables/llx_product.sql mode change 100755 => 100644 htdocs/install/mysql/tables/llx_product_fournisseur_price.sql mode change 100755 => 100644 htdocs/install/mysql/tables/llx_product_price.sql mode change 100755 => 100644 htdocs/install/mysql/tables/llx_ticket.key.sql diff --git a/htdocs/install/mysql/tables/llx_c_holiday_types.sql b/htdocs/install/mysql/tables/llx_c_holiday_types.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/tables/llx_c_price_expression.sql b/htdocs/install/mysql/tables/llx_c_price_expression.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/tables/llx_c_ticket_category.sql b/htdocs/install/mysql/tables/llx_c_ticket_category.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/tables/llx_c_ticket_severity.sql b/htdocs/install/mysql/tables/llx_c_ticket_severity.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/tables/llx_c_ticket_type.sql b/htdocs/install/mysql/tables/llx_c_ticket_type.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/tables/llx_expensereport.sql b/htdocs/install/mysql/tables/llx_expensereport.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/tables/llx_product.sql b/htdocs/install/mysql/tables/llx_product.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql b/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/tables/llx_product_price.sql b/htdocs/install/mysql/tables/llx_product_price.sql old mode 100755 new mode 100644 diff --git a/htdocs/install/mysql/tables/llx_ticket.key.sql b/htdocs/install/mysql/tables/llx_ticket.key.sql old mode 100755 new mode 100644 From 4ea3fe7609c3302b42b965fb354816320876f609 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Thu, 14 Nov 2019 17:57:29 +0100 Subject: [PATCH 22/47] NEW get user connected informations in REST API --- htdocs/user/class/api_users.class.php | 83 +++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index 778823d3d7d..a7d98ca0b2d 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -108,6 +108,7 @@ class Users extends DolibarrApi if ($result) { + $i = 0; $num = $db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); while ($i < $min) @@ -159,6 +160,41 @@ class Users extends DolibarrApi return $this->_cleanObjectDatas($this->useraccount); } + /** + * Get properties of user connected + * + * @url GET /info + * + * @return array|mixed Data without useless information + * + * @throws 401 RestException Insufficient rights + * @throws 404 RestException User not found + * @throws 404 RestException User group not found + */ + public function getInfo() + { + $apiUser = DolibarrApiAccess::$user; + + $result = $this->useraccount->fetch($apiUser->id); + if (!$result) { + throw new RestException(404, 'User not found'); + } + + if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user')) { + throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); + } + + $usergroup = new UserGroup($this->db); + $userGroupList = $usergroup->listGroupsForUser($apiUser->id, false); + if (!is_array($userGroupList)) { + throw new RestException(404, 'User group not found'); + } + + $this->useraccount = $this->_cleanObjectDatas($this->useraccount); + $this->useraccount->user_group_list = $this->_cleanUserGroupListDatas($userGroupList); + + return $this->useraccount; + } /** * Create user account @@ -414,6 +450,53 @@ class Users extends DolibarrApi return $object; } + /** + * Clean sensible user group list datas + * + * @param array $objectList Array of object to clean + * @return array Array of cleaned object properties + */ + private function _cleanUserGroupListDatas($objectList) + { + $cleanObjectList = array(); + + foreach ($objectList as $object) { + $cleanObject = parent::_cleanObjectDatas($object); + + unset($cleanObject->default_values); + unset($cleanObject->lastsearch_values); + unset($cleanObject->lastsearch_values_tmp); + + unset($cleanObject->total_ht); + unset($cleanObject->total_tva); + unset($cleanObject->total_localtax1); + unset($cleanObject->total_localtax2); + unset($cleanObject->total_ttc); + + unset($cleanObject->libelle_incoterms); + unset($cleanObject->location_incoterms); + + unset($cleanObject->fk_delivery_address); + unset($cleanObject->fk_incoterms); + unset($cleanObject->all_permissions_are_loaded); + unset($cleanObject->shipping_method_id); + unset($cleanObject->nb_rights); + unset($cleanObject->search_sid); + unset($cleanObject->ldap_sid); + unset($cleanObject->clicktodial_loaded); + + unset($cleanObject->datec); + unset($cleanObject->datem); + unset($cleanObject->members); + unset($cleanObject->note); + unset($cleanObject->note_private); + + $cleanObjectList[] = $cleanObject; + } + + return $cleanObjectList; + } + /** * Validate fields before create or update object * From fc55123af0b9b37b9afca4ade68a49919cdf6723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 14 Nov 2019 18:31:09 +0100 Subject: [PATCH 23/47] Update api_thirdparties.class.php --- htdocs/societe/class/api_thirdparties.class.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index b8fbb099fb3..8a29d653912 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -112,7 +112,7 @@ class Thirdparties extends DolibarrApi */ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $sqlfilters = '') { - global $db, $conf; + global $db; $obj_ret = array(); @@ -137,7 +137,7 @@ class Thirdparties extends DolibarrApi $sql .= ' AND t.entity IN ('.getEntity('societe').')'; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; //if ($email != NULL) $sql.= " AND s.email = \"".$email."\""; - if ($socid) $sql .= " AND t.rowid IN (".$socids.")"; + if ($socids) $sql .= " AND t.rowid IN (".$socids.")"; if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale // Insert sale filter if ($search_sale > 0) @@ -172,6 +172,7 @@ class Thirdparties extends DolibarrApi { $num = $db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); + $i = 0; while ($i < $min) { $obj = $db->fetch_object($result); @@ -1722,7 +1723,7 @@ class Thirdparties extends DolibarrApi * * Return an array with thirdparty informations * - * @param int $rowid Id of third party to load + * @param int $rowid Id of third party to load * @param string $ref Reference of third party, name (Warning, this can return several records) * @param string $ref_ext External reference of third party (Warning, this information is a free field not provided by Dolibarr) * @param string $ref_int Internal reference of third party (not used by dolibarr) @@ -1740,6 +1741,7 @@ class Thirdparties extends DolibarrApi */ private function _fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $idprof1 = '', $idprof2 = '', $idprof3 = '', $idprof4 = '', $idprof5 = '', $idprof6 = '', $email = '', $ref_alias = '') { + global $conf; if(! DolibarrApiAccess::$user->rights->societe->lire) { throw new RestException(401); } From 1936b11db81173b6a4d3fb6b28df9b8eb8df1eb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 14 Nov 2019 18:40:30 +0100 Subject: [PATCH 24/47] doxygen --- htdocs/user/class/user.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index a2083f35bec..c5a3add278d 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2083,9 +2083,9 @@ class User extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Read clicktodial information for user + * Read clicktodial information for user * - * @return <0 if KO, >0 if OK + * @return int <0 if KO, >0 if OK */ public function fetch_clicktodial() { @@ -2123,7 +2123,7 @@ class User extends CommonObject /** * Update clicktodial info * - * @return integer + * @return int <0 if KO, >0 if OK */ public function update_clicktodial() { From 91eb6eb7d7af9c5879355d0411647729873c1cab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 14 Nov 2019 18:44:18 +0100 Subject: [PATCH 25/47] Update user.class.php --- htdocs/user/class/user.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index c5a3add278d..4144a27685b 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2886,7 +2886,7 @@ class User extends CommonObject /** * Return and array with all instanciated first level children users of current user * - * @return void + * @return User[]|int * @see getAllChildIds() */ public function get_children() From e73202c2af6565ed82799cf944694a4a673a9f6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 14 Nov 2019 18:47:16 +0100 Subject: [PATCH 26/47] Update user.class.php --- htdocs/user/class/user.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 4144a27685b..104ff767299 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2895,7 +2895,7 @@ class User extends CommonObject $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."user"; $sql .= " WHERE fk_user = ".$this->id; - dol_syslog(get_class($this)."::get_children result=".$result, LOG_DEBUG); + dol_syslog(get_class($this)."::get_children sql=".$sql, LOG_DEBUG); $res = $this->db->query($sql); if ($res) { From 67d05cae1baf2d6859e46c01384f9856cf22ecce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 14 Nov 2019 19:06:14 +0100 Subject: [PATCH 27/47] doxygen --- htdocs/projet/class/project.class.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index f969679a9f6..0ec6652f20b 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -88,6 +88,15 @@ class Project extends CommonObject public $thirdparty_name; // To store name of thirdparty (defined only in some cases) public $user_author_id; //!< Id of project creator. Not defined if shared project. + + /** + * @var int user close id + */ + public $fk_user_close; + + /** + * @var int user close id + */ public $user_close_id; public $public; //!< Tell if this is a public or private project public $budget_amount; From 892b61f1c2872d4218ba44a839356021564d5fdb Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 14 Nov 2019 20:02:44 +0100 Subject: [PATCH 28/47] Update adherent_type.class.php --- htdocs/adherents/class/adherent_type.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 77fa991d07f..304f54b4c30 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -627,7 +627,8 @@ class AdherentType extends CommonObject return -1; } } - + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return translated label by the nature of a adherent (physical or moral) * @@ -642,7 +643,8 @@ class AdherentType extends CommonObject else return $langs->trans("MorPhy"); //return $morphy; } - + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return clicable name (with picto eventually) * From f369fa06a61aca17ab8b3ecb7bc44341c3798d1f Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 14 Nov 2019 19:04:18 +0000 Subject: [PATCH 29/47] Fixing style errors. --- htdocs/adherents/class/adherent_type.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 304f54b4c30..cb1f80bb081 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -627,7 +627,7 @@ class AdherentType extends CommonObject return -1; } } - + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return translated label by the nature of a adherent (physical or moral) @@ -643,7 +643,7 @@ class AdherentType extends CommonObject else return $langs->trans("MorPhy"); //return $morphy; } - + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return clicable name (with picto eventually) From fc2e0d4f9544b2df718c3c2ba112da9088bddc1e Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 14 Nov 2019 20:09:36 +0100 Subject: [PATCH 30/47] Update adherent_type.class.php --- htdocs/adherents/class/adherent_type.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index cb1f80bb081..a658cff86b8 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -671,6 +671,7 @@ class AdherentType extends CommonObject return $result; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of status (activity, closed) * From 332c91aa11ccdd91d118e248b8689871cb80c94c Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 14 Nov 2019 20:10:14 +0100 Subject: [PATCH 31/47] Update adherent_type.class.php --- htdocs/adherents/class/adherent_type.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index a658cff86b8..14a0c0186a5 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -628,7 +628,6 @@ class AdherentType extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return translated label by the nature of a adherent (physical or moral) * @@ -644,7 +643,6 @@ class AdherentType extends CommonObject //return $morphy; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return clicable name (with picto eventually) * From 7e52c70321fdd5270f7ae94419e8858b6ea50a30 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Nov 2019 21:16:18 +0100 Subject: [PATCH 32/47] FIX Advisory ID: usd20190067 --- htdocs/core/lib/functions.lib.php | 6 ++++-- htdocs/fourn/class/fournisseur.product.class.php | 2 +- htdocs/product/fournisseurs.php | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 9d926b3bc98..071b7a3b794 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5134,16 +5134,18 @@ function get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, if ($idprodfournprice > 0) { - if (! class_exists('ProductFournisseur')) + if (! class_exists('ProductFournisseur')) { require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php'; + } $prodprice = new ProductFournisseur($db); $prodprice->fetch_product_fournisseur_price($idprodfournprice); return $prodprice->fourn_tva_npr; } elseif ($idprod > 0) { - if (! class_exists('Product')) + if (! class_exists('Product')) { require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + } $prod = new Product($db); $prod->fetch($idprod); return $prod->tva_npr; diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index faa681b0e88..786a650efb3 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -499,7 +499,7 @@ class ProductFournisseur extends Product $sql.= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,"; $sql.=" pfp.barcode, pfp.fk_barcode_type"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql.= " WHERE pfp.rowid = ".$rowid; + $sql.= " WHERE pfp.rowid = ".(int) $rowid; dol_syslog(get_class($this)."::fetch_product_fournisseur_price", LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 560f5b1b574..0bda7d44564 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -254,8 +254,8 @@ if (empty($reshook)) { $supplier=new Fournisseur($db); $result=$supplier->fetch($id_fourn); - if (isset($_POST['ref_fourn_price_id'])) - $object->fetch_product_fournisseur_price($_POST['ref_fourn_price_id']); + if (GETPOSTISSET('ref_fourn_price_id')) + $object->fetch_product_fournisseur_price(GETPOST('ref_fourn_price_id', 'int')); $newprice = price2num(GETPOST("price", "alpha")); From 71003281168583e6d0d8edd01be81223b5971a3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 14 Nov 2019 21:25:12 +0100 Subject: [PATCH 33/47] doxygen menubase class --- htdocs/core/class/menubase.class.php | 95 +++++++++++++++++++++++----- 1 file changed, 79 insertions(+), 16 deletions(-) diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index d47146abc64..3af8d3924a8 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2009-2012 Regis Houssin - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -45,17 +45,32 @@ class Menubase public $errors = array(); /** - * @var int ID - */ - public $id; + * @var int ID + */ + public $id; + /** + * @var string Menu handler + */ public $menu_handler; + + /** + * @var string Module name if record is added by a module + */ public $module; + + /** + * @var string Menu top or left + */ public $type; + + /** + * @var string Name family/module for top menu (home, companies, ...) + */ public $mainmenu; /** - * @var int ID + * @var int 0 or Id of mother menu line, or -1 if we use fk_mainmenu and fk_leftmenu */ public $fk_menu; @@ -70,23 +85,71 @@ class Menubase public $fk_leftmenu; /** - * @var int position + * @var int Sort order of entry */ public $position; + + /** + * @var string Relative (or absolute) url to go + */ public $url; + + /** + * @var string Target of Url link + */ public $target; + + /** + * @var string Key for menu translation + * @deprecated + * @see title + */ public $titre; + + /** + * @var string Key for menu translation + */ + public $title; + + /** + * @var string Lang file to load for translation + */ public $langs; + + /** + * @var string Not used + * @deprecated + */ public $level; - public $leftmenu; //langs=trim($this->langs); $this->perms=trim($this->perms); $this->enabled=trim($this->enabled); - $this->user=trim($this->user); + $this->user = (int) $this->user; if (empty($this->position)) $this->position=0; if (! $this->level) $this->level=0; @@ -246,7 +309,7 @@ class Menubase */ public function update($user = null, $notrigger = 0) { - global $conf, $langs; + //global $conf, $langs; // Clean parameters $this->rowid=trim($this->rowid); @@ -265,7 +328,7 @@ class Menubase $this->langs=trim($this->langs); $this->perms=trim($this->perms); $this->enabled=trim($this->enabled); - $this->user=trim($this->user); + $this->user = (int) $this->user; // Check parameters // Put here code to add control on parameters values @@ -311,7 +374,7 @@ class Menubase */ public function fetch($id, $user = null) { - global $langs; + //global $langs; $sql = "SELECT"; $sql.= " t.rowid,"; @@ -385,7 +448,7 @@ class Menubase */ public function delete($user) { - global $conf, $langs; + //global $conf, $langs; $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu"; $sql.= " WHERE rowid=".$this->id; From 837c7276aba8ab2df1cda27fb2a4b61b18c702f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Thu, 14 Nov 2019 21:57:21 +0100 Subject: [PATCH 34/47] API New get categories linked to an object --- .../categories/class/api_categories.class.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 0f2a425fe87..5b8f0cdbe39 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -264,6 +264,41 @@ class Categories extends DolibarrApi ) ); } + + /** + * List categories of an object + * + * Get the list of categories linked to an object + * + * @param int $id Object ID + * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @return array Array of category objects + * + * @throws RestException + * + * @url GET /object/{type}/{id} + */ + public function getListForObject($id, $type = 'customer', $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) + { + // TODO add other types + if (!in_array($type, ['product'/*, 'member', 'customer', 'supplier', 'contact'*/])) { + throw new RestException(401); + } + + if($type == 'product' && ! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + throw new RestException(401); + } + + $categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page); + + if( ! count($categories)) { + throw new RestException(404, 'No category found for this object'); + } + return $categories; + } /** * Link an object to a category by id From b2d18a8e0c011f5011c42450eb4cacdd3fb4335b Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 14 Nov 2019 20:56:31 +0000 Subject: [PATCH 35/47] Fixing style errors. --- htdocs/categories/class/api_categories.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 5b8f0cdbe39..92ce17642ab 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -264,7 +264,7 @@ class Categories extends DolibarrApi ) ); } - + /** * List categories of an object * @@ -278,7 +278,7 @@ class Categories extends DolibarrApi * @return array Array of category objects * * @throws RestException - * + * * @url GET /object/{type}/{id} */ public function getListForObject($id, $type = 'customer', $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) @@ -287,13 +287,13 @@ class Categories extends DolibarrApi if (!in_array($type, ['product'/*, 'member', 'customer', 'supplier', 'contact'*/])) { throw new RestException(401); } - + if($type == 'product' && ! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { throw new RestException(401); } - + $categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page); - + if( ! count($categories)) { throw new RestException(404, 'No category found for this object'); } From 88692fe95d62628a7d4fd89fd0fd4aa2c86e71ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Thu, 14 Nov 2019 22:00:46 +0100 Subject: [PATCH 36/47] Doc for $page --- htdocs/categories/class/api_categories.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 92ce17642ab..a202ee97df9 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -275,6 +275,7 @@ class Categories extends DolibarrApi * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list + * @param int $page Page number * @return array Array of category objects * * @throws RestException From 100827ae0be85e0891f2879cde9050beaac00caa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Thu, 14 Nov 2019 22:16:08 +0100 Subject: [PATCH 37/47] Fix error process --- htdocs/categories/class/api_categories.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index a202ee97df9..d532c481c24 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -295,8 +295,11 @@ class Categories extends DolibarrApi $categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page); - if( ! count($categories)) { - throw new RestException(404, 'No category found for this object'); + if( ! is_array($categories)) { + if ($categories == 0) { + throw new RestException(404, 'No category found for this object'); + } + throw new RestException(500, 'Error when fetching object categories', array_merge(array($this->category->error), $this->category->errors)); } return $categories; } From 0f907fbc297143dcdec0d58a79c97f6d4817e680 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Thu, 14 Nov 2019 22:26:15 +0100 Subject: [PATCH 38/47] $type is mandatory --- htdocs/categories/class/api_categories.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index d532c481c24..5cb733789ee 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -282,7 +282,7 @@ class Categories extends DolibarrApi * * @url GET /object/{type}/{id} */ - public function getListForObject($id, $type = 'customer', $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) + public function getListForObject($id, $type, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { // TODO add other types if (!in_array($type, ['product'/*, 'member', 'customer', 'supplier', 'contact'*/])) { From 0c9b4fe16b3a72445722107f465443242de89007 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Thu, 14 Nov 2019 22:36:16 +0100 Subject: [PATCH 39/47] Add all types --- htdocs/categories/class/api_categories.class.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 5cb733789ee..aa908ec7965 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -284,14 +284,21 @@ class Categories extends DolibarrApi */ public function getListForObject($id, $type, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { - // TODO add other types - if (!in_array($type, ['product'/*, 'member', 'customer', 'supplier', 'contact'*/])) { + if (!in_array($type, ['product', 'member', 'customer', 'supplier', 'contact'])) { throw new RestException(401); } - if($type == 'product' && ! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + if($type == Categorie::TYPE_PRODUCT && ! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { throw new RestException(401); - } + } elseif ($type == Categorie::TYPE_CONTACT && ! DolibarrApiAccess::$user->rights->contact->lire) { + throw new RestException(401); + } elseif ($type == Categorie::TYPE_CUSTOMER && ! DolibarrApiAccess::$user->rights->societe->lire) { + throw new RestException(401); + } elseif ($type == Categorie::TYPE_SUPPLIER && ! DolibarrApiAccess::$user->rights->fournisseur->lire) { + throw new RestException(401); + } elseif ($type == Categorie::TYPE_MEMBER && ! DolibarrApiAccess::$user->rights->adherent->lire) { + throw new RestException(401); + } $categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page); From bb8a4e9efcbb1ca93353322963821576c6742339 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 15 Nov 2019 09:02:21 +0100 Subject: [PATCH 40/47] FIX better look compatibility with Multicompany --- htdocs/user/card.php | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index e522f542621..1430ccc8483 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -2005,15 +2005,6 @@ else } } - if ($caneditgroup) - { - print ''."\n"; - print ''; - print ''; - } - - print '
'.$langs->trans("MemberNature").''.$object->getmorphylib($object->morphy).'
'."\n"; - // Other form for add user to group $parameters = array('caneditgroup' => $caneditgroup, 'groupslist' => $groupslist, 'exclude' => $exclude); $reshook = $hookmanager->executeHooks('formAddUserToGroup', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -2021,6 +2012,14 @@ else if (empty($reshook)) { + if ($caneditgroup) + { + print ''."\n"; + print ''; + print ''; + } + + print '
'."\n"; print ''."\n"; print ''; } - } - print "
'.$langs->trans("Groups").''; if ($caneditgroup) @@ -2068,15 +2067,15 @@ else { print '
'.$langs->trans("None").'
"; + print "
"; - if ($caneditgroup) - { - print ''; + if ($caneditgroup) + { + print ''; + } + print "
"; } - print "
"; } } } From fa3c63ea28f4872b24f73f5f3eb579a94b53c7e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Fri, 15 Nov 2019 14:47:08 +0100 Subject: [PATCH 41/47] API New can include childs when get a category --- htdocs/categories/class/api_categories.class.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index aa908ec7965..ffbfff4d90f 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -71,11 +71,12 @@ class Categories extends DolibarrApi * Return an array with category informations * * @param int $id ID of category + * @param bool $include_childs Include child categories list (true or false) * @return array|mixed data without useless information * * @throws RestException */ - public function get($id) + public function get($id, $include_childs = false) { if (! DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); @@ -89,6 +90,17 @@ class Categories extends DolibarrApi if ( ! DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } + + if ($include_childs) { + $cats = $this->category->get_filles(); + if (!is_array($cats)) { + throw new RestException(500, 'Error when fetching child categories', array_merge(array($this->category->error), $this->category->errors)); + } + $this->category->childs = []; + foreach ($cats as $cat) { + $this->category->childs[] = $this->_cleanObjectDatas($cat); + } + } return $this->_cleanObjectDatas($this->category); } From cc6d8f159bf102f8b8a81541680d15b2b0d1896d Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 15 Nov 2019 13:47:40 +0000 Subject: [PATCH 42/47] Fixing style errors. --- htdocs/categories/class/api_categories.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index ffbfff4d90f..3dff8066070 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -90,7 +90,7 @@ class Categories extends DolibarrApi if ( ! DolibarrApi::_checkAccessToResource('categorie', $this->category->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - + if ($include_childs) { $cats = $this->category->get_filles(); if (!is_array($cats)) { From 71a683658887123fc896330705acf53dc5e0f5dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Fri, 15 Nov 2019 16:12:35 +0100 Subject: [PATCH 43/47] Implement categorie field ref_ext --- htdocs/categories/class/categorie.class.php | 25 ++++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 033f3f38100..6bbc0afcb1c 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -240,25 +240,30 @@ class Categorie extends CommonObject /** * Load category into memory from database * - * @param int $id Id of category - * @param string $label Label of category - * @param string $type Type of category ('product', '...') or (0, 1, ...) + * @param int $id Id of category + * @param string $label Label of category + * @param string $type Type of category ('product', '...') or (0, 1, ...) + * @param string $ref_ext External reference of object * @return int <0 if KO, >0 if OK */ - public function fetch($id, $label = '', $type = null) + public function fetch($id, $label = '', $type = null, $ref_ext = '') { global $conf; // Check parameters - if (empty($id) && empty($label)) return -1; + if (empty($id) && empty($label) && empty($ref_ext)) return -1; if (!is_numeric($type)) $type = $this->MAP_ID[$type]; - $sql = "SELECT rowid, fk_parent, entity, label, description, color, fk_soc, visible, type"; + $sql = "SELECT rowid, fk_parent, entity, label, description, color, fk_soc, visible, type, ref_ext"; $sql .= " FROM ".MAIN_DB_PREFIX."categorie"; if ($id > 0) { $sql .= " WHERE rowid = ".$id; } + elseif (!empty($ref_ext)) + { + $sql .= " WHERE ref_ext LIKE '".$this->db->escape($ref_ext)."'"; + } else { $sql .= " WHERE label = '".$this->db->escape($label)."' AND entity IN (".getEntity('category').")"; @@ -282,6 +287,7 @@ class Categorie extends CommonObject $this->socid = $res['fk_soc']; $this->visible = $res['visible']; $this->type = $res['type']; + $this->ref_ext = $res['ref_ext']; $this->entity = $res['entity']; // Retreive all extrafield @@ -334,6 +340,7 @@ class Categorie extends CommonObject $this->description = trim($this->description); $this->color = trim($this->color); $this->import_key = trim($this->import_key); + $this->ref_ext = trim($this->ref_ext); if (empty($this->visible)) $this->visible = 0; $this->fk_parent = ($this->fk_parent != "" ? intval($this->fk_parent) : 0); @@ -359,6 +366,7 @@ class Categorie extends CommonObject $sql .= " visible,"; $sql .= " type,"; $sql .= " import_key,"; + $sql .= " ref_ext,"; $sql .= " entity"; $sql .= ") VALUES ("; $sql .= $this->db->escape($this->fk_parent).","; @@ -372,6 +380,7 @@ class Categorie extends CommonObject $sql .= "'".$this->db->escape($this->visible)."',"; $sql .= $this->db->escape($type).","; $sql .= (!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : 'null').","; + $sql .= (!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : 'null').","; $sql .= $this->db->escape($conf->entity); $sql .= ")"; @@ -446,6 +455,7 @@ class Categorie extends CommonObject // Clean parameters $this->label = trim($this->label); $this->description = trim($this->description); + $this->ref_ext = trim($this->ref_ext); $this->fk_parent = ($this->fk_parent != "" ? intval($this->fk_parent) : 0); $this->visible = ($this->visible != "" ? intval($this->visible) : 0); @@ -461,6 +471,7 @@ class Categorie extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."categorie"; $sql .= " SET label = '".$this->db->escape($this->label)."',"; $sql .= " description = '".$this->db->escape($this->description)."',"; + $sql .= " ref_ext = '".$this->db->escape($this->ref_ext)."',"; $sql .= " color = '".$this->db->escape($this->color)."'"; if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)) { @@ -918,6 +929,7 @@ class Categorie extends CommonObject $categories[$i]['description'] = $category_static->description; $categories[$i]['color'] = $category_static->color; $categories[$i]['socid'] = $category_static->socid; + $categories[$i]['ref_ext'] = $category_static->ref_ext; $categories[$i]['visible'] = $category_static->visible; $categories[$i]['type'] = $category_static->type; $categories[$i]['entity'] = $category_static->entity; @@ -1082,6 +1094,7 @@ class Categorie extends CommonObject $this->cats[$obj->rowid]['description'] = !empty($obj->description_trans) ? $obj->description_trans : $obj->description; $this->cats[$obj->rowid]['color'] = $obj->color; $this->cats[$obj->rowid]['visible'] = $obj->visible; + $this->cats[$obj->rowid]['ref_ext'] = $obj->ref_ext; $i++; } } From 4332834ff7cd0b28ecab32837f889c97c22569dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Fri, 15 Nov 2019 23:08:25 +0100 Subject: [PATCH 44/47] Add all types everywhere --- .../categories/class/api_categories.class.php | 118 +++++++++++++++--- 1 file changed, 100 insertions(+), 18 deletions(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 3dff8066070..d1b2973041e 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -296,21 +296,27 @@ class Categories extends DolibarrApi */ public function getListForObject($id, $type, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { - if (!in_array($type, ['product', 'member', 'customer', 'supplier', 'contact'])) { + if (!in_array($type, [ + Categorie::TYPE_PRODUCT, + Categorie::TYPE_CONTACT, + Categorie::TYPE_CUSTOMER, + Categorie::TYPE_SUPPLIER, + Categorie::TYPE_MEMBER + ])) { throw new RestException(401); } - + if($type == Categorie::TYPE_PRODUCT && ! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { throw new RestException(401); } elseif ($type == Categorie::TYPE_CONTACT && ! DolibarrApiAccess::$user->rights->contact->lire) { throw new RestException(401); - } elseif ($type == Categorie::TYPE_CUSTOMER && ! DolibarrApiAccess::$user->rights->societe->lire) { + } elseif ($type == Categorie::TYPE_CUSTOMER && ! DolibarrApiAccess::$user->rights->societe->lire) { throw new RestException(401); - } elseif ($type == Categorie::TYPE_SUPPLIER && ! DolibarrApiAccess::$user->rights->fournisseur->lire) { + } elseif ($type == Categorie::TYPE_SUPPLIER && ! DolibarrApiAccess::$user->rights->fournisseur->lire) { throw new RestException(401); - } elseif ($type == Categorie::TYPE_MEMBER && ! DolibarrApiAccess::$user->rights->adherent->lire) { + } elseif ($type == Categorie::TYPE_MEMBER && ! DolibarrApiAccess::$user->rights->adherent->lire) { throw new RestException(401); - } + } $categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page); @@ -349,13 +355,32 @@ class Categories extends DolibarrApi if( ! $result ) { throw new RestException(404, 'category not found'); } - - // TODO Add all types - if ($type === "product") { + + if ($type === Categorie::TYPE_PRODUCT) { if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); } $object = new Product($this->db); + } elseif ($type === Categorie::TYPE_CUSTOMER) { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_SUPPLIER) { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_CONTACT) { + if(! DolibarrApiAccess::$user->rights->societe->contact->creer) { + throw new RestException(401); + } + $object = new Contact($this->db); + } elseif ($type === Categorie::TYPE_MEMBER) { + if(! DolibarrApiAccess::$user->rights->adherent->creer) { + throw new RestException(401); + } + $object = new Adherent($this->db); } else { throw new RestException(401, "this type is not recognized yet."); } @@ -410,13 +435,32 @@ class Categories extends DolibarrApi if( ! $result ) { throw new RestException(404, 'category not found'); } - - // TODO Add all types - if ($type === "product") { + + if ($type === Categorie::TYPE_PRODUCT) { if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); } $object = new Product($this->db); + } elseif ($type === Categorie::TYPE_CUSTOMER) { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_SUPPLIER) { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_CONTACT) { + if(! DolibarrApiAccess::$user->rights->societe->contact->creer) { + throw new RestException(401); + } + $object = new Contact($this->db); + } elseif ($type === Categorie::TYPE_MEMBER) { + if(! DolibarrApiAccess::$user->rights->adherent->creer) { + throw new RestException(401); + } + $object = new Adherent($this->db); } else { throw new RestException(401, "this type is not recognized yet."); } @@ -471,13 +515,32 @@ class Categories extends DolibarrApi if( ! $result ) { throw new RestException(404, 'category not found'); } - - // TODO Add all types - if ($type === "product") { + + if ($type === Categorie::TYPE_PRODUCT) { if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); } $object = new Product($this->db); + } elseif ($type === Categorie::TYPE_CUSTOMER) { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_SUPPLIER) { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_CONTACT) { + if(! DolibarrApiAccess::$user->rights->societe->contact->creer) { + throw new RestException(401); + } + $object = new Contact($this->db); + } elseif ($type === Categorie::TYPE_MEMBER) { + if(! DolibarrApiAccess::$user->rights->adherent->creer) { + throw new RestException(401); + } + $object = new Adherent($this->db); } else { throw new RestException(401, "this type is not recognized yet."); } @@ -530,13 +593,32 @@ class Categories extends DolibarrApi if( ! $result ) { throw new RestException(404, 'category not found'); } - - // TODO Add all types - if ($type === "product") { + + if ($type === Categorie::TYPE_PRODUCT) { if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); } $object = new Product($this->db); + } elseif ($type === Categorie::TYPE_CUSTOMER) { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_SUPPLIER) { + if(! DolibarrApiAccess::$user->rights->societe->creer) { + throw new RestException(401); + } + $object = new Societe($this->db); + } elseif ($type === Categorie::TYPE_CONTACT) { + if(! DolibarrApiAccess::$user->rights->societe->contact->creer) { + throw new RestException(401); + } + $object = new Contact($this->db); + } elseif ($type === Categorie::TYPE_MEMBER) { + if(! DolibarrApiAccess::$user->rights->adherent->creer) { + throw new RestException(401); + } + $object = new Adherent($this->db); } else { throw new RestException(401, "this type is not recognized yet."); } From 17667d6a1be453e7b6195f122811320ddf2396bd Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 15 Nov 2019 22:08:56 +0000 Subject: [PATCH 45/47] Fixing style errors. --- htdocs/categories/class/api_categories.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index d1b2973041e..e916255f7b5 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -305,7 +305,7 @@ class Categories extends DolibarrApi ])) { throw new RestException(401); } - + if($type == Categorie::TYPE_PRODUCT && ! (DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { throw new RestException(401); } elseif ($type == Categorie::TYPE_CONTACT && ! DolibarrApiAccess::$user->rights->contact->lire) { @@ -355,7 +355,7 @@ class Categories extends DolibarrApi if( ! $result ) { throw new RestException(404, 'category not found'); } - + if ($type === Categorie::TYPE_PRODUCT) { if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); @@ -435,7 +435,7 @@ class Categories extends DolibarrApi if( ! $result ) { throw new RestException(404, 'category not found'); } - + if ($type === Categorie::TYPE_PRODUCT) { if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); @@ -515,7 +515,7 @@ class Categories extends DolibarrApi if( ! $result ) { throw new RestException(404, 'category not found'); } - + if ($type === Categorie::TYPE_PRODUCT) { if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); @@ -593,7 +593,7 @@ class Categories extends DolibarrApi if( ! $result ) { throw new RestException(404, 'category not found'); } - + if ($type === Categorie::TYPE_PRODUCT) { if(! (DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { throw new RestException(401); From 3898db3956cd2bf46f9a8da32818e88f2fac6181 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Nov 2019 00:39:23 +0100 Subject: [PATCH 46/47] FIX #12446 --- htdocs/core/class/conf.class.php | 10 +++++----- htdocs/core/photos_resize.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 0aae646b385..d35ddf946fb 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -354,11 +354,11 @@ class Conf $this->propal->dir_output=$rootfordata."/propale"; $this->propal->dir_temp=$rootfordata."/propale/temp"; - // For backward compatibility - $this->banque->multidir_output = array($this->entity => $rootfordata."/bank"); - $this->banque->multidir_temp = array($this->entity => $rootfordata."/bank/temp"); - $this->banque->dir_output=$rootfordata."/bank"; - $this->banque->dir_temp=$rootfordata."/bank/temp"; + // For bank storage + $this->bank->multidir_output = array($this->entity => $rootfordata."/bank"); + $this->bank->multidir_temp = array($this->entity => $rootfordata."/bank/temp"); + $this->bank->dir_output = $rootfordata."/bank"; + $this->bank->dir_temp = $rootfordata."/bank/temp"; // For medias storage $this->medias->multidir_output = array($this->entity => $rootfordata."/medias"); diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php index 826ed5fdd45..ba37ee0aa66 100644 --- a/htdocs/core/photos_resize.php +++ b/htdocs/core/photos_resize.php @@ -218,7 +218,7 @@ elseif ($modulepart == 'bank') { $result = $object->fetch($id); if ($result <= 0) dol_print_error($db, 'Failed to load object'); - $dir=$conf->banque->dir_output; // By default + $dir=$conf->bank->dir_output; // By default } } else { From d2aa4ba54e3d2b3dc2492c8ce24d8116c370f55c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Nov 2019 00:41:55 +0100 Subject: [PATCH 47/47] Update adherent_type.class.php --- htdocs/adherents/class/adherent_type.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 14a0c0186a5..5006becb053 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -489,7 +489,7 @@ class AdherentType extends CommonObject { global $langs, $conf; - $sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut, d.duration, d.subscription, d.mail_valid, d.note, d.vote"; + $sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut as status, d.duration, d.subscription, d.mail_valid, d.note, d.vote"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; $sql .= " WHERE d.rowid = ".(int) $rowid; @@ -506,8 +506,8 @@ class AdherentType extends CommonObject $this->ref = $obj->rowid; $this->label = $obj->label; $this->morphy = $obj->morphy; - $this->statut = $obj->statut; - $this->status = $obj->statut; + $this->statut = $obj->status; // deprecated + $this->status = $obj->status; $this->duration = $obj->duration; $this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration)-1); $this->duration_unit = substr($obj->duration, -1);