forked from Wavyzz/dolibarr
Merge branch 'develop' into 16a12_assets_code
This commit is contained in:
@@ -83,6 +83,11 @@ abstract class CommonObject
|
||||
*/
|
||||
public $element;
|
||||
|
||||
/**
|
||||
* @var string Name to use for 'features' parameter to check module permissions with restrictedArea(). Undefined means same value than $element.
|
||||
*/
|
||||
public $element_for_permission;
|
||||
|
||||
/**
|
||||
* @var string Name of table without prefix where object is stored
|
||||
*/
|
||||
|
||||
@@ -2219,9 +2219,10 @@ class Form
|
||||
* '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)
|
||||
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)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs, $conf;
|
||||
@@ -2261,7 +2262,7 @@ class Form
|
||||
}
|
||||
}
|
||||
// mode=1 means customers products
|
||||
$urloption = 'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished.'&hidepriceinlabel='.$hidepriceinlabel.'&warehousestatus='.$warehouseStatus;
|
||||
$urloption = 'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&status_purchase='.$status_purchase.'&finished='.$finished.'&hidepriceinlabel='.$hidepriceinlabel.'&warehousestatus='.$warehouseStatus;
|
||||
//Price by customer
|
||||
if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) {
|
||||
$urloption .= '&socid='.$socid;
|
||||
@@ -2357,7 +2358,7 @@ class Form
|
||||
$out .= img_picto($langs->trans("Search"), 'search');
|
||||
}
|
||||
} else {
|
||||
$out .= $this->select_produits_list($selected, $htmlname, $filtertype, $limit, $price_level, '', $status, $finished, 0, $socid, $showempty, $forcecombo, $morecss, $hidepriceinlabel, $warehouseStatus);
|
||||
$out .= $this->select_produits_list($selected, $htmlname, $filtertype, $limit, $price_level, '', $status, $finished, 0, $socid, $showempty, $forcecombo, $morecss, $hidepriceinlabel, $warehouseStatus, $status_purchase);
|
||||
}
|
||||
|
||||
if (empty($nooutput)) {
|
||||
@@ -2453,9 +2454,10 @@ class Form
|
||||
* '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 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 = '')
|
||||
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)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs, $conf;
|
||||
@@ -2593,6 +2595,9 @@ class Form
|
||||
} elseif ($status >= 0) {
|
||||
$sql .= " AND p.tosell = ".((int) $status);
|
||||
}
|
||||
if ($status_purchase >= 0) {
|
||||
$sql .= " AND p.tobuy = ".((int) $status_purchase);
|
||||
}
|
||||
// Filter by product type
|
||||
if (strval($filtertype) != '') {
|
||||
$sql .= " AND p.fk_product_type = ".((int) $filtertype);
|
||||
@@ -7379,10 +7384,17 @@ class Form
|
||||
|
||||
$objecttmp = null;
|
||||
|
||||
// Example of value for $objectdec:
|
||||
// Bom:bom/class/bom.class.php:0:t.status=1
|
||||
// Bom:bom/class/bom.class.php:0:t.status=1:ref
|
||||
// Bom:bom/class/bom.class.php:0:(t.status:=:1):ref
|
||||
$InfoFieldList = explode(":", $objectdesc, 4);
|
||||
$vartmp = $InfoFieldList[3];
|
||||
$InfoFieldList[4] = preg_replace('/^.*:(\w*)$/', '\1', $vartmp); // take the sort field
|
||||
$InfoFieldList[3] = preg_replace('/:\w*$/', '', $vartmp); // take the filter field
|
||||
$reg = array();
|
||||
if (preg_match('/^.*:(\w*)$/', $vartmp, $reg)) {
|
||||
$InfoFieldList[4] = $reg[1]; // take the sort field
|
||||
}
|
||||
$InfoFieldList[3] = preg_replace('/:\w*$/', '', $vartmp); // take the filter field
|
||||
|
||||
$classname = $InfoFieldList[0];
|
||||
$classpath = $InfoFieldList[1];
|
||||
@@ -8126,8 +8138,15 @@ class Form
|
||||
}
|
||||
$out .= '};'."\n";
|
||||
$out .= '$(document).ready(function () {
|
||||
$(\'#'.$htmlname.'\').'.$tmpplugin.'({
|
||||
dir: \'ltr\',
|
||||
$(\'#'.$htmlname.'\').'.$tmpplugin.'({';
|
||||
if ($placeholder) {
|
||||
$out .= '
|
||||
placeholder: {
|
||||
id: \'-1\',
|
||||
text: \''.dol_escape_js($placeholder).'\'
|
||||
},';
|
||||
}
|
||||
$out .= ' dir: \'ltr\',
|
||||
// Specify format function for dropdown item
|
||||
formatResult: formatResult,
|
||||
templateResult: formatResult, /* For 4.0 */
|
||||
@@ -9744,24 +9763,45 @@ class Form
|
||||
|
||||
$ret = '';
|
||||
|
||||
$ret .= '<div class="nowrap centpercent">';
|
||||
$ret .= '<div class="divadvancedsearchfieldcomp inline-block">';
|
||||
//$ret .= '<button type="submit" class="liste_titre button_removefilter" name="button_removefilter_x" value="x"><span class="fa fa-remove"></span></button>';
|
||||
$ret .= '<a href="#" class="dropdownsearch-toggle unsetcolor paddingright">';
|
||||
$ret .= '<span class="fas fa-filter linkobject boxfilter" title="Filter" id="idsubimgproductdistribution"></span>';
|
||||
$ret .= $langs->trans("Filters");
|
||||
$ret .= '<a href="#" class="dropdownsearch-toggle unsetcolor">';
|
||||
$ret .= '<span class="fas fa-filter linkobject boxfilter pictofixedwidth" title="'.dol_escape_htmltag($langs->trans("Filters")).'" id="idsubimgproductdistribution"></span>';
|
||||
//$ret .= $langs->trans("Filters");
|
||||
$ret .= '</a>';
|
||||
//$ret .= '<button type="submit" class="liste_titre button_search paddingleftonly" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
|
||||
$ret .= '<div name="search_component_params" class="search_component_params inline-block minwidth500 maxwidth300onsmartphone valignmiddle">';
|
||||
$texttoshow = '<div class="opacitymedium inline-block search_component_searchtext">'.$langs->trans("Search").'</div>';
|
||||
|
||||
$ret .= '<div class="search_component inline-block valignmiddle">'.$texttoshow.'</div>';
|
||||
$ret .= '</div>';
|
||||
$ret .= "<!-- Syntax of Generic filter string: t.ref:like:'SO-%', t.date_creation:<:'20160101', t.date_creation:<:'2016-01-01 12:30:00', t.nature:is:NULL, t.field2:isnot:NULL -->\n";
|
||||
if (GETPOST('show_search_component_params_hidden', 'int')) {
|
||||
$ret .= '<div class="divadvancedsearchfieldcompinput inline-block minwidth500 maxwidth300onsmartphone">';
|
||||
|
||||
// Show select fields as tags.
|
||||
$ret .= '<div name="divsearch_component_params" class="noborderbottom search_component_params inline-block valignmiddle">';
|
||||
|
||||
if ($search_component_params_hidden) {
|
||||
if (!preg_match('/^\(.*\)$/', $search_component_params_hidden)) { // If $search_component_params_hidden does not start and end with ()
|
||||
$search_component_params_hidden .= '('.$search_component_params_hidden.')';
|
||||
}
|
||||
$errormessage = '';
|
||||
if (!dolCheckFilters($search_component_params_hidden, $errormessage)) {
|
||||
print 'ERROR in parsing search string';
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
|
||||
//var_dump($search_component_params_hidden);
|
||||
$htmltags = preg_replace_callback('/'.$regexstring.'/', 'dolForgeCriteriaCallback', $search_component_params_hidden);
|
||||
//var_dump($htmltags);
|
||||
$ret .= '<span class="marginleftonlyshort valignmiddle tagsearch"><span class="tagsearchdelete select2-selection__choice__remove">x</span> '.$htmltags.'</span>';
|
||||
}
|
||||
|
||||
//$ret .= '<button type="submit" class="liste_titre button_search paddingleftonly" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
|
||||
|
||||
//$ret .= search_component_params
|
||||
//$texttoshow = '<div class="opacitymedium inline-block search_component_searchtext">'.$langs->trans("Search").'</div>';
|
||||
//$ret .= '<div class="search_component inline-block valignmiddle">'.$texttoshow.'</div>';
|
||||
|
||||
$show_search_component_params_hidden = 1;
|
||||
if ($show_search_component_params_hidden) {
|
||||
$ret .= '<input type="hidden" name="show_search_component_params_hidden" value="1">';
|
||||
}
|
||||
$ret .= '<input type="'.(GETPOST('show_search_component_params_hidden', 'int') ? 'text' : 'hidden').'" name="search_component_params_hidden" class="search_component_params_hidden marginleftonly" value="'.$search_component_params_hidden.'">';
|
||||
|
||||
$ret .= "<!-- We store the full search string into this field. For example: (t.ref:like:'SO-%') and ((t.ref:like:'CO-%') or (t.ref:like:'AA%')) -->";
|
||||
$ret .= '<input type="hidden" name="search_component_params_hidden" value="'.dol_escape_htmltag($search_component_params_hidden).'">';
|
||||
// For compatibility with forms that show themself the search criteria in addition of this component, we output the fields
|
||||
foreach ($arrayofcriterias as $criterias) {
|
||||
foreach ($criterias as $criteriafamilykey => $criteriafamilyval) {
|
||||
@@ -9785,8 +9825,14 @@ class Form
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$ret .= '</div>';
|
||||
|
||||
$ret .= "<!-- Syntax of Generic filter string: t.ref:like:'SO-%', t.date_creation:<:'20160101', t.date_creation:<:'2016-01-01 12:30:00', t.nature:is:NULL, t.field2:isnot:NULL -->\n";
|
||||
$ret .= '<input type="text" placeholder="'.$langs->trans("Search").'" name="search_component_params_input" class="noborderbottom search_component_input" value="">';
|
||||
|
||||
$ret .= '</div>';
|
||||
$ret .= '</div>';
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
@@ -460,7 +460,7 @@ class FormOther
|
||||
* @param string $htmlname Name of combo list (example: 'search_sale')
|
||||
* @param User $user Object user
|
||||
* @param int $showstatus 0=show user status only if status is disabled, 1=always show user status into label, -1=never show user status
|
||||
* @param int|string $showempty 1=show also an empty value
|
||||
* @param int|string $showempty 1=show also an empty value or text to show for empty
|
||||
* @param string $morecss More CSS
|
||||
* @param int $norepresentative Show also an entry "Not categorized"
|
||||
* @return string Html combo list code
|
||||
@@ -489,12 +489,12 @@ class FormOther
|
||||
$out .= '<select class="flat'.($morecss ? ' '.$morecss : '').'" id="'.$htmlname.'" name="'.$htmlname.'">';
|
||||
if ($showempty) {
|
||||
$textforempty = ' ';
|
||||
if (!empty($conf->use_javascript_ajax)) {
|
||||
$textforempty = ' '; // If we use ajaxcombo, we need here to avoid to have an empty element that is too small.
|
||||
}
|
||||
if (!is_numeric($showempty)) {
|
||||
$textforempty = $showempty;
|
||||
}
|
||||
if (!empty($conf->use_javascript_ajax) && $textforempty == ' ') {
|
||||
$textforempty = ' '; // If we use ajaxcombo, we need here to avoid to have an empty element that is too small.
|
||||
}
|
||||
$out .= '<option class="optiongrey" value="'.($showempty < 0 ? $showempty : -1).'"'.($selected == $showempty ? ' selected' : '').'>'.$textforempty.'</option>'."\n";
|
||||
}
|
||||
|
||||
@@ -1479,9 +1479,10 @@ class FormOther
|
||||
* @param array $search_groupby Array of preselected fields
|
||||
* @param array $arrayofgroupby Array of groupby to fill
|
||||
* @param string $morecss More CSS
|
||||
* @param string $showempty '1' or 'text'
|
||||
* @return string HTML string component
|
||||
*/
|
||||
public function selectGroupByField($object, $search_groupby, &$arrayofgroupby, $morecss = 'minwidth200 maxwidth250')
|
||||
public function selectGroupByField($object, $search_groupby, &$arrayofgroupby, $morecss = 'minwidth200 maxwidth250', $showempty = '1')
|
||||
{
|
||||
global $langs, $extrafields, $form;
|
||||
|
||||
@@ -1493,7 +1494,7 @@ class FormOther
|
||||
$SS = substr($langs->trans("Second"), 0, 1).substr($langs->trans("Second"), 0, 1);
|
||||
|
||||
foreach ($object->fields as $key => $val) {
|
||||
if (!$val['measure']) {
|
||||
if (!$val['isameasure']) {
|
||||
if (in_array($key, array(
|
||||
'id', 'ref_int', 'ref_ext', 'rowid', 'entity', 'last_main_doc', 'logo', 'logo_squarred', 'extraparams',
|
||||
'parent', 'photo', 'socialnetworks', 'webservices_url', 'webservices_key'))) {
|
||||
@@ -1541,7 +1542,7 @@ class FormOther
|
||||
foreach ($arrayofgroupby as $key => $val) {
|
||||
$arrayofgroupbylabel[$key] = $val['label'];
|
||||
}
|
||||
$result = $form->selectarray('search_groupby', $arrayofgroupbylabel, $search_groupby, 1, 0, 0, '', 0, 0, 0, '', $morecss, 1);
|
||||
$result = $form->selectarray('search_groupby', $arrayofgroupbylabel, $search_groupby, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1);
|
||||
|
||||
return $result;
|
||||
}
|
||||
@@ -1552,9 +1553,10 @@ class FormOther
|
||||
* @param mixed $object Object analyzed
|
||||
* @param array $search_xaxis Array of preselected fields
|
||||
* @param array $arrayofxaxis Array of groupby to fill
|
||||
* @return string HTML string component
|
||||
* @param string $showempty '1' or 'text'
|
||||
* @return string HTML string component
|
||||
*/
|
||||
public function selectXAxisField($object, $search_xaxis, &$arrayofxaxis)
|
||||
public function selectXAxisField($object, $search_xaxis, &$arrayofxaxis, $showempty = '1')
|
||||
{
|
||||
global $langs, $extrafields, $form;
|
||||
|
||||
@@ -1589,9 +1591,9 @@ class FormOther
|
||||
continue;
|
||||
}
|
||||
if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) {
|
||||
$arrayofxaxis['t.'.$key.'-year'] = array('label' => $langs->trans($val['label']).' ('.$YYYY.')', 'position' => $val['position'].'-y');
|
||||
$arrayofxaxis['t.'.$key.'-month'] = array('label' => $langs->trans($val['label']).' ('.$YYYY.'-'.$MM.')', 'position' => $val['position'].'-m');
|
||||
$arrayofxaxis['t.'.$key.'-day'] = array('label' => $langs->trans($val['label']).' ('.$YYYY.'-'.$MM.'-'.$DD.')', 'position' => $val['position'].'-d');
|
||||
$arrayofxaxis['t.'.$key.'-year'] = array('label' => $langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.')</span>', 'position' => $val['position'].'-y');
|
||||
$arrayofxaxis['t.'.$key.'-month'] = array('label' => $langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.')</span>', 'position' => $val['position'].'-m');
|
||||
$arrayofxaxis['t.'.$key.'-day'] = array('label' => $langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.'-'.$DD.')</span>', 'position' => $val['position'].'-d');
|
||||
} else {
|
||||
$arrayofxaxis['t.'.$key] = array('label' => $langs->trans($val['label']), 'position' => (int) $val['position']);
|
||||
}
|
||||
@@ -1617,7 +1619,7 @@ class FormOther
|
||||
foreach ($arrayofxaxis as $key => $val) {
|
||||
$arrayofxaxislabel[$key] = $val['label'];
|
||||
}
|
||||
$result = $form->selectarray('search_xaxis', $arrayofxaxislabel, $search_xaxis, 1, 0, 0, '', 0, 0, 0, '', 'minwidth250', 1);
|
||||
$result = $form->selectarray('search_xaxis', $arrayofxaxislabel, $search_xaxis, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth250', 1);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user