diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 418dcc18f73..92de49d66ed 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -632,19 +632,19 @@ $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $obj if (empty($reshook)) { // Button re-export if (!empty($conf->global->ACCOUNTING_REEXPORT)) { - $newcardbutton = '' . img_picto($langs->trans("Activated"), 'switch_on') . ' '; + $newcardbutton = ''.img_picto($langs->trans("Activated"), 'switch_on').' '; } else { - $newcardbutton = '' . img_picto($langs->trans("Disabled"), 'switch_off') . ' '; + $newcardbutton = ''.img_picto($langs->trans("Disabled"), 'switch_off').' '; } - $newcardbutton .= '' . $langs->trans("IncludeDocsAlreadyExported") . ''; + $newcardbutton .= ''.$langs->trans("IncludeDocsAlreadyExported").''; - $newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList") . ' (' . $listofformat[$formatexportset] . ')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"] . '?action=export_file' . ($param ? '&' . $param : ''), $user->rights->accounting->mouvements->export); + $newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param ? '&'.$param : ''), $user->rights->accounting->mouvements->export); - $newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/list.php?' . $param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); - $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?' . $param, '', 1, array('morecss' => 'marginleftonly')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); + $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly')); $url = './card.php?action=create'; - if (!empty($socid)) $url .= '&socid=' . $socid; + if (!empty($socid)) $url .= '&socid='.$socid; $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', $url, '', $user->rights->accounting->mouvements->creer); } diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 80d8b4961c8..18661f8a887 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -379,12 +379,12 @@ print ''; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { - $newcardbutton = dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/list.php?' . $param); - $newcardbutton .= dolGetButtonTitle($langs->trans('VueByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?' . $param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); + $newcardbutton = dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param); + $newcardbutton .= dolGetButtonTitle($langs->trans('VueByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); $newcardbutton .= '   '; - $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT . '/accountancy/bookkeeping/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create'); } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); diff --git a/htdocs/accountancy/bookkeeping/listbysubaccount.php b/htdocs/accountancy/bookkeeping/listbysubaccount.php index 0a70034aaa6..3bc0351b09b 100644 --- a/htdocs/accountancy/bookkeeping/listbysubaccount.php +++ b/htdocs/accountancy/bookkeeping/listbysubaccount.php @@ -380,8 +380,8 @@ print ''; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { - $newcardbutton = dolGetButtonTitle($langs->trans('ViewAccountList'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php', '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); - $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT . '/accountancy/bookkeeping/card.php?action=create'); + $newcardbutton = dolGetButtonTitle($langs->trans('ViewAccountList'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php', '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create'); } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 51e66f3360c..3423f096794 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -57,8 +57,8 @@ class AccountancyExport public static $EXPORT_TYPE_OPENCONCERTO = 100; public static $EXPORT_TYPE_LDCOMPTA = 110; public static $EXPORT_TYPE_LDCOMPTA10 = 120; - public static $EXPORT_TYPE_GESTINUMV3 = 130; - public static $EXPORT_TYPE_GESTINUMV5 = 135; + public static $EXPORT_TYPE_GESTINUMV3 = 130; + public static $EXPORT_TYPE_GESTINUMV5 = 135; public static $EXPORT_TYPE_FEC = 1000; @@ -115,11 +115,11 @@ class AccountancyExport self::$EXPORT_TYPE_AGIRIS => $langs->trans('Modelcsv_agiris'), self::$EXPORT_TYPE_OPENCONCERTO => $langs->trans('Modelcsv_openconcerto'), self::$EXPORT_TYPE_SAGE50_SWISS => $langs->trans('Modelcsv_Sage50_Swiss'), - self::$EXPORT_TYPE_CHARLEMAGNE => $langs->trans('Modelcsv_charlemagne'), + self::$EXPORT_TYPE_CHARLEMAGNE => $langs->trans('Modelcsv_charlemagne'), self::$EXPORT_TYPE_LDCOMPTA => $langs->trans('Modelcsv_LDCompta'), self::$EXPORT_TYPE_LDCOMPTA10 => $langs->trans('Modelcsv_LDCompta10'), - self::$EXPORT_TYPE_GESTINUMV3 => $langs->trans('Modelcsv_Gestinum_v3'), - self::$EXPORT_TYPE_GESTINUMV5 => $langs->trans('Modelcsv_Gestinum_v5'), + self::$EXPORT_TYPE_GESTINUMV3 => $langs->trans('Modelcsv_Gestinum_v3'), + self::$EXPORT_TYPE_GESTINUMV5 => $langs->trans('Modelcsv_Gestinum_v5'), self::$EXPORT_TYPE_FEC => $langs->trans('Modelcsv_FEC'), ); @@ -148,12 +148,12 @@ class AccountancyExport self::$EXPORT_TYPE_COGILOG => 'cogilog', self::$EXPORT_TYPE_AGIRIS => 'agiris', self::$EXPORT_TYPE_OPENCONCERTO => 'openconcerto', - self::$EXPORT_TYPE_SAGE50_SWISS => 'sage50ch', - self::$EXPORT_TYPE_CHARLEMAGNE => 'charlemagne', - self::$EXPORT_TYPE_LDCOMPTA => 'ldcompta', - self::$EXPORT_TYPE_LDCOMPTA10 => 'ldcompta10', - self::$EXPORT_TYPE_GESTINUMV3 => 'gestinumv3', - self::$EXPORT_TYPE_GESTINUMV5 => 'gestinumv5', + self::$EXPORT_TYPE_SAGE50_SWISS => 'sage50ch', + self::$EXPORT_TYPE_CHARLEMAGNE => 'charlemagne', + self::$EXPORT_TYPE_LDCOMPTA => 'ldcompta', + self::$EXPORT_TYPE_LDCOMPTA10 => 'ldcompta10', + self::$EXPORT_TYPE_GESTINUMV3 => 'gestinumv3', + self::$EXPORT_TYPE_GESTINUMV5 => 'gestinumv5', self::$EXPORT_TYPE_FEC => 'fec', ); @@ -208,9 +208,9 @@ class AccountancyExport self::$EXPORT_TYPE_AGIRIS => array( 'label' => $langs->trans('Modelcsv_agiris'), ), - self::$EXPORT_TYPE_OPENCONCERTO => array( - 'label' => $langs->trans('Modelcsv_openconcerto'), - ), + self::$EXPORT_TYPE_OPENCONCERTO => array( + 'label' => $langs->trans('Modelcsv_openconcerto'), + ), self::$EXPORT_TYPE_SAGE50_SWISS => array( 'label' => $langs->trans('Modelcsv_Sage50_Swiss'), ), @@ -218,18 +218,18 @@ class AccountancyExport 'label' => $langs->trans('Modelcsv_charlemagne'), 'ACCOUNTING_EXPORT_FORMAT' => 'txt', ), - self::$EXPORT_TYPE_LDCOMPTA => array( - 'label' => $langs->trans('Modelcsv_LDCompta'), - ), + self::$EXPORT_TYPE_LDCOMPTA => array( + 'label' => $langs->trans('Modelcsv_LDCompta'), + ), self::$EXPORT_TYPE_LDCOMPTA10 => array( - 'label' => $langs->trans('Modelcsv_LDCompta10'), - ), - self::$EXPORT_TYPE_GESTINUMV3 => array( - 'label' => $langs->trans('Modelcsv_Gestinumv3'), - ), - self::$EXPORT_TYPE_GESTINUMV5 => array( - 'label' => $langs->trans('Modelcsv_Gestinumv5'), - ), + 'label' => $langs->trans('Modelcsv_LDCompta10'), + ), + self::$EXPORT_TYPE_GESTINUMV3 => array( + 'label' => $langs->trans('Modelcsv_Gestinumv3'), + ), + self::$EXPORT_TYPE_GESTINUMV5 => array( + 'label' => $langs->trans('Modelcsv_Gestinumv5'), + ), self::$EXPORT_TYPE_FEC => array( 'label' => $langs->trans('Modelcsv_FEC'), 'ACCOUNTING_EXPORT_FORMAT' => 'txt', @@ -307,21 +307,21 @@ class AccountancyExport case self::$EXPORT_TYPE_CHARLEMAGNE : $this->exportCharlemagne($TData); break; - case self::$EXPORT_TYPE_LDCOMPTA : - $this->exportLDCompta($TData); - break; - case self::$EXPORT_TYPE_LDCOMPTA10 : - $this->exportLDCompta10($TData); - break; - case self::$EXPORT_TYPE_GESTINUMV3 : - $this->exportGestimumV3($TData); - break; - case self::$EXPORT_TYPE_GESTINUMV5 : - $this->exportGestimumV5($TData); - break; - case self::$EXPORT_TYPE_FEC : - $this->exportFEC($TData); - break; + case self::$EXPORT_TYPE_LDCOMPTA : + $this->exportLDCompta($TData); + break; + case self::$EXPORT_TYPE_LDCOMPTA10 : + $this->exportLDCompta10($TData); + break; + case self::$EXPORT_TYPE_GESTINUMV3 : + $this->exportGestimumV3($TData); + break; + case self::$EXPORT_TYPE_GESTINUMV5 : + $this->exportGestimumV5($TData); + break; + case self::$EXPORT_TYPE_FEC : + $this->exportFEC($TData); + break; default: $this->errors[] = $langs->trans('accountancy_error_modelnotfound'); break; @@ -1484,136 +1484,136 @@ class AccountancyExport } } - /** - * Export format : Gestimum V3 - * - * @param array $objectLines data - * - * @return void - */ - public function exportGestimumV3($objectLines) + /** + * Export format : Gestimum V3 + * + * @param array $objectLines data + * + * @return void + */ + public function exportGestimumV3($objectLines) { - global $langs; + global $langs; - $this->separator = ','; + $this->separator = ','; - $invoices_infos = array(); - $supplier_invoices_infos = array(); - foreach ($objectLines as $line) { - $date = dol_print_date($line->doc_date, '%d/%m/%Y'); + $invoices_infos = array(); + $supplier_invoices_infos = array(); + foreach ($objectLines as $line) { + $date = dol_print_date($line->doc_date, '%d/%m/%Y'); - $invoice_ref = $line->doc_ref; - $company_name = ""; + $invoice_ref = $line->doc_ref; + $company_name = ""; - if (($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice') && $line->fk_doc > 0) { - if (($line->doc_type == 'customer_invoice' && !isset($invoices_infos[$line->fk_doc])) || - ($line->doc_type == 'supplier_invoice' && !isset($supplier_invoices_infos[$line->fk_doc]))) { - if ($line->doc_type == 'customer_invoice') { - // Get new customer invoice ref and company name - $sql = 'SELECT f.facnumber, s.nom FROM ' . MAIN_DB_PREFIX . 'facture as f'; - $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON f.fk_soc = s.rowid'; - $sql .= ' WHERE f.rowid = ' . $line->fk_doc; - $resql = $this->db->query($sql); - if ($resql) { - if ($obj = $this->db->fetch_object($resql)) { - // Save invoice infos - $invoices_infos[$line->fk_doc] = array('ref' => $obj->facnumber, 'company_name' => $obj->nom); - $invoice_ref = $obj->facnumber; - $company_name = $obj->nom; - } - } - } else { - // Get new supplier invoice ref and company name - $sql = 'SELECT ff.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture_fourn as ff'; - $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON ff.fk_soc = s.rowid'; - $sql .= ' WHERE ff.rowid = ' . $line->fk_doc; - $resql = $this->db->query($sql); - if ($resql) { - if ($obj = $this->db->fetch_object($resql)) { - // Save invoice infos - $supplier_invoices_infos[$line->fk_doc] = array('ref' => $obj->ref, 'company_name' => $obj->nom); - $invoice_ref = $obj->ref; - $company_name = $obj->nom; - } - } - } - } elseif ($line->doc_type == 'customer_invoice') { - // Retrieve invoice infos - $invoice_ref = $invoices_infos[$line->fk_doc]['ref']; - $company_name = $invoices_infos[$line->fk_doc]['company_name']; - } else { - // Retrieve invoice infos - $invoice_ref = $supplier_invoices_infos[$line->fk_doc]['ref']; - $company_name = $supplier_invoices_infos[$line->fk_doc]['company_name']; - } - } + if (($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice') && $line->fk_doc > 0) { + if (($line->doc_type == 'customer_invoice' && !isset($invoices_infos[$line->fk_doc])) || + ($line->doc_type == 'supplier_invoice' && !isset($supplier_invoices_infos[$line->fk_doc]))) { + if ($line->doc_type == 'customer_invoice') { + // Get new customer invoice ref and company name + $sql = 'SELECT f.facnumber, s.nom FROM ' . MAIN_DB_PREFIX . 'facture as f'; + $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON f.fk_soc = s.rowid'; + $sql .= ' WHERE f.rowid = ' . $line->fk_doc; + $resql = $this->db->query($sql); + if ($resql) { + if ($obj = $this->db->fetch_object($resql)) { + // Save invoice infos + $invoices_infos[$line->fk_doc] = array('ref' => $obj->facnumber, 'company_name' => $obj->nom); + $invoice_ref = $obj->facnumber; + $company_name = $obj->nom; + } + } + } else { + // Get new supplier invoice ref and company name + $sql = 'SELECT ff.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture_fourn as ff'; + $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON ff.fk_soc = s.rowid'; + $sql .= ' WHERE ff.rowid = ' . $line->fk_doc; + $resql = $this->db->query($sql); + if ($resql) { + if ($obj = $this->db->fetch_object($resql)) { + // Save invoice infos + $supplier_invoices_infos[$line->fk_doc] = array('ref' => $obj->ref, 'company_name' => $obj->nom); + $invoice_ref = $obj->ref; + $company_name = $obj->nom; + } + } + } + } elseif ($line->doc_type == 'customer_invoice') { + // Retrieve invoice infos + $invoice_ref = $invoices_infos[$line->fk_doc]['ref']; + $company_name = $invoices_infos[$line->fk_doc]['company_name']; + } else { + // Retrieve invoice infos + $invoice_ref = $supplier_invoices_infos[$line->fk_doc]['ref']; + $company_name = $supplier_invoices_infos[$line->fk_doc]['company_name']; + } + } - print $line->id . $this->separator; - print $date . $this->separator; - print substr($line->code_journal, 0, 4) . $this->separator; + print $line->id . $this->separator; + print $date . $this->separator; + print substr($line->code_journal, 0, 4) . $this->separator; - if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) { - print length_accountg($line->subledger_account) . $this->separator; - } else { - print substr(length_accountg($line->numero_compte), 0, 15) . $this->separator; - } - //Libellé Auto - print $this->separator; - //print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator; - //Libellé manuel - print dol_trunc(str_replace('"', '', $invoice_ref . (!empty($company_name) ? ' - ' : '') . $company_name), 40, 'right', 'UTF-8', 1) . $this->separator; - //Numéro de pièce - print dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1) . $this->separator; - //Devise - print 'EUR' . $this->separator; - //Montant - print price2num(abs($line->montant)) . $this->separator; - //Sens - print $line->sens . $this->separator; - //Code lettrage - print $this->separator; - //Date Echéance - print $date; - print $this->end_line; - } - } + if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) { + print length_accountg($line->subledger_account) . $this->separator; + } else { + print substr(length_accountg($line->numero_compte), 0, 15) . $this->separator; + } + //Libellé Auto + print $this->separator; + //print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator; + //Libellé manuel + print dol_trunc(str_replace('"', '', $invoice_ref . (!empty($company_name) ? ' - ' : '') . $company_name), 40, 'right', 'UTF-8', 1) . $this->separator; + //Numéro de pièce + print dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1) . $this->separator; + //Devise + print 'EUR' . $this->separator; + //Montant + print price2num(abs($line->montant)) . $this->separator; + //Sens + print $line->sens . $this->separator; + //Code lettrage + print $this->separator; + //Date Echéance + print $date; + print $this->end_line; + } + } - /** - * Export format : Gestimum V5 - * - * @param array $objectLines data - * - * @return void - */ - public function exportGestimumV5($objectLines) + /** + * Export format : Gestimum V5 + * + * @param array $objectLines data + * + * @return void + */ + public function exportGestimumV5($objectLines) { - $this->separator = ','; + $this->separator = ','; - foreach ($objectLines as $line) { - $date = dol_print_date($line->doc_date, '%d%m%Y'); + foreach ($objectLines as $line) { + $date = dol_print_date($line->doc_date, '%d%m%Y'); - print $line->id . $this->separator; - print $date . $this->separator; - print substr($line->code_journal, 0, 4) . $this->separator; - if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) { - print length_accountg($line->subledger_account) . $this->separator; - } else { - print substr(length_accountg($line->numero_compte), 0, 15) . $this->separator; - } - print $this->separator; - //print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator; - print '"'.dol_trunc(str_replace('"', '', $line->doc_ref), 40, 'right', 'UTF-8', 1).'"' . $this->separator; - print '"'.dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1).'"'.$this->separator; - print price2num($line->montant).$this->separator; - print $line->sens.$this->separator; - print $date . $this->separator; - print $this->separator; - print $this->separator; - print 'EUR'; - print $this->end_line; - } - } + print $line->id . $this->separator; + print $date . $this->separator; + print substr($line->code_journal, 0, 4) . $this->separator; + if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) { + print length_accountg($line->subledger_account) . $this->separator; + } else { + print substr(length_accountg($line->numero_compte), 0, 15) . $this->separator; + } + print $this->separator; + //print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator; + print '"'.dol_trunc(str_replace('"', '', $line->doc_ref), 40, 'right', 'UTF-8', 1).'"' . $this->separator; + print '"'.dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1).'"'.$this->separator; + print price2num($line->montant).$this->separator; + print $line->sens.$this->separator; + print $date . $this->separator; + print $this->separator; + print $this->separator; + print 'EUR'; + print $this->end_line; + } + } /** * trunc diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index b1331cd1dc7..9f44e02aafa 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -621,18 +621,18 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! foreach ($arrayofvat[$key] as $k => $mt) { if ($mt) { - print '"' . $key . '"' . $sep; - print '"' . $date . '"' . $sep; - print '"' . $val["ref"] . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep; - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '""' . $sep; - print '"' . $langs->trans("VAT") . ' - ' . join(', ', $def_tva[$key][$k]) . ' %"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . join(', ', $def_tva[$key][$k]) . ' %' . ($numtax ? ' - Localtax ' . $numtax : '') . '"' . $sep; - print '"' . ($mt < 0 ? price(-$mt) : '') . '"' . $sep; - print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; - print '"' . $journal . '"'; + print '"'.$key.'"'.$sep; + print '"'.$date.'"'.$sep; + print '"'.$val["ref"].'"'.$sep; + print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; + print '""'.$sep; + print '"'.$langs->trans("VAT").' - '.join(', ', $def_tva[$key][$k]).' %"'.$sep; + print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$invoicestatic->ref.' - '.$langs->trans("VAT").join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '').'"'.$sep; + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; + print '"'.$journal.'"'; print "\n"; } } diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 15494596e0f..0e57b274258 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -79,8 +79,8 @@ class Adherent extends CommonObject public $pass; /** - * @var string Clear password in database (defined if DATABASE_PWD_ENCRYPTED=0) - */ + * @var string Clear password in database (defined if DATABASE_PWD_ENCRYPTED=0) + */ public $pass_indatabase; /** diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 713812b639b..b6349bf9dc2 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -250,10 +250,10 @@ class Subscription extends CommonObject $this->db->begin(); - if (!is_numeric($this->amount)) { - $this->error = 'BadValueForParameterAmount'; - return -1; - } + if (!is_numeric($this->amount)) { + $this->error = 'BadValueForParameterAmount'; + return -1; + } $sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET "; $sql .= " fk_type = ".$this->fk_type.","; diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index e7b8ac8536b..926a51456c7 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -19,9 +19,9 @@ // Create the autoloader for Luracast require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/AutoLoader.php'; call_user_func(function () { - $loader = Luracast\Restler\AutoLoader::instance(); - spl_autoload_register($loader); - return $loader; + $loader = Luracast\Restler\AutoLoader::instance(); + spl_autoload_register($loader); + return $loader; }); require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/iAuthenticate.php'; diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 9408898a984..550d78068a4 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -475,7 +475,7 @@ class Documents extends DolibarrApi $upload_dir = $conf->categorie->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'category').$object->id."/photos/".dol_sanitizeFileName($object->ref); } elseif ($modulepart == 'ecm') { - throw new RestException(500, 'Modulepart Ecm not implemented yet.'); + throw new RestException(500, 'Modulepart Ecm not implemented yet.'); // // require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; // if (!DolibarrApiAccess::$user->rights->ecm->read) { @@ -634,7 +634,7 @@ class Documents extends DolibarrApi require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; $object = new Propal($this->db); } else { - // TODO Implement additional moduleparts + // TODO Implement additional moduleparts throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); } diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 2fba9fbb554..2c85533fd11 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -46,9 +46,9 @@ if (!$res) die("Include of main fails"); require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/AutoLoader.php'; call_user_func(function () { - $loader = Luracast\Restler\AutoLoader::instance(); - spl_autoload_register($loader); - return $loader; + $loader = Luracast\Restler\AutoLoader::instance(); + spl_autoload_register($loader); + return $loader; }); require_once DOL_DOCUMENT_ROOT.'/api/class/api.class.php'; diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 7f673a1ecff..864de6e2e98 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -294,7 +294,7 @@ if ($user->rights->categorie->creer) if ($user->rights->categorie->supprimer) { - print 'id.'&type='.$type.'">'.$langs->trans("Delete").''; + print 'id.'&type='.$type.'">'.$langs->trans("Delete").''; } print ""; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index b7b25e28d3c..5a9b0afa336 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -524,7 +524,7 @@ class ActionComm extends CommonObject $resql = $this->db->query($sql); if ($resql) { - $this->ref =$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm", "id"); + $this->ref = $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm", "id"); // Now insert assigned users if (!$error) @@ -2186,7 +2186,7 @@ class ActionComm extends CommonObject $this->db->commit(); return 0; } else { - $this->db->commit(); // We commit also on error, to have the error message recorded. + $this->db->commit(); // We commit also on error, to have the error message recorded. $this->error = 'Nb of emails sent : '.$nbMailSend.', '.(!empty($errorsMsg)) ? join(', ', $errorsMsg) : $error; return $error; } diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 8ce38ba4ea3..7524de9055f 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -233,7 +233,7 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa $supplierproposalstatic->total_ht = $obj->total_ht; $supplierproposalstatic->total_tva = $obj->total_tva; $supplierproposalstatic->total_ttc = $obj->total_ttc; - $supplierproposalstatic->statut = $obj->status; + $supplierproposalstatic->statut = $obj->status; $companystatic->id = $obj->socid; $companystatic->name = $obj->name; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 4742aebfde0..db64dd65fe9 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -343,7 +343,7 @@ if (empty($reshook)) $object->ref = GETPOST('ref'); $object->datep = $datep; $object->date = $datep; - $object->date_livraison = $date_delivery; // deprecated + $object->date_livraison = $date_delivery; // deprecated $object->delivery_date = $date_delivery; $object->availability_id = GETPOST('availability_id'); $object->demand_reason_id = GETPOST('demand_reason_id'); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index e906c4163d6..c761f8b3321 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -155,7 +155,7 @@ class Propal extends CommonObject * @var int Date expected for delivery * @deprecated */ - public $date_livraison; // deprecated; Use delivery_date instead. + public $date_livraison; // deprecated; Use delivery_date instead. /** * @var integer|string $delivery_date; @@ -1503,7 +1503,7 @@ class Propal extends CommonObject $this->date = $this->db->jdate($obj->dp); // Proposal date $this->datep = $this->db->jdate($obj->dp); // deprecated $this->fin_validite = $this->db->jdate($obj->dfv); - $this->date_livraison = $this->db->jdate($obj->delivery_date); // deprecated + $this->date_livraison = $this->db->jdate($obj->delivery_date); // deprecated $this->delivery_date = $this->db->jdate($obj->delivery_date); $this->shipping_method_id = ($obj->fk_shipping_method > 0) ? $obj->fk_shipping_method : null; $this->availability_id = $obj->fk_availability; @@ -2922,7 +2922,7 @@ class Propal extends CommonObject $tabletodelete = $this->table_element_line; $sqlef = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete."_extrafields WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id.")"; $sql = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id; - if (! $this->db->query($sqlef) || ! $this->db->query($sql)) { + if (!$this->db->query($sqlef) || !$this->db->query($sql)) { $error++; $this->error = $this->db->lasterror(); $this->errors[] = $this->error; @@ -2955,7 +2955,7 @@ class Propal extends CommonObject if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element." WHERE rowid = ".$this->id; $res = $this->db->query($sql); - if (! $res) { + if (!$res) { $error++; $this->error = $this->db->lasterror(); $this->errors[] = $this->error; @@ -2966,7 +2966,7 @@ class Propal extends CommonObject // Delete record into ECM index and physically if (!$error) { $res = $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive - if (! $res) { + if (!$res) { $error++; } } diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index bba2d61a422..d8f523f16da 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -188,7 +188,7 @@ $arrayfields = array( 'p.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), ); // Extra fields -include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; /* diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 16e53e0a23b..a583b370ac9 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -276,7 +276,7 @@ if (empty($reshook)) $object->fk_account = GETPOST('fk_account', 'int'); $object->availability_id = GETPOST('availability_id'); $object->demand_reason_id = GETPOST('demand_reason_id'); - $object->date_livraison = $datelivraison; // deprecated + $object->date_livraison = $datelivraison; // deprecated $object->delivery_date = $datelivraison; $object->shipping_method_id = GETPOST('shipping_method_id', 'int'); $object->warehouse_id = GETPOST('warehouse_id', 'int'); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index f2734b5b8b6..506cf84c8fd 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -184,7 +184,7 @@ class Commande extends CommonOrder * @var int Date expected for delivery * @deprecated */ - public $date_livraison; // deprecated; Use delivery_date instead. + public $date_livraison; // deprecated; Use delivery_date instead. public $delivery_date; // Date expected of shipment (date starting shipment, not the reception that occurs some days after) @@ -1359,7 +1359,7 @@ class Commande extends CommonOrder $this->fk_account = $object->fk_account; $this->availability_id = $object->availability_id; $this->demand_reason_id = $object->demand_reason_id; - $this->date_livraison = $object->date_livraison; // deprecated + $this->date_livraison = $object->date_livraison; // deprecated $this->delivery_date = $object->date_livraison; $this->shipping_method_id = $object->shipping_method_id; $this->warehouse_id = $object->warehouse_id; @@ -1867,7 +1867,7 @@ class Commande extends CommonOrder $this->availability = $obj->availability_label; $this->demand_reason_id = $obj->fk_input_reason; $this->demand_reason_code = $obj->demand_reason_code; - $this->date_livraison = $this->db->jdate($obj->delivery_date); // deprecated + $this->date_livraison = $this->db->jdate($obj->delivery_date); // deprecated $this->delivery_date = $this->db->jdate($obj->delivery_date); $this->shipping_method_id = ($obj->fk_shipping_method > 0) ? $obj->fk_shipping_method : null; $this->warehouse_id = ($obj->fk_warehouse > 0) ? $obj->fk_warehouse : null; @@ -3358,7 +3358,7 @@ class Commande extends CommonOrder $tabletodelete = $this->table_element_line; $sqlef = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete."_extrafields WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id.")"; $sql = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id; - if (! $this->db->query($sqlef) || ! $this->db->query($sql)) { + if (!$this->db->query($sqlef) || !$this->db->query($sql)) { $error++; $this->error = $this->db->lasterror(); $this->errors[] = $this->error; @@ -3391,7 +3391,7 @@ class Commande extends CommonOrder if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element." WHERE rowid = ".$this->id; $res = $this->db->query($sql); - if (! $res) { + if (!$res) { $error++; $this->error = $this->db->lasterror(); $this->errors[] = $this->error; @@ -3402,7 +3402,7 @@ class Commande extends CommonOrder // Delete record into ECM index and physically if (!$error) { $res = $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive - if (! $res) { + if (!$res) { $error++; } } diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 9a7a0dfff70..53359a0cb5e 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -143,37 +143,37 @@ if (empty($user->socid)) $fieldstosearchall["c.note_private"] = "NotePrivate"; $checkedtypetiers = 0; $arrayfields = array( 'c.ref'=>array('label'=>"Ref", 'checked'=>1, 'position'=>5), - 'c.ref_client'=>array('label'=>"RefCustomerOrder", 'checked'=>-1, 'position'=>10), - 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1), 'position'=>20), - 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1), 'position'=>25), - 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30), - 's.town'=>array('label'=>"Town", 'checked'=>1, 'position'=>35), - 's.zip'=>array('label'=>"Zip", 'checked'=>1, 'position'=>40), - 'state.nom'=>array('label'=>"StateShort", 'checked'=>0, 'position'=>45), - 'country.code_iso'=>array('label'=>"Country", 'checked'=>0, 'position'=>50), - 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers, 'position'=>55), - 'c.date_commande'=>array('label'=>"OrderDateShort", 'checked'=>1, 'position'=>60), - 'c.date_delivery'=>array('label'=>"DateDeliveryPlanned", 'checked'=>1, 'enabled'=>empty($conf->global->ORDER_DISABLE_DELIVERY_DATE), 'position'=>65), - 'c.total_ht'=>array('label'=>"AmountHT", 'checked'=>1, 'position'=>75), - 'c.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0, 'position'=>80), - 'c.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0, 'position'=>85), - 'c.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>90), - 'c.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>95), - 'c.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>100), - 'c.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>105), - 'c.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>110), - 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>10, 'position'=>115), - 'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500, 'position'=>120), - 'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500, 'position'=>125), - 'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500, 'position'=>130), - 'c.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'position'=>510, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PUBLIC_NOTES)), 'position'=>135), - 'c.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'position'=>511, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PRIVATE_NOTES)), 'position'=>140), - 'c.facture'=>array('label'=>"Billed", 'checked'=>1, 'position'=>990, 'enabled'=>(empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)), 'position'=>145), - 'shippable'=>array('label'=>"Shippable", 'checked'=>1, 'position'=>995, 'enabled'=>(!empty($conf->expedition->enabled)), 'position'=>150), - 'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000, 'position'=>155) + 'c.ref_client'=>array('label'=>"RefCustomerOrder", 'checked'=>-1, 'position'=>10), + 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1), 'position'=>20), + 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1), 'position'=>25), + 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30), + 's.town'=>array('label'=>"Town", 'checked'=>1, 'position'=>35), + 's.zip'=>array('label'=>"Zip", 'checked'=>1, 'position'=>40), + 'state.nom'=>array('label'=>"StateShort", 'checked'=>0, 'position'=>45), + 'country.code_iso'=>array('label'=>"Country", 'checked'=>0, 'position'=>50), + 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers, 'position'=>55), + 'c.date_commande'=>array('label'=>"OrderDateShort", 'checked'=>1, 'position'=>60), + 'c.date_delivery'=>array('label'=>"DateDeliveryPlanned", 'checked'=>1, 'enabled'=>empty($conf->global->ORDER_DISABLE_DELIVERY_DATE), 'position'=>65), + 'c.total_ht'=>array('label'=>"AmountHT", 'checked'=>1, 'position'=>75), + 'c.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0, 'position'=>80), + 'c.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0, 'position'=>85), + 'c.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>90), + 'c.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>95), + 'c.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>100), + 'c.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>105), + 'c.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>110), + 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>10, 'position'=>115), + 'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500, 'position'=>120), + 'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500, 'position'=>125), + 'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500, 'position'=>130), + 'c.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'position'=>510, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PUBLIC_NOTES)), 'position'=>135), + 'c.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'position'=>511, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PRIVATE_NOTES)), 'position'=>140), + 'c.facture'=>array('label'=>"Billed", 'checked'=>1, 'position'=>990, 'enabled'=>(empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)), 'position'=>145), + 'shippable'=>array('label'=>"Shippable", 'checked'=>1, 'position'=>995, 'enabled'=>(!empty($conf->expedition->enabled)), 'position'=>150), + 'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000, 'position'=>155) ); // Extra fields -include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -448,10 +448,10 @@ if ($resql) if ($search_status != '') $param .= '&search_status='.urlencode($search_status); if ($search_datecloture_start) $param .= '&search_datecloture_start='.urlencode($search_datecloture_start); if ($search_datecloture_end) $param .= '&search_datecloture_end='.urlencode($search_datecloture_end); - if ($search_dateorder_start) $param .= '&search_dateorder_start_day=' . dol_print_date($search_dateorder_start, '%d') . '&search_dateorder_start_month=' . dol_print_date($search_dateorder_start, '%m') . '&search_dateorder_start_year=' . dol_print_date($search_dateorder_start, '%Y'); - if ($search_dateorder_end) $param .= '&search_dateorder_end_day=' . dol_print_date($search_dateorder_end, '%d') . '&search_dateorder_end_month=' . dol_print_date($search_dateorder_end, '%m') . '&search_dateorder_end_year=' . dol_print_date($search_dateorder_end, '%Y'); - if ($search_datedelivery_start) $param .= '&search_datedelivery_start_day=' . dol_print_date($search_datedelivery_start, '%d') . '&search_datedelivery_start_month=' . dol_print_date($search_datedelivery_start, '%m') . '&search_datedelivery_start_year=' . dol_print_date($search_datedelivery_start, '%Y'); - if ($search_datedelivery_end) $param .= '&search_datedelivery_end_day=' . dol_print_date($search_datedelivery_end, '%d') . '&search_datedelivery_end_month=' . dol_print_date($search_datedelivery_end, '%m') . '&search_datedelivery_end_year=' . dol_print_date($search_datedelivery_end, '%Y'); + if ($search_dateorder_start) $param .= '&search_dateorder_start_day='.dol_print_date($search_dateorder_start, '%d').'&search_dateorder_start_month='.dol_print_date($search_dateorder_start, '%m').'&search_dateorder_start_year='.dol_print_date($search_dateorder_start, '%Y'); + if ($search_dateorder_end) $param .= '&search_dateorder_end_day='.dol_print_date($search_dateorder_end, '%d').'&search_dateorder_end_month='.dol_print_date($search_dateorder_end, '%m').'&search_dateorder_end_year='.dol_print_date($search_dateorder_end, '%Y'); + if ($search_datedelivery_start) $param .= '&search_datedelivery_start_day='.dol_print_date($search_datedelivery_start, '%d').'&search_datedelivery_start_month='.dol_print_date($search_datedelivery_start, '%m').'&search_datedelivery_start_year='.dol_print_date($search_datedelivery_start, '%Y'); + if ($search_datedelivery_end) $param .= '&search_datedelivery_end_day='.dol_print_date($search_datedelivery_end, '%d').'&search_datedelivery_end_month='.dol_print_date($search_datedelivery_end, '%m').'&search_datedelivery_end_year='.dol_print_date($search_datedelivery_end, '%Y'); if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); if ($search_company) $param .= '&search_company='.urlencode($search_company); if ($search_ref_customer) $param .= '&search_ref_customer='.urlencode($search_ref_customer); @@ -836,7 +836,7 @@ if ($resql) { print ''; //print $form->selectyesno('search_shippable', $search_shippable, 1, 0, 1, 1); - if (! empty($conf->global->ORDER_SHIPABLE_STATUS_DISABLED_BY_DEFAULT)) { + if (!empty($conf->global->ORDER_SHIPABLE_STATUS_DISABLED_BY_DEFAULT)) { print ''; print $langs->trans('ShowShippableStatus'); } else { @@ -854,17 +854,17 @@ if ($resql) // Status if (!empty($arrayfields['c.fk_statut']['checked'])) { - print ''; - $liststatus = array( - Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraftShort"), - Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), - Commande::STATUS_SHIPMENTONPROCESS=>$langs->trans("StatusOrderSentShort"), - Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"), - -3=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort").'+'.$langs->trans("StatusOrderDelivered"), - Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceledShort") - ); - print $form->selectarray('search_status', $liststatus, $search_status, -4, 0, 0, '', 0, 0, 0, '', 'maxwidth100', 1); - print ''; + print ''; + $liststatus = array( + Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraftShort"), + Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), + Commande::STATUS_SHIPMENTONPROCESS=>$langs->trans("StatusOrderSentShort"), + Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"), + -3=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort").'+'.$langs->trans("StatusOrderDelivered"), + Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceledShort") + ); + print $form->selectarray('search_status', $liststatus, $search_status, -4, 0, 0, '', 0, 0, 0, '', 'maxwidth100', 1); + print ''; } // Action column print ''; @@ -950,7 +950,7 @@ if ($resql) $generic_commande->statut = $obj->fk_statut; $generic_commande->billed = $obj->billed; $generic_commande->date = $db->jdate($obj->date_commande); - $generic_commande->date_livraison = $db->jdate($obj->date_delivery); // deprecated + $generic_commande->date_livraison = $db->jdate($obj->date_delivery); // deprecated $generic_commande->delivery_date = $db->jdate($obj->date_delivery); $generic_commande->ref_client = $obj->ref_client; $generic_commande->total_ht = $obj->total_ht; @@ -1235,7 +1235,7 @@ if ($resql) // Get local and virtual stock and store it into cache if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product])) { - $generic_product->load_stock('nobatch'); // ->load_virtual_stock() is already included into load_stock() + $generic_product->load_stock('nobatch'); // ->load_virtual_stock() is already included into load_stock() $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_reel; $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique; } else { @@ -1245,9 +1245,9 @@ if ($resql) if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) // Default code. Default should be this case. { - $text_info .= $generic_commande->lines[$lig]->qty . ' X ' . $generic_commande->lines[$lig]->product_ref . ' ' . dol_trunc($generic_commande->lines[$lig]->product_label, 25); - $text_info .= ' - ' . $langs->trans("Stock") . ': ' . $generic_product->stock_reel . ''; - $text_info .= ' - ' . $langs->trans("VirtualStock") . ': ' . $generic_product->stock_theorique . ''; + $text_info .= $generic_commande->lines[$lig]->qty.' X '.$generic_commande->lines[$lig]->product_ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 25); + $text_info .= ' - '.$langs->trans("Stock").': '.$generic_product->stock_reel.''; + $text_info .= ' - '.$langs->trans("VirtualStock").': '.$generic_product->stock_theorique.''; $text_info .= '
'; if ($generic_commande->lines[$lig]->qty > $generic_product->stock_reel) { @@ -1281,20 +1281,20 @@ if ($resql) $stock_order_supplier = $generic_product->stats_commande_fournisseur['qty']; } } - $text_info .= $generic_commande->lines[$lig]->qty . ' X ' . $generic_commande->lines[$lig]->ref . ' ' . dol_trunc($generic_commande->lines[$lig]->product_label, 25); - $text_stock_reel = $generic_product->stock_reel . '/' . $stock_order; + $text_info .= $generic_commande->lines[$lig]->qty.' X '.$generic_commande->lines[$lig]->ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 25); + $text_stock_reel = $generic_product->stock_reel.'/'.$stock_order; if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $generic_commande->lines[$lig]->qty)) { $warning++; - $text_warning .= '' . $langs->trans('Available') . ' : ' . $text_stock_reel . ''; + $text_warning .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; } if ($generic_product->stock_reel < $generic_commande->lines[$lig]->qty) { $notshippable++; - $text_info .= '' . $langs->trans('Available') . ' : ' . $text_stock_reel . ''; + $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; } else { - $text_info .= '' . $langs->trans('Available') . ' : ' . $text_stock_reel . ''; + $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; } if (!empty($conf->fournisseur->enabled)) { - $text_info .= ' ' . $langs->trans('SupplierOrder') . ' : ' . $stock_order_supplier . '
'; + $text_info .= ' '.$langs->trans('SupplierOrder').' : '.$stock_order_supplier.'
'; } else { $text_info .= '
'; } @@ -1303,10 +1303,10 @@ if ($resql) } if ($notshippable == 0) { $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'green paddingleft'); - $text_info = $langs->trans('Shippable') . '
' . $text_info; + $text_info = $langs->trans('Shippable').'
'.$text_info; } else { $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'error paddingleft'); - $text_info = $langs->trans('NonShippable') . '
' . $text_info; + $text_info = $langs->trans('NonShippable').'
'.$text_info; } } @@ -1314,7 +1314,7 @@ if ($resql) print $form->textwithtooltip('', $text_info, 2, 1, $text_icon, '', 2); } if ($warning) { // Always false in default mode - print $form->textwithtooltip('', $langs->trans('NotEnoughForAllOrders') . '
' . $text_warning, 2, 1, img_picto('', 'error'), '', 2); + print $form->textwithtooltip('', $langs->trans('NotEnoughForAllOrders').'
'.$text_warning, 2, 1, img_picto('', 'error'), '', 2); } } print ''; @@ -1330,8 +1330,8 @@ if ($resql) // Status if (!empty($arrayfields['c.fk_statut']['checked'])) { - print ''.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).''; - if (!$i) $totalarray['nbfield']++; + print ''.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).''; + if (!$i) $totalarray['nbfield']++; } // Action column diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index 70eecf02bbf..6e5e022c651 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -306,7 +306,7 @@ if ($mode == 'customer') } if ($mode == 'supplier') { - $formorder->selectSupplierOrderStatus((strstr($object_status, ',') ? -1 : $object_status), 0, 'object_status'); + $formorder->selectSupplierOrderStatus((strstr($object_status, ',') ? -1 : $object_status), 0, 'object_status'); } print ''; // Year diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 0f138833ae6..20be732da17 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -119,7 +119,7 @@ class Facture extends CommonInvoice * @var int Date expected for delivery * @deprecated */ - public $date_livraison; // deprecated; Use delivery_date instead. + public $date_livraison; // deprecated; Use delivery_date instead. public $delivery_date; // Date expected of shipment (date starting shipment, not the reception that occurs some days after) @@ -1331,7 +1331,7 @@ class Facture extends CommonInvoice $this->availability_id = $object->availability_id; $this->demand_reason_id = $object->demand_reason_id; $this->delivery_date = (empty($object->delivery_date) ? $object->date_livraison : $object->delivery_date); - $this->date_livraison = $object->delivery_date; // deprecated + $this->date_livraison = $object->delivery_date; // deprecated $this->fk_delivery_address = $object->fk_delivery_address; // deprecated $this->contact_id = $object->contact_id; $this->ref_client = $object->ref_client; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index b693238924f..09acbcb7eb7 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -223,7 +223,7 @@ if ($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_RETAINED_ } // Extra fields -include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 792ff73bcd3..7e852846d5c 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -632,10 +632,10 @@ if ($object->id > 0) print "\n
\n"; $buttonlabel = $langs->trans("MakeWithdrawRequest"); - $user_perms=$user->rights->prelevement->bons->creer; + $user_perms = $user->rights->prelevement->bons->creer; if ($type == 'bank-transfer') { $buttonlabel = $langs->trans("MakeBankTransferOrder"); - $user_perms=$user->rights->paymentbybanktransfer->create; + $user_perms = $user->rights->paymentbybanktransfer->create; } // Add a transfer request diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 21bf795079a..fb2f114b579 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -164,12 +164,12 @@ class BonPrelevement extends CommonObject $result = 0; } else { $result = -1; - $this->errors[] = get_class($this)."::AddFacture " . $this->db->lasterror; + $this->errors[] = get_class($this)."::AddFacture ".$this->db->lasterror; dol_syslog(get_class($this)."::AddFacture Error $result"); } } else { $result = -2; - $this->errors[]=get_class($this)."::AddFacture linedid Empty"; + $this->errors[] = get_class($this)."::AddFacture linedid Empty"; dol_syslog(get_class($this)."::AddFacture Error $result"); } } else { @@ -247,7 +247,7 @@ class BonPrelevement extends CommonObject $line_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_lignes"); $result = 0; } else { - $this->errors[]=get_class($this)."::addline Error -2 " .$this->db->lasterror; + $this->errors[] = get_class($this)."::addline Error -2 ".$this->db->lasterror; dol_syslog(get_class($this)."::addline Error -2"); $result = -2; } @@ -1124,7 +1124,7 @@ class BonPrelevement extends CommonObject if (!$resql) { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); dol_syslog(__METHOD__."::Update Error=".$this->db->lasterror(), LOG_ERR); } } diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 16f7ea82f36..5b8c708b1b2 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -203,7 +203,7 @@ if (!empty($conf->socialnetworks->enabled)) { } // Extra fields -include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index ad36a6e5ee7..80f16cb037d 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -62,7 +62,7 @@ if ($action == 'add' && !empty($permissiontoadd)) // Ignore special fields if (in_array($key, array('rowid', 'entity', 'import_key'))) continue; if (in_array($key, array('date_creation', 'tms', 'fk_user_creat', 'fk_user_modif'))) { - if (!in_array(abs($val['visible']), array(1, 3))) continue; // Only 1 and 3 that are case to create + if (!in_array(abs($val['visible']), array(1, 3))) continue; // Only 1 and 3 that are case to create } // Set value to insert @@ -146,7 +146,7 @@ if ($action == 'update' && !empty($permissiontoadd)) // Ignore special fields if (in_array($key, array('rowid', 'entity', 'import_key'))) continue; if (in_array($key, array('date_creation', 'tms', 'fk_user_creat', 'fk_user_modif'))) { - if (!in_array(abs($val['visible']), array(1, 3, 4))) continue; // Only 1 and 3 and 4 that are case to update + if (!in_array(abs($val['visible']), array(1, 3, 4))) continue; // Only 1 and 3 and 4 that are case to update } // Set value to update diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index 3181ea882da..d5936a6dadb 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -374,7 +374,7 @@ if ($action == 'update') GETPOST('computed_value', 'alpha'), (GETPOST('entitycurrentorall', 'alpha') ? 0 : ''), GETPOST('langfile'), - GETPOST('enabled', 'alpha'), + GETPOST('enabled', 'alpha'), (GETPOST('totalizable', 'alpha') ? 1 : 0), GETPOST('printable', 'alpha') ); diff --git a/htdocs/core/boxes/box_birthdays.php b/htdocs/core/boxes/box_birthdays.php index 7c33ace20ab..dcb3fefe13a 100644 --- a/htdocs/core/boxes/box_birthdays.php +++ b/htdocs/core/boxes/box_birthdays.php @@ -89,7 +89,7 @@ class box_birthdays extends ModeleBoxes $sql = "SELECT u.rowid, u.firstname, u.lastname, u.birth"; $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE u.entity IN (".getEntity('user').")"; - $sql.= " AND u.statut = 1"; + $sql .= " AND u.statut = 1"; $sql .= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], 0); $sql .= " ORDER BY u.birth ASC"; $sql .= $this->db->plimit($max, 0); diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index a0564e3be0b..631c88d2123 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -123,7 +123,7 @@ abstract class CommonDocGenerator if ($member->photo) { $logotouse = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $member, 'user').'/photos/'.$member->photo; } else { - $logotouse = DOL_DOCUMENT_ROOT . '/public/theme/common/nophoto.png'; + $logotouse = DOL_DOCUMENT_ROOT.'/public/theme/common/nophoto.png'; } $array_member = array( @@ -585,7 +585,7 @@ abstract class CommonDocGenerator 'line_product_ref'=>(empty($line->product_ref) ? '' : $line->product_ref), 'line_product_ref_fourn'=>(empty($line->ref_fourn) ? '' : $line->ref_fourn), // for supplier doc lines - 'line_product_label'=>(empty($line->product_label) ? '' :$line->product_label), + 'line_product_label'=>(empty($line->product_label) ? '' : $line->product_label), 'line_product_type'=>(empty($line->product_type) ? '' : $line->product_type), 'line_product_barcode'=>(empty($line->product_barcode) ? '' : $line->product_barcode), @@ -1342,7 +1342,7 @@ abstract class CommonDocGenerator if (!empty($fields)) { // Sort extrafields by rank - uasort($fields, function ($a, $b) { + uasort($fields, function($a, $b) { return ($a->rank > $b->rank) ? 1 : -1; }); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 64cf44e10c1..9d2317d3c2c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5092,7 +5092,7 @@ abstract class CommonObject global $conf, $extrafields; if (empty($rowid)) $rowid = $this->id; - if (empty($rowid) && isset($this->rowid)) $rowid = $this->rowid; // deprecated + if (empty($rowid) && isset($this->rowid)) $rowid = $this->rowid; // deprecated // To avoid SQL errors. Probably not the better solution though if (!$this->table_element) { @@ -5939,7 +5939,7 @@ abstract class CommonObject $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1); } elseif (in_array($type, array('duration'))) { $out = $form->select_duration($keyprefix.$key.$keysuffix, $value, 0, 'text', 0, 1); - } elseif (in_array($type, array('int', 'integer'))) { + } elseif (in_array($type, array('int', 'integer'))) { $tmp = explode(',', $size); $newsize = $tmp[0]; $out = ''; @@ -5949,7 +5949,7 @@ abstract class CommonObject $out = ''; } elseif (in_array($type, array('mail', 'phone', 'url'))) { $out = ''; - } elseif (preg_match('/^text/', $type)) { + } elseif (preg_match('/^text/', $type)) { if (!preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field { require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -8060,7 +8060,7 @@ abstract class CommonObject // Delete llx_ecm_files if (!$error) { $res = $this->deleteEcmFiles(1); // Deleting files physically is done later with the dol_delete_dir_recursive - if (! $res) { + if (!$res) { $error++; } } @@ -8492,7 +8492,7 @@ abstract class CommonObject // Delete ecm_files extrafields $sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_files_extrafields WHERE fk_object IN ("; $sql .= " SELECT rowid FROM ".MAIN_DB_PREFIX."ecm_files WHERE filename LIKE '".$this->db->escape($this->ref)."%'"; - $sql .= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity; // No need of getEntity here + $sql .= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity; // No need of getEntity here $sql .= ")"; if (!$this->db->query($sql)) { @@ -8504,7 +8504,7 @@ abstract class CommonObject // Delete ecm_files $sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_files"; $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%'"; - $sql .= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity; // No need of getEntity here + $sql .= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity; // No need of getEntity here if (!$this->db->query($sql)) { $this->error = $this->db->lasterror(); diff --git a/htdocs/core/class/dolgeoip.class.php b/htdocs/core/class/dolgeoip.class.php index 215a1710b82..98fbe62e4c5 100644 --- a/htdocs/core/class/dolgeoip.class.php +++ b/htdocs/core/class/dolgeoip.class.php @@ -98,7 +98,7 @@ class DolGeoIP //print 'function_exists(geoip_country_code_by_name))='.function_exists('geoip_country_code_by_name'); //print geoip_database_info(); } else { - $this->gi = ''; // For avoid error + $this->gi = ''; // For avoid error } } diff --git a/htdocs/core/class/events.class.php b/htdocs/core/class/events.class.php index 1b8a9eb3291..16c133f9dab 100644 --- a/htdocs/core/class/events.class.php +++ b/htdocs/core/class/events.class.php @@ -141,7 +141,7 @@ class Events // extends CommonObject // Clean parameters $this->description = trim($this->description); - if (empty($this->user_agent)) $this->user_agent = (empty($_SERVER['HTTP_USER_AGENT'])?'':$_SERVER['HTTP_USER_AGENT']); + if (empty($this->user_agent)) $this->user_agent = (empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT']); // Check parameters if (empty($this->description)) { $this->error = 'ErrorBadValueForParameterCreateEventDesc'; return -1; } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5e8173b2b94..edde06227ba 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1490,7 +1490,7 @@ class Form $out .= ajax_combobox($htmlid, $events, $conf->global->CONTACT_USE_SEARCH_TO_SELECT); } - if ($htmlname != 'none' && !$options_only) $out .= ''; if (($showempty == 1 || ($showempty == 3 && $num > 1)) && !$multiple) $out .= ''; if ($showempty == 2) $out .= ''; @@ -1523,7 +1523,7 @@ class Form if (!empty($contact_town)) $extendedInfos[] = $contact_town; elseif (!empty($company_town)) $extendedInfos[] = $company_town; $extendedInfos = implode(' - ', $extendedInfos); - if (!empty($extendedInfos)) $extendedInfos = ' - ' . $extendedInfos; + if (!empty($extendedInfos)) $extendedInfos = ' - '.$extendedInfos; } $contactstatic->id = $obj->rowid; @@ -1540,7 +1540,7 @@ class Form $out .= ''; @@ -1548,7 +1548,7 @@ class Form $out .= ''; @@ -1556,7 +1556,7 @@ class Form } else { if (in_array($obj->rowid, $selected)) { - $out .= $contactstatic->getFullName($langs) . $extendedInfos; + $out .= $contactstatic->getFullName($langs).$extendedInfos; if ($showfunction && $obj->poste) $out .= ' ('.$obj->poste.')'; if (($showsoc > 0) && $obj->company) $out .= ' - ('.$obj->company.')'; } diff --git a/htdocs/core/class/html.formorder.class.php b/htdocs/core/class/html.formorder.class.php index a0e1da55c7f..be169106621 100644 --- a/htdocs/core/class/html.formorder.class.php +++ b/htdocs/core/class/html.formorder.class.php @@ -62,11 +62,11 @@ class FormOrder extends Form $options[$value] = $tmpsupplierorder->getLibStatut($short); } - if (is_array($selected)) $selectedarray = $selected; - else $selectedarray = explode(',', $selected); + if (is_array($selected)) $selectedarray = $selected; + else $selectedarray = explode(',', $selected); - print Form::multiselectarray($hmlname, $options, $selectedarray, 0); - } + print Form::multiselectarray($hmlname, $options, $selectedarray, 0); + } /** * Return list of input method (mode used to receive order, like order received by email, fax, online) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index ab7bf604446..3c0aa7fba9e 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -623,7 +623,7 @@ class Translate // We replace some HTML tags by __xx__ to avoid having them encoded by htmlentities because // we want to keep '"' '' '' '' '' '
' '< ' '' that are reliable HTML tags inside translation strings. $str = str_replace( - array('"', '', '', '', '', '
', '
', '', '< ', '>'), // We accept '< ' but not '<'. We can accept however '>' + array('"', '', '', '', '', '
', '
', '', '< ', '>'), // We accept '< ' but not '<'. We can accept however '>' array('__quot__', '__tagbold__', '__tagboldend__', '__tagbold__', '__tagboldend__', '__taga__', '__tagaend__', '__tagbr__', '__tagspan__', '__tagspanend__', '__lt__', '__gt__'), $str ); @@ -745,7 +745,7 @@ class Translate */ public function transcountrynoentities($str, $countrycode) { - if (! empty($this->tab_translate["$str$countrycode"])) return $this->transnoentities("$str$countrycode"); + if (!empty($this->tab_translate["$str$countrycode"])) return $this->transnoentities("$str$countrycode"); else return $this->transnoentities($str); } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 3cee55b78f2..7523d2f5d77 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -272,7 +272,7 @@ function GETPOSTISSET($paramname) $isset = true; } } else { - $isset = (isset($_POST[$paramname]) || isset($_GET[$paramname])); // We must keep $_POST and $_GET here + $isset = (isset($_POST[$paramname]) || isset($_GET[$paramname])); // We must keep $_POST and $_GET here } return $isset; @@ -1289,11 +1289,11 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = */ function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled = '') { - if (strpos($url, '?') > 0) { - $url .= '&dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup=1'; - } else { - $url .= '?dol_hide_menuinpopup=1&dol_hide_leftmenu=1&dol_openinpopup=1'; - } + if (strpos($url, '?') > 0) { + $url .= '&dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup=1'; + } else { + $url .= '?dol_hide_menuinpopup=1&dol_hide_leftmenu=1&dol_openinpopup=1'; + } //print ''; $out = '
'.$buttonstring.''; @@ -4139,7 +4139,7 @@ function dol_print_error($db = '', $error = '', $errors = null) print $out; } else { if (empty($langs->defaultlang)) $langs->setDefaultLang(); - $langs->loadLangs(array("main", "errors")); // Reload main because language may have been set only on previous line so we have to reload files we need. + $langs->loadLangs(array("main", "errors")); // Reload main because language may have been set only on previous line so we have to reload files we need. // This should not happen, except if there is a bug somewhere. Enabled and check log in such case. print 'This website or feature is currently temporarly not available or failed after a technical error.

This may be due to a maintenance operation. Current status of operation are on next line...

'."\n"; print $langs->trans("DolibarrHasDetectedError").'. '; @@ -5592,7 +5592,7 @@ function get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart = ' // In a future, we may distribut directories on several levels depending on setup and object. // Here, $object->id, $object->ref and $modulepart are required. //var_dump($modulepart); - if (! in_array($modulepart, array('product'))) { // Test to remove + if (!in_array($modulepart, array('product'))) { // Test to remove $path = dol_sanitizeFileName(empty($object->ref) ? $object->id : $object->ref); } } @@ -6294,7 +6294,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, if (is_object($object) && ($object->element == 'adherent' || $object->element == 'member') && $object->id > 0) { - $birthday = (empty($object->birth) ? '': dol_print_date($object->birth, 'day')); + $birthday = (empty($object->birth) ? '' : dol_print_date($object->birth, 'day')); $substitutionarray['__MEMBER_ID__'] = (isset($object->id) ? $object->id : ''); if (method_exists($object, 'getCivilityLabel')) $substitutionarray['__MEMBER_CIVILITY__'] = $object->getCivilityLabel(); @@ -6694,7 +6694,7 @@ function complete_substitutions_array(&$substitutionarray, $outputlangs, $object // to list all tags in odt template $tags = ''; foreach ($substitutionarray as $key => $value) { - $tags .= '{' . $key . '} => ' . $value ."\n"; + $tags .= '{'.$key.'} => '.$value."\n"; } $substitutionarray = array_merge($substitutionarray, array('__ALL_TAGS__' => $tags)); } diff --git a/htdocs/core/lib/phpsessionindb.lib.php b/htdocs/core/lib/phpsessionindb.lib.php index d0e96434d00..f2e7d42597e 100644 --- a/htdocs/core/lib/phpsessionindb.lib.php +++ b/htdocs/core/lib/phpsessionindb.lib.php @@ -150,7 +150,7 @@ function dolSessionGC($max_lifetime) $time_stamp = dol_now(); - $delete_query = "DELETE FROM ".MAIN_DB_PREFIX."session"; + $delete_query = "DELETE FROM ".MAIN_DB_PREFIX."session"; $delete_query .= " WHERE last_accessed < '".$dbsession->idate($time_stamp - $max_lifetime)."'"; $resql = $dbsession->query($delete_query); diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 10789d2b367..736044fafe7 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -485,7 +485,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t $taskstatic->fk_statut = $lines[$i]->status; $taskstatic->date_start = $lines[$i]->date_start; $taskstatic->date_end = $lines[$i]->date_end; - $taskstatic->datee = $lines[$i]->date_end; // deprecated + $taskstatic->datee = $lines[$i]->date_end; // deprecated $taskstatic->planned_workload = $lines[$i]->planned_workload; $taskstatic->duration_effective = $lines[$i]->duration; @@ -1319,7 +1319,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr global $daytoparse; $tmparray = dol_getdate($daytoparse, true); // detail of current day - $idw = ($tmparray['wday'] - (empty($conf->global->MAIN_START_WEEK)?0:1)); + $idw = ($tmparray['wday'] - (empty($conf->global->MAIN_START_WEEK) ? 0 : 1)); global $numstartworkingday, $numendworkingday; $cssweekend = ''; if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) // This is a day is not inside the setup of working days, so we use a week-end css. diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index e005c93e976..32c58f21eac 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -420,7 +420,7 @@ class pdf_crabe extends ModelePDFFactures $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); // Incoterm - if (! empty($conf->incoterm->enabled)) + if (!empty($conf->incoterm->enabled)) { $desc_incoterms = $object->getIncotermsForPDF(); if ($desc_incoterms) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 959cb45a77e..36dc3ca8f13 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -605,7 +605,7 @@ class ImportCsv extends ModeleImports $errorforthistable++; $error++; } else { - $newval = $arrayrecord[($key - 1)]['val']; //We get new value computed. + $newval = $arrayrecord[($key - 1)]['val']; //We get new value computed. } } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'numeric') { $newval = price2num($newval); diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 5502508d350..858dc8e1076 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -639,7 +639,7 @@ class ImportXlsx extends ModeleImports $errorforthistable++; $error++; } else { - $newval = $arrayrecord[($key - 1)]['val']; //We get new value computed. + $newval = $arrayrecord[($key - 1)]['val']; //We get new value computed. } } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'numeric') { $newval = price2num($newval); diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php index 694c77b8881..4b397df65e4 100644 --- a/htdocs/core/modules/modUser.class.php +++ b/htdocs/core/modules/modUser.class.php @@ -258,10 +258,10 @@ class modUser extends DolibarrModules $keyforselect = 'user'; $keyforelement = 'user'; $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; if (empty($conf->adherent->enabled)) - { - unset($this->export_fields_array[$r]['u.fk_member']); - unset($this->export_entities_array[$r]['u.fk_member']); - } + { + unset($this->export_fields_array[$r]['u.fk_member']); + unset($this->export_entities_array[$r]['u.fk_member']); + } $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'user as u'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user_extrafields as extra ON u.rowid = extra.fk_object'; diff --git a/htdocs/core/tpl/extrafields_list_array_fields.tpl.php b/htdocs/core/tpl/extrafields_list_array_fields.tpl.php index 54cb8cbc93b..6e68dd94bea 100644 --- a/htdocs/core/tpl/extrafields_list_array_fields.tpl.php +++ b/htdocs/core/tpl/extrafields_list_array_fields.tpl.php @@ -9,10 +9,10 @@ if (empty($conf) || !is_object($conf)) exit; } -if (empty($extrafieldsobjectkey) && is_object($object)) $extrafieldsobjectkey=$object->table_element; +if (empty($extrafieldsobjectkey) && is_object($object)) $extrafieldsobjectkey = $object->table_element; // Loop to show all columns of extrafields from $obj, $extrafields and $db -if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ... +if (!empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ... { if (is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label']) > 0) { if (empty($extrafieldsobjectprefix)) $extrafieldsobjectprefix = 'ef.'; diff --git a/htdocs/core/triggers/interface_20_all_Logevents.class.php b/htdocs/core/triggers/interface_20_all_Logevents.class.php index e1bcaf85034..48c9614dea6 100644 --- a/htdocs/core/triggers/interface_20_all_Logevents.class.php +++ b/htdocs/core/triggers/interface_20_all_Logevents.class.php @@ -174,7 +174,7 @@ class InterfaceLogevents extends DolibarrTriggers $event->dateevent = $date; $event->label = $text; $event->description = $desc; - $event->user_agent = (empty($_SERVER["HTTP_USER_AGENT"])?'':$_SERVER["HTTP_USER_AGENT"]); + $event->user_agent = (empty($_SERVER["HTTP_USER_AGENT"]) ? '' : $_SERVER["HTTP_USER_AGENT"]); $result = $event->create($user); if ($result > 0) { diff --git a/htdocs/document.php b/htdocs/document.php index c48a0363f78..060722e8d5b 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -245,7 +245,7 @@ if (!file_exists($fullpath_original_file_osencoded)) // Hooks if (!is_object($hookmanager)) { - include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('document')); @@ -254,9 +254,9 @@ $parameters = array('ecmfile' => $ecmfile, 'modulepart' => $modulepart, 'origina 'filename' => $filename, 'fullpath_original_file_osencoded' => $fullpath_original_file_osencoded); $reshook = $hookmanager->executeHooks('downloadDocument', $parameters); // Note that $action and $object may have been if ($reshook < 0) { - $errors = $hookmanager->error . (is_array($hookmanager->errors) ? (!empty($hookmanager->error) ? ', ' : '') . join($separator, $hookmanager->errors) : ''); - dol_syslog("document.php - Errors when executing the hook 'downloadDocument' : " . $errors); - print "ErrorDownloadDocumentHooks: " . $errors; + $errors = $hookmanager->error.(is_array($hookmanager->errors) ? (!empty($hookmanager->error) ? ', ' : '').join($separator, $hookmanager->errors) : ''); + dol_syslog("document.php - Errors when executing the hook 'downloadDocument' : ".$errors); + print "ErrorDownloadDocumentHooks: ".$errors; exit; } diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 907b7ea9051..09a46f94bb8 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -620,7 +620,7 @@ class Expedition extends CommonObject $this->getUrlTrackingStatus($obj->tracking_number); // Thirdparty - $result = $this->fetch_thirdparty(); // TODO Remove this + $result = $this->fetch_thirdparty(); // TODO Remove this // Retrieve extrafields $this->fetch_optionals(); diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 77a62bf8561..eaae2438b55 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -133,7 +133,7 @@ $arrayfields = array( ); // Extra fields -include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index c61dff46b38..ac1d052486f 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1101,7 +1101,7 @@ class ExpenseReport extends CommonObject $tabletodelete = $this->table_element_line; //$sqlef = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete."_extrafields WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id.")"; $sql = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id; - if (! $this->db->query($sql)) { + if (!$this->db->query($sql)) { $error++; $this->error = $this->db->lasterror(); $this->errors[] = $this->error; @@ -1134,7 +1134,7 @@ class ExpenseReport extends CommonObject if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element." WHERE rowid = ".$this->id; $res = $this->db->query($sql); - if (! $res) { + if (!$res) { $error++; $this->error = $this->db->lasterror(); $this->errors[] = $this->error; @@ -1145,7 +1145,7 @@ class ExpenseReport extends CommonObject // Delete record into ECM index and physically if (!$error) { $res = $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive - if (! $res) { + if (!$res) { $error++; } } @@ -1186,7 +1186,7 @@ class ExpenseReport extends CommonObject $this->db->rollback(); return -1; } - } + } /** * Set to status validate diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 6fe473cc12f..b03faf7f629 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -363,7 +363,7 @@ class CommandeFournisseur extends CommonOrder $this->date_approve = $this->db->jdate($obj->date_approve); $this->date_approve2 = $this->db->jdate($obj->date_approve2); $this->date_commande = $this->db->jdate($obj->date_commande); // date we make the order to supplier - $this->date_livraison = $this->db->jdate($obj->delivery_date); // deprecated + $this->date_livraison = $this->db->jdate($obj->delivery_date); // deprecated $this->delivery_date = $this->db->jdate($obj->delivery_date); $this->remise_percent = $obj->remise_percent; $this->methode_commande_id = $obj->fk_input_method; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index cf6543c96e0..abb6245fa22 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1143,9 +1143,9 @@ if (empty($reshook)) $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->fk_account = GETPOST('fk_account', 'int'); - $object->note_private = GETPOST('note_private', 'restricthtml'); + $object->note_private = GETPOST('note_private', 'restricthtml'); $object->note_public = GETPOST('note_public', 'restricthtml'); - $object->date_livraison = $datelivraison; // deprecated + $object->date_livraison = $datelivraison; // deprecated $object->delivery_date = $datelivraison; $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); diff --git a/htdocs/index.php b/htdocs/index.php index 706e9a1a1ef..887baa04e78 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -595,7 +595,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $valid_dashboardlines = array(); foreach ($dashboardlines as $workboardid => $tmp) { if ($tmp instanceof WorkboardResponse) { - $tmp->id = $workboardid; // Complete the object to add its id into its name + $tmp->id = $workboardid; // Complete the object to add its id into its name $valid_dashboardlines[$workboardid] = $tmp; } } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 782685daeba..1724ae9dd42 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -995,7 +995,7 @@ if (!defined('NOLOGIN')) $user->getrights(); } -dol_syslog("--- Access to ".$_SERVER["REQUEST_METHOD"].' '.$_SERVER["PHP_SELF"].' - action='.GETPOST('action', 'aZ09').', massaction='.GETPOST('massaction', 'aZ09').' NOTOKENRENEWAL='.(defined('NOTOKENRENEWAL')?constant('NOTOKENRENEWAL'):'')); +dol_syslog("--- Access to ".$_SERVER["REQUEST_METHOD"].' '.$_SERVER["PHP_SELF"].' - action='.GETPOST('action', 'aZ09').', massaction='.GETPOST('massaction', 'aZ09').' NOTOKENRENEWAL='.(defined('NOTOKENRENEWAL') ?constant('NOTOKENRENEWAL') : '')); //Another call for easy debugg //dol_syslog("Access to ".$_SERVER["PHP_SELF"].' GET='.join(',',array_keys($_GET)).'->'.join(',',$_GET).' POST:'.join(',',array_keys($_POST)).'->'.join(',',$_POST)); @@ -1702,8 +1702,8 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead $title = $langs->trans($mode == 'wiki' ? 'GoToWikiHelpPage' : 'GoToHelpPage').'...'; if ($mode == 'wiki') { $title .= '
'.$langs->trans("PageWiki").' '.dol_escape_htmltag('"'.strtr($helppage, '_', ' ').'"'); - if ($helppresent) $title.= ' ('.$langs->trans("DedicatedPageAvailable").')'; - else $title.= ' ('.$langs->trans("HomePage").')'; + if ($helppresent) $title .= ' ('.$langs->trans("DedicatedPageAvailable").')'; + else $title .= ' ('.$langs->trans("HomePage").')'; } $text .= 'assertLessThan($result, 0); @@ -175,15 +175,15 @@ class MyObjectTest extends \PHPUnit_Framework_TestCase */ public function testMyObjectDelete($id) { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf, $user, $langs, $db; + $conf = $this->savconf; + $user = $this->savuser; + $langs = $this->savlangs; + $db = $this->savdb; - $localobject=new MyObject($this->savdb); - $result=$localobject->fetch($id); - $result=$localobject->delete($user); + $localobject = new MyObject($this->savdb); + $result = $localobject->fetch($id); + $result = $localobject->delete($user); print __METHOD__." id=".$id." result=".$result."\n"; $this->assertLessThan($result, 0); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 3c76d25df8b..8fd41228b83 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4238,15 +4238,15 @@ class Product extends CommonObject if ($mode == 0) { $sql .= " WHERE pa.fk_product_fils = ".$this->id." OR pa.fk_product_pere = ".$this->id; } elseif ($mode == -1) { - $sql .= " WHERE pa.fk_product_fils = ".$this->id; // We are a child, so we found lines that link to parents (can have several parents) + $sql .= " WHERE pa.fk_product_fils = ".$this->id; // We are a child, so we found lines that link to parents (can have several parents) } elseif ($mode == 1) { - $sql .= " WHERE pa.fk_product_pere = ".$this->id; // We are a parent, so we found lines that link to children (can have several children) + $sql .= " WHERE pa.fk_product_pere = ".$this->id; // We are a parent, so we found lines that link to children (can have several children) } $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); - if ($obj) { $nb = $obj->nb; } + if ($obj) { $nb = $obj->nb; } } else { return -1; } diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index d30c10408f1..4853d04f120 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -610,17 +610,17 @@ if ($id > 0 || $ref) '; } - if (!empty($conf->multicurrency->enabled)) { - // Currency - print ''.$langs->trans("Currency").''; - print ''; - $currencycodetouse = GETPOST('multicurrency_code') ?GETPOST('multicurrency_code') : (isset($object->fourn_multicurrency_code) ? $object->fourn_multicurrency_code : ''); - if (empty($currencycodetouse) && $object->fourn_multicurrency_tx == 1) $currencycodetouse = $conf->currency; - print $form->selectMultiCurrency($currencycodetouse, "multicurrency_code", 1); - print '   '.$langs->trans("CurrencyRate").' '; - print ''; - print ''; - print ''; + if (!empty($conf->multicurrency->enabled)) { + // Currency + print ''.$langs->trans("Currency").''; + print ''; + $currencycodetouse = GETPOST('multicurrency_code') ?GETPOST('multicurrency_code') : (isset($object->fourn_multicurrency_code) ? $object->fourn_multicurrency_code : ''); + if (empty($currencycodetouse) && $object->fourn_multicurrency_tx == 1) $currencycodetouse = $conf->currency; + print $form->selectMultiCurrency($currencycodetouse, "multicurrency_code", 1); + print '   '.$langs->trans("CurrencyRate").' '; + print ''; + print ''; + print ''; // Currency price qty min print ''.$langs->trans("PriceQtyMinCurrency").''; diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 12a6c807515..86b8b62fc81 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -243,7 +243,7 @@ if ($conf->global->PRODUIT_MULTIPRICES) { //var_dump($arraypricelevel); // Extra fields -include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -1283,58 +1283,58 @@ if ($resql) // Multiprices if (! empty($conf->global->PRODUIT_MULTIPRICES)) { - if (! isset($productpricescache)) { - $productpricescache=array(); - } - if (! isset($productpricescache[$obj->rowid])) { - $productpricescache[$obj->rowid] = array(); - } + if (! isset($productpricescache)) { + $productpricescache=array(); + } + if (! isset($productpricescache[$obj->rowid])) { + $productpricescache[$obj->rowid] = array(); + } - if ($obj->tosell) - { - // Make 1 request for all price levels (without filter on price_level) and saved result into an cache array - // then reuse the cache array if we need prices for other price levels - $sqlp = "SELECT p.rowid, p.fk_product, p.price, p.price_ttc, p.price_level, p.date_price, p.price_base_type"; - $sqlp .= " FROM ".MAIN_DB_PREFIX."product_price as p"; - $sqlp .= " WHERE fk_product = ".$obj->rowid; - $sqlp .= " ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC"; - $resultp = $db->query($sqlp); - if ($resultp) - { - $nump = $db->num_rows($resultp); - $j = 0; - while ($j < $nump) - { - $objp = $db->fetch_object($resultp); + if ($obj->tosell) + { + // Make 1 request for all price levels (without filter on price_level) and saved result into an cache array + // then reuse the cache array if we need prices for other price levels + $sqlp = "SELECT p.rowid, p.fk_product, p.price, p.price_ttc, p.price_level, p.date_price, p.price_base_type"; + $sqlp .= " FROM ".MAIN_DB_PREFIX."product_price as p"; + $sqlp .= " WHERE fk_product = ".$obj->rowid; + $sqlp .= " ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC"; + $resultp = $db->query($sqlp); + if ($resultp) + { + $nump = $db->num_rows($resultp); + $j = 0; + while ($j < $nump) + { + $objp = $db->fetch_object($resultp); - if (empty($productpricescache[$obj->rowid][$objp->price_level])) - { - $productpricescache[$obj->rowid][$objp->price_level]['price'] = $objp->price; - $productpricescache[$obj->rowid][$objp->price_level]['price_ttc'] = $objp->price_ttc; - $productpricescache[$obj->rowid][$objp->price_level]['price_base_type'] = $objp->price_base_type; - } + if (empty($productpricescache[$obj->rowid][$objp->price_level])) + { + $productpricescache[$obj->rowid][$objp->price_level]['price'] = $objp->price; + $productpricescache[$obj->rowid][$objp->price_level]['price_ttc'] = $objp->price_ttc; + $productpricescache[$obj->rowid][$objp->price_level]['price_base_type'] = $objp->price_base_type; + } - $j++; - } + $j++; + } - $db->free($resultp); - } else { - dol_print_error($db); - } - } + $db->free($resultp); + } else { + dol_print_error($db); + } + } foreach ($arraypricelevel as $key => $value) { if (!empty($arrayfields['p.sellprice'.$key]['checked'])) { print ''; - if (! empty($productpricescache[$obj->rowid])) + if (!empty($productpricescache[$obj->rowid])) { - if ($productpricescache[$obj->rowid][$key]['price_base_type'] == 'TTC') { - print price($productpricescache[$obj->rowid][$key]['price_ttc']).' '.$langs->trans("TTC"); - } else { - print price($productpricescache[$obj->rowid][$key]['price']).' '.$langs->trans("HT"); - } + if ($productpricescache[$obj->rowid][$key]['price_base_type'] == 'TTC') { + print price($productpricescache[$obj->rowid][$key]['price_ttc']).' '.$langs->trans("TTC"); + } else { + print price($productpricescache[$obj->rowid][$key]['price']).' '.$langs->trans("HT"); + } } print ''; if (!$i) $totalarray['nbfield']++; diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 74d6946d6e4..a4c5de4c47d 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -112,7 +112,7 @@ if (empty($reshook)) // We must define tva_tx, npr and local taxes $tva_tx = $tva_tx_txt; - $reg = array(); + $reg = array(); $vatratecode = ''; if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) { @@ -330,7 +330,7 @@ if (empty($reshook)) 'price' => $newprice, 'price_min' => $newprice_min, 'price_base_type' => $newpricebase, - 'default_vat_code' => $vatratecode, + 'default_vat_code' => $vatratecode, 'vat_tx' => $tva_tx, // default_vat_code should be used in priority in a future 'npr' => $npr, // default_vat_code should be used in priority in a future 'localtaxes_array' => array('0'=>$localtax1_type, '1'=>$localtax1, '2'=>$localtax2_type, '3'=>$localtax2) // default_vat_code should be used in priority in a future diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 38cc5fedd88..535da42eeba 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -102,7 +102,7 @@ if (empty($reshook)) $object->address = (string) GETPOST("address", "alpha"); $object->zip = (string) GETPOST("zipcode", "alpha"); $object->town = (string) GETPOST("town", "alpha"); - $object->country_id = GETPOST("country_id"); + $object->country_id = GETPOST("country_id"); $object->phone = (string) GETPOST("phone", "alpha"); $object->fax = (string) GETPOST("fax", "alpha"); diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 8e13553113a..c97c56b2887 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -159,7 +159,7 @@ class MouvementStock extends CommonObject dol_syslog(get_class($this)."::_create start userid=$user->id, fk_product=$fk_product, warehouse_id=$entrepot_id, qty=$qty, type=$type, price=$price, label=$label, inventorycode=$inventorycode, datem=".$datem.", eatby=".$eatby.", sellby=".$sellby.", batch=".$batch.", skip_batch=".$skip_batch); // Clean parameters - $price = price2num($price, 'MU'); // Clean value for the casse we receive a float zero value, to have it a real zero value. + $price = price2num($price, 'MU'); // Clean value for the casse we receive a float zero value, to have it a real zero value. if (empty($price)) $price = 0; $now = (!empty($datem) ? $datem : dol_now()); diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 76724dfd80f..9e15a580358 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -620,7 +620,7 @@ if ($test) $isavailable[$daytoparse] = array('morning'=>false, 'afternoon'=>fals $tmparray = dol_getdate($daytoparse, true); // detail of current day // For monday, must be 0 for monday if MAIN_START_WEEK = 1, must be 1 for monday if MAIN_START_WEEK = 0 -$idw = ($tmparray['wday'] - (empty($conf->global->MAIN_START_WEEK)?0:1)); +$idw = ($tmparray['wday'] - (empty($conf->global->MAIN_START_WEEK) ? 0 : 1)); // numstartworkingday and numendworkingday are default start and end date of working days (1 means sunday if MAIN_START_WEEK is 0, 1 means monday if MAIN_START_WEEK is 1) $cssweekend = ''; if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) // This is a day is not inside the setup of working days, so we use a week-end css. diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index d1d02db3485..d71ac0852bc 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -922,7 +922,7 @@ class Task extends CommonObject $tasks[$i]->planned_workload = $obj->planned_workload; if ($includebilltime) { - $tasks[$i]->tobill = $obj->tobill; + $tasks[$i]->tobill = $obj->tobill; $tasks[$i]->billed = $obj->billed; } diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 9939d8f0d32..e076bee598d 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -963,7 +963,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) print $langs->trans('InvoiceToUse'); print ''; print ''; - $form->selectInvoice('invoice', '', 'invoiceid', 24, 0, $langs->trans('NewInvoice'), 1, 0, 0, 'maxwidth500', '', 'all'); + $form->selectInvoice('invoice', '', 'invoiceid', 24, 0, $langs->trans('NewInvoice'), 1, 0, 0, 'maxwidth500', '', 'all'); print ''; print ''; /*print ''; diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index b52cc3afe84..07e32b64432 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -390,7 +390,7 @@ class Reception extends CommonObject $this->ref = $obj->ref; $this->socid = $obj->socid; $this->ref_supplier = $obj->ref_supplier; - $this->ref_ext = $obj->ref_ext; + $this->ref_ext = $obj->ref_ext; $this->statut = $obj->fk_statut; $this->user_author_id = $obj->fk_user_author; $this->date_creation = $this->db->jdate($obj->date_creation); diff --git a/htdocs/recruitment/recruitmentcandidature_card.php b/htdocs/recruitment/recruitmentcandidature_card.php index 8c76fdbb28e..9d05674d656 100644 --- a/htdocs/recruitment/recruitmentcandidature_card.php +++ b/htdocs/recruitment/recruitmentcandidature_card.php @@ -247,7 +247,7 @@ if (empty($reshook)) $nuser->personal_mobile = $object->phone; $nuser->birth = $object->date_birth; $nuser->salary = $object->remuneration_proposed; - $nuser->fk_user = $jobposition->fk_user_supervisor; // Supervisor + $nuser->fk_user = $jobposition->fk_user_supervisor; // Supervisor $result = $nuser->create($user); diff --git a/htdocs/recruitment/recruitmentjobposition_list.php b/htdocs/recruitment/recruitmentjobposition_list.php index c942975a91d..1891d9ce822 100644 --- a/htdocs/recruitment/recruitmentjobposition_list.php +++ b/htdocs/recruitment/recruitmentjobposition_list.php @@ -269,20 +269,20 @@ $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $objec $sql .= $hookmanager->resPrint; /* If a group by is required */ -$sql.= " GROUP BY "; +$sql .= " GROUP BY "; foreach ($object->fields as $key => $val) { - $sql.='t.'.$key.', '; + $sql .= 't.'.$key.', '; } // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); } // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListGroupBy', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/,\s*$/', '', $sql); +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql = preg_replace('/,\s*$/', '', $sql); $sql .= $db->order($sortfield, $sortorder); diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index ac26eed537a..49b58d61d08 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -813,14 +813,14 @@ print ''; print ''; print ''; -print '' . $langs->trans("AddEmailPhoneTownInContactList") . ''; +print ''.$langs->trans("AddEmailPhoneTownInContactList").''; print ' '; print ''; if (!empty($conf->global->CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST)) { - print ''; + print ''; print img_picto($langs->trans("Activated"), 'switch_on'); } else { - print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); } print ''; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 56e774e7a9b..5a843e9856a 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -214,7 +214,7 @@ $arrayfields = array( 's.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100), ); // Extra fields -include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 893748deee7..ade660ef1b4 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -257,7 +257,7 @@ if (empty($reshook)) { if ($object->fetch(GETPOST('copie_supplier_proposal')) > 0) { $object->ref = GETPOST('ref'); - $object->date_livraison = $date_delivery; // deprecated + $object->date_livraison = $date_delivery; // deprecated $object->delivery_date = $date_delivery; $object->shipping_method_id = GETPOST('shipping_method_id', 'int'); $object->cond_reglement_id = GETPOST('cond_reglement_id'); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 9a6ed7e1d38..b46ed476629 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1240,7 +1240,7 @@ class SupplierProposal extends CommonObject $this->datev = $this->db->jdate($obj->datev); // TODO deprecated $this->date_creation = $this->db->jdate($obj->datec); //Creation date $this->date_validation = $this->db->jdate($obj->datev); //Validation date - $this->date_livraison = $this->db->jdate($obj->delivery_date); // deprecated + $this->date_livraison = $this->db->jdate($obj->delivery_date); // deprecated $this->delivery_date = $this->db->jdate($obj->delivery_date); $this->shipping_method_id = ($obj->fk_shipping_method > 0) ? $obj->fk_shipping_method : null; diff --git a/htdocs/takepos/floors.php b/htdocs/takepos/floors.php index 9e6f9d2a448..72f25a86ce4 100644 --- a/htdocs/takepos/floors.php +++ b/htdocs/takepos/floors.php @@ -64,8 +64,8 @@ if ($action == "getTables") $rows = array(); while ($row = $db->fetch_array($resql)) { $invoice = new Facture($db); - $result=$invoice->fetch('', '(PROV-POS'.$_SESSION['takeposterminal'].'-'.$row['rowid'].')'); - if ($result>0) $row['occupied']="red"; + $result = $invoice->fetch('', '(PROV-POS'.$_SESSION['takeposterminal'].'-'.$row['rowid'].')'); + if ($result > 0) $row['occupied'] = "red"; $rows[] = $row; } echo json_encode($rows); diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 81da82087ec..f5e40806f5a 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -420,9 +420,9 @@ if ($action == 'creditnote') } } -if ($action == 'history' || $action=='creditnote') +if ($action == 'history' || $action == 'creditnote') { - if ($action=='creditnote') $placeid = $creditnote->id; + if ($action == 'creditnote') $placeid = $creditnote->id; else $placeid = (int) GETPOST('placeid', 'int'); $invoice = new Facture($db); $invoice->fetch($placeid); @@ -679,8 +679,8 @@ if ($action == "order" and $placeid != 0) } $sql = "SELECT label FROM ".MAIN_DB_PREFIX."takepos_floor_tables where rowid=".((int) $place); - $resql = $db->query($sql); - $row = $db->fetch_object($resql); + $resql = $db->query($sql); + $row = $db->fetch_object($resql); $headerorder = '
'.$langs->trans('Place').' '.$row->label.'
'; $footerorder = '
'.$langs->trans("Label").''.$langs->trans("Qty").'
'.dol_print_date(dol_now(), 'dayhour').'
'; $order_receipt_printer1 = ""; @@ -858,7 +858,7 @@ $(document).ready(function() { global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true){ + if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) { ?> $.ajax({ type: "POST", @@ -880,7 +880,7 @@ if ($action == "order" and $order_receipt_printer1 != "") { } if ($action == "order" and $order_receipt_printer2 != "") { - if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true){ + if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) { ?> $.ajax({ type: "POST", @@ -902,7 +902,7 @@ if ($action == "order" and $order_receipt_printer2 != "") { } if ($action == "order" and $order_receipt_printer3 != "") { - if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true){ + if (filter_var($conf->global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) { ?> $.ajax({ type: "POST", diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php index 5ba67060552..4a0bcbe7b92 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -29,544 +29,544 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/ticket.lib.php'; */ class Tickets extends DolibarrApi { - /** - * @var array $FIELDS Mandatory fields, checked when create and update object - */ - public static $FIELDS = array( - 'subject', - 'message' - ); + /** + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + public static $FIELDS = array( + 'subject', + 'message' + ); - /** - * @var array $FIELDS_MESSAGES Mandatory fields, checked when create and update object - */ - public static $FIELDS_MESSAGES = array( - 'track_id', - 'message' - ); + /** + * @var array $FIELDS_MESSAGES Mandatory fields, checked when create and update object + */ + public static $FIELDS_MESSAGES = array( + 'track_id', + 'message' + ); - /** - * @var Ticket $ticket {@type Ticket} - */ - public $ticket; + /** + * @var Ticket $ticket {@type Ticket} + */ + public $ticket; - /** - * Constructor - */ - public function __construct() - { - global $db; - $this->db = $db; - $this->ticket = new Ticket($this->db); - } + /** + * Constructor + */ + public function __construct() + { + global $db; + $this->db = $db; + $this->ticket = new Ticket($this->db); + } - /** - * Get properties of a Ticket object. - * - * Return an array with ticket informations - * - * @param int $id ID of ticket - * @return array|mixed Data without useless information - * - * @throws RestException 401 - * @throws RestException 403 - * @throws RestException 404 - */ - public function get($id) - { - return $this->getCommon($id, '', ''); - } + /** + * Get properties of a Ticket object. + * + * Return an array with ticket informations + * + * @param int $id ID of ticket + * @return array|mixed Data without useless information + * + * @throws RestException 401 + * @throws RestException 403 + * @throws RestException 404 + */ + public function get($id) + { + return $this->getCommon($id, '', ''); + } - /** - * Get properties of a Ticket object from track id - * - * Return an array with ticket informations - * - * @param string $track_id Tracking ID of ticket - * @return array|mixed Data without useless information - * - * @url GET track_id/{track_id} - * - * @throws RestException 401 - * @throws RestException 403 - * @throws RestException 404 - */ - public function getByTrackId($track_id) - { - return $this->getCommon(0, $track_id, ''); - } + /** + * Get properties of a Ticket object from track id + * + * Return an array with ticket informations + * + * @param string $track_id Tracking ID of ticket + * @return array|mixed Data without useless information + * + * @url GET track_id/{track_id} + * + * @throws RestException 401 + * @throws RestException 403 + * @throws RestException 404 + */ + public function getByTrackId($track_id) + { + return $this->getCommon(0, $track_id, ''); + } - /** - * Get properties of a Ticket object from ref - * - * Return an array with ticket informations - * - * @param string $ref Reference for ticket - * @return array|mixed Data without useless information - * - * @url GET ref/{ref} - * - * @throws RestException 401 - * @throws RestException 403 - * @throws RestException 404 - */ - public function getByRef($ref) - { - try { - return $this->getCommon(0, '', $ref); - } catch (Exception $e) - { - throw $e; - } - } + /** + * Get properties of a Ticket object from ref + * + * Return an array with ticket informations + * + * @param string $ref Reference for ticket + * @return array|mixed Data without useless information + * + * @url GET ref/{ref} + * + * @throws RestException 401 + * @throws RestException 403 + * @throws RestException 404 + */ + public function getByRef($ref) + { + try { + return $this->getCommon(0, '', $ref); + } catch (Exception $e) + { + throw $e; + } + } - /** - * Get properties of a Ticket object - * Return an array with ticket informations - * - * @param int $id ID of ticket - * @param string $track_id Tracking ID of ticket - * @param string $ref Reference for ticket - * @return array|mixed Data without useless information - */ - private function getCommon($id = 0, $track_id = '', $ref = '') - { - if (!DolibarrApiAccess::$user->rights->ticket->read) { - throw new RestException(403); - } + /** + * Get properties of a Ticket object + * Return an array with ticket informations + * + * @param int $id ID of ticket + * @param string $track_id Tracking ID of ticket + * @param string $ref Reference for ticket + * @return array|mixed Data without useless information + */ + private function getCommon($id = 0, $track_id = '', $ref = '') + { + if (!DolibarrApiAccess::$user->rights->ticket->read) { + throw new RestException(403); + } - // Check parameters - if (($id < 0) && !$track_id && !$ref) { - throw new RestException(401, 'Wrong parameters'); - } + // Check parameters + if (($id < 0) && !$track_id && !$ref) { + throw new RestException(401, 'Wrong parameters'); + } if ($id == 0) { $result = $this->ticket->initAsSpecimen(); } else { $result = $this->ticket->fetch($id, $ref, $track_id); } - if (!$result) { - throw new RestException(404, 'Ticket not found'); - } + if (!$result) { + throw new RestException(404, 'Ticket not found'); + } - // String for user assigned - if ($this->ticket->fk_user_assign > 0) { - $userStatic = new User($this->db); - $userStatic->fetch($this->ticket->fk_user_assign); - $this->ticket->fk_user_assign_string = $userStatic->firstname.' '.$userStatic->lastname; - } + // String for user assigned + if ($this->ticket->fk_user_assign > 0) { + $userStatic = new User($this->db); + $userStatic->fetch($this->ticket->fk_user_assign); + $this->ticket->fk_user_assign_string = $userStatic->firstname.' '.$userStatic->lastname; + } - // Messages of ticket - $messages = array(); - $this->ticket->loadCacheMsgsTicket(); - if (is_array($this->ticket->cache_msgs_ticket) && count($this->ticket->cache_msgs_ticket) > 0) { - $num = count($this->ticket->cache_msgs_ticket); - $i = 0; - while ($i < $num) { - if ($this->ticket->cache_msgs_ticket[$i]['fk_user_author'] > 0) { - $user_action = new User($this->db); - $user_action->fetch($this->ticket->cache_msgs_ticket[$i]['fk_user_author']); - } + // Messages of ticket + $messages = array(); + $this->ticket->loadCacheMsgsTicket(); + if (is_array($this->ticket->cache_msgs_ticket) && count($this->ticket->cache_msgs_ticket) > 0) { + $num = count($this->ticket->cache_msgs_ticket); + $i = 0; + while ($i < $num) { + if ($this->ticket->cache_msgs_ticket[$i]['fk_user_author'] > 0) { + $user_action = new User($this->db); + $user_action->fetch($this->ticket->cache_msgs_ticket[$i]['fk_user_author']); + } - // Now define messages - $messages[] = array( - 'id' => $this->ticket->cache_msgs_ticket[$i]['id'], - 'fk_user_action' => $this->ticket->cache_msgs_ticket[$i]['fk_user_author'], - 'fk_user_action_socid' => $user_action->socid, - 'fk_user_action_string' => dolGetFirstLastname($user_action->firstname, $user_action->lastname), - 'message' => $this->ticket->cache_msgs_ticket[$i]['message'], - 'datec' => $this->ticket->cache_msgs_ticket[$i]['datec'], - 'private' => $this->ticket->cache_msgs_ticket[$i]['private'] - ); - $i++; - } - $this->ticket->messages = $messages; - } + // Now define messages + $messages[] = array( + 'id' => $this->ticket->cache_msgs_ticket[$i]['id'], + 'fk_user_action' => $this->ticket->cache_msgs_ticket[$i]['fk_user_author'], + 'fk_user_action_socid' => $user_action->socid, + 'fk_user_action_string' => dolGetFirstLastname($user_action->firstname, $user_action->lastname), + 'message' => $this->ticket->cache_msgs_ticket[$i]['message'], + 'datec' => $this->ticket->cache_msgs_ticket[$i]['datec'], + 'private' => $this->ticket->cache_msgs_ticket[$i]['private'] + ); + $i++; + } + $this->ticket->messages = $messages; + } - // History - $history = array(); - $this->ticket->loadCacheLogsTicket(); - if (is_array($this->ticket->cache_logs_ticket) && count($this->ticket->cache_logs_ticket) > 0) { - $num = count($this->ticket->cache_logs_ticket); - $i = 0; - while ($i < $num) { - if ($this->ticket->cache_logs_ticket[$i]['fk_user_create'] > 0) { - $user_action = new User($this->db); - $user_action->fetch($this->ticket->cache_logs_ticket[$i]['fk_user_create']); - } + // History + $history = array(); + $this->ticket->loadCacheLogsTicket(); + if (is_array($this->ticket->cache_logs_ticket) && count($this->ticket->cache_logs_ticket) > 0) { + $num = count($this->ticket->cache_logs_ticket); + $i = 0; + while ($i < $num) { + if ($this->ticket->cache_logs_ticket[$i]['fk_user_create'] > 0) { + $user_action = new User($this->db); + $user_action->fetch($this->ticket->cache_logs_ticket[$i]['fk_user_create']); + } - // Now define messages - $history[] = array( - 'id' => $this->ticket->cache_logs_ticket[$i]['id'], - 'fk_user_author' => $this->ticket->cache_msgs_ticket[$i]['fk_user_author'], - 'fk_user_action' => $this->ticket->cache_logs_ticket[$i]['fk_user_create'], - 'fk_user_action_string' => dolGetFirstLastname($user_action->firstname, $user_action->lastname), - 'message' => $this->ticket->cache_logs_ticket[$i]['message'], - 'datec' => $this->ticket->cache_logs_ticket[$i]['datec'], - ); - $i++; - } - $this->ticket->history = $history; - } + // Now define messages + $history[] = array( + 'id' => $this->ticket->cache_logs_ticket[$i]['id'], + 'fk_user_author' => $this->ticket->cache_msgs_ticket[$i]['fk_user_author'], + 'fk_user_action' => $this->ticket->cache_logs_ticket[$i]['fk_user_create'], + 'fk_user_action_string' => dolGetFirstLastname($user_action->firstname, $user_action->lastname), + 'message' => $this->ticket->cache_logs_ticket[$i]['message'], + 'datec' => $this->ticket->cache_logs_ticket[$i]['datec'], + ); + $i++; + } + $this->ticket->history = $history; + } - if (!DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - return $this->_cleanObjectDatas($this->ticket); - } + if (!DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + return $this->_cleanObjectDatas($this->ticket); + } - /** - * List tickets - * - * Get a list of tickets - * - * @param int $socid Filter list with thirdparty ID - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101') and (t.fk_statut:=:1)" - * - * @return array Array of ticket objects - * - */ - public function index($socid = 0, $sortfield = "t.rowid", $sortorder = "ASC", $limit = 100, $page = 0, $sqlfilters = '') - { - global $db, $conf; + /** + * List tickets + * + * Get a list of tickets + * + * @param int $socid Filter list with thirdparty ID + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101') and (t.fk_statut:=:1)" + * + * @return array Array of ticket objects + * + */ + public function index($socid = 0, $sortfield = "t.rowid", $sortorder = "ASC", $limit = 100, $page = 0, $sqlfilters = '') + { + global $db, $conf; - $obj_ret = array(); + $obj_ret = array(); - if (!$socid && DolibarrApiAccess::$user->socid) { - $socid = DolibarrApiAccess::$user->socid; - } + if (!$socid && DolibarrApiAccess::$user->socid) { + $socid = DolibarrApiAccess::$user->socid; + } - // If the internal user must only see his customers, force searching by him - if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) { - $search_sale = DolibarrApiAccess::$user->id; - } + // If the internal user must only see his customers, force searching by him + if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) { + $search_sale = DolibarrApiAccess::$user->id; + } - $sql = "SELECT t.rowid"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $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."ticket as t"; + $sql = "SELECT t.rowid"; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $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."ticket as t"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $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 - } + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $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 .= ' WHERE t.entity IN ('.getEntity('ticket', 1).')'; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { - $sql .= " AND t.fk_soc = sc.fk_soc"; - } - if ($socid > 0) { - $sql .= " AND t.fk_soc = ".$socid; - } - if ($search_sale > 0) { - $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale - } + $sql .= ' WHERE t.entity IN ('.getEntity('ticket', 1).')'; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { + $sql .= " AND t.fk_soc = sc.fk_soc"; + } + if ($socid > 0) { + $sql .= " AND t.fk_soc = ".$socid; + } + 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) { - $sql .= " AND sc.fk_user = ".$search_sale; - } - // Add sql filters - if ($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).")"; - } + // Insert sale filter + if ($search_sale > 0) { + $sql .= " AND sc.fk_user = ".$search_sale; + } + // Add sql filters + if ($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).")"; + } - $sql .= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->order($sortfield, $sortorder); - if ($limit) { - if ($page < 0) { - $page = 0; - } - $offset = $limit * $page; + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; - $sql .= $this->db->plimit($limit, $offset); - } + $sql .= $this->db->plimit($limit, $offset); + } - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); - $i = 0; - while ($i < $num) { - $obj = $this->db->fetch_object($result); - $ticket_static = new Ticket($this->db); - if ($ticket_static->fetch($obj->rowid)) { - if ($ticket_static->fk_user_assign > 0) { - $userStatic = new User($this->db); - $userStatic->fetch($ticket_static->fk_user_assign); - $ticket_static->fk_user_assign_string = $userStatic->firstname.' '.$userStatic->lastname; - } - $obj_ret[] = $this->_cleanObjectDatas($ticket_static); - } - $i++; - } - } else { - throw new RestException(503, 'Error when retrieve ticket list'); - } - if (!count($obj_ret)) { - throw new RestException(404, 'No ticket found'); - } - return $obj_ret; - } + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + $i = 0; + while ($i < $num) { + $obj = $this->db->fetch_object($result); + $ticket_static = new Ticket($this->db); + if ($ticket_static->fetch($obj->rowid)) { + if ($ticket_static->fk_user_assign > 0) { + $userStatic = new User($this->db); + $userStatic->fetch($ticket_static->fk_user_assign); + $ticket_static->fk_user_assign_string = $userStatic->firstname.' '.$userStatic->lastname; + } + $obj_ret[] = $this->_cleanObjectDatas($ticket_static); + } + $i++; + } + } else { + throw new RestException(503, 'Error when retrieve ticket list'); + } + if (!count($obj_ret)) { + throw new RestException(404, 'No ticket found'); + } + return $obj_ret; + } - /** - * Create ticket object - * - * @param array $request_data Request datas - * @return int ID of ticket - */ - public function post($request_data = null) - { - $ticketstatic = new Ticket($this->db); - if (!DolibarrApiAccess::$user->rights->ticket->write) { - throw new RestException(401); - } - // Check mandatory fields - $result = $this->_validate($request_data); + /** + * Create ticket object + * + * @param array $request_data Request datas + * @return int ID of ticket + */ + public function post($request_data = null) + { + $ticketstatic = new Ticket($this->db); + if (!DolibarrApiAccess::$user->rights->ticket->write) { + throw new RestException(401); + } + // Check mandatory fields + $result = $this->_validate($request_data); - foreach ($request_data as $field => $value) { - $this->ticket->$field = $value; - } - if (empty($this->ticket->ref)) { - $this->ticket->ref = $ticketstatic->getDefaultRef(); - } - if (empty($this->ticket->track_id)) { - $this->ticket->track_id = generate_random_id(16); - } + foreach ($request_data as $field => $value) { + $this->ticket->$field = $value; + } + if (empty($this->ticket->ref)) { + $this->ticket->ref = $ticketstatic->getDefaultRef(); + } + if (empty($this->ticket->track_id)) { + $this->ticket->track_id = generate_random_id(16); + } - if ($this->ticket->create(DolibarrApiAccess::$user) < 0) { - throw new RestException(500, "Error creating ticket", array_merge(array($this->ticket->error), $this->ticket->errors)); - } + if ($this->ticket->create(DolibarrApiAccess::$user) < 0) { + throw new RestException(500, "Error creating ticket", array_merge(array($this->ticket->error), $this->ticket->errors)); + } - return $this->ticket->id; - } + return $this->ticket->id; + } - /** - * Create ticket object - * - * @param array $request_data Request datas - * @return int ID of ticket - * - */ - public function postNewMessage($request_data = null) - { - $ticketstatic = new Ticket($this->db); - if (!DolibarrApiAccess::$user->rights->ticket->write) { - throw new RestException(401); - } - // Check mandatory fields - $result = $this->_validateMessage($request_data); + /** + * Create ticket object + * + * @param array $request_data Request datas + * @return int ID of ticket + * + */ + public function postNewMessage($request_data = null) + { + $ticketstatic = new Ticket($this->db); + if (!DolibarrApiAccess::$user->rights->ticket->write) { + throw new RestException(401); + } + // Check mandatory fields + $result = $this->_validateMessage($request_data); - foreach ($request_data as $field => $value) { - $this->ticket->$field = $value; - } - $ticketMessageText = $this->ticket->message; - $result = $this->ticket->fetch('', '', $this->ticket->track_id); - if (!$result) { - throw new RestException(404, 'Ticket not found'); - } - $this->ticket->message = $ticketMessageText; - if (!$this->ticket->createTicketMessage(DolibarrApiAccess::$user)) { - throw new RestException(500); - } - return $this->ticket->id; - } + foreach ($request_data as $field => $value) { + $this->ticket->$field = $value; + } + $ticketMessageText = $this->ticket->message; + $result = $this->ticket->fetch('', '', $this->ticket->track_id); + if (!$result) { + throw new RestException(404, 'Ticket not found'); + } + $this->ticket->message = $ticketMessageText; + if (!$this->ticket->createTicketMessage(DolibarrApiAccess::$user)) { + throw new RestException(500); + } + return $this->ticket->id; + } - /** - * Update ticket - * - * @param int $id Id of ticket to update - * @param array $request_data Datas - * @return int - * - */ - public function put($id, $request_data = null) - { - if (!DolibarrApiAccess::$user->rights->ticket->write) { - throw new RestException(401); - } + /** + * Update ticket + * + * @param int $id Id of ticket to update + * @param array $request_data Datas + * @return int + * + */ + public function put($id, $request_data = null) + { + if (!DolibarrApiAccess::$user->rights->ticket->write) { + throw new RestException(401); + } - $result = $this->ticket->fetch($id); - if (!$result) { - throw new RestException(404, 'Ticket not found'); - } + $result = $this->ticket->fetch($id); + if (!$result) { + throw new RestException(404, 'Ticket not found'); + } - if (!DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - foreach ($request_data as $field => $value) { - $this->ticket->$field = $value; - } + foreach ($request_data as $field => $value) { + $this->ticket->$field = $value; + } - if ($this->ticket->update($id, DolibarrApiAccess::$user)) { - return $this->get($id); - } + if ($this->ticket->update($id, DolibarrApiAccess::$user)) { + return $this->get($id); + } - return false; - } + return false; + } - /** - * Delete ticket - * - * @param int $id Ticket ID - * @return array - * - */ - public function delete($id) - { - if (!DolibarrApiAccess::$user->rights->ticket->delete) { - throw new RestException(401); - } - $result = $this->ticket->fetch($id); - if (!$result) { - throw new RestException(404, 'Ticket not found'); - } + /** + * Delete ticket + * + * @param int $id Ticket ID + * @return array + * + */ + public function delete($id) + { + if (!DolibarrApiAccess::$user->rights->ticket->delete) { + throw new RestException(401); + } + $result = $this->ticket->fetch($id); + if (!$result) { + throw new RestException(404, 'Ticket not found'); + } - if (!DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - if (!$this->ticket->delete($id)) { - throw new RestException(500); - } + if (!$this->ticket->delete($id)) { + throw new RestException(500); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Ticket deleted' - ) - ); - } + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Ticket deleted' + ) + ); + } - /** - * Validate fields before create or update object - * - * @param array $data Data to validate - * @return array - * - * @throws RestException - */ - private function _validate($data) - { - $ticket = array(); - foreach (Tickets::$FIELDS as $field) { - if (!isset($data[$field])) { - throw new RestException(400, "$field field missing"); - } - $ticket[$field] = $data[$field]; - } - return $ticket; - } + /** + * Validate fields before create or update object + * + * @param array $data Data to validate + * @return array + * + * @throws RestException + */ + private function _validate($data) + { + $ticket = array(); + foreach (Tickets::$FIELDS as $field) { + if (!isset($data[$field])) { + throw new RestException(400, "$field field missing"); + } + $ticket[$field] = $data[$field]; + } + return $ticket; + } - /** - * Validate fields before create or update object message - * - * @param array $data Data to validate - * @return array - * - * @throws RestException - */ - private function _validateMessage($data) - { - $ticket = array(); - foreach (Tickets::$FIELDS_MESSAGES as $field) { - if (!isset($data[$field])) { - throw new RestException(400, "$field field missing"); - } - $ticket[$field] = $data[$field]; - } - return $ticket; - } + /** + * Validate fields before create or update object message + * + * @param array $data Data to validate + * @return array + * + * @throws RestException + */ + private function _validateMessage($data) + { + $ticket = array(); + foreach (Tickets::$FIELDS_MESSAGES as $field) { + if (!isset($data[$field])) { + throw new RestException(400, "$field field missing"); + } + $ticket[$field] = $data[$field]; + } + return $ticket; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - /** - * Clean sensible object datas - * - * @param Object $object Object to clean - * @return Object Object with cleaned properties - * - * @todo use an array for properties to clean - * - */ - protected function _cleanObjectDatas($object) - { - // phpcs:enable - $object = parent::_cleanObjectDatas($object); + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Clean sensible object datas + * + * @param Object $object Object to clean + * @return Object Object with cleaned properties + * + * @todo use an array for properties to clean + * + */ + protected function _cleanObjectDatas($object) + { + // phpcs:enable + $object = parent::_cleanObjectDatas($object); - // Other attributes to clean - $attr2clean = array( - "contact", - "contact_id", - "ref_previous", - "ref_next", - "ref_ext", - "table_element_line", - "statut", - "country", - "country_id", - "country_code", - "barcode_type", - "barcode_type_code", - "barcode_type_label", - "barcode_type_coder", - "mode_reglement_id", - "cond_reglement_id", - "cond_reglement", - "fk_delivery_address", - "shipping_method_id", - "modelpdf", - "fk_account", - "note_public", - "note_private", - "note", - "total_ht", - "total_tva", - "total_localtax1", - "total_localtax2", - "total_ttc", - "fk_incoterms", - "label_incoterms", - "location_incoterms", - "name", - "lastname", - "firstname", - "civility_id", - "canvas", - "cache_msgs_ticket", - "cache_logs_ticket", - "cache_types_tickets", - "cache_category_tickets", - "regeximgext", - "statuts_short", - "statuts" - ); - foreach ($attr2clean as $toclean) { - unset($object->$toclean); - } + // Other attributes to clean + $attr2clean = array( + "contact", + "contact_id", + "ref_previous", + "ref_next", + "ref_ext", + "table_element_line", + "statut", + "country", + "country_id", + "country_code", + "barcode_type", + "barcode_type_code", + "barcode_type_label", + "barcode_type_coder", + "mode_reglement_id", + "cond_reglement_id", + "cond_reglement", + "fk_delivery_address", + "shipping_method_id", + "modelpdf", + "fk_account", + "note_public", + "note_private", + "note", + "total_ht", + "total_tva", + "total_localtax1", + "total_localtax2", + "total_ttc", + "fk_incoterms", + "label_incoterms", + "location_incoterms", + "name", + "lastname", + "firstname", + "civility_id", + "canvas", + "cache_msgs_ticket", + "cache_logs_ticket", + "cache_types_tickets", + "cache_category_tickets", + "regeximgext", + "statuts_short", + "statuts" + ); + foreach ($attr2clean as $toclean) { + unset($object->$toclean); + } - // If object has lines, remove $db property - if (isset($object->lines) && count($object->lines) > 0) { - $nboflines = count($object->lines); - for ($i = 0; $i < $nboflines; $i++) { - $this->_cleanObjectDatas($object->lines[$i]); - } - } + // If object has lines, remove $db property + if (isset($object->lines) && count($object->lines) > 0) { + $nboflines = count($object->lines); + for ($i = 0; $i < $nboflines; $i++) { + $this->_cleanObjectDatas($object->lines[$i]); + } + } - // If object has linked objects, remove $db property - if (isset($object->linkedObjects) && count($object->linkedObjects) > 0) { - foreach ($object->linkedObjects as $type_object => $linked_object) { - foreach ($linked_object as $object2clean) { - $this->_cleanObjectDatas($object2clean); - } - } - } - return $object; - } + // If object has linked objects, remove $db property + if (isset($object->linkedObjects) && count($object->linkedObjects) > 0) { + foreach ($object->linkedObjects as $type_object => $linked_object) { + foreach ($linked_object as $object2clean) { + $this->_cleanObjectDatas($object2clean); + } + } + } + return $object; + } } diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index bd28149627f..fc1cca1aa0f 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -112,7 +112,7 @@ foreach ($object->fields as $key => $val) if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); } // Extra fields -include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -316,7 +316,7 @@ if ($socid > 0) foreach ($search as $key => $val) { - if ($key == 'fk_statut' && !empty($search['fk_statut'])) + if ($key == 'fk_statut' && !empty($search['fk_statut'])) { $newarrayofstatus = array(); foreach ($search['fk_statut'] as $key2 => $val2) { @@ -636,9 +636,9 @@ foreach ($object->fields as $key => $val) $formTicket->selectSeveritiesTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css'] ? $val['css'] : 'maxwidth150')); print ''; } elseif ($key == 'fk_user_assign' || $key == 'fk_user_create') { - print ''; - print $form->select_dolusers($search[$key], 'search_'.$key, 1, null, 0, '', '', '0', 0, 0, '', 0, '', ($val['css'] ? $val['css'] : 'maxwidth150')); - print ''; + print ''; + print $form->select_dolusers($search[$key], 'search_'.$key, 1, null, 0, '', '', '0', 0, 0, '', 0, '', ($val['css'] ? $val['css'] : 'maxwidth150')); + print ''; } elseif ($key == 'fk_statut') { $arrayofstatus = array(); $arrayofstatus['openall'] = '-- '.$langs->trans('OpenAll').' --'; diff --git a/htdocs/user/list.php b/htdocs/user/list.php index d17507b3b33..126bfd0bac1 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -343,7 +343,7 @@ if ($search_thirdparty != '') $sql .= natural_search(array('s.nom'), $search_thi if ($search_login != '') $sql .= natural_search("u.login", $search_login); if ($search_lastname != '') $sql .= natural_search("u.lastname", $search_lastname); if ($search_firstname != '') $sql .= natural_search("u.firstname", $search_firstname); -if ($search_gender != '' && $search_gender != '-1') $sql .= " AND u.gender = '".$db->escape($search_gender)."'"; // Cannot use natural_search as looking for %man% also includes woman +if ($search_gender != '' && $search_gender != '-1') $sql .= " AND u.gender = '".$db->escape($search_gender)."'"; // Cannot use natural_search as looking for %man% also includes woman if (is_numeric($search_employee) && $search_employee >= 0) { $sql .= ' AND u.employee = '.(int) $search_employee; } diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 631de0a5fa8..42b39e7e902 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -882,7 +882,7 @@ class Website extends CommonObject global $user; $this->id = 0; - $this->specimen =1; + $this->specimen = 1; $this->entity = 1; $this->ref = 'myspecimenwebsite'; $this->description = 'A specimen website'; diff --git a/htdocs/zapier/class/api_zapier.class.php b/htdocs/zapier/class/api_zapier.class.php index bb3e42f5f05..945a6a69a8f 100644 --- a/htdocs/zapier/class/api_zapier.class.php +++ b/htdocs/zapier/class/api_zapier.class.php @@ -244,7 +244,7 @@ class ZapierApi extends DolibarrApi $fields = array( 'url', ); - dol_syslog("API Zapier create hook receive : " . print_r($request_data, true), LOG_DEBUG); + dol_syslog("API Zapier create hook receive : ".print_r($request_data, true), LOG_DEBUG); $result = $this->validate($request_data, $fields); foreach ($request_data as $field => $value) { diff --git a/scripts/emailings/reset-invalid-emails.php b/scripts/emailings/reset-invalid-emails.php index ed10aded257..59c7e5372dd 100755 --- a/scripts/emailings/reset-invalid-emails.php +++ b/scripts/emailings/reset-invalid-emails.php @@ -77,12 +77,12 @@ if (!$myfile) } $tmp = 1; -while ($tmp!=null) +while ($tmp != null) { - $groupofemails=array(); - for ($i=0; $i < MAXEMAILS; $i++) + $groupofemails = array(); + for ($i = 0; $i < MAXEMAILS; $i++) { - $tmp =fgets($myfile); + $tmp = fgets($myfile); if ($tmp == null) { break; @@ -99,7 +99,7 @@ while ($tmp!=null) { // Loop on each record and update the email to null if email into $groupofemails - $sql=$sql_base."societe as s SET s.email = NULL WHERE s.email = '".$db->escape($email)."';"; + $sql = $sql_base."societe as s SET s.email = NULL WHERE s.email = '".$db->escape($email)."';"; $db->query($sql); } @@ -107,7 +107,7 @@ while ($tmp!=null) { // Loop on each record and update the email to null if email into $groupofemails - $sql=$sql_base."socpeople as s SET s.email = NULL WHERE s.email = '".$db->escape($email)."';"; + $sql = $sql_base."socpeople as s SET s.email = NULL WHERE s.email = '".$db->escape($email)."';"; $db->query($sql); } @@ -115,7 +115,7 @@ while ($tmp!=null) { // Loop on each record and update the email to null if email into $groupofemails - $sql=$sql_base."user as u SET u.email = NULL WHERE u.email = '".$db->escape($email)."';"; + $sql = $sql_base."user as u SET u.email = NULL WHERE u.email = '".$db->escape($email)."';"; $db->query($sql); } @@ -123,8 +123,8 @@ while ($tmp!=null) { // Loop on each record and update the email to null if email into $groupofemails - $sql=$sql_base."adherent as a SET a.email = NULL WHERE a.email = '".$db->escape($email)."';"; - $resql=$db->query($sql); + $sql = $sql_base."adherent as a SET a.email = NULL WHERE a.email = '".$db->escape($email)."';"; + $resql = $db->query($sql); } echo $email; }