From be877ffb4b5044995e8e4579224eb1e9b2c0aec0 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 3 Mar 2023 10:15:11 +0100 Subject: [PATCH 1/9] WIP --- htdocs/core/class/html.form.class.php | 14 ++++++++------ htdocs/projet/tasks/time.php | 7 +++++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 4cb98acbe45..fc9a20fbf8a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -10027,9 +10027,10 @@ class Form * @param string $projectsListId ''=Automatic filter on project allowed. List of id=Filter on project ids. * @param string $showproject 'all' = Show project info, ''=Hide project info * @param User $usertofilter User object to use for filtering + * @param int $status Invoice status filter (-1 for no filter) * @return int Nbr of project if OK, <0 if KO */ - public function selectInvoice($socid = -1, $selected = '', $htmlname = 'invoiceid', $maxlength = 24, $option_only = 0, $show_empty = '1', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss = 'maxwidth500', $projectsListId = '', $showproject = 'all', $usertofilter = null) + public function selectInvoice($socid = -1,$selected = '', $htmlname = 'invoiceid', $maxlength = 24, $option_only = 0, $show_empty = '1', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss = 'maxwidth500', $projectsListId = '', $showproject = 'all', $usertofilter = null, $status=0, $events=array()) { global $user, $conf, $langs; @@ -10061,7 +10062,10 @@ class Form $sql .= ' LEFT JOIN '.$this->db->prefix().'societe as s ON s.rowid = p.fk_soc,'; $sql .= ' '.$this->db->prefix().'facture as f'; $sql .= " WHERE p.entity IN (".getEntity('project').")"; - $sql .= " AND f.fk_projet = p.rowid AND f.fk_statut=0"; //Brouillons seulement + $sql .= " AND f.fk_projet = p.rowid "; //Brouillons seulement + if ($status!== -1){ + $sql .= " AND f.fk_statut=".(int)$status; + } //if ($projectsListId) $sql.= " AND p.rowid IN (".$this->db->sanitize($projectsListId).")"; //if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)"; //if ($socid > 0) $sql.= " AND (p.fk_soc=".((int) $socid)." OR p.fk_soc IS NULL)"; @@ -10154,13 +10158,11 @@ class Form $out .= ''; } - print $out; + return $out; $this->db->free($resql); - return $num; } else { - dol_print_error($this->db); - return -1; + dol_print_error($this->db->lasterror); } } diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 85d83031ccd..eea9963bf23 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -1468,7 +1468,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print $langs->trans('InvoiceToUse'); print ''; print ''; - $form->selectInvoice($projectstatic->thirdparty->id, '', 'invoiceid', 24, 0, $langs->trans('NewInvoice'), 1, 0, 0, 'maxwidth500', '', 'all'); + print $form->selectInvoice($projectstatic->thirdparty->id, '', 'invoiceid', 24, 0, $langs->trans('NewInvoice'), 1, 0, 0, 'maxwidth500', '', 'all'); print ''; print ''; /*print ''; @@ -1553,6 +1553,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $sql .= " u.lastname, u.firstname, u.login, u.photo, u.statut as user_status,"; $sql .= " il.fk_facture as invoice_id, inv.fk_statut,"; $sql .= " p.fk_soc,s.name_alias,"; + $sql .= " t.invoice_line_id"; // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook @@ -2344,7 +2345,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if ($task_time->invoice_id) { $result = $tmpinvoice->fetch($task_time->invoice_id); if ($result > 0) { - print $tmpinvoice->getNomUrl(1); + var_dump($task_time->invoice_line_id); + //print $tmpinvoice->getNomUrl(1); + //print $form->selectInvoiceAndLines($projectstatic->thirdparty->id, $tmpinvoice->id, 'invoiceid', 'invoicelineid', 24, 0, $langs->trans('NewInvoice'), 1, 0, 0, 'maxwidth500', '', 'all',null,-1); } } else { print $langs->trans("No"); From b658b9b1d35445415f902bb6cff897c3fa18f268 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 3 Mar 2023 11:18:19 +0100 Subject: [PATCH 2/9] WIP --- htdocs/core/class/html.form.class.php | 4876 ++++++++++--------- htdocs/core/class/html.formprojet.class.php | 118 + htdocs/projet/tasks/time.php | 8 +- 3 files changed, 2585 insertions(+), 2417 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index fc9a20fbf8a..01e3dc99cce 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -37,15 +37,15 @@ */ /** - * \file htdocs/core/class/html.form.class.php + * \file htdocs/core/class/html.form.class.php * \ingroup core - * \brief File of class with all html predefined components + * \brief File of class with all html predefined components */ /** - * Class to manage generation of HTML components - * Only common components must be here. + * Class to manage generation of HTML components + * Only common components must be here. * * TODO Merge all function load_cache_* and loadCache* (except load_cache_vatrates) into one generic function loadCacheTable */ @@ -81,7 +81,7 @@ class Form /** * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $db Database handler */ public function __construct($db) { @@ -91,18 +91,18 @@ class Form /** * Output key field for an editable field * - * @param string $text Text of label or key to translate - * @param string $htmlname Name of select field ('edit' prefix will be added) - * @param string $preselected Value to show/edit (not used in this function) - * @param object $object Object (on the page we show) - * @param boolean $perm Permission to allow button to edit parameter. Set it to 0 to have a not edited field. - * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'datepicker' ('day' do not work, don't know why), 'dayhour' or 'datehourpicker' 'checkbox:ckeditor:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select;xxx[:class]'...) - * @param string $moreparam More param to add on a href URL. - * @param int $fieldrequired 1 if we want to show field as mandatory using the "fieldrequired" CSS. - * @param int $notabletag 1=Do not output table tags but output a ':', 2=Do not output table tags and no ':', 3=Do not output table tags but output a ' ' - * @param string $paramid Key of parameter for id ('id', 'socid') - * @param string $help Tooltip help - * @return string HTML edit field + * @param string $text Text of label or key to translate + * @param string $htmlname Name of select field ('edit' prefix will be added) + * @param string $preselected Value to show/edit (not used in this function) + * @param object $object Object (on the page we show) + * @param boolean $perm Permission to allow button to edit parameter. Set it to 0 to have a not edited field. + * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'datepicker' ('day' do not work, don't know why), 'dayhour' or 'datehourpicker' 'checkbox:ckeditor:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select;xxx[:class]'...) + * @param string $moreparam More param to add on a href URL. + * @param int $fieldrequired 1 if we want to show field as mandatory using the "fieldrequired" CSS. + * @param int $notabletag 1=Do not output table tags but output a ':', 2=Do not output table tags and no ':', 3=Do not output table tags but output a ' ' + * @param string $paramid Key of parameter for id ('id', 'socid') + * @param string $help Tooltip help + * @return string HTML edit field */ public function editfieldkey($text, $htmlname, $preselected, $object, $perm, $typeofdata = 'string', $moreparam = '', $fieldrequired = 0, $notabletag = 0, $paramid = 'id', $help = '') { @@ -114,7 +114,7 @@ class Form if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !preg_match('/^select;/', $typeofdata)) { if (!empty($perm)) { $tmp = explode(':', $typeofdata); - $ret .= '
'; + $ret .= '
'; if ($fieldrequired) { $ret .= ''; } @@ -126,7 +126,7 @@ class Form if ($fieldrequired) { $ret .= ''; } - $ret .= '
'."\n"; + $ret .= '
' . "\n"; } else { if ($fieldrequired) { $ret .= ''; @@ -164,8 +164,8 @@ class Form if (empty($notabletag) && $perm) { $ret .= ''; } - if ($htmlname && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) { - $ret .= 'id.$moreparam.'">'.img_edit($langs->trans('Edit'), ($notabletag ? 0 : 1)).''; + if ($htmlname && GETPOST('action', 'aZ09') != 'edit' . $htmlname && $perm) { + $ret .= '' . img_edit($langs->trans('Edit'), ($notabletag ? 0 : 1)) . ''; } if (!empty($notabletag) && $notabletag == 1) { if ($text) { @@ -191,23 +191,23 @@ class Form /** * Output value of a field for an editable field * - * @param string $text Text of label (not used in this function) - * @param string $htmlname Name of select field - * @param string $value Value to show/edit - * @param object $object Object (that we want to show) - * @param boolean $perm Permission to allow button to edit parameter - * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols%', 'datepicker' ('day' do not work, don't know why), 'dayhour' or 'datehourpicker', 'ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols', 'select;xkey:xval,ykey:yval,...') - * @param string $editvalue When in edit mode, use this value as $value instead of value (for example, you can provide here a formated price instead of numeric value). Use '' to use same than $value - * @param object $extObject External object ??? - * @param mixed $custommsg String or Array of custom messages : eg array('success' => 'MyMessage', 'error' => 'MyMessage') - * @param string $moreparam More param to add on the form on action href URL parameter - * @param int $notabletag Do no output table tags - * @param string $formatfunc Call a specific function to output field in view mode (For example: 'dol_print_email') - * @param string $paramid Key of parameter for id ('id', 'socid') - * @param string $gm 'auto' or 'tzuser' or 'tzuserrel' or 'tzserver' (when $typeofdata is a date) - * @param array $moreoptions Array with more options. For example array('addnowlink'=>1), array('valuealreadyhtmlescaped'=>1) - * @param string $editaction [=''] use GETPOST default action or set action to edit mode - * @return string HTML edit field + * @param string $text Text of label (not used in this function) + * @param string $htmlname Name of select field + * @param string $value Value to show/edit + * @param object $object Object (that we want to show) + * @param boolean $perm Permission to allow button to edit parameter + * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols%', 'datepicker' ('day' do not work, don't know why), 'dayhour' or 'datehourpicker', 'ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols', 'select;xkey:xval,ykey:yval,...') + * @param string $editvalue When in edit mode, use this value as $value instead of value (for example, you can provide here a formated price instead of numeric value). Use '' to use same than $value + * @param object $extObject External object ??? + * @param mixed $custommsg String or Array of custom messages : eg array('success' => 'MyMessage', 'error' => 'MyMessage') + * @param string $moreparam More param to add on the form on action href URL parameter + * @param int $notabletag Do no output table tags + * @param string $formatfunc Call a specific function to output field in view mode (For example: 'dol_print_email') + * @param string $paramid Key of parameter for id ('id', 'socid') + * @param string $gm 'auto' or 'tzuser' or 'tzuserrel' or 'tzserver' (when $typeofdata is a date) + * @param array $moreoptions Array with more options. For example array('addnowlink'=>1), array('valuealreadyhtmlescaped'=>1) + * @param string $editaction [=''] use GETPOST default action or set action to edit mode + * @return string HTML edit field */ public function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata = 'string', $editvalue = '', $extObject = null, $custommsg = null, $moreparam = '', $notabletag = 1, $formatfunc = '', $paramid = 'id', $gm = 'auto', $moreoptions = array(), $editaction = '') { @@ -230,7 +230,7 @@ class Form } elseif ($reg[1] == 'int') { $typeofdata = 'numeric'; } else { - return 'ErrorBadParameter '.$typeofdata; + return 'ErrorBadParameter ' . $typeofdata; } } @@ -241,13 +241,13 @@ class Form if ($editaction == '') { $editaction = GETPOST('action', 'aZ09'); } - $editmode = ($editaction == 'edit'.$htmlname); + $editmode = ($editaction == 'edit' . $htmlname); if ($editmode) { $ret .= "\n"; - $ret .= '
'; - $ret .= ''; - $ret .= ''; - $ret .= ''; + $ret .= ''; + $ret .= ''; + $ret .= ''; + $ret .= ''; if (empty($notabletag)) { $ret .= ''; } @@ -256,29 +256,29 @@ class Form } if (preg_match('/^(string|safehtmlstring|email)/', $typeofdata)) { $tmp = explode(':', $typeofdata); - $ret .= ''; + $ret .= ''; } elseif (preg_match('/^(integer)/', $typeofdata)) { $tmp = explode(':', $typeofdata); $valuetoshow = price2num($editvalue ? $editvalue : $value, 0); - $ret .= ''; + $ret .= ''; } elseif (preg_match('/^(numeric|amount)/', $typeofdata)) { $tmp = explode(':', $typeofdata); $valuetoshow = price2num($editvalue ? $editvalue : $value); - $ret .= ''; + $ret .= ''; } elseif (preg_match('/^(checkbox)/', $typeofdata)) { $tmp = explode(':', $typeofdata); $ret .= ''; - } elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) { // if wysiwyg is enabled $typeofdata = 'ckeditor' + } elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) { // if wysiwyg is enabled $typeofdata = 'ckeditor' $tmp = explode(':', $typeofdata); $cols = (empty($tmp[2]) ? '' : $tmp[2]); $morealt = ''; if (preg_match('/%/', $cols)) { - $morealt = ' style="width: '.$cols.'"'; + $morealt = ' style="width: ' . $cols . '"'; $cols = ''; } $valuetoshow = ($editvalue ? $editvalue : $value); - $ret .= ''; } else { - $resultforextrlang .= ''; + $resultforextrlang .= ''; } } $result .= $resultforextrlang; $result .= ''; - $result .= ''; + $result .= ''; } return $result; @@ -467,15 +467,15 @@ class Form /** * Output edit in place form * - * @param object $object Object - * @param string $value Value to show/edit - * @param string $htmlname DIV ID (field name) - * @param int $condition Condition to edit - * @param string $inputType Type of input ('string', 'numeric', 'datepicker' ('day' do not work, don't know why), 'textarea:rows:cols', 'ckeditor:dolibarr_zzz:width:height:?:1:rows:cols', 'select:loadmethod:savemethod:buttononly') - * @param string $editvalue When in edit mode, use this value as $value instead of value - * @param object $extObject External object - * @param mixed $custommsg String or Array of custom messages : eg array('success' => 'MyMessage', 'error' => 'MyMessage') - * @return string HTML edit in place + * @param object $object Object + * @param string $value Value to show/edit + * @param string $htmlname DIV ID (field name) + * @param int $condition Condition to edit + * @param string $inputType Type of input ('string', 'numeric', 'datepicker' ('day' do not work, don't know why), 'textarea:rows:cols', 'ckeditor:dolibarr_zzz:width:height:?:1:rows:cols', 'select:loadmethod:savemethod:buttononly') + * @param string $editvalue When in edit mode, use this value as $value instead of value + * @param object $extObject External object + * @param mixed $custommsg String or Array of custom messages : eg array('success' => 'MyMessage', 'error' => 'MyMessage') + * @return string HTML edit in place */ protected function editInPlace($object, $value, $htmlname, $condition, $inputType = 'textarea', $editvalue = null, $extObject = null, $custommsg = null) { @@ -495,11 +495,11 @@ class Form if ($condition) { $element = false; $table_element = false; - $fk_element = false; - $loadmethod = false; - $savemethod = false; - $ext_element = false; - $button_only = false; + $fk_element = false; + $loadmethod = false; + $savemethod = false; + $ext_element = false; + $button_only = false; $inputOption = ''; $rows = ''; $cols = ''; @@ -523,7 +523,7 @@ class Form if (!empty($tmp[2])) { $savemethod = $tmp[2]; } - $out .= ''."\n"; + $out .= '' . "\n"; } elseif ((preg_match('/^day$/', $inputType)) || (preg_match('/^datepicker/', $inputType)) || (preg_match('/^datehourpicker/', $inputType))) { $tmp = explode(':', $inputType); $inputType = $tmp[0]; @@ -534,7 +534,7 @@ class Form $savemethod = $tmp[2]; } - $out .= ''."\n"; // Use for timestamp format + $out .= '' . "\n"; // Use for timestamp format } elseif (preg_match('/^(select|autocomplete)/', $inputType)) { $tmp = explode(':', $inputType); $inputType = $tmp[0]; @@ -565,40 +565,40 @@ class Form } if (isModEnabled('fckeditor')) { - $out .= ''."\n"; + $out .= '' . "\n"; } else { $inputType = 'textarea'; } } - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; - $out .= ''."\n"; + $out .= '' . "\n"; + $out .= '' . "\n"; + $out .= '' . "\n"; + $out .= '' . "\n"; if (!empty($savemethod)) { - $out .= ''."\n"; + $out .= '' . "\n"; } if (!empty($ext_element)) { - $out .= ''."\n"; + $out .= '' . "\n"; } if (!empty($custommsg)) { if (is_array($custommsg)) { if (!empty($custommsg['success'])) { - $out .= ''."\n"; + $out .= '' . "\n"; } if (!empty($custommsg['error'])) { - $out .= ''."\n"; + $out .= '' . "\n"; } } else { - $out .= ''."\n"; + $out .= '' . "\n"; } } if ($inputType == 'textarea') { - $out .= ''."\n"; - $out .= ''."\n"; + $out .= '' . "\n"; + $out .= '' . "\n"; } - $out .= ''.$value.''."\n"; - $out .= ''.(!empty($editvalue) ? $editvalue : $value).''."\n"; + $out .= '' . $value . '' . "\n"; + $out .= '' . (!empty($editvalue) ? $editvalue : $value) . '' . "\n"; } else { $out = $value; } @@ -607,32 +607,32 @@ class Form } /** - * Show a text and picto with tooltip on text or picto. + * Show a text and picto with tooltip on text or picto. * Can be called by an instancied $form->textwithtooltip or by a static call Form::textwithtooltip * - * @param string $text Text to show - * @param string $htmltext HTML content of tooltip. Must be HTML/UTF8 encoded. - * @param int $tooltipon 1=tooltip on text, 2=tooltip on image, 3=tooltip sur les 2 - * @param int $direction -1=image is before, 0=no image, 1=image is after - * @param string $img Html code for image (use img_xxx() function to get it) - * @param string $extracss Add a CSS style to td tags - * @param int $notabs 0=Include table and tr tags, 1=Do not include table and tr tags, 2=use div, 3=use span - * @param string $incbefore Include code before the text - * @param int $noencodehtmltext Do not encode into html entity the htmltext - * @param string $tooltiptrigger ''=Tooltip on hover, 'abc'=Tooltip on click (abc is a unique key) - * @param int $forcenowrap Force no wrap between text and picto (works with notabs=2 only) - * @return string Code html du tooltip (texte+picto) - * @see textwithpicto() Use thisfunction if you can. + * @param string $text Text to show + * @param string $htmltext HTML content of tooltip. Must be HTML/UTF8 encoded. + * @param int $tooltipon 1=tooltip on text, 2=tooltip on image, 3=tooltip sur les 2 + * @param int $direction -1=image is before, 0=no image, 1=image is after + * @param string $img Html code for image (use img_xxx() function to get it) + * @param string $extracss Add a CSS style to td tags + * @param int $notabs 0=Include table and tr tags, 1=Do not include table and tr tags, 2=use div, 3=use span + * @param string $incbefore Include code before the text + * @param int $noencodehtmltext Do not encode into html entity the htmltext + * @param string $tooltiptrigger ''=Tooltip on hover, 'abc'=Tooltip on click (abc is a unique key) + * @param int $forcenowrap Force no wrap between text and picto (works with notabs=2 only) + * @return string Code html du tooltip (texte+picto) + * @see textwithpicto() Use thisfunction if you can. */ public function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img = '', $extracss = '', $notabs = 3, $incbefore = '', $noencodehtmltext = 0, $tooltiptrigger = '', $forcenowrap = 0) { if ($incbefore) { - $text = $incbefore.$text; + $text = $incbefore . $text; } if (!$htmltext) { return $text; } - $direction = (int) $direction; // For backward compatibility when $direction was set to '' instead of 0 + $direction = (int)$direction; // For backward compatibility when $direction was set to '' instead of 0 $tag = 'td'; if ($notabs == 2) { @@ -646,11 +646,11 @@ class Form $extrastyle = ''; if ($direction < 0) { - $extracss = ($extracss ? $extracss.' ' : '').($notabs != 3 ? 'inline-block' : ''); + $extracss = ($extracss ? $extracss . ' ' : '') . ($notabs != 3 ? 'inline-block' : ''); $extrastyle = 'padding: 0px; padding-left: 3px;'; } if ($direction > 0) { - $extracss = ($extracss ? $extracss.' ' : '').($notabs != 3 ? 'inline-block' : ''); + $extracss = ($extracss ? $extracss . ' ' : '') . ($notabs != 3 ? 'inline-block' : ''); $extrastyle = 'padding: 0px; padding-right: 3px;'; } @@ -663,53 +663,53 @@ class Form $htmltext = str_replace('"', '"', $htmltext); } else { $classfortooltip = 'classfortooltiponclick'; - $textfordialog .= ''; + $textfordialog .= ''; } if ($tooltipon == 2 || $tooltipon == 3) { - $paramfortooltipimg = ' class="'.$classfortooltip.($notabs != 3 ? ' inline-block' : '').($extracss ? ' '.$extracss : '').'" style="padding: 0px;'.($extrastyle ? ' '.$extrastyle : '').'"'; + $paramfortooltipimg = ' class="' . $classfortooltip . ($notabs != 3 ? ' inline-block' : '') . ($extracss ? ' ' . $extracss : '') . '" style="padding: 0px;' . ($extrastyle ? ' ' . $extrastyle : '') . '"'; if ($tooltiptrigger == '') { - $paramfortooltipimg .= ' title="'.($noencodehtmltext ? $htmltext : dol_escape_htmltag($htmltext, 1)).'"'; // Attribut to put on img tag to store tooltip + $paramfortooltipimg .= ' title="' . ($noencodehtmltext ? $htmltext : dol_escape_htmltag($htmltext, 1)) . '"'; // Attribut to put on img tag to store tooltip } else { - $paramfortooltipimg .= ' dolid="'.$tooltiptrigger.'"'; + $paramfortooltipimg .= ' dolid="' . $tooltiptrigger . '"'; } } else { - $paramfortooltipimg = ($extracss ? ' class="'.$extracss.'"' : '').($extrastyle ? ' style="'.$extrastyle.'"' : ''); // Attribut to put on td text tag + $paramfortooltipimg = ($extracss ? ' class="' . $extracss . '"' : '') . ($extrastyle ? ' style="' . $extrastyle . '"' : ''); // Attribut to put on td text tag } if ($tooltipon == 1 || $tooltipon == 3) { - $paramfortooltiptd = ' class="'.($tooltipon == 3 ? 'cursorpointer ' : '').$classfortooltip.' inline-block'.($extracss ? ' '.$extracss : '').'" style="padding: 0px;'.($extrastyle ? ' '.$extrastyle : '').'" '; + $paramfortooltiptd = ' class="' . ($tooltipon == 3 ? 'cursorpointer ' : '') . $classfortooltip . ' inline-block' . ($extracss ? ' ' . $extracss : '') . '" style="padding: 0px;' . ($extrastyle ? ' ' . $extrastyle : '') . '" '; if ($tooltiptrigger == '') { - $paramfortooltiptd .= ' title="'.($noencodehtmltext ? $htmltext : dol_escape_htmltag($htmltext, 1)).'"'; // Attribut to put on td tag to store tooltip + $paramfortooltiptd .= ' title="' . ($noencodehtmltext ? $htmltext : dol_escape_htmltag($htmltext, 1)) . '"'; // Attribut to put on td tag to store tooltip } else { - $paramfortooltiptd .= ' dolid="'.$tooltiptrigger.'"'; + $paramfortooltiptd .= ' dolid="' . $tooltiptrigger . '"'; } } else { - $paramfortooltiptd = ($extracss ? ' class="'.$extracss.'"' : '').($extrastyle ? ' style="'.$extrastyle.'"' : ''); // Attribut to put on td text tag + $paramfortooltiptd = ($extracss ? ' class="' . $extracss . '"' : '') . ($extrastyle ? ' style="' . $extrastyle . '"' : ''); // Attribut to put on td text tag } if (empty($notabs)) { $s .= '
'; } elseif ($notabs == 2) { - $s .= '
'; + $s .= '
'; } // Define value if value is before if ($direction < 0) { - $s .= '<'.$tag.$paramfortooltipimg; + $s .= '<' . $tag . $paramfortooltipimg; if ($tag == 'td') { $s .= ' class="valigntop" width="14"'; } - $s .= '>'.$textfordialog.$img.''; + $s .= '>' . $textfordialog . $img . ''; } // Use another method to help avoid having a space in value in order to use this value with jquery // Define label - if ((string) $text != '') { - $s .= '<'.$tag.$paramfortooltiptd.'>'.$text.''; + if ((string)$text != '') { + $s .= '<' . $tag . $paramfortooltiptd . '>' . $text . ''; } // Define value if value is after if ($direction > 0) { - $s .= '<'.$tag.$paramfortooltipimg; + $s .= '<' . $tag . $paramfortooltipimg; if ($tag == 'td') { $s .= ' class="valignmiddle" width="14"'; } - $s .= '>'.$textfordialog.$img.''; + $s .= '>' . $textfordialog . $img . ''; } if (empty($notabs)) { $s .= '
'; @@ -721,18 +721,18 @@ class Form } /** - * Show a text with a picto and a tooltip on picto + * Show a text with a picto and a tooltip on picto * - * @param string $text Text to show - * @param string $htmltext Content of tooltip - * @param int $direction 1=Icon is after text, -1=Icon is before text, 0=no icon - * @param string $type Type of picto ('info', 'infoclickable', 'help', 'helpclickable', 'warning', 'superadmin', 'mypicto@mymodule', ...) or image filepath or 'none' - * @param string $extracss Add a CSS style to td, div or span tag - * @param int $noencodehtmltext Do not encode into html entity the htmltext - * @param int $notabs 0=Include table and tr tags, 1=Do not include table and tr tags, 2=use div, 3=use span - * @param string $tooltiptrigger ''=Tooltip on hover and hidden on smartphone, 'abconsmartphone'=Tooltip on hover and on click on smartphone, 'abc'=Tooltip on click (abc is a unique key, clickable link is on image or on link if param $type='none' or on both if $type='xxxclickable') - * @param int $forcenowrap Force no wrap between text and picto (works with notabs=2 only) - * @return string HTML code of text, picto, tooltip + * @param string $text Text to show + * @param string $htmltext Content of tooltip + * @param int $direction 1=Icon is after text, -1=Icon is before text, 0=no icon + * @param string $type Type of picto ('info', 'infoclickable', 'help', 'helpclickable', 'warning', 'superadmin', 'mypicto@mymodule', ...) or image filepath or 'none' + * @param string $extracss Add a CSS style to td, div or span tag + * @param int $noencodehtmltext Do not encode into html entity the htmltext + * @param int $notabs 0=Include table and tr tags, 1=Do not include table and tr tags, 2=use div, 3=use span + * @param string $tooltiptrigger ''=Tooltip on hover and hidden on smartphone, 'abconsmartphone'=Tooltip on hover and on click on smartphone, 'abc'=Tooltip on click (abc is a unique key, clickable link is on image or on link if param $type='none' or on both if $type='xxxclickable') + * @param int $forcenowrap Force no wrap between text and picto (works with notabs=2 only) + * @return string HTML code of text, picto, tooltip */ public function textwithpicto($text, $htmltext, $direction = 1, $type = 'help', $extracss = '', $noencodehtmltext = 0, $notabs = 3, $tooltiptrigger = '', $forcenowrap = 0) { @@ -799,12 +799,12 @@ class Form /** * Generate select HTML to choose massaction * - * @param string $selected Value auto selected when at least one record is selected. Not a preselected value. Use '0' by default. - * @param array $arrayofaction array('code'=>'label', ...). The code is the key stored into the GETPOST('massaction') when submitting action. - * @param int $alwaysvisible 1=select button always visible - * @param string $name Name for massaction - * @param string $cssclass CSS class used to check for select - * @return string|void Select list + * @param string $selected Value auto selected when at least one record is selected. Not a preselected value. Use '0' by default. + * @param array $arrayofaction array('code'=>'label', ...). The code is the key stored into the GETPOST('massaction') when submitting action. + * @param int $alwaysvisible 1=select button always visible + * @param string $name Name for massaction + * @param string $cssclass CSS class used to check for select + * @return string|void Select list */ public function selectMassAction($selected, $arrayofaction, $alwaysvisible = 0, $name = 'massaction', $cssclass = 'checkforselect') { @@ -813,7 +813,7 @@ class Form $disabled = 0; $ret = '
'; - $ret .= ''; // Complete list with data from external modules. THe module can use $_SERVER['PHP_SELF'] to know on which page we are, or use the $parameters['currentcontext'] completed by executeHooks. $parameters = array(); @@ -823,9 +823,9 @@ class Form return; } if (empty($reshook)) { - $ret .= ''; + $ret .= ''; foreach ($arrayofaction as $code => $label) { - $ret .= ''; + $ret .= ''; } } $ret .= $hookmanager->resPrint; @@ -833,17 +833,17 @@ class Form $ret .= ''; if (empty($conf->dol_optimize_smallscreen)) { - $ret .= ajax_combobox('.'.$name.'select'); + $ret .= ajax_combobox('.' . $name . 'select'); } // Warning: if you set submit button to disabled, post using 'Enter' will no more work if there is no another input submit. So we add a hidden button $ret .= ''; // Hidden button BEFORE so it is the one used when we submit with ENTER. - $ret .= 'use_javascript_ajax) ? '' : ' style="display: none"').' class="button smallpaddingimp'.(empty($conf->use_javascript_ajax) ? '' : ' hideobject').' '.$name.' '.$name.'confirmed" value="'.dol_escape_htmltag($langs->trans("Confirm")).'">'; + $ret .= 'use_javascript_ajax) ? '' : ' style="display: none"') . ' class="button smallpaddingimp' . (empty($conf->use_javascript_ajax) ? '' : ' hideobject') . ' ' . $name . ' ' . $name . 'confirmed" value="' . dol_escape_htmltag($langs->trans("Confirm")) . '">'; $ret .= '
'; if (!empty($conf->use_javascript_ajax)) { $ret .= ' - '; $out .= $this->select_dolusers('', $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity, $maxlength, $showstatus, $morefilter); - $out .= ' '; + $out .= ' '; $out .= '
'; } @@ -2288,32 +2302,33 @@ class Form // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Return list of products for customer in Ajax if Ajax activated or go to select_produits_list * - * @param int $selected Preselected products - * @param string $htmlname Name of HTML select field (must be unique in page). - * @param int|string $filtertype Filter on product type (''=nofilter, 0=product, 1=service) - * @param int $limit Limit on number of returned lines - * @param int $price_level Level of price to show - * @param int $status Sell status -1=Return all products, 0=Products not on sell, 1=Products on sell - * @param int $finished 2=all, 1=finished, 0=raw material - * @param string $selected_input_value Value of preselected input text (for use with ajax) - * @param int $hidelabel Hide label (0=no, 1=yes, 2=show search icon (before) and placeholder, 3 search icon after) - * @param array $ajaxoptions Options for ajax_autocompleter - * @param int $socid Thirdparty Id (to get also price dedicated to this customer) - * @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. - * @param int $forcecombo Force to use combo box - * @param string $morecss Add more css on select - * @param int $hidepriceinlabel 1=Hide prices in label - * @param string $warehouseStatus Warehouse status filter to count the quantity in stock. Following comma separated filter options can be used - * 'warehouseopen' = count products from open warehouses, - * 'warehouseclosed' = count products from closed warehouses, - * 'warehouseinternal' = count products from warehouses for internal correct/transfer only - * @param array $selected_combinations Selected combinations. Format: array([attrid] => attrval, [...]) - * @param string $nooutput No print, return the output into a string - * @param int $status_purchase Purchase status -1=Return all products, 0=Products not on purchase, 1=Products on purchase - * @return void|string + * @param int $selected Preselected products + * @param string $htmlname Name of HTML select field (must be unique in page). + * @param int|string $filtertype Filter on product type (''=nofilter, 0=product, 1=service) + * @param int $limit Limit on number of returned lines + * @param int $price_level Level of price to show + * @param int $status Sell status -1=Return all products, 0=Products not on sell, 1=Products on sell + * @param int $finished 2=all, 1=finished, 0=raw material + * @param string $selected_input_value Value of preselected input text (for use with ajax) + * @param int $hidelabel Hide label (0=no, 1=yes, 2=show search icon (before) and placeholder, 3 search icon after) + * @param array $ajaxoptions Options for ajax_autocompleter + * @param int $socid Thirdparty Id (to get also price dedicated to this customer) + * @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. + * @param int $forcecombo Force to use combo box + * @param string $morecss Add more css on select + * @param int $hidepriceinlabel 1=Hide prices in label + * @param string $warehouseStatus Warehouse status filter to count the quantity in stock. Following comma separated filter options can be used + * 'warehouseopen' = count products from open warehouses, + * 'warehouseclosed' = count products from closed warehouses, + * 'warehouseinternal' = count products from warehouses for internal correct/transfer only + * @param array $selected_combinations Selected combinations. Format: array([attrid] => attrval, [...]) + * @param string $nooutput No print, return the output into a string + * @param int $status_purchase Purchase status -1=Return all products, 0=Products not on purchase, 1=Products on purchase + * @return void|string */ public function select_produits($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 0, $price_level = 0, $status = 1, $finished = 2, $selected_input_value = '', $hidelabel = 0, $ajaxoptions = array(), $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '', $selected_combinations = null, $nooutput = 0, $status_purchase = -1) { @@ -2340,7 +2355,7 @@ class Form $placeholder = ''; if ($selected && empty($selected_input_value)) { - require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; $producttmpselect = new Product($this->db); $producttmpselect->fetch($selected); $selected_input_value = $producttmpselect->ref; @@ -2355,17 +2370,17 @@ class Form } } // mode=1 means customers products - $urloption = ($socid > 0 ? 'socid='.$socid.'&' : '').'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&status_purchase='.$status_purchase.'&finished='.$finished.'&hidepriceinlabel='.$hidepriceinlabel.'&warehousestatus='.$warehouseStatus; - $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions); + $urloption = ($socid > 0 ? 'socid=' . $socid . '&' : '') . 'htmlname=' . $htmlname . '&outjson=1&price_level=' . $price_level . '&type=' . $filtertype . '&mode=1&status=' . $status . '&status_purchase=' . $status_purchase . '&finished=' . $finished . '&hidepriceinlabel=' . $hidepriceinlabel . '&warehousestatus=' . $warehouseStatus; + $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions); if (isModEnabled('variants') && is_array($selected_combinations)) { // Code to automatically insert with javascript the select of attributes under the select of product // when a parent of variant has been selected. $out .= ' - '; } if (empty($hidelabel)) { - $out .= $langs->trans("RefOrLabel").' : '; + $out .= $langs->trans("RefOrLabel") . ' : '; } elseif ($hidelabel > 1) { - $placeholder = ' placeholder="'.$langs->trans("RefOrLabel").'"'; + $placeholder = ' placeholder="' . $langs->trans("RefOrLabel") . '"'; if ($hidelabel == 2) { $out .= img_picto($langs->trans("Search"), 'search'); } } - $out .= 'global->PRODUCT_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />'; + $out .= 'global->PRODUCT_SEARCH_AUTOFOCUS) ? 'autofocus' : '') . ' />'; if ($hidelabel == 3) { $out .= img_picto($langs->trans("Search"), 'search'); } @@ -2471,7 +2486,7 @@ class Form * @param string $morecss Add more css on select * @param string $nooutput No print, return the output into a string * @param int $forcecombo Force to use combo box - * @param array $TProducts Add filter on a defined product + * @param array $TProducts Add filter on a defined product * @return void|string */ public function select_bom($selected = '', $htmlname = 'bom_id', $limit = 0, $status = 1, $type = 0, $showempty = '1', $morecss = '', $nooutput = '', $forcecombo = 0, $TProducts = []) @@ -2479,29 +2494,29 @@ class Form // phpcs:enable global $conf, $user, $langs, $db; - require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; $error = 0; $out = ''; if (!$forcecombo) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; $events = array(); $out .= ajax_combobox($htmlname, $events, getDolGlobalInt("PRODUIT_USE_SEARCH_TO_SELECT")); } - $out .= ''; $sql = 'SELECT b.rowid, b.ref, b.label, b.fk_product'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'bom_bom as b'; - $sql.= ' WHERE b.entity IN ('.getEntity('bom').')'; - if (!empty($status)) $sql.= ' AND status = '. (int) $status; - if (!empty($type)) $sql.= ' AND bomtype = '. (int) $type; - if (!empty($TProducts)) $sql .= ' AND fk_product IN ('.$this->db->sanitize(implode(',', $TProducts)).')'; - if (!empty($limit)) $sql.= ' LIMIT '. (int) $limit; + $sql .= ' FROM ' . MAIN_DB_PREFIX . 'bom_bom as b'; + $sql .= ' WHERE b.entity IN (' . getEntity('bom') . ')'; + if (!empty($status)) $sql .= ' AND status = ' . (int)$status; + if (!empty($type)) $sql .= ' AND bomtype = ' . (int)$type; + if (!empty($TProducts)) $sql .= ' AND fk_product IN (' . $this->db->sanitize(implode(',', $TProducts)) . ')'; + if (!empty($limit)) $sql .= ' LIMIT ' . (int)$limit; $resql = $db->query($sql); if ($resql) { - if ($showempty) { + if ($showempty) { $out .= ''; + $out .= '>' . $obj->ref . ' - ' . $product->label . ' - ' . $obj->label . ''; } } else { $error++; @@ -2525,30 +2540,31 @@ class Form } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** - * Return list of products for a customer. + * Return list of products for a customer. * Called by select_produits. * - * @param int $selected Preselected product - * @param string $htmlname Name of select html - * @param string $filtertype Filter on product type (''=nofilter, 0=product, 1=service) - * @param int $limit Limit on number of returned lines - * @param int $price_level Level of price to show - * @param string $filterkey Filter on product - * @param int $status -1=Return all products, 0=Products not on sell, 1=Products on sell - * @param int $finished Filter on finished field: 2=No filter - * @param int $outputmode 0=HTML select string, 1=Array - * @param int $socid Thirdparty Id (to get also price dedicated to this customer) - * @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. - * @param int $forcecombo Force to use combo box - * @param string $morecss Add more css on select - * @param int $hidepriceinlabel 1=Hide prices in label - * @param string $warehouseStatus Warehouse status filter to group/count stock. Following comma separated filter options can be used. - * 'warehouseopen' = count products from open warehouses, - * 'warehouseclosed' = count products from closed warehouses, - * 'warehouseinternal' = count products from warehouses for internal correct/transfer only - * @param int $status_purchase Purchase status -1=Return all products, 0=Products not on purchase, 1=Products on purchase - * @return array|string Array of keys for json + * @param int $selected Preselected product + * @param string $htmlname Name of select html + * @param string $filtertype Filter on product type (''=nofilter, 0=product, 1=service) + * @param int $limit Limit on number of returned lines + * @param int $price_level Level of price to show + * @param string $filterkey Filter on product + * @param int $status -1=Return all products, 0=Products not on sell, 1=Products on sell + * @param int $finished Filter on finished field: 2=No filter + * @param int $outputmode 0=HTML select string, 1=Array + * @param int $socid Thirdparty Id (to get also price dedicated to this customer) + * @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. + * @param int $forcecombo Force to use combo box + * @param string $morecss Add more css on select + * @param int $hidepriceinlabel 1=Hide prices in label + * @param string $warehouseStatus Warehouse status filter to group/count stock. Following comma separated filter options can be used. + * 'warehouseopen' = count products from open warehouses, + * 'warehouseclosed' = count products from closed warehouses, + * 'warehouseinternal' = count products from warehouses for internal correct/transfer only + * @param int $status_purchase Purchase status -1=Return all products, 0=Products not on purchase, 1=Products on purchase + * @return array|string Array of keys for json */ public function select_produits_list($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 20, $price_level = 0, $filterkey = '', $status = 1, $finished = 2, $outputmode = 0, $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '', $status_purchase = -1) { @@ -2566,7 +2582,7 @@ class Form $warehouseStatusArray = array(); if (!empty($warehouseStatus)) { - require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; + require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php'; if (preg_match('/warehouseclosed/', $warehouseStatus)) { $warehouseStatusArray[] = Entrepot::STATUS_CLOSED; } @@ -2580,19 +2596,19 @@ class Form $selectFields = " p.rowid, p.ref, p.label, p.description, p.barcode, p.fk_country, p.fk_product_type, p.price, p.price_ttc, p.price_base_type, p.tva_tx, p.default_vat_code, p.duration, p.fk_price_expression"; if (count($warehouseStatusArray)) { - $selectFieldsGrouped = ", sum(".$this->db->ifsql("e.statut IS NULL", "0", "ps.reel").") as stock"; // e.statut is null if there is no record in stock + $selectFieldsGrouped = ", sum(" . $this->db->ifsql("e.statut IS NULL", "0", "ps.reel") . ") as stock"; // e.statut is null if there is no record in stock } else { - $selectFieldsGrouped = ", ".$this->db->ifsql("p.stock IS NULL", 0, "p.stock")." AS stock"; + $selectFieldsGrouped = ", " . $this->db->ifsql("p.stock IS NULL", 0, "p.stock") . " AS stock"; } $sql = "SELECT "; - $sql .= $selectFields.$selectFieldsGrouped; + $sql .= $selectFields . $selectFieldsGrouped; if (!empty($conf->global->PRODUCT_SORT_BY_CATEGORY)) { //Product category - $sql .= ", (SELECT ".$this->db->prefix()."categorie_product.fk_categorie - FROM ".$this->db->prefix()."categorie_product - WHERE ".$this->db->prefix()."categorie_product.fk_product=p.rowid + $sql .= ", (SELECT " . $this->db->prefix() . "categorie_product.fk_categorie + FROM " . $this->db->prefix() . "categorie_product + WHERE " . $this->db->prefix() . "categorie_product.fk_product=p.rowid LIMIT 1 ) AS categorie_product_id "; } @@ -2618,83 +2634,83 @@ class Form } // Price by quantity if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { - $sql .= ", (SELECT pp.rowid FROM ".$this->db->prefix()."product_price as pp WHERE pp.fk_product = p.rowid"; + $sql .= ", (SELECT pp.rowid FROM " . $this->db->prefix() . "product_price as pp WHERE pp.fk_product = p.rowid"; if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { - $sql .= " AND price_level = ".((int) $price_level); + $sql .= " AND price_level = " . ((int)$price_level); } $sql .= " ORDER BY date_price"; $sql .= " DESC LIMIT 1) as price_rowid"; - $sql .= ", (SELECT pp.price_by_qty FROM ".$this->db->prefix()."product_price as pp WHERE pp.fk_product = p.rowid"; // price_by_qty is 1 if some prices by qty exists in subtable + $sql .= ", (SELECT pp.price_by_qty FROM " . $this->db->prefix() . "product_price as pp WHERE pp.fk_product = p.rowid"; // price_by_qty is 1 if some prices by qty exists in subtable if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { - $sql .= " AND price_level = ".((int) $price_level); + $sql .= " AND price_level = " . ((int)$price_level); } $sql .= " ORDER BY date_price"; $sql .= " DESC LIMIT 1) as price_by_qty"; $selectFields .= ", price_rowid, price_by_qty"; } - $sql .= " FROM ".$this->db->prefix()."product as p"; + $sql .= " FROM " . $this->db->prefix() . "product as p"; if (count($warehouseStatusArray)) { - $sql .= " LEFT JOIN ".$this->db->prefix()."product_stock as ps on ps.fk_product = p.rowid"; - $sql .= " LEFT JOIN ".$this->db->prefix()."entrepot as e on ps.fk_entrepot = e.rowid AND e.entity IN (".getEntity('stock').")"; - $sql .= ' AND e.statut IN ('.$this->db->sanitize($this->db->escape(implode(',', $warehouseStatusArray))).')'; // Return line if product is inside the selected stock. If not, an empty line will be returned so we will count 0. + $sql .= " LEFT JOIN " . $this->db->prefix() . "product_stock as ps on ps.fk_product = p.rowid"; + $sql .= " LEFT JOIN " . $this->db->prefix() . "entrepot as e on ps.fk_entrepot = e.rowid AND e.entity IN (" . getEntity('stock') . ")"; + $sql .= ' AND e.statut IN (' . $this->db->sanitize($this->db->escape(implode(',', $warehouseStatusArray))) . ')'; // Return line if product is inside the selected stock. If not, an empty line will be returned so we will count 0. } // include search in supplier ref if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF)) { - $sql .= " LEFT JOIN ".$this->db->prefix()."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; + $sql .= " LEFT JOIN " . $this->db->prefix() . "product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; } //Price by customer if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) { - $sql .= " LEFT JOIN ".$this->db->prefix()."product_customer_price as pcp ON pcp.fk_soc=".((int) $socid)." AND pcp.fk_product=p.rowid"; + $sql .= " LEFT JOIN " . $this->db->prefix() . "product_customer_price as pcp ON pcp.fk_soc=" . ((int)$socid) . " AND pcp.fk_product=p.rowid"; } // Units if (getDolGlobalInt('PRODUCT_USE_UNITS')) { - $sql .= " LEFT JOIN ".$this->db->prefix()."c_units u ON u.rowid = p.fk_unit"; + $sql .= " LEFT JOIN " . $this->db->prefix() . "c_units u ON u.rowid = p.fk_unit"; } // Multilang : we add translation if (getDolGlobalInt('MAIN_MULTILANGS')) { - $sql .= " LEFT JOIN ".$this->db->prefix()."product_lang as pl ON pl.fk_product = p.rowid "; + $sql .= " LEFT JOIN " . $this->db->prefix() . "product_lang as pl ON pl.fk_product = p.rowid "; if (!empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE) && !empty($socid)) { - require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; $soc = new Societe($this->db); $result = $soc->fetch($socid); if ($result > 0 && !empty($soc->default_lang)) { - $sql .= " AND pl.lang = '".$this->db->escape($soc->default_lang)."'"; + $sql .= " AND pl.lang = '" . $this->db->escape($soc->default_lang) . "'"; } else { - $sql .= " AND pl.lang = '".$this->db->escape($langs->getDefaultLang())."'"; + $sql .= " AND pl.lang = '" . $this->db->escape($langs->getDefaultLang()) . "'"; } } else { - $sql .= " AND pl.lang = '".$this->db->escape($langs->getDefaultLang())."'"; + $sql .= " AND pl.lang = '" . $this->db->escape($langs->getDefaultLang()) . "'"; } } if (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) { - $sql .= " LEFT JOIN ".$this->db->prefix()."product_attribute_combination pac ON pac.fk_product_child = p.rowid"; + $sql .= " LEFT JOIN " . $this->db->prefix() . "product_attribute_combination pac ON pac.fk_product_child = p.rowid"; } - $sql .= ' WHERE p.entity IN ('.getEntity('product').')'; + $sql .= ' WHERE p.entity IN (' . getEntity('product') . ')'; if (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) { $sql .= " AND pac.rowid IS NULL"; } if ($finished == 0) { - $sql .= " AND p.finished = ".((int) $finished); + $sql .= " AND p.finished = " . ((int)$finished); } elseif ($finished == 1) { - $sql .= " AND p.finished = ".((int) $finished); + $sql .= " AND p.finished = " . ((int)$finished); if ($status >= 0) { - $sql .= " AND p.tosell = ".((int) $status); + $sql .= " AND p.tosell = " . ((int)$status); } } elseif ($status >= 0) { - $sql .= " AND p.tosell = ".((int) $status); + $sql .= " AND p.tosell = " . ((int)$status); } if ($status_purchase >= 0) { - $sql .= " AND p.tobuy = ".((int) $status_purchase); + $sql .= " AND p.tobuy = " . ((int)$status_purchase); } // Filter by product type if (strval($filtertype) != '') { - $sql .= " AND p.fk_product_type = ".((int) $filtertype); + $sql .= " AND p.fk_product_type = " . ((int)$filtertype); } elseif (!isModEnabled('product')) { // when product module is disabled, show services only $sql .= " AND p.fk_product_type = 1"; } elseif (!isModEnabled('service')) { // when service module is disabled, show products only @@ -2718,21 +2734,21 @@ class Form if ($i > 0) { $sql .= " AND "; } - $sql .= "(p.ref LIKE '".$this->db->escape($prefix.$crit)."%' OR p.label LIKE '".$this->db->escape($prefix.$crit)."%'"; + $sql .= "(p.ref LIKE '" . $this->db->escape($prefix . $crit) . "%' OR p.label LIKE '" . $this->db->escape($prefix . $crit) . "%'"; if (getDolGlobalInt('MAIN_MULTILANGS')) { - $sql .= " OR pl.label LIKE '".$this->db->escape($prefix.$crit)."%'"; + $sql .= " OR pl.label LIKE '" . $this->db->escape($prefix . $crit) . "%'"; } if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) { - $sql .= " OR pcp.ref_customer LIKE '".$this->db->escape($prefix.$crit)."%'"; + $sql .= " OR pcp.ref_customer LIKE '" . $this->db->escape($prefix . $crit) . "%'"; } if (!empty($conf->global->PRODUCT_AJAX_SEARCH_ON_DESCRIPTION)) { - $sql .= " OR p.description LIKE '".$this->db->escape($prefix.$crit)."%'"; + $sql .= " OR p.description LIKE '" . $this->db->escape($prefix . $crit) . "%'"; if (getDolGlobalInt('MAIN_MULTILANGS')) { - $sql .= " OR pl.description LIKE '".$this->db->escape($prefix.$crit)."%'"; + $sql .= " OR pl.description LIKE '" . $this->db->escape($prefix . $crit) . "%'"; } } if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF)) { - $sql .= " OR pfp.ref_fourn LIKE '".$this->db->escape($prefix.$crit)."%'"; + $sql .= " OR pfp.ref_fourn LIKE '" . $this->db->escape($prefix . $crit) . "%'"; } $sql .= ")"; $i++; @@ -2741,12 +2757,12 @@ class Form $sql .= ")"; } if (isModEnabled('barcode')) { - $sql .= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; + $sql .= " OR p.barcode LIKE '" . $this->db->escape($prefix . $filterkey) . "%'"; } $sql .= ')'; } if (count($warehouseStatusArray)) { - $sql .= " GROUP BY ".$selectFields; + $sql .= " GROUP BY " . $selectFields; } //Sort by category @@ -2761,23 +2777,23 @@ class Form $sql .= $this->db->plimit($limit, 0); // Build output string - dol_syslog(get_class($this)."::select_produits_list search products", LOG_DEBUG); + dol_syslog(get_class($this) . "::select_produits_list search products", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { - require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; + require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + require_once DOL_DOCUMENT_ROOT . '/product/dynamic_price/class/price_parser.class.php'; + require_once DOL_DOCUMENT_ROOT . '/core/lib/product.lib.php'; $num = $this->db->num_rows($result); $events = null; if (!$forcecombo) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; $out .= ajax_combobox($htmlname, $events, getDolGlobalInt("PRODUIT_USE_SEARCH_TO_SELECT")); } - $out .= ''; $textifempty = ''; // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'. @@ -2794,7 +2810,7 @@ class Form } } if ($showempty) { - $out .= ''; + $out .= ''; } $i = 0; @@ -2805,11 +2821,11 @@ class Form if ((!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !empty($objp->price_by_qty) && $objp->price_by_qty == 1) { // Price by quantity will return many prices for the same product $sql = "SELECT rowid, quantity, price, unitprice, remise_percent, remise, price_base_type"; - $sql .= " FROM ".$this->db->prefix()."product_price_by_qty"; - $sql .= " WHERE fk_product_price = ".((int) $objp->price_rowid); + $sql .= " FROM " . $this->db->prefix() . "product_price_by_qty"; + $sql .= " WHERE fk_product_price = " . ((int)$objp->price_rowid); $sql .= " ORDER BY quantity ASC"; - dol_syslog(get_class($this)."::select_produits_list search prices by qty", LOG_DEBUG); + dol_syslog(get_class($this) . "::select_produits_list search prices by qty", LOG_DEBUG); $result2 = $this->db->query($sql); if ($result2) { $nb_prices = $this->db->num_rows($result2); @@ -2847,7 +2863,7 @@ class Form $price_product = new Product($this->db); $price_product->fetch($objp->rowid, '', '', 1); - require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; + require_once DOL_DOCUMENT_ROOT . '/product/dynamic_price/class/price_parser.class.php'; $priceparser = new PriceParser($this->db); $price_result = $priceparser->parseProduct($price_product); if ($price_result >= 0) { @@ -2891,15 +2907,15 @@ class Form * This define value for &$opt and &$optJson. * This function is called by select_produits_list(). * - * @param object $objp Resultset of fetch - * @param string $opt Option (var used for returned value in string option format) - * @param string $optJson Option (var used for returned value in json format) - * @param int $price_level Price level - * @param string $selected Preselected value - * @param int $hidepriceinlabel Hide price in label - * @param string $filterkey Filter key to highlight - * @param int $novirtualstock Do not load virtual stock, even if slow option STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO is on. - * @return void + * @param object $objp Resultset of fetch + * @param string $opt Option (var used for returned value in string option format) + * @param string $optJson Option (var used for returned value in json format) + * @param int $price_level Price level + * @param string $selected Preselected value + * @param int $hidepriceinlabel Hide price in label + * @param string $filterkey Filter key to highlight + * @param int $novirtualstock Do not load virtual stock, even if slow option STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO is on. + * @return void */ protected function constructProductListOption(&$objp, &$opt, &$optJson, $price_level, $selected, $hidepriceinlabel = 0, $filterkey = '', $novirtualstock = 0) { @@ -2930,7 +2946,7 @@ class Form $label = $objp->label_translated; } if (!empty($filterkey) && $filterkey != '') { - $label = preg_replace('/('.preg_quote($filterkey, '/').')/i', '$1', $label, 1); + $label = preg_replace('/(' . preg_quote($filterkey, '/') . ')/i', '$1', $label, 1); } $outkey = $objp->rowid; @@ -2947,36 +2963,36 @@ class Form $outpbq = empty($objp->price_by_qty_rowid) ? '' : $objp->price_by_qty_rowid; $outtype = $objp->fk_product_type; - $outdurationvalue = $outtype == Product::TYPE_SERVICE ?substr($objp->duration, 0, dol_strlen($objp->duration) - 1) : ''; - $outdurationunit = $outtype == Product::TYPE_SERVICE ?substr($objp->duration, -1) : ''; + $outdurationvalue = $outtype == Product::TYPE_SERVICE ? substr($objp->duration, 0, dol_strlen($objp->duration) - 1) : ''; + $outdurationunit = $outtype == Product::TYPE_SERVICE ? substr($objp->duration, -1) : ''; if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; + require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; } // Units $outvalUnits = ''; if (getDolGlobalInt('PRODUCT_USE_UNITS')) { if (!empty($objp->unit_short)) { - $outvalUnits .= ' - '.$objp->unit_short; + $outvalUnits .= ' - ' . $objp->unit_short; } } if (!empty($conf->global->PRODUCT_SHOW_DIMENSIONS_IN_COMBO)) { if (!empty($objp->weight) && $objp->weight_units !== null) { $unitToShow = showDimensionInBestUnit($objp->weight, $objp->weight_units, 'weight', $langs); - $outvalUnits .= ' - '.$unitToShow; + $outvalUnits .= ' - ' . $unitToShow; } if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !== null) { - $unitToShow = $objp->length.' x '.$objp->width.' x '.$objp->height.' '.measuringUnitString(0, 'size', $objp->length_units); - $outvalUnits .= ' - '.$unitToShow; + $unitToShow = $objp->length . ' x ' . $objp->width . ' x ' . $objp->height . ' ' . measuringUnitString(0, 'size', $objp->length_units); + $outvalUnits .= ' - ' . $unitToShow; } if (!empty($objp->surface) && $objp->surface_units !== null) { $unitToShow = showDimensionInBestUnit($objp->surface, $objp->surface_units, 'surface', $langs); - $outvalUnits .= ' - '.$unitToShow; + $outvalUnits .= ' - ' . $unitToShow; } if (!empty($objp->volume) && $objp->volume_units !== null) { $unitToShow = showDimensionInBestUnit($objp->volume, $objp->volume_units, 'volume', $langs); - $outvalUnits .= ' - '.$unitToShow; + $outvalUnits .= ' - ' . $unitToShow; } } if ($outdurationvalue && $outdurationunit) { @@ -2988,14 +3004,14 @@ class Form 'y' => $langs->trans('Year') ); if (isset($da[$outdurationunit])) { - $outvalUnits .= ' - '.$outdurationvalue.' '.$langs->transnoentities($da[$outdurationunit].($outdurationvalue > 1 ? 's' : '')); + $outvalUnits .= ' - ' . $outdurationvalue . ' ' . $langs->transnoentities($da[$outdurationunit] . ($outdurationvalue > 1 ? 's' : '')); } } - $opt = '\n"; $optJson = array( - 'key'=>$outkey, - 'value'=>$outref, - 'label'=>$outval, - 'label2'=>$outlabel, - 'desc'=>$outdesc, - 'type'=>$outtype, - 'price_ht'=>price2num($outprice_ht), - 'price_ttc'=>price2num($outprice_ttc), - 'price_ht_locale'=>price(price2num($outprice_ht)), - 'price_ttc_locale'=>price(price2num($outprice_ttc)), - 'pricebasetype'=>$outpricebasetype, - 'tva_tx'=>$outtva_tx, - 'default_vat_code'=>$outdefault_vat_code, - 'qty'=>$outqty, - 'discount'=>$outdiscount, - 'duration_value'=>$outdurationvalue, - 'duration_unit'=>$outdurationunit, - 'pbq'=>$outpbq, - 'labeltrans'=>$outlabel_translated, - 'desctrans'=>$outdesc_translated, - 'ref_customer'=>$outrefcust + 'key' => $outkey, + 'value' => $outref, + 'label' => $outval, + 'label2' => $outlabel, + 'desc' => $outdesc, + 'type' => $outtype, + 'price_ht' => price2num($outprice_ht), + 'price_ttc' => price2num($outprice_ttc), + 'price_ht_locale' => price(price2num($outprice_ht)), + 'price_ttc_locale' => price(price2num($outprice_ttc)), + 'pricebasetype' => $outpricebasetype, + 'tva_tx' => $outtva_tx, + 'default_vat_code' => $outdefault_vat_code, + 'qty' => $outqty, + 'discount' => $outdiscount, + 'duration_value' => $outdurationvalue, + 'duration_unit' => $outdurationunit, + 'pbq' => $outpbq, + 'labeltrans' => $outlabel_translated, + 'desctrans' => $outdesc_translated, + 'ref_customer' => $outrefcust ); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** - * Return list of products for customer (in Ajax if Ajax activated or go to select_produits_fournisseurs_list) + * Return list of products for customer (in Ajax if Ajax activated or go to select_produits_fournisseurs_list) * - * @param int $socid Id third party - * @param string $selected Preselected product - * @param string $htmlname Name of HTML Select - * @param string $filtertype Filter on product type (''=nofilter, 0=product, 1=service) - * @param string $filtre For a SQL filter - * @param array $ajaxoptions Options for ajax_autocompleter - * @param int $hidelabel Hide label (0=no, 1=yes) - * @param int $alsoproductwithnosupplierprice 1=Add also product without supplier prices - * @param string $morecss More CSS - * @param string $placeholder Placeholder - * @return void + * @param int $socid Id third party + * @param string $selected Preselected product + * @param string $htmlname Name of HTML Select + * @param string $filtertype Filter on product type (''=nofilter, 0=product, 1=service) + * @param string $filtre For a SQL filter + * @param array $ajaxoptions Options for ajax_autocompleter + * @param int $hidelabel Hide label (0=no, 1=yes) + * @param int $alsoproductwithnosupplierprice 1=Add also product without supplier prices + * @param string $morecss More CSS + * @param string $placeholder Placeholder + * @return void */ public function select_produits_fournisseurs($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $ajaxoptions = array(), $hidelabel = 0, $alsoproductwithnosupplierprice = 0, $morecss = '', $placeholder = '') { @@ -3244,7 +3261,7 @@ class Form $selected_input_value = ''; if (!empty($conf->use_javascript_ajax) && !empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) { if ($selected > 0) { - require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; $producttmpselect = new Product($this->db); $producttmpselect->fetch($selected); $selected_input_value = $producttmpselect->ref; @@ -3252,33 +3269,34 @@ class Form } // mode=2 means suppliers products - $urloption = ($socid > 0 ? 'socid='.$socid.'&' : '').'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=2&status='.$status.'&finished='.$finished.'&alsoproductwithnosupplierprice='.$alsoproductwithnosupplierprice; - print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); + $urloption = ($socid > 0 ? 'socid=' . $socid . '&' : '') . 'htmlname=' . $htmlname . '&outjson=1&price_level=' . $price_level . '&type=' . $filtertype . '&mode=2&status=' . $status . '&finished=' . $finished . '&alsoproductwithnosupplierprice=' . $alsoproductwithnosupplierprice; + print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); - print ($hidelabel ? '' : $langs->trans("RefOrLabel").' : ').''; + print ($hidelabel ? '' : $langs->trans("RefOrLabel") . ' : ') . ''; } else { print $this->select_produits_fournisseurs_list($socid, $selected, $htmlname, $filtertype, $filtre, '', $status, 0, 0, $alsoproductwithnosupplierprice, $morecss, 0, $placeholder); } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** - * Return list of suppliers products + * Return list of suppliers products * - * @param int $socid Id of supplier thirdparty (0 = no filter) - * @param int $selected Product price pre-selected (must be 'id' in product_fournisseur_price or 'idprod_IDPROD') - * @param string $htmlname Name of HTML select - * @param string $filtertype Filter on product type (''=nofilter, 0=product, 1=service) - * @param string $filtre Generic filter. Data must not come from user input. - * @param string $filterkey Filter of produdts - * @param int $statut -1=Return all products, 0=Products not on buy, 1=Products on buy - * @param int $outputmode 0=HTML select string, 1=Array - * @param int $limit Limit of line number - * @param int $alsoproductwithnosupplierprice 1=Add also product without supplier prices - * @param string $morecss Add more CSS - * @param int $showstockinlist Show stock information (slower). - * @param string $placeholder Placeholder - * @return array|string Array of keys for json or HTML component + * @param int $socid Id of supplier thirdparty (0 = no filter) + * @param int $selected Product price pre-selected (must be 'id' in product_fournisseur_price or 'idprod_IDPROD') + * @param string $htmlname Name of HTML select + * @param string $filtertype Filter on product type (''=nofilter, 0=product, 1=service) + * @param string $filtre Generic filter. Data must not come from user input. + * @param string $filterkey Filter of produdts + * @param int $statut -1=Return all products, 0=Products not on buy, 1=Products on buy + * @param int $outputmode 0=HTML select string, 1=Array + * @param int $limit Limit of line number + * @param int $alsoproductwithnosupplierprice 1=Add also product without supplier prices + * @param string $morecss Add more CSS + * @param int $showstockinlist Show stock information (slower). + * @param string $placeholder Placeholder + * @return array|string Array of keys for json or HTML component */ public function select_produits_fournisseurs_list($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $filterkey = '', $statut = -1, $outputmode = 0, $limit = 100, $alsoproductwithnosupplierprice = 0, $morecss = '', $showstockinlist = 0, $placeholder = '') { @@ -3314,25 +3332,25 @@ class Form if (isModEnabled('barcode')) { $sql .= ", pfp.barcode"; } - $sql .= " FROM ".$this->db->prefix()."product as p"; - $sql .= " LEFT JOIN ".$this->db->prefix()."product_fournisseur_price as pfp ON ( p.rowid = pfp.fk_product AND pfp.entity IN (".getEntity('product').") )"; + $sql .= " FROM " . $this->db->prefix() . "product as p"; + $sql .= " LEFT JOIN " . $this->db->prefix() . "product_fournisseur_price as pfp ON ( p.rowid = pfp.fk_product AND pfp.entity IN (" . getEntity('product') . ") )"; if ($socid > 0) { - $sql .= " AND pfp.fk_soc = ".((int) $socid); + $sql .= " AND pfp.fk_soc = " . ((int)$socid); } - $sql .= " LEFT JOIN ".$this->db->prefix()."societe as s ON pfp.fk_soc = s.rowid"; + $sql .= " LEFT JOIN " . $this->db->prefix() . "societe as s ON pfp.fk_soc = s.rowid"; // Units if (getDolGlobalInt('PRODUCT_USE_UNITS')) { - $sql .= " LEFT JOIN ".$this->db->prefix()."c_units u ON u.rowid = p.fk_unit"; + $sql .= " LEFT JOIN " . $this->db->prefix() . "c_units u ON u.rowid = p.fk_unit"; } - $sql .= " WHERE p.entity IN (".getEntity('product').")"; + $sql .= " WHERE p.entity IN (" . getEntity('product') . ")"; if ($statut != -1) { - $sql .= " AND p.tobuy = ".((int) $statut); + $sql .= " AND p.tobuy = " . ((int)$statut); } if (strval($filtertype) != '') { - $sql .= " AND p.fk_product_type = ".((int) $filtertype); + $sql .= " AND p.fk_product_type = " . ((int)$filtertype); } if (!empty($filtre)) { - $sql .= " ".$filtre; + $sql .= " " . $filtre; } // Add where from hooks $parameters = array(); @@ -3352,9 +3370,9 @@ class Form if ($i > 0) { $sql .= " AND "; } - $sql .= "(pfp.ref_fourn LIKE '".$this->db->escape($prefix.$crit)."%' OR p.ref LIKE '".$this->db->escape($prefix.$crit)."%' OR p.label LIKE '".$this->db->escape($prefix.$crit)."%'"; + $sql .= "(pfp.ref_fourn LIKE '" . $this->db->escape($prefix . $crit) . "%' OR p.ref LIKE '" . $this->db->escape($prefix . $crit) . "%' OR p.label LIKE '" . $this->db->escape($prefix . $crit) . "%'"; if (!empty($conf->global->PRODUIT_FOURN_TEXTS)) { - $sql .= " OR pfp.desc_fourn LIKE '".$this->db->escape($prefix.$crit)."%'"; + $sql .= " OR pfp.desc_fourn LIKE '" . $this->db->escape($prefix . $crit) . "%'"; } $sql .= ")"; $i++; @@ -3363,8 +3381,8 @@ class Form $sql .= ")"; } if (isModEnabled('barcode')) { - $sql .= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; - $sql .= " OR pfp.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; + $sql .= " OR p.barcode LIKE '" . $this->db->escape($prefix . $filterkey) . "%'"; + $sql .= " OR pfp.barcode LIKE '" . $this->db->escape($prefix . $filterkey) . "%'"; } $sql .= ')'; } @@ -3373,20 +3391,20 @@ class Form // Build output string - dol_syslog(get_class($this)."::select_produits_fournisseurs_list", LOG_DEBUG); + dol_syslog(get_class($this) . "::select_produits_fournisseurs_list", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { - require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; + require_once DOL_DOCUMENT_ROOT . '/product/dynamic_price/class/price_parser.class.php'; + require_once DOL_DOCUMENT_ROOT . '/core/lib/product.lib.php'; $num = $this->db->num_rows($result); //$out.=''; + $out .= ''; + $form = ''; + print ''; + print ''; + print ''; + $out .= ''; + $out .= ''; if ($user->admin && empty($noinfoadmin)) { - $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } - $out.= ajax_combobox($htmlname); + $out .= ajax_combobox($htmlname); if ($deposit_percent >= 0) { - $out .= '