';
@@ -244,7 +249,7 @@ foreach ($dirmodels as $reldir) {
print $module->info();
print '';
- // Show example of numbering model
+ // Show example of numbering module
print '
';
// Ref customer
diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php
index 5833072e8be..e65a1b5e1a3 100644
--- a/htdocs/comm/propal/card.php
+++ b/htdocs/comm/propal/card.php
@@ -1809,7 +1809,7 @@ if ($action == 'create') {
print img_picto('', 'company', 'class="pictofixedwidth"').$form->select_company('', 'socid', '((s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1)', 'SelectThirdParty', 1, 0, null, 0, 'minwidth300 maxwidth500 widthcentpercentminusxx');
// reload page to retrieve customer informations
if (empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED)) {
- print '';
+ $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 .= '
'.$htmltext.'
';
+ $textfordialog .= '
' . $htmltext . '
';
}
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.''.$tag.'>';
+ $s .= '>' . $textfordialog . $img . '' . $tag . '>';
}
// 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.''.$tag.'>';
+ $s .= '<' . $tag . $paramfortooltiptd . '>' . $text . '' . $tag . '>';
}
// 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.''.$tag.'>';
+ $s .= '>' . $textfordialog . $img . '' . $tag . '>';
}
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 .= '
';
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 .= '';
+ $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,22 +2596,28 @@ 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 ";
+
+
// Add select from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('selectProductsListSelect', $parameters); // Note that $action and $object may have been modified by hook
- $sql .= $selectFields.$selectFieldsGrouped.$hookmanager->resPrint;
+ if ($reshook > 0) {
+ $sql .= $selectFields.$selectFieldsGrouped.$hookmanager->resPrint;
+ } else {
+ $sql .= $hookmanager->resPrint;
+ }
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 ";
}
@@ -2621,87 +2643,89 @@ 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";
// Add from (left join) from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('selectProductsListFrom', $parameters); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
+
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
@@ -2725,21 +2749,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++;
@@ -2748,12 +2772,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
@@ -2768,23 +2792,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 .= '';
+ $out .= '';
$textifempty = '';
// Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'.
@@ -2801,7 +2825,7 @@ class Form
}
}
if ($showempty) {
- $out .= '';
+ $out .= '';
}
$i = 0;
@@ -2812,11 +2836,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);
@@ -2854,7 +2878,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) {
@@ -2898,15 +2922,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)
{
@@ -2938,7 +2962,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;
@@ -2955,36 +2979,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) {
@@ -2996,14 +3020,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 = '')
{
@@ -3260,7 +3285,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;
@@ -3268,33 +3293,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 = '')
{
@@ -3330,25 +3356,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();
@@ -3368,9 +3394,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++;
@@ -3379,8 +3405,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 .= ')';
}
@@ -3389,20 +3415,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.=''; // remove select to have id same with combo and ajax
- $out .= '';
+ $out .= '';
if (!$selected) {
- $out .= '';
+ $out .= '';
} else {
- $out .= '';
+ $out .= '';
}
$i = 0;
@@ -3417,7 +3443,7 @@ class Form
$outkey = $objp->idprodfournprice; // id in table of price
if (!$outkey && $alsoproductwithnosupplierprice) {
- $outkey = 'idprod_'.$objp->rowid; // id of product
+ $outkey = 'idprod_' . $objp->rowid; // id of product
}
$outref = $objp->ref;
@@ -3425,30 +3451,30 @@ class Form
$outqty = 1;
$outdiscount = 0;
$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) : '';
// Units
$outvalUnits = '';
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
if (!empty($objp->unit_short)) {
- $outvalUnits .= ' - '.$objp->unit_short;
+ $outvalUnits .= ' - ' . $objp->unit_short;
}
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) {
$da = array(
@@ -3459,41 +3485,41 @@ 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' : ''));
}
}
}
$objRef = $objp->ref;
if ($filterkey && $filterkey != '') {
- $objRef = preg_replace('/('.preg_quote($filterkey, '/').')/i', '$1', $objRef, 1);
+ $objRef = preg_replace('/(' . preg_quote($filterkey, '/') . ')/i', '$1', $objRef, 1);
}
$objRefFourn = $objp->ref_fourn;
if ($filterkey && $filterkey != '') {
- $objRefFourn = preg_replace('/('.preg_quote($filterkey, '/').')/i', '$1', $objRefFourn, 1);
+ $objRefFourn = preg_replace('/(' . preg_quote($filterkey, '/') . ')/i', '$1', $objRefFourn, 1);
}
$label = $objp->label;
if ($filterkey && $filterkey != '') {
- $label = preg_replace('/('.preg_quote($filterkey, '/').')/i', '$1', $label, 1);
+ $label = preg_replace('/(' . preg_quote($filterkey, '/') . ')/i', '$1', $label, 1);
}
$optlabel = $objp->ref;
if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) {
- $optlabel .= ' ('.$objp->ref_fourn.')';
+ $optlabel .= ' (' . $objp->ref_fourn . ')';
}
if (isModEnabled('barcode') && !empty($objp->barcode)) {
- $optlabel .= ' ('.$outbarcode.')';
+ $optlabel .= ' (' . $outbarcode . ')';
}
- $optlabel .= ' - '.dol_trunc($label, $maxlengtharticle);
+ $optlabel .= ' - ' . dol_trunc($label, $maxlengtharticle);
$outvallabel = $objRef;
if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) {
- $outvallabel .= ' ('.$objRefFourn.')';
+ $outvallabel .= ' (' . $objRefFourn . ')';
}
if (isModEnabled('barcode') && !empty($objp->barcode)) {
- $outvallabel .= ' ('.$outbarcode.')';
+ $outvallabel .= ' (' . $outbarcode . ')';
}
- $outvallabel .= ' - '.dol_trunc($label, $maxlengtharticle);
+ $outvallabel .= ' - ' . dol_trunc($label, $maxlengtharticle);
// Units
$optlabel .= $outvalUnits;
@@ -3510,7 +3536,7 @@ class Form
$prod_supplier->fourn_tva_tx = $objp->tva_tx;
$prod_supplier->fk_supplier_price_expression = $objp->fk_supplier_price_expression;
- 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->parseProductSupplier($prod_supplier);
if ($price_result >= 0) {
@@ -3521,48 +3547,48 @@ class Form
}
}
if ($objp->quantity == 1) {
- $optlabel .= ' - '.price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency)."/";
- $outvallabel .= ' - '.price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 0, $langs, 0, 0, -1, $conf->currency)."/";
+ $optlabel .= ' - ' . price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency) . "/";
+ $outvallabel .= ' - ' . price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 0, $langs, 0, 0, -1, $conf->currency) . "/";
$optlabel .= $langs->trans("Unit"); // Do not use strtolower because it breaks utf8 encoding
$outvallabel .= $langs->transnoentities("Unit");
} else {
- $optlabel .= ' - '.price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity;
- $outvallabel .= ' - '.price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 0, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity;
- $optlabel .= ' '.$langs->trans("Units"); // Do not use strtolower because it breaks utf8 encoding
- $outvallabel .= ' '.$langs->transnoentities("Units");
+ $optlabel .= ' - ' . price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency) . "/" . $objp->quantity;
+ $outvallabel .= ' - ' . price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 0, $langs, 0, 0, -1, $conf->currency) . "/" . $objp->quantity;
+ $optlabel .= ' ' . $langs->trans("Units"); // Do not use strtolower because it breaks utf8 encoding
+ $outvallabel .= ' ' . $langs->transnoentities("Units");
}
if ($objp->quantity > 1) {
- $optlabel .= " (".price($objp->unitprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit").")"; // Do not use strtolower because it breaks utf8 encoding
- $outvallabel .= " (".price($objp->unitprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 0, $langs, 0, 0, -1, $conf->currency)."/".$langs->transnoentities("Unit").")"; // Do not use strtolower because it breaks utf8 encoding
+ $optlabel .= " (" . price($objp->unitprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency) . "/" . $langs->trans("Unit") . ")"; // Do not use strtolower because it breaks utf8 encoding
+ $outvallabel .= " (" . price($objp->unitprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 0, $langs, 0, 0, -1, $conf->currency) . "/" . $langs->transnoentities("Unit") . ")"; // Do not use strtolower because it breaks utf8 encoding
}
if ($objp->remise_percent >= 1) {
- $optlabel .= " - ".$langs->trans("Discount")." : ".vatrate($objp->remise_percent).' %';
- $outvallabel .= " - ".$langs->transnoentities("Discount")." : ".vatrate($objp->remise_percent).' %';
+ $optlabel .= " - " . $langs->trans("Discount") . " : " . vatrate($objp->remise_percent) . ' %';
+ $outvallabel .= " - " . $langs->transnoentities("Discount") . " : " . vatrate($objp->remise_percent) . ' %';
}
if ($objp->duration) {
- $optlabel .= " - ".$objp->duration;
- $outvallabel .= " - ".$objp->duration;
+ $optlabel .= " - " . $objp->duration;
+ $outvallabel .= " - " . $objp->duration;
}
if (!$socid) {
- $optlabel .= " - ".dol_trunc($objp->name, 8);
- $outvallabel .= " - ".dol_trunc($objp->name, 8);
+ $optlabel .= " - " . dol_trunc($objp->name, 8);
+ $outvallabel .= " - " . dol_trunc($objp->name, 8);
}
if ($objp->supplier_reputation) {
//TODO dictionary
- $reputations = array(''=>$langs->trans('Standard'), 'FAVORITE'=>$langs->trans('Favorite'), 'NOTTHGOOD'=>$langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER'=>$langs->trans('DoNotOrderThisProductToThisSupplier'));
+ $reputations = array('' => $langs->trans('Standard'), 'FAVORITE' => $langs->trans('Favorite'), 'NOTTHGOOD' => $langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER' => $langs->trans('DoNotOrderThisProductToThisSupplier'));
- $optlabel .= " - ".$reputations[$objp->supplier_reputation];
- $outvallabel .= " - ".$reputations[$objp->supplier_reputation];
+ $optlabel .= " - " . $reputations[$objp->supplier_reputation];
+ $outvallabel .= " - " . $reputations[$objp->supplier_reputation];
}
} else {
if (empty($alsoproductwithnosupplierprice)) { // No supplier price defined for couple product/supplier
- $optlabel .= " - ".$langs->trans("NoPriceDefinedForThisSupplier").'';
- $outvallabel .= ' - '.$langs->transnoentities("NoPriceDefinedForThisSupplier");
+ $optlabel .= " - " . $langs->trans("NoPriceDefinedForThisSupplier") . '';
+ $outvallabel .= ' - ' . $langs->transnoentities("NoPriceDefinedForThisSupplier");
} else // No supplier price defined for product, even on other suppliers
{
- $optlabel .= " - ".$langs->trans("NoPriceDefinedForThisSupplier").'';
- $outvallabel .= ' - '.$langs->transnoentities("NoPriceDefinedForThisSupplier");
+ $optlabel .= " - " . $langs->trans("NoPriceDefinedForThisSupplier") . '';
+ $outvallabel .= ' - ' . $langs->transnoentities("NoPriceDefinedForThisSupplier");
}
}
@@ -3570,14 +3596,14 @@ class Form
$novirtualstock = ($showstockinlist == 2);
if (!empty($user->rights->stock->lire)) {
- $outvallabel .= ' - '.$langs->trans("Stock").': '.price(price2num($objp->stock, 'MS'));
+ $outvallabel .= ' - ' . $langs->trans("Stock") . ': ' . price(price2num($objp->stock, 'MS'));
if ($objp->stock > 0) {
$optlabel .= ' - ';
} elseif ($objp->stock <= 0) {
$optlabel .= ' - ';
}
- $optlabel .= $langs->transnoentities("Stock").':'.price(price2num($objp->stock, 'MS'));
+ $optlabel .= $langs->transnoentities("Stock") . ':' . price(price2num($objp->stock, 'MS'));
$optlabel .= '';
if (empty($novirtualstock) && !empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO)) { // Warning, this option may slow down combo list generation
$langs->load("stocks");
@@ -3587,9 +3613,9 @@ class Form
$tmpproduct->load_virtual_stock();
$virtualstock = $tmpproduct->stock_theorique;
- $outvallabel .= ' - '.$langs->trans("VirtualStock").':'.$virtualstock;
+ $outvallabel .= ' - ' . $langs->trans("VirtualStock") . ':' . $virtualstock;
- $optlabel .= ' - '.$langs->transnoentities("VirtualStock").':';
+ $optlabel .= ' - ' . $langs->transnoentities("VirtualStock") . ':';
if ($virtualstock > 0) {
$optlabel .= '';
} elseif ($virtualstock <= 0) {
@@ -3603,7 +3629,7 @@ class Form
}
}
- $optstart = '\n";
+ $out .= $optstart . ' data-html="' . dol_escape_htmltag($optlabel) . '">' . $optlabel . "\n";
array_push(
$outarray,
- array('key'=>$outkey,
- 'value'=>$outref,
- 'label'=>$outvallabel,
- 'qty'=>$outqty,
- 'price_qty_ht'=>price2num($objp->fprice, 'MU'), // Keep higher resolution for price for the min qty
- 'price_qty_ht_locale'=>price($objp->fprice),
- 'price_unit_ht'=>price2num($objp->unitprice, 'MU'), // This is used to fill the Unit Price
- 'price_unit_ht_locale'=>price($objp->unitprice),
- 'price_ht'=>price2num($objp->unitprice, 'MU'), // This is used to fill the Unit Price (for compatibility)
+ array('key' => $outkey,
+ 'value' => $outref,
+ 'label' => $outvallabel,
+ 'qty' => $outqty,
+ 'price_qty_ht' => price2num($objp->fprice, 'MU'), // Keep higher resolution for price for the min qty
+ 'price_qty_ht_locale' => price($objp->fprice),
+ 'price_unit_ht' => price2num($objp->unitprice, 'MU'), // This is used to fill the Unit Price
+ 'price_unit_ht_locale' => price($objp->unitprice),
+ 'price_ht' => price2num($objp->unitprice, 'MU'), // This is used to fill the Unit Price (for compatibility)
'tva_tx_formated' => price($objp->tva_tx),
- 'tva_tx'=>price2num($objp->tva_tx),
- 'default_vat_code'=>$objp->default_vat_code,
- 'discount'=>$outdiscount,
- 'type'=>$outtype,
- 'duration_value'=>$outdurationvalue,
- 'duration_unit'=>$outdurationunit,
- 'disabled'=>(empty($objp->idprodfournprice) ? true : false),
- 'description'=>$objp->description
+ 'tva_tx' => price2num($objp->tva_tx),
+ 'default_vat_code' => $objp->default_vat_code,
+ 'discount' => $outdiscount,
+ 'type' => $outtype,
+ 'duration_value' => $outdurationvalue,
+ 'duration_unit' => $outdurationunit,
+ 'disabled' => (empty($objp->idprodfournprice) ? true : false),
+ 'description' => $objp->description
)
);
// Exemple of var_dump $outarray
@@ -3694,7 +3720,7 @@ class Form
$this->db->free($result);
- include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
+ include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
$out .= ajax_combobox($htmlname);
} else {
dol_print_error($this->db);
@@ -3707,13 +3733,14 @@ class Form
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+
/**
- * Return list of suppliers prices for a product
+ * Return list of suppliers prices for a product
*
- * @param int $productid Id of product
- * @param string $htmlname Name of HTML field
- * @param int $selected_supplier Pre-selected supplier if more than 1 result
- * @return string
+ * @param int $productid Id of product
+ * @param string $htmlname Name of HTML field
+ * @param int $selected_supplier Pre-selected supplier if more than 1 result
+ * @return string
*/
public function select_product_fourn_price($productid, $htmlname = 'productfournpriceid', $selected_supplier = '')
{
@@ -3725,43 +3752,43 @@ class Form
$sql = "SELECT p.rowid, p.ref, p.label, p.price, p.duration, pfp.fk_soc,";
$sql .= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.remise_percent, pfp.quantity, pfp.unitprice,";
$sql .= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, s.nom as name";
- $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";
- $sql .= " LEFT JOIN ".$this->db->prefix()."societe as s ON pfp.fk_soc = s.rowid";
- $sql .= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")";
+ $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";
+ $sql .= " LEFT JOIN " . $this->db->prefix() . "societe as s ON pfp.fk_soc = s.rowid";
+ $sql .= " WHERE pfp.entity IN (" . getEntity('productsupplierprice') . ")";
$sql .= " AND p.tobuy = 1";
$sql .= " AND s.fournisseur = 1";
- $sql .= " AND p.rowid = ".((int) $productid);
+ $sql .= " AND p.rowid = " . ((int) $productid);
if (empty($conf->global->PRODUCT_BEST_SUPPLIER_PRICE_PRESELECTED)) {
$sql .= " ORDER BY s.nom, pfp.ref_fourn DESC";
} else {
$sql .= " ORDER BY pfp.unitprice ASC";
}
- dol_syslog(get_class($this)."::select_product_fourn_price", LOG_DEBUG);
+ dol_syslog(get_class($this) . "::select_product_fourn_price", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {
$num = $this->db->num_rows($result);
- $form = '';
+ $form = '';
if (!$num) {
- $form .= '';
+ $form .= '';
} else {
- 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';
$form .= '';
$i = 0;
while ($i < $num) {
$objp = $this->db->fetch_object($result);
- $opt = '\n";
@@ -3816,28 +3843,29 @@ class Form
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+
/**
* Return list of delivery address
*
- * @param string $selected Id contact pre-selectionn
- * @param int $socid Id of company
- * @param string $htmlname Name of HTML field
- * @param int $showempty Add an empty field
- * @return integer
+ * @param string $selected Id contact pre-selectionn
+ * @param int $socid Id of company
+ * @param string $htmlname Name of HTML field
+ * @param int $showempty Add an empty field
+ * @return integer
*/
public function select_address($selected, $socid, $htmlname = 'address_id', $showempty = 0)
{
// phpcs:enable
// looking for users
$sql = "SELECT a.rowid, a.label";
- $sql .= " FROM ".$this->db->prefix()."societe_address as a";
- $sql .= " WHERE a.fk_soc = ".((int) $socid);
+ $sql .= " FROM " . $this->db->prefix() . "societe_address as a";
+ $sql .= " WHERE a.fk_soc = " . ((int) $socid);
$sql .= " ORDER BY a.label ASC";
- dol_syslog(get_class($this)."::select_address", LOG_DEBUG);
+ dol_syslog(get_class($this) . "::select_address", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
- print '';
+ print '';
if ($showempty) {
print '';
}
@@ -3848,9 +3876,9 @@ class Form
$obj = $this->db->fetch_object($resql);
if ($selected && $selected == $obj->rowid) {
- print '';
+ print '';
} else {
- print '';
+ print '';
}
$i++;
}
@@ -3864,10 +3892,11 @@ class Form
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+
/**
* Load into cache list of payment terms
*
- * @return int Nb of lines loaded, <0 if KO
+ * @return int Nb of lines loaded, <0 if KO
*/
public function load_cache_conditions_paiements()
{
@@ -3882,8 +3911,8 @@ class Form
dol_syslog(__METHOD__, LOG_DEBUG);
$sql = "SELECT rowid, code, libelle as label, deposit_percent";
- $sql .= " FROM ".$this->db->prefix().'c_payment_term';
- $sql .= " WHERE entity IN (".getEntity('c_payment_term').")";
+ $sql .= " FROM " . $this->db->prefix() . 'c_payment_term';
+ $sql .= " WHERE entity IN (" . getEntity('c_payment_term') . ")";
$sql .= " AND active > 0";
$sql .= " ORDER BY sortorder";
@@ -3895,7 +3924,7 @@ class Form
$obj = $this->db->fetch_object($resql);
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
- $label = ($langs->trans("PaymentConditionShort".$obj->code) != ("PaymentConditionShort".$obj->code) ? $langs->trans("PaymentConditionShort".$obj->code) : ($obj->label != '-' ? $obj->label : ''));
+ $label = ($langs->trans("PaymentConditionShort" . $obj->code) != ("PaymentConditionShort" . $obj->code) ? $langs->trans("PaymentConditionShort" . $obj->code) : ($obj->label != '-' ? $obj->label : ''));
$this->cache_conditions_paiements[$obj->rowid]['code'] = $obj->code;
$this->cache_conditions_paiements[$obj->rowid]['label'] = $label;
$this->cache_conditions_paiements[$obj->rowid]['deposit_percent'] = $obj->deposit_percent;
@@ -3912,17 +3941,18 @@ class Form
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+
/**
* Load int a cache property th elist of possible delivery delays.
*
- * @return int Nb of lines loaded, <0 if KO
+ * @return int Nb of lines loaded, <0 if KO
*/
public function load_cache_availability()
{
// phpcs:enable
global $langs;
- $num = count($this->cache_availability); // TODO Use $conf->cache['availability'] instead of $this->cache_availability
+ $num = count($this->cache_availability); // TODO Use $conf->cache['availability'] instead of $this->cache_availability
if ($num > 0) {
return 0; // Cache already loaded
}
@@ -3932,7 +3962,7 @@ class Form
$langs->load('propal');
$sql = "SELECT rowid, code, label, position";
- $sql .= " FROM ".$this->db->prefix().'c_availability';
+ $sql .= " FROM " . $this->db->prefix() . 'c_availability';
$sql .= " WHERE active > 0";
$resql = $this->db->query($sql);
@@ -3943,7 +3973,7 @@ class Form
$obj = $this->db->fetch_object($resql);
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
- $label = ($langs->trans("AvailabilityType".$obj->code) != ("AvailabilityType".$obj->code) ? $langs->trans("AvailabilityType".$obj->code) : ($obj->label != '-' ? $obj->label : ''));
+ $label = ($langs->trans("AvailabilityType" . $obj->code) != ("AvailabilityType" . $obj->code) ? $langs->trans("AvailabilityType" . $obj->code) : ($obj->label != '-' ? $obj->label : ''));
$this->cache_availability[$obj->rowid]['code'] = $obj->code;
$this->cache_availability[$obj->rowid]['label'] = $label;
$this->cache_availability[$obj->rowid]['position'] = $obj->position;
@@ -3962,12 +3992,12 @@ class Form
/**
* Retourne la liste des types de delais de livraison possibles
*
- * @param int $selected Id du type de delais pre-selectionne
- * @param string $htmlname Nom de la zone select
- * @param string $filtertype To add a filter
- * @param int $addempty Add empty entry
- * @param string $morecss More CSS
- * @return void
+ * @param int $selected Id du type de delais pre-selectionne
+ * @param string $htmlname Nom de la zone select
+ * @param string $filtertype To add a filter
+ * @param int $addempty Add empty entry
+ * @param string $morecss More CSS
+ * @return void
*/
public function selectAvailabilityDelay($selected = '', $htmlname = 'availid', $filtertype = '', $addempty = 0, $morecss = '')
{
@@ -3975,17 +4005,17 @@ class Form
$this->load_cache_availability();
- dol_syslog(__METHOD__." selected=".$selected.", htmlname=".$htmlname, LOG_DEBUG);
+ dol_syslog(__METHOD__ . " selected=" . $selected . ", htmlname=" . $htmlname, LOG_DEBUG);
- print '';
+ print '';
if ($addempty) {
print '';
}
foreach ($this->cache_availability as $id => $arrayavailability) {
if ($selected == $id) {
- print '';
@@ -4000,19 +4030,19 @@ class Form
/**
* Load into cache cache_demand_reason, array of input reasons
*
- * @return int Nb of lines loaded, <0 if KO
+ * @return int Nb of lines loaded, <0 if KO
*/
public function loadCacheInputReason()
{
global $langs;
- $num = count($this->cache_demand_reason); // TODO Use $conf->cache['input_reason'] instead of $this->cache_demand_reason
+ $num = count($this->cache_demand_reason); // TODO Use $conf->cache['input_reason'] instead of $this->cache_demand_reason
if ($num > 0) {
return 0; // Cache already loaded
}
$sql = "SELECT rowid, code, label";
- $sql .= " FROM ".$this->db->prefix().'c_input_reason';
+ $sql .= " FROM " . $this->db->prefix() . 'c_input_reason';
$sql .= " WHERE active > 0";
$resql = $this->db->query($sql);
@@ -4025,14 +4055,14 @@ class Form
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
$label = ($obj->label != '-' ? $obj->label : '');
- if ($langs->trans("DemandReasonType".$obj->code) != ("DemandReasonType".$obj->code)) {
- $label = $langs->trans("DemandReasonType".$obj->code); // So translation key DemandReasonTypeSRC_XXX will work
+ if ($langs->trans("DemandReasonType" . $obj->code) != ("DemandReasonType" . $obj->code)) {
+ $label = $langs->trans("DemandReasonType" . $obj->code); // So translation key DemandReasonTypeSRC_XXX will work
}
if ($langs->trans($obj->code) != $obj->code) {
$label = $langs->trans($obj->code); // So translation key SRC_XXX will work
}
- $tmparray[$obj->rowid]['id'] = $obj->rowid;
+ $tmparray[$obj->rowid]['id'] = $obj->rowid;
$tmparray[$obj->rowid]['code'] = $obj->code;
$tmparray[$obj->rowid]['label'] = $label;
$i++;
@@ -4049,16 +4079,16 @@ class Form
}
/**
- * Return list of input reason (events that triggered an object creation, like after sending an emailing, making an advert, ...)
+ * Return list of input reason (events that triggered an object creation, like after sending an emailing, making an advert, ...)
* List found into table c_input_reason loaded by loadCacheInputReason
*
- * @param int $selected Id or code of type origin to select by default
- * @param string $htmlname Nom de la zone select
- * @param string $exclude To exclude a code value (Example: SRC_PROP)
- * @param int $addempty Add an empty entry
- * @param string $morecss Add more css to the HTML select component
- * @param int $notooltip Do not show the tooltip for admin
- * @return void
+ * @param int $selected Id or code of type origin to select by default
+ * @param string $htmlname Nom de la zone select
+ * @param string $exclude To exclude a code value (Example: SRC_PROP)
+ * @param int $addempty Add an empty entry
+ * @param string $morecss Add more css to the HTML select component
+ * @param int $notooltip Do not show the tooltip for admin
+ * @return void
*/
public function selectInputReason($selected = '', $htmlname = 'demandreasonid', $exclude = '', $addempty = 0, $morecss = '', $notooltip = 0)
{
@@ -4066,9 +4096,9 @@ class Form
$this->loadCacheInputReason();
- print '';
+ print '';
if ($addempty) {
- print '';
+ print '';
}
foreach ($this->cache_demand_reason as $id => $arraydemandreason) {
if ($arraydemandreason['code'] == $exclude) {
@@ -4076,9 +4106,9 @@ class Form
}
if ($selected && ($selected == $arraydemandreason['id'] || $selected == $arraydemandreason['code'])) {
- 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 .= ' ';
+ $out .= ' ';
$out .= $langs->trans('DepositPercent') . ' : ';
- $out .= '';
+ $out .= '';
$out .= '';
$out .= '
- '."\n";
*
- * @param string $page Url of page to call if confirmation is OK. Can contains parameters (param 'action' and 'confirm' will be reformated)
- * @param string $title Title
- * @param string $question Question
- * @param string $action Action
- * @param array|string $formquestion An array with complementary inputs to add into forms: array(array('label'=> ,'type'=> , 'size'=>, 'morecss'=>, 'moreattr'=>'autofocus' or 'style=...'))
- * 'type' can be 'text', 'password', 'checkbox', 'radio', 'date', 'datetime', 'select', 'multiselect', 'morecss',
- * 'other', 'onecolumn' or 'hidden'...
- * @param int|string $selectedchoice '' or 'no', or 'yes' or '1', 1, '0' or 0
- * @param int|string $useajax 0=No, 1=Yes use Ajax to show the popup, 2=Yes and also submit page with &confirm=no if choice is No, 'xxx'=Yes and preoutput confirm box with div id=dialog-confirm-xxx
- * @param int|string $height Force height of box (0 = auto)
- * @param int $width Force width of box ('999' or '90%'). Ignored and forced to 90% on smartphones.
- * @param int $disableformtag 1=Disable form tag. Can be used if we are already inside a
' . "\n";
- $formconfirm .= "\n\n";
- $formconfirm .= '';
$formconfirm .= "\n";
} else {
- $formconfirm .= "\n\n";
+ $formconfirm .= "\n\n";
if (empty($disableformtag)) {
- $formconfirm .= '\n";
@@ -5424,7 +5461,7 @@ class Form
if (!empty($conf->use_javascript_ajax)) {
$formconfirm .= '';
- $formconfirm .= ''."\n";
+ $formconfirm .= '' . "\n";
}
$formconfirm .= "\n";
@@ -5447,28 +5484,29 @@ class Form
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+
/**
* Show a form to select a project
*
- * @param int $page Page
- * @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id)
- * @param int $selected Id pre-selected project
- * @param string $htmlname Name of select field
- * @param int $discard_closed Discard closed projects (0=Keep,1=hide completely except $selected,2=Disable)
- * @param int $maxlength Max length
- * @param int $forcefocus Force focus on field (works with javascript only)
- * @param int $nooutput No print is done. String is returned.
- * @param string $textifnoproject Text to show if no project
- * @param string $morecss More CSS
- * @return string Return html content
+ * @param int $page Page
+ * @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id)
+ * @param int $selected Id pre-selected project
+ * @param string $htmlname Name of select field
+ * @param int $discard_closed Discard closed projects (0=Keep,1=hide completely except $selected,2=Disable)
+ * @param int $maxlength Max length
+ * @param int $forcefocus Force focus on field (works with javascript only)
+ * @param int $nooutput No print is done. String is returned.
+ * @param string $textifnoproject Text to show if no project
+ * @param string $morecss More CSS
+ * @return string Return html content
*/
public function form_project($page, $socid, $selected = '', $htmlname = 'projectid', $discard_closed = 0, $maxlength = 20, $forcefocus = 0, $nooutput = 0, $textifnoproject = '', $morecss = '')
{
// phpcs:enable
global $langs;
- require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
- require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
+ require_once DOL_DOCUMENT_ROOT . '/core/lib/project.lib.php';
+ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
$out = '';
@@ -5476,11 +5514,11 @@ class Form
$langs->load("project");
if ($htmlname != "none") {
- $out .= '';
} else {
$out .= '';
@@ -5489,7 +5527,7 @@ class Form
$projet->fetch($selected);
$out .= $projet->getNomUrl(0, '', 1);
} else {
- $out .= ''.$textifnoproject.'';
+ $out .= '' . $textifnoproject . '';
}
$out .= '';
}
@@ -5502,20 +5540,21 @@ class Form
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+
/**
- * Show a form to select payment conditions
+ * Show a form to select payment conditions
*
- * @param int $page Page
- * @param string $selected Id condition pre-selectionne
- * @param string $htmlname Name of select html field
- * @param int $addempty Add empty entry
- * @param string $type Type ('direct-debit' or 'bank-transfer')
- * @param int $filtertype If > 0, include payment terms with deposit percentage (for objects other than invoices and invoice templates)
- * @param string $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters)
- * 0 : use default deposit percentage from entry
- * > 0 : force deposit percentage (for example, from company object)
- * @param int $nooutput No print is done. String is returned.
- * @return string HTML output or ''
+ * @param int $page Page
+ * @param string $selected Id condition pre-selectionne
+ * @param string $htmlname Name of select html field
+ * @param int $addempty Add empty entry
+ * @param string $type Type ('direct-debit' or 'bank-transfer')
+ * @param int $filtertype If > 0, include payment terms with deposit percentage (for objects other than invoices and invoice templates)
+ * @param string $deposit_percent < 0 : deposit_percent input makes no sense (for example, in list filters)
+ * 0 : use default deposit percentage from entry
+ * > 0 : force deposit percentage (for example, from company object)
+ * @param int $nooutput No print is done. String is returned.
+ * @return string HTML output or ''
*/
public function form_conditions_reglement($page, $selected = '', $htmlname = 'cond_reglement_id', $addempty = 0, $type = '', $filtertype = -1, $deposit_percent = -1, $nooutput = 0)
{
@@ -5525,14 +5564,14 @@ class Form
$out = '';
if ($htmlname != "none") {
- $out .= '';
} else {
if ($selected) {
@@ -5562,26 +5601,27 @@ class Form
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+
/**
* Show a form to select a delivery delay
*
- * @param int $page Page
- * @param string $selected Id condition pre-selectionne
- * @param string $htmlname Name of select html field
- * @param int $addempty Ajoute entree vide
- * @return void
+ * @param int $page Page
+ * @param string $selected Id condition pre-selectionne
+ * @param string $htmlname Name of select html field
+ * @param int $addempty Ajoute entree vide
+ * @return void
*/
public function form_availability($page, $selected = '', $htmlname = 'availability', $addempty = 0)
{
// phpcs:enable
global $langs;
if ($htmlname != "none") {
- print '';
} else {
if ($selected) {
@@ -5597,21 +5637,21 @@ class Form
* Output HTML form to select list of input reason (events that triggered an object creation, like after sending an emailing, making an advert, ...)
* List found into table c_input_reason loaded by loadCacheInputReason
*
- * @param string $page Page
- * @param string $selected Id condition pre-selectionne
- * @param string $htmlname Name of select html field
- * @param int $addempty Add empty entry
- * @return void
+ * @param string $page Page
+ * @param string $selected Id condition pre-selectionne
+ * @param string $htmlname Name of select html field
+ * @param int $addempty Add empty entry
+ * @return void
*/
public function formInputReason($page, $selected = '', $htmlname = 'demandreason', $addempty = 0)
{
global $langs;
if ($htmlname != "none") {
- print '';
} else {
if ($selected) {
@@ -5629,18 +5669,19 @@ class Form
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+
/**
* Show a form + html select a date
*
- * @param string $page Page
- * @param string $selected Date preselected
- * @param string $htmlname Html name of date input fields or 'none'
- * @param int $displayhour Display hour selector
- * @param int $displaymin Display minutes selector
- * @param int $nooutput 1=No print output, return string
- * @param string $type 'direct-debit' or 'bank-transfer'
- * @return string
- * @see selectDate()
+ * @param string $page Page
+ * @param string $selected Date preselected
+ * @param string $htmlname Html name of date input fields or 'none'
+ * @param int $displayhour Display hour selector
+ * @param int $displaymin Display minutes selector
+ * @param int $nooutput 1=No print output, return string
+ * @param string $type 'direct-debit' or 'bank-transfer'
+ * @return string
+ * @see selectDate()
*/
public function form_date($page, $selected, $htmlname, $displayhour = 0, $displaymin = 0, $nooutput = 0, $type = '')
{
@@ -5650,17 +5691,17 @@ class Form
$ret = '';
if ($htmlname != "none") {
- $ret .= '';
} else {
if ($displayhour) {
@@ -5678,15 +5719,16 @@ class Form
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+
/**
* Show a select form to choose a user
*
- * @param string $page Page
- * @param string $selected Id of user preselected
- * @param string $htmlname Name of input html field. If 'none', we just output the user link.
- * @param array $exclude List of users id to exclude
- * @param array $include List of users id to include
- * @return void
+ * @param string $page Page
+ * @param string $selected Id of user preselected
+ * @param string $htmlname Name of input html field. If 'none', we just output the user link.
+ * @param array $exclude List of users id to exclude
+ * @param array $include List of users id to include
+ * @return void
*/
public function form_users($page, $selected = '', $htmlname = 'userid', $exclude = '', $include = '')
{
@@ -5694,15 +5736,15 @@ class Form
global $langs;
if ($htmlname != "none") {
- print '';
} else {
if ($selected) {
- require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
+ require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php';
$theuser = new User($this->db);
$theuser->fetch($selected);
print $theuser->getNomUrl(1);
@@ -5714,18 +5756,19 @@ class Form
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+
/**
* Show form with payment mode
*
- * @param string $page Page
- * @param int $selected Id mode pre-selectionne
- * @param string $htmlname Name of select html field
- * @param string $filtertype To filter on field type in llx_c_paiement ('CRDT' or 'DBIT' or array('code'=>xx,'label'=>zz))
- * @param int $active Active or not, -1 = all
- * @param int $addempty 1=Add empty entry
- * @param string $type Type ('direct-debit' or 'bank-transfer')
- * @param int $nooutput 1=Return string, no output
- * @return string HTML output or ''
+ * @param string $page Page
+ * @param int $selected Id mode pre-selectionne
+ * @param string $htmlname Name of select html field
+ * @param string $filtertype To filter on field type in llx_c_paiement ('CRDT' or 'DBIT' or array('code'=>xx,'label'=>zz))
+ * @param int $active Active or not, -1 = all
+ * @param int $addempty 1=Add empty entry
+ * @param string $type Type ('direct-debit' or 'bank-transfer')
+ * @param int $nooutput 1=Return string, no output
+ * @return string HTML output or ''
*/
public function form_modes_reglement($page, $selected = '', $htmlname = 'mode_reglement_id', $filtertype = '', $active = 1, $addempty = 0, $type = '', $nooutput = 0)
{
@@ -5734,14 +5777,14 @@ class Form
$out = '';
if ($htmlname != "none") {
- $out .= '';
} else {
if ($selected) {
@@ -5763,22 +5806,22 @@ class Form
/**
* Show form with transport mode
*
- * @param string $page Page
- * @param int $selected Id mode pre-select
- * @param string $htmlname Name of select html field
- * @param int $active Active or not, -1 = all
- * @param int $addempty 1=Add empty entry
- * @return void
+ * @param string $page Page
+ * @param int $selected Id mode pre-select
+ * @param string $htmlname Name of select html field
+ * @param int $active Active or not, -1 = all
+ * @param int $addempty 1=Add empty entry
+ * @return void
*/
public function formSelectTransportMode($page, $selected = '', $htmlname = 'transport_mode_id', $active = 1, $addempty = 0)
{
global $langs;
if ($htmlname != "none") {
- print '';
} else {
if ($selected) {
@@ -5791,24 +5834,25 @@ class Form
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+
/**
* Show form with multicurrency code
*
- * @param string $page Page
- * @param string $selected code pre-selectionne
- * @param string $htmlname Name of select html field
- * @return void
+ * @param string $page Page
+ * @param string $selected code pre-selectionne
+ * @param string $htmlname Name of select html field
+ * @return void
*/
public function form_multicurrency_code($page, $selected = '', $htmlname = 'multicurrency_code')
{
// phpcs:enable
global $langs;
if ($htmlname != "none") {
- print '';
} else {
dol_include_once('/core/lib/company.lib.php');
@@ -5817,14 +5861,15 @@ class Form
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+
/**
* Show form with multicurrency rate
*
- * @param string $page Page
- * @param double $rate Current rate
- * @param string $htmlname Name of select html field
- * @param string $currency Currency code to explain the rate
- * @return void
+ * @param string $page Page
+ * @param double $rate Current rate
+ * @param string $htmlname Name of select html field
+ * @param string $currency Currency code to explain the rate
+ * @return void
*/
public function form_multicurrency_rate($page, $rate = '', $htmlname = 'multicurrency_tx', $currency = '')
{
@@ -5832,21 +5877,21 @@ class Form
global $langs, $mysoc, $conf;
if ($htmlname != "none") {
- print '';
} else {
if (!empty($rate)) {
print price($rate, 1, $langs, 1, 0);
if ($currency && $rate != 1) {
- print ' ('.price($rate, 1, $langs, 1, 0).' '.$currency.' = 1 '.$conf->currency.')';
+ print ' (' . price($rate, 1, $langs, 1, 0) . ' ' . $currency . ' = 1 ' . $conf->currency . ')';
}
} else {
print 1;
@@ -5856,29 +5901,30 @@ class Form
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+
/**
- * Show a select box with available absolute discounts
+ * Show a select box with available absolute discounts
*
- * @param string $page Page URL where form is shown
- * @param int $selected Value pre-selected
- * @param string $htmlname Name of SELECT component. If 'none', not changeable. Example 'remise_id'.
- * @param int $socid Third party id
- * @param float $amount Total amount available
- * @param string $filter SQL filter on discounts
- * @param int $maxvalue Max value for lines that can be selected
- * @param string $more More string to add
- * @param int $hidelist 1=Hide list
- * @param int $discount_type 0 => customer discount, 1 => supplier discount
- * @return void
+ * @param string $page Page URL where form is shown
+ * @param int $selected Value pre-selected
+ * @param string $htmlname Name of SELECT component. If 'none', not changeable. Example 'remise_id'.
+ * @param int $socid Third party id
+ * @param float $amount Total amount available
+ * @param string $filter SQL filter on discounts
+ * @param int $maxvalue Max value for lines that can be selected
+ * @param string $more More string to add
+ * @param int $hidelist 1=Hide list
+ * @param int $discount_type 0 => customer discount, 1 => supplier discount
+ * @return void
*/
public function form_remise_dispo($page, $selected, $htmlname, $socid, $amount, $filter = '', $maxvalue = 0, $more = '', $hidelist = 0, $discount_type = 0)
{
// phpcs:enable
global $conf, $langs;
if ($htmlname != "none") {
- print '
';
+ } else {
+ $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
+ }
+ }
+ }
+
+ if ($withpicto != 2) {
+ $result .= $this->ref;
+ }
+
+ $result .= $linkend;
+ //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
+
+ global $action, $hookmanager;
+ $hookmanager->initHooks(array($this->element.'dao'));
+ $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
+ $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
+ if ($reshook > 0) {
+ $result = $hookmanager->resPrint;
+ } else {
+ $result .= $hookmanager->resPrint;
+ }
+
+ return $result;
+ }
+
+ /**
+ * Return a thumb for kanban views
+ *
+ * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link)
+ * @param array $arraydata Array of data
+ * @return string HTML Code for Kanban thumb.
+ */
+ public function getKanbanView($option = '', $arraydata = null)
+ {
+ global $conf, $langs;
+ $return = '
';
diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php
index bbd9442f876..8f69a8afada 100644
--- a/htdocs/projet/activity/index.php
+++ b/htdocs/projet/activity/index.php
@@ -3,6 +3,7 @@
* Copyright (C) 2006-2015 Laurent Destailleur
* Copyright (C) 2010 Regis Houssin
* Copyright (C) 2019 Nicolas ZABOURI
+ * Copyright (C) 2023 Gauthier VERDOL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -116,15 +117,16 @@ print '
'.$langs->trans('ActivityOnProjectToday').'
';
print '
'.$langs->trans("Time").'
';
print "
\n";
-$sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb";
+$sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.element_duration) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql .= ", ".MAIN_DB_PREFIX."projet_task as t";
-$sql .= ", ".MAIN_DB_PREFIX."projet_task_time as tt";
+$sql .= ", ".MAIN_DB_PREFIX."element_time as tt";
$sql .= " WHERE t.fk_projet = p.rowid";
$sql .= " AND p.entity = ".((int) $conf->entity);
-$sql .= " AND tt.fk_task = t.rowid";
+$sql .= " AND tt.fk_element = t.rowid";
+$sql .= " AND tt.elementtype = 'task'";
$sql .= " AND tt.fk_user = ".((int) $user->id);
-$sql .= " AND task_date BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'";
+$sql .= " AND element_date BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'";
$sql .= " AND p.rowid in (".$db->sanitize($projectsListId).")";
$sql .= " GROUP BY p.rowid, p.ref, p.title, p.public";
@@ -169,15 +171,16 @@ print '
'.$langs->trans('ActivityOnProjectYesterday').'
';
print '
'.$langs->trans("Time").'
';
print "
\n";
-$sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb";
+$sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.element_duration) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql .= ", ".MAIN_DB_PREFIX."projet_task as t";
-$sql .= ", ".MAIN_DB_PREFIX."projet_task_time as tt";
+$sql .= ", ".MAIN_DB_PREFIX."element_time as tt";
$sql .= " WHERE t.fk_projet = p.rowid";
$sql .= " AND p.entity = ".((int) $conf->entity);
-$sql .= " AND tt.fk_task = t.rowid";
+$sql .= " AND tt.fk_element = t.rowid";
+$sql .= " AND tt.elementtype = 'task'";
$sql .= " AND tt.fk_user = ".((int) $user->id);
-$sql .= " AND task_date BETWEEN '".$db->idate(dol_time_plus_duree(dol_mktime(0, 0, 0, $month, $day, $year), -1, 'd'))."' AND '".$db->idate(dol_time_plus_duree(dol_mktime(23, 59, 59, $month, $day, $year), -1, 'd'))."'";
+$sql .= " AND element_date BETWEEN '".$db->idate(dol_time_plus_duree(dol_mktime(0, 0, 0, $month, $day, $year), -1, 'd'))."' AND '".$db->idate(dol_time_plus_duree(dol_mktime(23, 59, 59, $month, $day, $year), -1, 'd'))."'";
$sql .= " AND p.rowid in (".$db->sanitize($projectsListId).")";
$sql .= " GROUP BY p.rowid, p.ref, p.title, p.public";
@@ -281,15 +284,16 @@ if (!empty($conf->global->PROJECT_TASK_TIME_MONTH)) {
print '
'.$langs->trans("Time").'
';
print "\n";
- $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb";
+ $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.element_duration) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql .= ", ".MAIN_DB_PREFIX."projet_task as t";
- $sql .= ", ".MAIN_DB_PREFIX."projet_task_time as tt";
+ $sql .= ", ".MAIN_DB_PREFIX."element_time as tt";
$sql .= " WHERE t.fk_projet = p.rowid";
$sql .= " AND p.entity = ".((int) $conf->entity);
- $sql .= " AND tt.fk_task = t.rowid";
+ $sql .= " AND tt.fk_element = t.rowid";
+ $sql .= " AND tt.elementtype = 'task'";
$sql .= " AND tt.fk_user = ".((int) $user->id);
- $sql .= " AND task_date BETWEEN '".$db->idate(dol_get_first_day($year, $month))."' AND '".$db->idate(dol_get_last_day($year, $month))."'";
+ $sql .= " AND element_date BETWEEN '".$db->idate(dol_get_first_day($year, $month))."' AND '".$db->idate(dol_get_last_day($year, $month))."'";
$sql .= " AND p.rowid in (".$db->sanitize($projectsListId).")";
$sql .= " GROUP BY p.rowid, p.ref, p.title, p.public";
@@ -327,15 +331,16 @@ if (!empty($conf->global->PROJECT_TASK_TIME_YEAR)) {
print '
'.$langs->trans("Time").'
';
print "\n";
- $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb";
+ $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.element_duration) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql .= ", ".MAIN_DB_PREFIX."projet_task as t";
- $sql .= ", ".MAIN_DB_PREFIX."projet_task_time as tt";
+ $sql .= ", ".MAIN_DB_PREFIX."element_time as tt";
$sql .= " WHERE t.fk_projet = p.rowid";
$sql .= " AND p.entity = ".((int) $conf->entity);
- $sql .= " AND tt.fk_task = t.rowid";
+ $sql .= " AND tt.fk_element = t.rowid";
+ $sql .= " AND tt.elementtype = 'task'";
$sql .= " AND tt.fk_user = ".((int) $user->id);
- $sql .= " AND YEAR(task_date) = '".strftime("%Y", $now)."'";
+ $sql .= " AND YEAR(element_date) = '".strftime("%Y", $now)."'";
$sql .= " AND p.rowid in (".$db->sanitize($projectsListId).")";
$sql .= " GROUP BY p.rowid, p.ref, p.title, p.public";
@@ -407,11 +412,11 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_SH
$max = (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA) ? 1000 : $conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA);
$sql = "SELECT p.ref, p.title, p.rowid as projectid, p.fk_statut as status, p.fk_opp_status as opp_status, p.public, p.dateo as projdateo, p.datee as projdatee,";
- $sql .= " t.label, t.rowid as taskid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee, SUM(tasktime.task_duration) as timespent";
+ $sql .= " t.label, t.rowid as taskid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee, SUM(tasktime.element_duration) as timespent";
$sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid";
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tasktime on tasktime.fk_task = t.rowid";
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_time as tasktime on (tasktime.fk_element = t.rowid AND tasktime.elementtype = 'task')";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on tasktime.fk_user = u.rowid";
if ($mine) {
$sql .= ", ".MAIN_DB_PREFIX."element_contact as ect";
diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php
index 1c8105ea931..7c68b8bdeab 100644
--- a/htdocs/projet/class/api_tasks.class.php
+++ b/htdocs/projet/class/api_tasks.class.php
@@ -271,6 +271,7 @@ class Tasks extends DolibarrApi
* @return array Array of roles
*
* @url GET {id}/roles
+ *
*/
public function getRoles($id, $userid = 0)
{
diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php
index fc4f6acb426..f9e2656d1f5 100644
--- a/htdocs/projet/class/project.class.php
+++ b/htdocs/projet/class/project.class.php
@@ -7,6 +7,7 @@
* Copyright (C) 2017 Ferran Marcet
* Copyright (C) 2019 Juanjo Menent
* Copyright (C) 2022 Charlene Benke
+ * Copyright (C) 2023 Gauthier VERDOL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -782,8 +783,8 @@ class Project extends CommonObject
$sql = "SELECT ed.rowid FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."expensereport_det as ed WHERE e.rowid = ed.fk_expensereport AND e.entity IN (".getEntity('expensereport').") AND ed.fk_projet IN (".$this->db->sanitize($ids).")";
} elseif ($type == 'project_task') {
$sql = "SELECT DISTINCT pt.rowid FROM ".MAIN_DB_PREFIX."projet_task as pt WHERE pt.fk_projet IN (".$this->db->sanitize($ids).")";
- } elseif ($type == 'project_task_time') { // Case we want to duplicate line foreach user
- $sql = "SELECT DISTINCT pt.rowid, ptt.fk_user FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet IN (".$this->db->sanitize($ids).")";
+ } elseif ($type == 'element_time') { // Case we want to duplicate line foreach user
+ $sql = "SELECT DISTINCT pt.rowid, ptt.fk_user FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."element_time as ptt WHERE pt.rowid = ptt.fk_element AND ptt.elementtype = 'task' AND pt.fk_projet IN (".$this->db->sanitize($ids).")";
} elseif ($type == 'stock_mouvement') {
$sql = "SELECT ms.rowid, ms.fk_user_author as fk_user FROM ".MAIN_DB_PREFIX."stock_mouvement as ms, ".MAIN_DB_PREFIX."entrepot as e WHERE e.rowid = ms.fk_entrepot AND e.entity IN (".getEntity('stock').") AND ms.origintype = 'project' AND ms.fk_origin IN (".$this->db->sanitize($ids).") AND ms.type_mouvement = 1";
} elseif ($type == 'loan') {
@@ -1041,8 +1042,8 @@ class Project extends CommonObject
$sql = "SELECT COUNT(ed.rowid) as nb FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."expensereport_det as ed WHERE e.rowid = ed.fk_expensereport AND e.entity IN (".getEntity('expensereport').") AND ed.fk_projet = ".((int) $this->id);
} elseif ($type == 'project_task') {
$sql = "SELECT DISTINCT COUNT(pt.rowid) as nb FROM ".MAIN_DB_PREFIX."projet_task as pt WHERE pt.fk_projet = ".((int) $this->id);
- } elseif ($type == 'project_task_time') { // Case we want to duplicate line foreach user
- $sql = "SELECT DISTINCT COUNT(pt.rowid) as nb FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet = ".((int) $this->id);
+ } elseif ($type == 'element_time') { // Case we want to duplicate line foreach user
+ $sql = "SELECT DISTINCT COUNT(pt.rowid) as nb FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."element_time as ptt WHERE pt.rowid = ptt.fk_element AND ptt.elementtype = 'task' AND pt.fk_projet = ".((int) $this->id);
} elseif ($type == 'stock_mouvement') {
$sql = "SELECT COUNT(ms.rowid) as nb FROM ".MAIN_DB_PREFIX."stock_mouvement as ms, ".MAIN_DB_PREFIX."entrepot as e WHERE e.rowid = ms.fk_entrepot AND e.entity IN (".getEntity('stock').") AND ms.origintype = 'project' AND ms.fk_origin = ".((int) $this->id)." AND ms.type_mouvement = 1";
} elseif ($type == 'loan') {
@@ -2017,14 +2018,15 @@ class Project extends CommonObject
dol_print_error('', 'Error datestart parameter is empty');
}
- $sql = "SELECT ptt.rowid as taskid, ptt.task_duration, ptt.task_date, ptt.task_datehour, ptt.fk_task";
- $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time AS ptt, ".MAIN_DB_PREFIX."projet_task as pt";
- $sql .= " WHERE ptt.fk_task = pt.rowid";
+ $sql = "SELECT ptt.rowid as taskid, ptt.element_duration, ptt.element_date, ptt.element_datehour, ptt.fk_element";
+ $sql .= " FROM ".MAIN_DB_PREFIX."element_time AS ptt, ".MAIN_DB_PREFIX."projet_task as pt";
+ $sql .= " WHERE ptt.fk_element = pt.rowid";
+ $sql .= " AND ptt.elementtype = 'task'";
$sql .= " AND pt.fk_projet = ".((int) $this->id);
- $sql .= " AND (ptt.task_date >= '".$this->db->idate($datestart)."' ";
- $sql .= " AND ptt.task_date <= '".$this->db->idate(dol_time_plus_duree($datestart, 1, 'w') - 1)."')";
+ $sql .= " AND (ptt.element_date >= '".$this->db->idate($datestart)."' ";
+ $sql .= " AND ptt.element_date <= '".$this->db->idate(dol_time_plus_duree($datestart, 1, 'w') - 1)."')";
if ($taskid) {
- $sql .= " AND ptt.fk_task=".((int) $taskid);
+ $sql .= " AND ptt.fk_element=".((int) $taskid);
}
if (is_numeric($userid)) {
$sql .= " AND ptt.fk_user=".((int) $userid);
@@ -2040,13 +2042,13 @@ class Project extends CommonObject
// Loop on each record found, so each couple (project id, task id)
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
- $day = $this->db->jdate($obj->task_date); // task_date is date without hours
+ $day = $this->db->jdate($obj->element_date); // task_date is date without hours
if (empty($daylareadyfound[$day])) {
- $this->weekWorkLoad[$day] = $obj->task_duration;
- $this->weekWorkLoadPerTask[$day][$obj->fk_task] = $obj->task_duration;
+ $this->weekWorkLoad[$day] = $obj->element_duration;
+ $this->weekWorkLoadPerTask[$day][$obj->fk_element] = $obj->element_duration;
} else {
- $this->weekWorkLoad[$day] += $obj->task_duration;
- $this->weekWorkLoadPerTask[$day][$obj->fk_task] += $obj->task_duration;
+ $this->weekWorkLoad[$day] += $obj->element_duration;
+ $this->weekWorkLoadPerTask[$day][$obj->fk_element] += $obj->element_duration;
}
$daylareadyfound[$day] = 1;
$i++;
@@ -2080,14 +2082,15 @@ class Project extends CommonObject
dol_print_error('', 'Error datestart parameter is empty');
}
- $sql = "SELECT ptt.rowid as taskid, ptt.task_duration, ptt.task_date, ptt.task_datehour, ptt.fk_task";
- $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time AS ptt, ".MAIN_DB_PREFIX."projet_task as pt";
- $sql .= " WHERE ptt.fk_task = pt.rowid";
+ $sql = "SELECT ptt.rowid as taskid, ptt.element_duration, ptt.element_date, ptt.element_datehour, ptt.fk_element";
+ $sql .= " FROM ".MAIN_DB_PREFIX."element_time AS ptt, ".MAIN_DB_PREFIX."projet_task as pt";
+ $sql .= " WHERE ptt.fk_element = pt.rowid";
+ $sql .= " AND ptt.elementtype = 'task'";
$sql .= " AND pt.fk_projet = ".((int) $this->id);
- $sql .= " AND (ptt.task_date >= '".$this->db->idate($datestart)."' ";
- $sql .= " AND ptt.task_date <= '".$this->db->idate(dol_time_plus_duree($datestart, 1, 'm') - 1)."')";
+ $sql .= " AND (ptt.element_date >= '".$this->db->idate($datestart)."' ";
+ $sql .= " AND ptt.element_date <= '".$this->db->idate(dol_time_plus_duree($datestart, 1, 'm') - 1)."')";
if ($taskid) {
- $sql .= " AND ptt.fk_task=".((int) $taskid);
+ $sql .= " AND ptt.fk_element=".((int) $taskid);
}
if (is_numeric($userid)) {
$sql .= " AND ptt.fk_user=".((int) $userid);
@@ -2103,16 +2106,16 @@ class Project extends CommonObject
// Loop on each record found, so each couple (project id, task id)
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
- if (!empty($obj->task_date)) {
- $date = explode('-', $obj->task_date);
+ if (!empty($obj->element_date)) {
+ $date = explode('-', $obj->element_date);
$week_number = getWeekNumber($date[2], $date[1], $date[0]);
}
if (empty($weekalreadyfound[$week_number])) {
- $this->monthWorkLoad[$week_number] = $obj->task_duration;
- $this->monthWorkLoadPerTask[$week_number][$obj->fk_task] = $obj->task_duration;
+ $this->monthWorkLoad[$week_number] = $obj->element_duration;
+ $this->monthWorkLoadPerTask[$week_number][$obj->fk_element] = $obj->element_duration;
} else {
- $this->monthWorkLoad[$week_number] += $obj->task_duration;
- $this->monthWorkLoadPerTask[$week_number][$obj->fk_task] += $obj->task_duration;
+ $this->monthWorkLoad[$week_number] += $obj->element_duration;
+ $this->monthWorkLoadPerTask[$week_number][$obj->fk_element] += $obj->element_duration;
}
$weekalreadyfound[$week_number] = 1;
$i++;
@@ -2384,7 +2387,10 @@ class Project extends CommonObject
*/
public function getKanbanView($option = '')
{
- global $langs,$user;
+ global $langs, $user;
+
+ $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
+
$return = '
'."\n";
} else {
- print $morphys[$conf->global->MEMBER_NEWFORM_FORCEMORPHY];
+ //print $morphys[$conf->global->MEMBER_NEWFORM_FORCEMORPHY];
print '';
}
diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php
index 2777e48c7f5..4ee7a4a77ca 100644
--- a/htdocs/public/payment/paymentok.php
+++ b/htdocs/public/payment/paymentok.php
@@ -354,7 +354,7 @@ if (empty($ipaddress)) {
$ipaddress = $_SESSION['ipaddress'];
}
if (empty($TRANSACTIONID)) {
- $TRANSACTIONID = $_SESSION['TRANSACTIONID'];
+ $TRANSACTIONID = $_SESSION['TRANSACTIONID']; // pi_... or ch_...
if (empty($TRANSACTIONID) && GETPOST('payment_intent', 'alphanohtml')) {
// For the case we use STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION = 2
$TRANSACTIONID = GETPOST('payment_intent', 'alphanohtml');
@@ -856,7 +856,8 @@ if ($ispaymentok) {
$paiement->paiementid = $paymentTypeId;
$paiement->num_payment = '';
$paiement->note_public = 'Online payment '.dol_print_date($now, 'standard').' from '.$ipaddress;
- $paiement->ext_payment_id = $TRANSACTIONID;
+ $paiement->ext_payment_id = $TRANSACTIONID; // TODO LDR May be we should store py_... instead of pi_... but we started with pi_... so we continue.
+ //$paiement->ext_payment_id = $TRANSACTIONID.':'.$customer->id.'@'.$stripearrayofkeysbyenv[$servicestatus]['publishable_key']; // TODO LDR It would be better if we could store this. Do we have customer->id and publishable_key ?
$paiement->ext_payment_site = $service;
if (!$error) {
@@ -973,8 +974,8 @@ if ($ispaymentok) {
$paiement->paiementid = $paymentTypeId;
$paiement->num_payment = '';
$paiement->note_public = 'Online payment ' . dol_print_date($now, 'standard') . ' from ' . $ipaddress;
- $paiement->ext_payment_id = $TRANSACTIONID;
- $paiement->ext_payment_site = '';
+ $paiement->ext_payment_id = $TRANSACTIONID; // pi_... for Stripe, ...
+ $paiement->ext_payment_site = $service; // 'StripeLive' or 'Stripe', or ...
if (!$error) {
$paiement_id = $paiement->create($user, 1); // This include closing invoices and regenerating documents
diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php
index 9c10041a64e..5d0944e9738 100644
--- a/htdocs/public/stripe/ipn.php
+++ b/htdocs/public/stripe/ipn.php
@@ -34,6 +34,11 @@ if (is_numeric($entity)) {
define("DOLENTITY", $entity);
}
+// So log file will have a suffix
+if (!defined('USESUFFIXINLOG')) {
+ define('USESUFFIXINLOG', '_stripeipn');
+}
+
// Load Dolibarr environment
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
@@ -311,9 +316,7 @@ if ($event->type == 'payout.created') {
} elseif ($event->type == 'payment_intent.succeeded') { // Called when making payment with PaymentIntent method ($conf->global->STRIPE_USE_NEW_CHECKOUT is on).
dol_syslog("object = ".var_export($event->data, true));
- // TODO: create fees
-
- /* TODO LMR Enable this only if this is a payment of a Dolibarr bon_prelevement only
+ /* TODO LMR We must retreive the invoice and payment amount from the id = ext_payment_id into llx_prelevement_demande
include_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php';
$object = $event->data->object;
$invoice_id = $object->metadata->dol_id;
@@ -330,20 +333,23 @@ if ($event->type == 'payout.created') {
global $stripearrayofkeysbyenv;
$stripeacc = $stripearrayofkeysbyenv[$servicestatus]['secret_key'];
- dol_syslog("Try to create sepa_debit with data = ".json_encode($dataforcard));
+ dol_syslog("Try to create payment with data = ".json_encode($dataforcard));
$s = new \Stripe\StripeClient($stripeacc);
$paymentmethodstripe = $s->paymentMethods->retrieve($paymentmethodstripeid);
- //$paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS;
$paymentTypeId = $paymentmethodstripe->type;
- if ($paymentTypeId == "sepa_debit") {
+ if ($paymentTypeId == "ban") {
+ $paymentTypeId = "PRE"
+ } elseif ($paymentTypeId == "sepa_debit") { // is this used ? how ?
$paymentTypeId = "BANCON";
} elseif ($paymentTypeId == "card") {
$paymentTypeId = "CB";
}
+ // TODO LMR Enable this only if this is a payment of a Dolibarr llx_prelevement_demande only
+
$paiement = new Paiement($db);
$paiement->datepaye = $now;
$paiement->date = $now;
@@ -359,13 +365,16 @@ if ($event->type == 'payout.created') {
$errorforinvoice++;
}
$paiement->paiementid = $paymentTypeId;
- $paiement->num_paiement = '';
$paiement->num_payment = '';
- // Add a comment with keyword 'SellYourSaas' in text. Used by trigger.
- $paiement->note_public = 'StripeSepa payment ' . dol_print_date($now, 'standard') . ' using ' . $paymentmethod . ($ipaddress ? ' from ip ' . $ipaddress : '') . ' - Transaction ID = ' . $TRANSACTIONID;
+ $paiement->note_public = '';
$paiement->note_private = 'StripeSepa payment ' . dol_print_date($now, 'standard') . ' using ' . $paymentmethod . ($ipaddress ? ' from ip ' . $ipaddress : '') . ' - Transaction ID = ' . $TRANSACTIONID;
- $paiement->ext_payment_id = $TRANSACTIONID . ':' . $customer_id . '@' . $stripearrayofkeysbyenv[$servicestatus]['publishable_key'];
- $paiement->ext_payment_site = 'stripe';
+ // TODO LMR Fill the $paiement->ext_payment_id with an ID of payment intent (so 'pi_....'). Like this:
+ $paiement->ext_payment_id = $TRANSACTIONID.':'.$customer_id.'@'.$stripearrayofkeysbyenv[$servicestatus]['publishable_key']; // May be we should store py_... instead of pi_... but we started with pi_... so we continue.
+ $paiement->ext_payment_site = $service; // 'StripeLive' or 'Stripe' if test
+
+
+ $db->begin();
+
if (!$errorforinvoice) {
dol_syslog('* Record payment for invoice id ' . $invoice_id . '. It includes closing of invoice and regenerating document');
diff --git a/htdocs/public/ticket/view.php b/htdocs/public/ticket/view.php
index 1bfc235ff65..67b582c0afd 100644
--- a/htdocs/public/ticket/view.php
+++ b/htdocs/public/ticket/view.php
@@ -218,6 +218,9 @@ include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
$form = new Form($db);
$formticket = new FormTicket($db);
+// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
+$hookmanager->initHooks(array('ticketpublicview', 'globalcard'));
+
if (!$conf->global->TICKET_ENABLE_PUBLIC_INTERFACE) {
print '