|
@@ -52,19 +52,19 @@
|
|
|
class Form
|
|
|
{
|
|
|
/**
|
|
|
- * @var DoliDB Database handler.
|
|
|
- */
|
|
|
- public $db;
|
|
|
+ * @var DoliDB Database handler.
|
|
|
+ */
|
|
|
+ public $db;
|
|
|
|
|
|
/**
|
|
|
* @var string Error code (or message)
|
|
|
*/
|
|
|
public $error = '';
|
|
|
|
|
|
- /**
|
|
|
- * @var string[] Array of error strings
|
|
|
- */
|
|
|
- public $errors = array();
|
|
|
+ /**
|
|
|
+ * @var string[] Array of error strings
|
|
|
+ */
|
|
|
+ public $errors = array();
|
|
|
|
|
|
public $num;
|
|
|
|
|
@@ -103,8 +103,8 @@ class Form
|
|
|
* @param string $help Tooltip help
|
|
|
* @return string HTML edit field
|
|
|
*/
|
|
|
- public function editfieldkey($text, $htmlname, $preselected, $object, $perm, $typeofdata = 'string', $moreparam = '', $fieldrequired = 0, $notabletag = 0, $paramid = 'id', $help = '')
|
|
|
- {
|
|
|
+ public function editfieldkey($text, $htmlname, $preselected, $object, $perm, $typeofdata = 'string', $moreparam = '', $fieldrequired = 0, $notabletag = 0, $paramid = 'id', $help = '')
|
|
|
+ {
|
|
|
global $conf, $langs;
|
|
|
|
|
|
$ret = '';
|
|
@@ -157,7 +157,7 @@ class Form
|
|
|
}
|
|
|
|
|
|
return $ret;
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* Output value of a field for an editable field
|
|
@@ -177,7 +177,7 @@ class Form
|
|
|
* @param string $paramid Key of parameter for id ('id', 'socid')
|
|
|
* @return string HTML edit field
|
|
|
*/
|
|
|
- public function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata = 'string', $editvalue = '', $extObject = null, $custommsg = null, $moreparam = '', $notabletag = 0, $formatfunc = '', $paramid = 'id')
|
|
|
+ public function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata = 'string', $editvalue = '', $extObject = null, $custommsg = null, $moreparam = '', $notabletag = 0, $formatfunc = '', $paramid = 'id')
|
|
|
{
|
|
|
global $conf, $langs, $db;
|
|
|
|
|
@@ -243,7 +243,7 @@ class Form
|
|
|
elseif (preg_match('/^select;/', $typeofdata))
|
|
|
{
|
|
|
$arraydata = explode(',', preg_replace('/^select;/', '', $typeofdata));
|
|
|
- $arraylist = array();
|
|
|
+ $arraylist = array();
|
|
|
foreach ($arraydata as $val)
|
|
|
{
|
|
|
$tmp = explode(':', $val);
|
|
@@ -254,7 +254,7 @@ class Form
|
|
|
}
|
|
|
elseif (preg_match('/^ckeditor/', $typeofdata))
|
|
|
{
|
|
|
- $tmp = explode(':', $typeofdata); // Example: ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols:uselocalbrowser
|
|
|
+ $tmp = explode(':', $typeofdata); // Example: ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols:uselocalbrowser
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
|
|
$doleditor = new DolEditor($htmlname, ($editvalue ? $editvalue : $value), ($tmp[2] ? $tmp[2] : ''), ($tmp[3] ? $tmp[3] : '100'), ($tmp[1] ? $tmp[1] : 'dolibarr_notes'), 'In', ($tmp[5] ? $tmp[5] : 0), (isset($tmp[8]) ? ($tmp[8] ?true:false) : true), true, ($tmp[6] ? $tmp[6] : '20'), ($tmp[7] ? $tmp[7] : '100'));
|
|
|
$ret .= $doleditor->Create(1);
|
|
@@ -263,12 +263,12 @@ class Form
|
|
|
|
|
|
if (empty($notabletag)) $ret .= '<td class="left">';
|
|
|
//else $ret.='<div class="clearboth"></div>';
|
|
|
- $ret .= '<input type="submit" class="button'.(empty($notabletag) ? '' : ' ').'" name="modify" value="'.$langs->trans("Modify").'">';
|
|
|
- if (preg_match('/ckeditor|textarea/', $typeofdata) && empty($notabletag)) $ret .= '<br>'."\n";
|
|
|
- $ret .= '<input type="submit" class="button'.(empty($notabletag) ? '' : ' ').'" name="cancel" value="'.$langs->trans("Cancel").'">';
|
|
|
- if (empty($notabletag)) $ret .= '</td>';
|
|
|
+ $ret .= '<input type="submit" class="button'.(empty($notabletag) ? '' : ' ').'" name="modify" value="'.$langs->trans("Modify").'">';
|
|
|
+ if (preg_match('/ckeditor|textarea/', $typeofdata) && empty($notabletag)) $ret .= '<br>'."\n";
|
|
|
+ $ret .= '<input type="submit" class="button'.(empty($notabletag) ? '' : ' ').'" name="cancel" value="'.$langs->trans("Cancel").'">';
|
|
|
+ if (empty($notabletag)) $ret .= '</td>';
|
|
|
|
|
|
- if (empty($notabletag)) $ret .= '</tr></table>'."\n";
|
|
|
+ if (empty($notabletag)) $ret .= '</tr></table>'."\n";
|
|
|
$ret .= '</form>'."\n";
|
|
|
}
|
|
|
else
|
|
@@ -282,7 +282,7 @@ class Form
|
|
|
elseif (preg_match('/^select;/', $typeofdata))
|
|
|
{
|
|
|
$arraydata = explode(',', preg_replace('/^select;/', '', $typeofdata));
|
|
|
- $arraylist = array();
|
|
|
+ $arraylist = array();
|
|
|
foreach ($arraydata as $val)
|
|
|
{
|
|
|
$tmp = explode(':', $val);
|
|
@@ -492,8 +492,8 @@ class Form
|
|
|
{
|
|
|
if (!empty($custommsg['success']))
|
|
|
$out .= '<input id="successmsg_'.$htmlname.'" value="'.$custommsg['success'].'" type="hidden"/>'."\n";
|
|
|
- if (!empty($custommsg['error']))
|
|
|
- $out .= '<input id="errormsg_'.$htmlname.'" value="'.$custommsg['error'].'" type="hidden"/>'."\n";
|
|
|
+ if (!empty($custommsg['error']))
|
|
|
+ $out .= '<input id="errormsg_'.$htmlname.'" value="'.$custommsg['error'].'" type="hidden"/>'."\n";
|
|
|
}
|
|
|
else
|
|
|
$out .= '<input id="successmsg_'.$htmlname.'" value="'.$custommsg.'" type="hidden"/>'."\n";
|
|
@@ -532,7 +532,7 @@ class Form
|
|
|
* @see textwithpicto() Use thisfunction if you can.
|
|
|
* TODO Move this as static as soon as everybody use textwithpicto or @Form::textwithtooltip
|
|
|
*/
|
|
|
- public function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img = '', $extracss = '', $notabs = 3, $incbefore = '', $noencodehtmltext = 0, $tooltiptrigger = '', $forcenowrap = 0)
|
|
|
+ public function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img = '', $extracss = '', $notabs = 3, $incbefore = '', $noencodehtmltext = 0, $tooltiptrigger = '', $forcenowrap = 0)
|
|
|
{
|
|
|
if ($incbefore) $text = $incbefore.$text;
|
|
|
if (!$htmltext) return $text;
|
|
@@ -613,7 +613,7 @@ class Form
|
|
|
* @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)
|
|
|
+ public function textwithpicto($text, $htmltext, $direction = 1, $type = 'help', $extracss = '', $noencodehtmltext = 0, $notabs = 3, $tooltiptrigger = '', $forcenowrap = 0)
|
|
|
{
|
|
|
global $conf, $langs;
|
|
|
|
|
@@ -643,7 +643,7 @@ class Form
|
|
|
// If info or help with smartphone, show only text (tooltip on click does not works with dialog on smaprtphone)
|
|
|
//if (! empty($conf->dol_no_mouse_hover) && ! empty($tooltiptrigger))
|
|
|
//{
|
|
|
- //if ($type == 'info' || $type == 'help') return '<a href="'..'">'.$text.''</a>';
|
|
|
+ //if ($type == 'info' || $type == 'help') return '<a href="'..'">'.$text.''</a>';
|
|
|
//}
|
|
|
|
|
|
$img = '';
|
|
@@ -666,7 +666,7 @@ class Form
|
|
|
* @param int $alwaysvisible 1=select button always visible
|
|
|
* @return string|void Select list
|
|
|
*/
|
|
|
- public function selectMassAction($selected, $arrayofaction, $alwaysvisible = 0)
|
|
|
+ public function selectMassAction($selected, $arrayofaction, $alwaysvisible = 0)
|
|
|
{
|
|
|
global $conf, $langs, $hookmanager;
|
|
|
|
|
@@ -760,7 +760,7 @@ class Form
|
|
|
return $ret;
|
|
|
}
|
|
|
|
|
|
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
|
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
|
/**
|
|
|
* Return combo list of activated countries, into language of user
|
|
|
*
|
|
@@ -776,9 +776,9 @@ class Form
|
|
|
* @param array $exclude_country_code Array of country code (iso2) to exclude
|
|
|
* @return string HTML string with select
|
|
|
*/
|
|
|
- public function select_country($selected = '', $htmlname = 'country_id', $htmloption = '', $maxlength = 0, $morecss = 'minwidth300', $usecodeaskey = '', $showempty = 1, $disablefavorites = 0, $addspecialentries = 0, $exclude_country_code = array())
|
|
|
+ public function select_country($selected = '', $htmlname = 'country_id', $htmloption = '', $maxlength = 0, $morecss = 'minwidth300', $usecodeaskey = '', $showempty = 1, $disablefavorites = 0, $addspecialentries = 0, $exclude_country_code = array())
|
|
|
{
|
|
|
- // phpcs:enable
|
|
|
+ // phpcs:enable
|
|
|
global $conf, $langs, $mysoc;
|
|
|
|
|
|
$langs->load("dict");
|
|
@@ -878,7 +878,7 @@ class Form
|
|
|
return $out;
|
|
|
}
|
|
|
|
|
|
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
|
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
|
/**
|
|
|
* Return select list of incoterms
|
|
|
*
|
|
@@ -891,9 +891,9 @@ class Form
|
|
|
* @param array $events Event options to run on change. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
|
|
|
* @return string HTML string with select and input
|
|
|
*/
|
|
|
- public function select_incoterms($selected = '', $location_incoterms = '', $page = '', $htmlname = 'incoterm_id', $htmloption = '', $forcecombo = 1, $events = array())
|
|
|
+ public function select_incoterms($selected = '', $location_incoterms = '', $page = '', $htmlname = 'incoterm_id', $htmloption = '', $forcecombo = 1, $events = array())
|
|
|
{
|
|
|
- // phpcs:enable
|
|
|
+ // phpcs:enable
|
|
|
global $conf, $langs;
|
|
|
|
|
|
$langs->load("dict");
|
|
@@ -972,7 +972,7 @@ class Form
|
|
|
return $out;
|
|
|
}
|
|
|
|
|
|
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
|
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
|
/**
|
|
|
* Return list of types of lines (product or service)
|
|
|
* Example: 0=product, 1=service, 9=other (for external module)
|
|
@@ -984,14 +984,14 @@ class Form
|
|
|
* @param integer $forceall 1=Force to show products and services in combo list, whatever are activated modules, 0=No force, 2=Force to show only Products, 3=Force to show only services, -1=Force none (and set hidden field to 'service')
|
|
|
* @return void
|
|
|
*/
|
|
|
- public function select_type_of_lines($selected = '', $htmlname = 'type', $showempty = 0, $hidetext = 0, $forceall = 0)
|
|
|
+ public function select_type_of_lines($selected = '', $htmlname = 'type', $showempty = 0, $hidetext = 0, $forceall = 0)
|
|
|
{
|
|
|
- // phpcs:enable
|
|
|
+ // phpcs:enable
|
|
|
global $db, $langs, $user, $conf;
|
|
|
|
|
|
// If product & services are enabled or both disabled.
|
|
|
if ($forceall == 1 || (empty($forceall) && !empty($conf->product->enabled) && !empty($conf->service->enabled))
|
|
|
- || (empty($forceall) && empty($conf->product->enabled) && empty($conf->service->enabled)))
|
|
|
+ || (empty($forceall) && empty($conf->product->enabled) && empty($conf->service->enabled)))
|
|
|
{
|
|
|
if (empty($hidetext)) print $langs->trans("Type").': ';
|
|
|
print '<select class="flat" id="select_'.$htmlname.'" name="'.$htmlname.'">';
|
|
@@ -1029,15 +1029,15 @@ class Form
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
|
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
|
/**
|
|
|
* Load into cache cache_types_fees, array of types of fees
|
|
|
*
|
|
|
* @return int Nb of lines loaded, <0 if KO
|
|
|
*/
|
|
|
- public function load_cache_types_fees()
|
|
|
+ public function load_cache_types_fees()
|
|
|
{
|
|
|
- // phpcs:enable
|
|
|
+ // phpcs:enable
|
|
|
global $langs;
|
|
|
|
|
|
$num = count($this->cache_types_fees);
|
|
@@ -1078,7 +1078,7 @@ class Form
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
|
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
|
/**
|
|
|
* Return list of types of notes
|
|
|
*
|
|
@@ -1087,9 +1087,9 @@ class Form
|
|
|
* @param int $showempty Add an empty field
|
|
|
* @return void
|
|
|
*/
|
|
|
- public function select_type_fees($selected = '', $htmlname = 'type', $showempty = 0)
|
|
|
+ public function select_type_fees($selected = '', $htmlname = 'type', $showempty = 0)
|
|
|
{
|
|
|
- // phpcs:enable
|
|
|
+ // phpcs:enable
|
|
|
global $user, $langs;
|
|
|
|
|
|
dol_syslog(__METHOD__." selected=".$selected.", htmlname=".$htmlname, LOG_DEBUG);
|
|
@@ -1118,7 +1118,7 @@ class Form
|
|
|
}
|
|
|
|
|
|
|
|
|
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
|
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
|
/**
|
|
|
* Return HTML code to select a company.
|
|
|
*
|
|
@@ -1131,13 +1131,13 @@ class Form
|
|
|
* @return string Return select box for thirdparty.
|
|
|
* @deprecated 3.8 Use select_company instead. For exemple $form->select_thirdparty(GETPOST('socid'),'socid','',0) => $form->select_company(GETPOST('socid'),'socid','',1,0,0,array(),0)
|
|
|
*/
|
|
|
- public function select_thirdparty($selected = '', $htmlname = 'socid', $filter = '', $limit = 20, $ajaxoptions = array(), $forcecombo = 0)
|
|
|
+ public function select_thirdparty($selected = '', $htmlname = 'socid', $filter = '', $limit = 20, $ajaxoptions = array(), $forcecombo = 0)
|
|
|
{
|
|
|
- // phpcs:enable
|
|
|
- return $this->select_thirdparty_list($selected, $htmlname, $filter, 1, 0, $forcecombo, array(), '', 0, $limit);
|
|
|
+ // phpcs:enable
|
|
|
+ return $this->select_thirdparty_list($selected, $htmlname, $filter, 1, 0, $forcecombo, array(), '', 0, $limit);
|
|
|
}
|
|
|
|
|
|
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
|
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
|
/**
|
|
|
* Output html form to select a third party
|
|
|
*
|
|
@@ -1157,9 +1157,9 @@ class Form
|
|
|
* @param bool $multiple add [] in the name of element and add 'multiple' attribut (not working with ajax_autocompleter)
|
|
|
* @return string HTML string with select box for thirdparty.
|
|
|
*/
|
|
|
- public function select_company($selected = '', $htmlname = 'socid', $filter = '', $showempty = '', $showtype = 0, $forcecombo = 0, $events = array(), $limit = 0, $morecss = 'minwidth100', $moreparam = '', $selected_input_value = '', $hidelabel = 1, $ajaxoptions = array(), $multiple = false)
|
|
|
+ public function select_company($selected = '', $htmlname = 'socid', $filter = '', $showempty = '', $showtype = 0, $forcecombo = 0, $events = array(), $limit = 0, $morecss = 'minwidth100', $moreparam = '', $selected_input_value = '', $hidelabel = 1, $ajaxoptions = array(), $multiple = false)
|
|
|
{
|
|
|
- // phpcs:enable
|
|
|
+ // phpcs:enable
|
|
|
global $conf, $user, $langs;
|
|
|
|
|
|
$out = '';
|
|
@@ -1201,7 +1201,7 @@ class Form
|
|
|
return $out;
|
|
|
}
|
|
|
|
|
|
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
|
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
|
/**
|
|
|
* Output html form to select a third party.
|
|
|
* Note, you must use the select_company to get the component to select a third party. This function must only be called by select_company.
|
|
@@ -1221,9 +1221,9 @@ class Form
|
|
|
* @param bool $multiple add [] in the name of element and add 'multiple' attribut
|
|
|
* @return string HTML string with
|
|
|
*/
|
|
|
- public function select_thirdparty_list($selected = '', $htmlname = 'socid', $filter = '', $showempty = '', $showtype = 0, $forcecombo = 0, $events = array(), $filterkey = '', $outputmode = 0, $limit = 0, $morecss = 'minwidth100', $moreparam = '', $multiple = false)
|
|
|
+ public function select_thirdparty_list($selected = '', $htmlname = 'socid', $filter = '', $showempty = '', $showtype = 0, $forcecombo = 0, $events = array(), $filterkey = '', $outputmode = 0, $limit = 0, $morecss = 'minwidth100', $moreparam = '', $multiple = false)
|
|
|
{
|
|
|
- // phpcs:enable
|
|
|
+ // phpcs:enable
|
|
|
global $conf, $user, $langs;
|
|
|
|
|
|
$out = '';
|
|
@@ -1245,7 +1245,7 @@ class Form
|
|
|
|
|
|
if ($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST) {
|
|
|
$sql .= ", s.address, s.zip, s.town";
|
|
|
- $sql .= ", dictp.code as country_code";
|
|
|
+ $sql .= ", dictp.code as country_code";
|
|
|
}
|
|
|
|
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
|
@@ -1288,7 +1288,7 @@ class Form
|
|
|
$resql = $this->db->query($sql);
|
|
|
if ($resql)
|
|
|
{
|
|
|
- if (!$forcecombo)
|
|
|
+ if (!$forcecombo)
|
|
|
{
|
|
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
|
|
|
$out .= ajax_combobox($htmlname, $events, $conf->global->COMPANY_USE_SEARCH_TO_SELECT);
|
|
@@ -1383,7 +1383,7 @@ class Form
|
|
|
}
|
|
|
|
|
|
|
|
|
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
|
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
|
/**
|
|
|
* Return HTML combo list of absolute discounts
|
|
|
*
|
|
@@ -1394,9 +1394,9 @@ class Form
|
|
|
* @param int $maxvalue Max value for lines that can be selected
|
|
|
* @return int Return number of qualifed lines in list
|
|
|
*/
|
|
|
- public function select_remises($selected, $htmlname, $filter, $socid, $maxvalue = 0)
|
|
|
+ public function select_remises($selected, $htmlname, $filter, $socid, $maxvalue = 0)
|
|
|
{
|
|
|
- // phpcs:enable
|
|
|
+ // phpcs:enable
|
|
|
global $langs, $conf;
|
|
|
|
|
|
// On recherche les remises
|
|
@@ -1460,7 +1460,7 @@ class Form
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
|
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
|
/**
|
|
|
* Return list of all contacts (for a third party or all)
|
|
|
*
|
|
@@ -1481,12 +1481,12 @@ class Form
|
|
|
* @return int <0 if KO, Nb of contact in list if OK
|
|
|
* @deprected You can use selectcontacts directly (warning order of param was changed)
|
|
|
*/
|
|
|
- public function select_contacts($socid, $selected = '', $htmlname = 'contactid', $showempty = 0, $exclude = '', $limitto = '', $showfunction = 0, $moreclass = '', $showsoc = 0, $forcecombo = 0, $events = array(), $options_only = false, $moreparam = '', $htmlid = '')
|
|
|
- {
|
|
|
- // phpcs:enable
|
|
|
+ public function select_contacts($socid, $selected = '', $htmlname = 'contactid', $showempty = 0, $exclude = '', $limitto = '', $showfunction = 0, $moreclass = '', $showsoc = 0, $forcecombo = 0, $events = array(), $options_only = false, $moreparam = '', $htmlid = '')
|
|
|
+ {
|
|
|
+ // phpcs:enable
|
|
|
print $this->selectcontacts($socid, $selected, $htmlname, $showempty, $exclude, $limitto, $showfunction, $moreclass, $options_only, $showsoc, $forcecombo, $events, $moreparam, $htmlid);
|
|
|
return $this->num;
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* Return HTML code of the SELECT of list of all contacts (for a third party or all).
|
|
@@ -1511,8 +1511,8 @@ class Form
|
|
|
* @param bool $multiple add [] in the name of element and add 'multiple' attribut
|
|
|
* @return int <0 if KO, Nb of contact in list if OK
|
|
|
*/
|
|
|
- public function selectcontacts($socid, $selected = '', $htmlname = 'contactid', $showempty = 0, $exclude = '', $limitto = '', $showfunction = 0, $moreclass = '', $options_only = false, $showsoc = 0, $forcecombo = 0, $events = array(), $moreparam = '', $htmlid = '', $multiple = false)
|
|
|
- {
|
|
|
+ public function selectcontacts($socid, $selected = '', $htmlname = 'contactid', $showempty = 0, $exclude = '', $limitto = '', $showfunction = 0, $moreclass = '', $options_only = false, $showsoc = 0, $forcecombo = 0, $events = array(), $moreparam = '', $htmlid = '', $multiple = false)
|
|
|
+ {
|
|
|
global $conf, $langs, $hookmanager, $action;
|
|
|
|
|
|
$langs->load('companies');
|
|
@@ -1570,42 +1570,42 @@ class Form
|
|
|
$contactstatic->lastname = $obj->lastname;
|
|
|
$contactstatic->firstname = $obj->firstname;
|
|
|
if ($obj->statut == 1) {
|
|
|
- if ($htmlname != 'none')
|
|
|
- {
|
|
|
- $disabled = 0;
|
|
|
- if (is_array($exclude) && count($exclude) && in_array($obj->rowid, $exclude)) $disabled = 1;
|
|
|
- if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) $disabled = 1;
|
|
|
- if (!empty($selected) && in_array($obj->rowid, $selected))
|
|
|
- {
|
|
|
- $out .= '<option value="'.$obj->rowid.'"';
|
|
|
- if ($disabled) $out .= ' disabled';
|
|
|
- $out .= ' selected>';
|
|
|
- $out .= $contactstatic->getFullName($langs);
|
|
|
- if ($showfunction && $obj->poste) $out .= ' ('.$obj->poste.')';
|
|
|
- if (($showsoc > 0) && $obj->company) $out .= ' - ('.$obj->company.')';
|
|
|
- $out .= '</option>';
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- $out .= '<option value="'.$obj->rowid.'"';
|
|
|
- if ($disabled) $out .= ' disabled';
|
|
|
- $out .= '>';
|
|
|
- $out .= $contactstatic->getFullName($langs);
|
|
|
- if ($showfunction && $obj->poste) $out .= ' ('.$obj->poste.')';
|
|
|
- if (($showsoc > 0) && $obj->company) $out .= ' - ('.$obj->company.')';
|
|
|
- $out .= '</option>';
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (in_array($obj->rowid, $selected))
|
|
|
- {
|
|
|
- $out .= $contactstatic->getFullName($langs);
|
|
|
- if ($showfunction && $obj->poste) $out .= ' ('.$obj->poste.')';
|
|
|
- if (($showsoc > 0) && $obj->company) $out .= ' - ('.$obj->company.')';
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ if ($htmlname != 'none')
|
|
|
+ {
|
|
|
+ $disabled = 0;
|
|
|
+ if (is_array($exclude) && count($exclude) && in_array($obj->rowid, $exclude)) $disabled = 1;
|
|
|
+ if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) $disabled = 1;
|
|
|
+ if (!empty($selected) && in_array($obj->rowid, $selected))
|
|
|
+ {
|
|
|
+ $out .= '<option value="'.$obj->rowid.'"';
|
|
|
+ if ($disabled) $out .= ' disabled';
|
|
|
+ $out .= ' selected>';
|
|
|
+ $out .= $contactstatic->getFullName($langs);
|
|
|
+ if ($showfunction && $obj->poste) $out .= ' ('.$obj->poste.')';
|
|
|
+ if (($showsoc > 0) && $obj->company) $out .= ' - ('.$obj->company.')';
|
|
|
+ $out .= '</option>';
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ $out .= '<option value="'.$obj->rowid.'"';
|
|
|
+ if ($disabled) $out .= ' disabled';
|
|
|
+ $out .= '>';
|
|
|
+ $out .= $contactstatic->getFullName($langs);
|
|
|
+ if ($showfunction && $obj->poste) $out .= ' ('.$obj->poste.')';
|
|
|
+ if (($showsoc > 0) && $obj->company) $out .= ' - ('.$obj->company.')';
|
|
|
+ $out .= '</option>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (in_array($obj->rowid, $selected))
|
|
|
+ {
|
|
|
+ $out .= $contactstatic->getFullName($langs);
|
|
|
+ if ($showfunction && $obj->poste) $out .= ' ('.$obj->poste.')';
|
|
|
+ if (($showsoc > 0) && $obj->company) $out .= ' - ('.$obj->company.')';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
$i++;
|
|
|
}
|
|
|
}
|
|
@@ -1642,7 +1642,7 @@ class Form
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
|
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
|
/**
|
|
|
* Return select list of users
|
|
|
*
|
|
@@ -1658,13 +1658,13 @@ class Form
|
|
|
* @deprecated Use select_dolusers instead
|
|
|
* @see select_dolusers()
|
|
|
*/
|
|
|
- public function select_users($selected = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = '0')
|
|
|
+ public function select_users($selected = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = '0')
|
|
|
{
|
|
|
- // phpcs:enable
|
|
|
+ // phpcs:enable
|
|
|
print $this->select_dolusers($selected, $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity);
|
|
|
}
|
|
|
|
|
|
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
|
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
|
/**
|
|
|
* Return select list of users
|
|
|
*
|
|
@@ -1688,9 +1688,9 @@ class Form
|
|
|
* @return string HTML select string
|
|
|
* @see select_dolgroups()
|
|
|
*/
|
|
|
- public function select_dolusers($selected = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = '0', $maxlength = 0, $showstatus = 0, $morefilter = '', $show_every = 0, $enableonlytext = '', $morecss = '', $noactive = 0, $outputmode = 0, $multiple = false)
|
|
|
+ public function select_dolusers($selected = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = '0', $maxlength = 0, $showstatus = 0, $morefilter = '', $show_every = 0, $enableonlytext = '', $morecss = '', $noactive = 0, $outputmode = 0, $multiple = false)
|
|
|
{
|
|
|
- // phpcs:enable
|
|
|
+ // phpcs:enable
|
|
|
global $conf, $user, $langs, $hookmanager;
|
|
|
|
|
|
// If no preselected user defined, we take current user
|
|
@@ -1773,7 +1773,7 @@ class Form
|
|
|
$i = 0;
|
|
|
if ($num)
|
|
|
{
|
|
|
- // Enhance with select2
|
|
|
+ // Enhance with select2
|
|
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
|
|
|
$out .= ajax_combobox($htmlname);
|
|
|
|
|
@@ -1847,7 +1847,7 @@ class Form
|
|
|
{
|
|
|
$out .= ($moreinfo ? ' - ' : ' (').($obj->label ? $obj->label : $langs->trans("EntityNameNotDefined"));
|
|
|
$moreinfo++;
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
$out .= ($moreinfo ? ')' : '');
|
|
|
if ($disableline && $disableline != '1')
|
|
@@ -1877,7 +1877,7 @@ class Form
|
|
|
}
|
|
|
|
|
|
|
|
|
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
|
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
|
/**
|
|
|
* Return select list of users. Selected users are stored into session.
|
|
|
* List of users are provided into $_SESSION['assignedtouser'].
|
|
@@ -1900,9 +1900,9 @@ class Form
|
|
|
* @return string HTML select string
|
|
|
* @see select_dolgroups()
|
|
|
*/
|
|
|
- public function select_dolusers_forevent($action = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = '0', $maxlength = 0, $showstatus = 0, $morefilter = '', $showproperties = 0, $listofuserid = array(), $listofcontactid = array(), $listofotherid = array())
|
|
|
+ public function select_dolusers_forevent($action = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = '0', $maxlength = 0, $showstatus = 0, $morefilter = '', $showproperties = 0, $listofuserid = array(), $listofcontactid = array(), $listofotherid = array())
|
|
|
{
|
|
|
- // phpcs:enable
|
|
|
+ // phpcs:enable
|
|
|
global $conf, $user, $langs;
|
|
|
|
|
|
$userstatic = new User($this->db);
|
|
@@ -1967,7 +1967,7 @@ class Form
|
|
|
}
|
|
|
|
|
|
|
|
|
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
|
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
|
/**
|
|
|
* Return list of products for customer in Ajax if Ajax activated or go to select_produits_list
|
|
|
*
|
|
@@ -1993,9 +1993,9 @@ class Form
|
|
|
* @param array $selected_combinations Selected combinations. Format: array([attrid] => attrval, [...])
|
|
|
* @return void
|
|
|
*/
|
|
|
- public function select_produits($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 20, $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 = array())
|
|
|
+ public function select_produits($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 20, $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 = array())
|
|
|
{
|
|
|
- // phpcs:enable
|
|
|
+ // phpcs:enable
|
|
|
global $langs, $conf;
|
|
|
|
|
|
// check parameters
|
|
@@ -6120,11 +6120,11 @@ class Form
|
|
|
}
|
|
|
if ($tmpfieldstoshow) $fieldstoshow = $tmpfieldstoshow;
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
+ else
|
|
|
+ {
|
|
|
// For backward compatibility
|
|
|
$objecttmp->fields['ref'] = array('type'=>'varchar(30)', 'label'=>'Ref', 'showoncombobox'=>1);
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
if (empty($fieldstoshow))
|
|
|
{
|
|
@@ -6146,100 +6146,107 @@ class Form
|
|
|
|
|
|
// Search data
|
|
|
$sql = "SELECT t.rowid, ".$fieldstoshow." FROM ".MAIN_DB_PREFIX.$objecttmp->table_element." as t";
|
|
|
- if ($objecttmp->ismultientitymanaged == 2)
|
|
|
+ if (isset($objecttmp->ismultientitymanaged) && !is_numeric($objecttmp->ismultientitymanaged)) {
|
|
|
+ $tmparray = explode('@', $objecttmp->ismultientitymanaged);
|
|
|
+ $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.$tmparray[1].' as parenttable ON parenttable.rowid = t.'.$tmparray[0];
|
|
|
+ }
|
|
|
+ if ($objecttmp->ismultientitymanaged == 'fk_soc@societe')
|
|
|
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
|
|
- $sql .= " WHERE 1=1";
|
|
|
- if (!empty($objecttmp->ismultientitymanaged)) $sql .= " AND t.entity IN (".getEntity($objecttmp->table_element).")";
|
|
|
- if ($objecttmp->ismultientitymanaged == 1 && !empty($user->socid)) {
|
|
|
- if ($objecttmp->element == 'societe') $sql .= " AND t.rowid = ".$user->socid;
|
|
|
- else $sql .= " AND t.fk_soc = ".$user->socid;
|
|
|
- }
|
|
|
- if ($searchkey != '') $sql .= natural_search(explode(',', $fieldstoshow), $searchkey);
|
|
|
- if ($objecttmp->ismultientitymanaged == 2) {
|
|
|
- if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND t.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
|
|
|
- }
|
|
|
- if ($objecttmp->filter) { // Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
|
|
|
- /*if (! DolibarrApi::_checkFilters($objecttmp->filter))
|
|
|
- {
|
|
|
- throw new RestException(503, 'Error when validating parameter sqlfilters '.$objecttmp->filter);
|
|
|
- }*/
|
|
|
- $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
|
|
- $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'Form::forgeCriteriaCallback', $objecttmp->filter).")";
|
|
|
- }
|
|
|
- $sql .= $this->db->order($fieldstoshow, "ASC");
|
|
|
- //$sql.=$this->db->plimit($limit, 0);
|
|
|
- //print $sql;
|
|
|
-
|
|
|
- // Build output string
|
|
|
- $resql = $this->db->query($sql);
|
|
|
- if ($resql)
|
|
|
- {
|
|
|
- if (!$forcecombo)
|
|
|
- {
|
|
|
- include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
|
|
|
- $out .= ajax_combobox($htmlname, null, $conf->global->$confkeyforautocompletemode);
|
|
|
- }
|
|
|
+ $sql .= " WHERE 1=1";
|
|
|
+ if (isset($objecttmp->ismultientitymanaged) && $objecttmp->ismultientitymanaged == 1) $sql .= " AND t.entity IN (".getEntity($objecttmp->table_element).")";
|
|
|
+ if (isset($objecttmp->ismultientitymanaged) && !is_numeric($objecttmp->ismultientitymanaged)) {
|
|
|
+ $sql .= ' AND parenttable.entity = t.'.$tmparray[0];
|
|
|
+ }
|
|
|
+ if ($objecttmp->ismultientitymanaged == 1 && !empty($user->socid)) {
|
|
|
+ if ($objecttmp->element == 'societe') $sql .= " AND t.rowid = ".$user->socid;
|
|
|
+ else $sql .= " AND t.fk_soc = ".$user->socid;
|
|
|
+ }
|
|
|
+ if ($searchkey != '') $sql .= natural_search(explode(',', $fieldstoshow), $searchkey);
|
|
|
+ if ($objecttmp->ismultientitymanaged == 'fk_soc@societe') {
|
|
|
+ if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND t.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
|
|
|
+ }
|
|
|
+ if ($objecttmp->filter) { // Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
|
|
|
+ /*if (! DolibarrApi::_checkFilters($objecttmp->filter))
|
|
|
+ {
|
|
|
+ throw new RestException(503, 'Error when validating parameter sqlfilters '.$objecttmp->filter);
|
|
|
+ }*/
|
|
|
+ $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
|
|
+ $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'Form::forgeCriteriaCallback', $objecttmp->filter).")";
|
|
|
+ }
|
|
|
+ $sql .= $this->db->order($fieldstoshow, "ASC");
|
|
|
+ //$sql.=$this->db->plimit($limit, 0);
|
|
|
+ //print $sql;
|
|
|
|
|
|
- // Construct $out and $outarray
|
|
|
- $out .= '<select id="'.$htmlname.'" class="flat'.($morecss ? ' '.$morecss : '').'"'.($disabled ? ' disabled="disabled"' : '').($moreparams ? ' '.$moreparams : '').' name="'.$htmlname.'">'."\n";
|
|
|
+ // Build output string
|
|
|
+ $resql = $this->db->query($sql);
|
|
|
+ if ($resql)
|
|
|
+ {
|
|
|
+ if (!$forcecombo)
|
|
|
+ {
|
|
|
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
|
|
|
+ $out .= ajax_combobox($htmlname, null, $conf->global->$confkeyforautocompletemode);
|
|
|
+ }
|
|
|
|
|
|
- // Warning: Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'. Seems it is no more true with selec2 v4
|
|
|
- $textifempty = ' ';
|
|
|
+ // Construct $out and $outarray
|
|
|
+ $out .= '<select id="'.$htmlname.'" class="flat'.($morecss ? ' '.$morecss : '').'"'.($disabled ? ' disabled="disabled"' : '').($moreparams ? ' '.$moreparams : '').' name="'.$htmlname.'">'."\n";
|
|
|
|
|
|
- //if (! empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
|
|
|
- if (!empty($conf->global->$confkeyforautocompletemode))
|
|
|
- {
|
|
|
- if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
|
|
|
- else $textifempty .= $langs->trans("All");
|
|
|
- }
|
|
|
- if ($showempty) $out .= '<option value="-1">'.$textifempty.'</option>'."\n";
|
|
|
+ // Warning: Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'. Seems it is no more true with selec2 v4
|
|
|
+ $textifempty = ' ';
|
|
|
|
|
|
- $num = $this->db->num_rows($resql);
|
|
|
- $i = 0;
|
|
|
- if ($num)
|
|
|
+ //if (! empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
|
|
|
+ if (!empty($conf->global->$confkeyforautocompletemode))
|
|
|
+ {
|
|
|
+ if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
|
|
|
+ else $textifempty .= $langs->trans("All");
|
|
|
+ }
|
|
|
+ if ($showempty) $out .= '<option value="-1">'.$textifempty.'</option>'."\n";
|
|
|
+
|
|
|
+ $num = $this->db->num_rows($resql);
|
|
|
+ $i = 0;
|
|
|
+ if ($num)
|
|
|
+ {
|
|
|
+ while ($i < $num)
|
|
|
{
|
|
|
- while ($i < $num)
|
|
|
+ $obj = $this->db->fetch_object($resql);
|
|
|
+ $label = '';
|
|
|
+ $tmparray = explode(',', $fieldstoshow);
|
|
|
+ foreach ($tmparray as $key => $val)
|
|
|
{
|
|
|
- $obj = $this->db->fetch_object($resql);
|
|
|
- $label = '';
|
|
|
- $tmparray = explode(',', $fieldstoshow);
|
|
|
- foreach ($tmparray as $key => $val)
|
|
|
- {
|
|
|
- $val = preg_replace('/t\./', '', $val);
|
|
|
- $label .= (($label && $obj->$val) ? ' - ' : '').$obj->$val;
|
|
|
- }
|
|
|
- if (empty($outputmode))
|
|
|
+ $val = preg_replace('/t\./', '', $val);
|
|
|
+ $label .= (($label && $obj->$val) ? ' - ' : '').$obj->$val;
|
|
|
+ }
|
|
|
+ if (empty($outputmode))
|
|
|
+ {
|
|
|
+ if ($preselectedvalue > 0 && $preselectedvalue == $obj->rowid)
|
|
|
{
|
|
|
- if ($preselectedvalue > 0 && $preselectedvalue == $obj->rowid)
|
|
|
- {
|
|
|
- $out .= '<option value="'.$obj->rowid.'" selected>'.$label.'</option>';
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- $out .= '<option value="'.$obj->rowid.'">'.$label.'</option>';
|
|
|
- }
|
|
|
+ $out .= '<option value="'.$obj->rowid.'" selected>'.$label.'</option>';
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- array_push($outarray, array('key'=>$obj->rowid, 'value'=>$label, 'label'=>$label));
|
|
|
+ $out .= '<option value="'.$obj->rowid.'">'.$label.'</option>';
|
|
|
}
|
|
|
-
|
|
|
- $i++;
|
|
|
- if (($i % 10) == 0) $out .= "\n";
|
|
|
}
|
|
|
- }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ array_push($outarray, array('key'=>$obj->rowid, 'value'=>$label, 'label'=>$label));
|
|
|
+ }
|
|
|
|
|
|
- $out .= '</select>'."\n";
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- dol_print_error($this->db);
|
|
|
+ $i++;
|
|
|
+ if (($i % 10) == 0) $out .= "\n";
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- $this->result = array('nbofelement'=>$num);
|
|
|
+ $out .= '</select>'."\n";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ dol_print_error($this->db);
|
|
|
+ }
|
|
|
|
|
|
- if ($outputmode) return $outarray;
|
|
|
- return $out;
|
|
|
+ $this->result = array('nbofelement'=>$num);
|
|
|
+
|
|
|
+ if ($outputmode) return $outarray;
|
|
|
+ return $out;
|
|
|
}
|
|
|
|
|
|
|