diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index cd2d8eec015..0d29209780e 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -1322,7 +1322,7 @@ while ($i < min($num, $limit)) { } if (!empty($arrayfields['t.import_key']['checked'])) { - print ''.$obj->import_key."\n"; + print ''.dol_escape_htmltag($obj->import_key)."\n"; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 338ca12e5f0..82a26a6534c 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -1295,7 +1295,7 @@ while ($i < min($num, $limit)) { } if (!empty($arrayfields['t.import_key']['checked'])) { - print ''.dol_escape_htmltag($line->import_key)."\n"; + print ''.dol_escape_htmltag($line->import_key)."\n"; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 94a8647974f..b26b935918c 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -272,7 +272,7 @@ class Proposals extends DolibarrApi throw new RestException(500, "Error creating order", array_merge(array($this->propal->error), $this->propal->errors)); } - return $this->propal->id; + return ((int) $this->propal->id); } /** diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 7256ee8e790..211edeb29ab 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -291,7 +291,7 @@ class Orders extends DolibarrApi throw new RestException(500, "Error creating order", array_merge(array($this->commande->error), $this->commande->errors)); } - return $this->commande->id; + return ((int) $this->commande->id); } /** diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 80126d347b6..fa51439ff72 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -321,7 +321,7 @@ class Invoices extends DolibarrApi if ($this->invoice->create(DolibarrApiAccess::$user, 0, (empty($request_data["date_lim_reglement"]) ? 0 : $request_data["date_lim_reglement"])) < 0) { throw new RestException(500, "Error creating invoice", array_merge(array($this->invoice->error), $this->invoice->errors)); } - return $this->invoice->id; + return ((int) $this->invoice->id); } /** diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 2f5a6df1449..846f4709e2b 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1369,7 +1369,7 @@ abstract class CommonDocGenerator $extrafieldOutputContent = ''; if (isset($object->array_options[$extrafieldOptionsKey])) { - $extrafieldOutputContent = $extrafields->showOutputField($extrafieldKey, $object->array_options[$extrafieldOptionsKey], '', $object->table_element); + $extrafieldOutputContent = $extrafields->showOutputField($extrafieldKey, $object->array_options[$extrafieldOptionsKey], '', $object->table_element, $outputlangs); } // TODO : allow showOutputField to be pdf public friendly, ex: in a link to object, clean getNomUrl to remove link and images... like a getName methode ... diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 7cfc5187d49..51fa68adfc3 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1629,12 +1629,17 @@ class ExtraFields * @param string $value Value to show * @param string $moreparam To add more parameters on html input tag (only checkbox use html input for output rendering) * @param string $extrafieldsobjectkey Required (for example $object->table_element). + * @param Translate $outputlangs Output language * @return string Formatted value */ - public function showOutputField($key, $value, $moreparam = '', $extrafieldsobjectkey = '') + public function showOutputField($key, $value, $moreparam = '', $extrafieldsobjectkey = '', $outputlangs = null) { global $conf, $langs; + if (is_null($outputlangs) || !is_object($outputlangs)) { + $outputlangs = $langs; + } + if (empty($extrafieldsobjectkey)) { dol_syslog(get_class($this).'::showOutputField extrafieldsobjectkey required', LOG_ERR); return 'BadValueForParamExtraFieldsObjectKey'; @@ -1683,7 +1688,7 @@ class ExtraFields //$value=price($value); $sizeparts = explode(",", $size); $number_decimals = array_key_exists(1, $sizeparts) ? $sizeparts[1] : 0; - $value = price($value, 0, $langs, 0, 0, $number_decimals, ''); + $value = price($value, 0, $outputlangs, 0, 0, $number_decimals, ''); } } elseif ($type == 'boolean') { $checked = ''; @@ -1708,7 +1713,7 @@ class ExtraFields } elseif ($type == 'price') { //$value = price($value, 0, $langs, 0, 0, -1, $conf->currency); if ($value || $value == '0') { - $value = price($value, 0, $langs, 0, $conf->global->MAIN_MAX_DECIMALS_TOT, -1).' '.$langs->getCurrencySymbol($conf->currency); + $value = price($value, 0, $outputlangs, 0, $conf->global->MAIN_MAX_DECIMALS_TOT, -1).' '.$outputlangs->getCurrencySymbol($conf->currency); } } elseif ($type == 'pricecy') { $currency = $conf->currency; @@ -1719,7 +1724,7 @@ class ExtraFields $value = $pricetmp[0]; } if ($value || $value == '0') { - $value = price($value, 0, $langs, 0, $conf->global->MAIN_MAX_DECIMALS_TOT, -1, $currency); + $value = price($value, 0, $outputlangs, 0, $conf->global->MAIN_MAX_DECIMALS_TOT, -1, $currency); } } elseif ($type == 'select') { $valstr = (!empty($param['options'][$value]) ? $param['options'][$value] : ''); @@ -1727,7 +1732,7 @@ class ExtraFields $valstr = substr($valstr, 0, $pos); } if ($langfile && $valstr) { - $value = $langs->trans($valstr); + $value = $outputlangs->trans($valstr); } else { $value = $valstr; } @@ -1786,12 +1791,12 @@ class ExtraFields foreach ($fields_label as $field_toshow) { $translabel = ''; if (!empty($obj->$field_toshow)) { - $translabel = $langs->trans($obj->$field_toshow); + $translabel = $outputlangs->trans($obj->$field_toshow); if ($translabel != $obj->$field_toshow) { - $value .= dol_trunc($translabel, 24).' '; + $value .= dol_trunc($translabel, 24) . ' '; } else { - $value .= $obj->$field_toshow.' '; + $value .= $obj->$field_toshow . ' '; } } } @@ -1800,7 +1805,7 @@ class ExtraFields $tmppropname = $InfoFieldList[1]; //$obj->$tmppropname = ''; if (!empty(isset($obj->$tmppropname) ? $obj->$tmppropname : '')) { - $translabel = $langs->trans($obj->$tmppropname); + $translabel = $outputlangs->trans($obj->$tmppropname); } if ($translabel != (isset($obj->$tmppropname) ? $obj->$tmppropname : '')) { $value = dol_trunc($translabel, 18); @@ -1829,10 +1834,10 @@ class ExtraFields } } elseif ($type == 'radio') { if (!isset($param['options'][$value])) { - $langs->load('errors'); - $value = $langs->trans('ErrorNoValueForRadioType'); + $outputlangs->load('errors'); + $value = $outputlangs->trans('ErrorNoValueForRadioType'); } else { - $value = $langs->trans($param['options'][$value]); + $value = $outputlangs->trans($param['options'][$value]); } } elseif ($type == 'checkbox') { $value_arr = explode(',', $value); @@ -1896,7 +1901,7 @@ class ExtraFields foreach ($fields_label as $field_toshow) { $translabel = ''; if (!empty($obj->$field_toshow)) { - $translabel = $langs->trans($obj->$field_toshow); + $translabel = $outputlangs->trans($obj->$field_toshow); } if ($translabel != $field_toshow) { $label .= ' '.dol_trunc($translabel, 18); @@ -1909,7 +1914,7 @@ class ExtraFields } else { $translabel = ''; if (!empty($obj->{$InfoFieldList[1]})) { - $translabel = $langs->trans($obj->{$InfoFieldList[1]}); + $translabel = $outputlangs->trans($obj->{$InfoFieldList[1]}); } if ($translabel != $obj->{$InfoFieldList[1]}) { $toprint[] = '
  • '.dol_trunc($translabel, 18).'
  • '; diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index 0542b30a4e3..c0a093e7244 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -305,15 +305,15 @@ class FormAccounting extends Form } $out .= ''; //if ($user->admin && $help) $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); + + $out .= ajax_combobox($htmlname, array()); } else { - $out = $langs->trans("ErrorNoAccountingCategoryForThisCountry", $mysoc->country_code, $langs->transnoentitiesnoconv("Accounting"), $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("AccountingCategories")); + $out = ''.$langs->trans("ErrorNoAccountingCategoryForThisCountry", $mysoc->country_code, $langs->transnoentitiesnoconv("Accounting"), $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("AccountingCategories")).''; } } else { dol_print_error($this->db); } - $out .= ajax_combobox($htmlname, array()); - return $out; } diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 0c3e6a4b8e4..d9ce20cf877 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -998,12 +998,6 @@ class pdf_espadon extends ModelePdfExpedition } $pdf->SetDrawColor(128, 128, 128); - if (isModEnabled('barcode')) { - // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref - //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); - //$pdf->Image($logo,10, 5, 0, 24); - } - $posx = $this->page_largeur - $w - $this->marge_droite; $posy = $this->marge_haute; diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 38073c5adb4..4c5e1e6d144 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -908,12 +908,6 @@ class pdf_rouget extends ModelePdfExpedition } $pdf->SetDrawColor(128, 128, 128); - if (isModEnabled('barcode')) { - // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref - //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); - //$pdf->Image($logo,10, 5, 0, 24); - } - $posx = $this->page_largeur - $w - $this->marge_droite; $posy = $this->marge_haute; diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index f96a96bac8c..057e854c86f 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -908,12 +908,6 @@ class pdf_squille extends ModelePdfReception } $pdf->SetDrawColor(128, 128, 128); - if (isModEnabled('barcode')) { - // TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref - //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); - //$pdf->Image($logo,10, 5, 0, 24); - } - $posx = $this->page_largeur - $w - $this->marge_droite; $posy = $this->marge_haute; diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php index 006d1ecbf2d..424bb125da5 100644 --- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php +++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php @@ -1008,12 +1008,6 @@ class pdf_eagle extends ModelePDFStockTransfer } $pdf->SetDrawColor(128, 128, 128); - if (isModEnabled('barcode')) { - // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref - //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); - //$pdf->Image($logo,10, 5, 0, 24); - } - $posx = $this->page_largeur - $w - $this->marge_droite; $posy = $this->marge_haute; diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 66cafdf2205..83c4511c9bc 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -1313,11 +1313,10 @@ class Cronjob extends CommonObject } else { $result = call_user_func_array(array($object, $this->methodename), $params_arr); } - + $errmsg = ''; if ($result === false || (!is_bool($result) && $result != 0)) { $langs->load("errors"); - $errmsg = ''; if (!is_array($object->errors) || !in_array($object->error, $object->errors)) { $errmsg .= $object->error; } diff --git a/htdocs/langs/en_US/interventions.lang b/htdocs/langs/en_US/interventions.lang index ecaf9e21020..4a51d7afac3 100644 --- a/htdocs/langs/en_US/interventions.lang +++ b/htdocs/langs/en_US/interventions.lang @@ -73,3 +73,7 @@ FichinterNoContractLinked=Intervention %s has been created without a linked cont ErrorFicheinterCompanyDoesNotExist=Company does not exist. Intervention has not been created. NextDateToIntervention=Date for next intervention generation NoIntervention=No intervention +TypeContact_fichinter_internal_INTERREPFOLL=Responsible for intervention follow-up +TypeContact_fichinter_internal_INTERVENING=Intervenant +TypeContact_fichinter_external_BILLING=Contact customer of intervention billing +TypeContact_fichinter_external_CUSTOMER=Customer contact of intervention follow-up diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 910720b56f2..65035f02da5 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2731,7 +2731,7 @@ function top_menu_quickadd() // Key map shortcut $(document).keydown(function(event){ - var ostype = "'.$conf->browser->os.'"; + var ostype = \''.dol_escape_js($conf->browser->os).'\'; if (ostype === "macintosh") { if ( event.which === 65 && event.ctrlKey ) { console.log(\'control + a : trigger open quick add dropdown\'); @@ -3003,7 +3003,7 @@ function top_menu_bookmark() // Key map shortcut jQuery(document).keydown(function(event) { - var ostype = "'.$conf->browser->os.'"; + var ostype = \''.dol_escape_js($conf->browser->os).'\'; if (ostype === "macintosh") { if ( event.which === 66 && event.ctrlKey ) { console.log("Click on control + b : trigger open bookmark dropdown"); diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 722e21c5cd0..773137b9a1f 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1749,7 +1749,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print ''; $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', '0', 0, 0, 'AND u.statut = 1', 0, '', '', 0, 2); // Note: If user has no right to "see all thirdparties", we force selection of sale representative to him, so after creation he can see the record. - $selected = (GETPOSTISARRAY('commercial') ? GETPOST('commercial', 'array:int') : (GETPOSTINT('commercial') > 0 ? array(GETPOSTINT('commercial')) : (!$user->hasRight('societe', 'client', 'voir') ? array($user->id) : array()))); + $selected = (GETPOSTISARRAY('commercial') ? GETPOST('commercial', 'array:int') : (GETPOSTINT('commercial') > 0 ? array(GETPOSTINT('commercial')) : array($user->id))); print img_picto('', 'user').$form->multiselectarray('commercial', $userlist, $selected, null, null, 'quatrevingtpercent widthcentpercentminusx', 0, 0); print ''; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index aecf5211359..8fc5513a792 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -4061,18 +4061,25 @@ class Societe extends CommonObject { // Define if third party is treated as company (or not) when nature is unknown $isACompany = getDolGlobalInt('MAIN_UNKNOWN_CUSTOMERS_ARE_COMPANIES'); + + // Now try to guess using different tips if (!empty($this->tva_intra)) { $isACompany = 1; } elseif (!empty($this->idprof1) || !empty($this->idprof2) || !empty($this->idprof3) || !empty($this->idprof4) || !empty($this->idprof5) || !empty($this->idprof6)) { $isACompany = 1; - } elseif (!empty($this->typent_code) && $this->typent_code != 'TE_UNKNOWN') { - // TODO Add a field is_a_company into dictionary - if (preg_match('/^TE_PRIVATE/', $this->typent_code)) { - $isACompany = 0; + } else { + if (!getDolGlobalString('MAIN_CUSTOMERS_ARE_COMPANIES_EVEN_IF_SET_AS_INDIVIDUAL')) { + // TODO Add a field is_a_company into dictionary + if (preg_match('/^TE_PRIVATE/', $this->typent_code)) { + $isACompany = 0; + } else { + $isACompany = 1; + } } else { $isACompany = 1; } } + return (bool) $isACompany; } diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 5217d61f217..d9c192d8891 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -209,8 +209,9 @@ if (empty($reshook)) { if ($invoice->total_ttc < 0) { $invoice->type = $invoice::TYPE_CREDIT_NOTE; - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture WHERE"; - $sql .= " fk_soc = ".((int) $invoice->socid); + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture"; + $sql .= " WHERE entity IN (".getEntity('invoice').")"; + $sql .= " AND fk_soc = ".((int) $invoice->socid); $sql .= " AND type <> ".Facture::TYPE_CREDIT_NOTE; $sql .= " AND fk_statut >= ".$invoice::STATUS_VALIDATED; $sql .= " ORDER BY rowid DESC"; @@ -809,7 +810,8 @@ if (empty($reshook)) { $varforconst = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; $sql .= " SET fk_soc = ".((int) getDolGlobalString($varforconst)).", "; $sql .= " datec = '".$db->idate(dol_now())."'"; - $sql .= " WHERE ref = '(PROV-POS".$db->escape($_SESSION["takeposterminal"]."-".$place).")'"; + $sql .= " WHERE entity IN (".getEntity('invoice').")"; + $sql .= " AND ref = '(PROV-POS".$db->escape($_SESSION["takeposterminal"]."-".$place).")'"; $resql1 = $db->query($sql); if ($resdeletelines && $resql1) { @@ -1364,14 +1366,14 @@ $( document ).ready(function() { escape(isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '')."-0%' AND entity IN (".getEntity('invoice').")"; + $sql .= " AND ref LIKE '(PROV-POS".$db->escape(isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '')."-0%'"; } else { // If TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED set, we show also draft invoice that already has a reference defined - $sql .= " WHERE pos_source = '".$db->escape($_SESSION["takeposterminal"])."'"; + $sql .= " AND pos_source = '".$db->escape($_SESSION["takeposterminal"])."'"; $sql .= " AND module_source = 'takepos'"; - $sql .= " AND entity IN (".getEntity('invoice').")"; } $sql .= $db->order('datec', 'ASC'); diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index 27fa2d103e3..b891f11de6e 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -152,7 +152,9 @@ $invoice = new Facture($db); if ($invoiceid > 0) { $invoice->fetch($invoiceid); } else { - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture"; + $sql .= " WHERE entity IN (".getEntity('invoice').")"; + $sql .= " AND ref = '(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; $resql = $db->query($sql); $obj = $db->fetch_object($resql); if ($obj) {