mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-03-13 13:57:07 +01:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
992731c8ca | ||
|
|
138c1bf5b3 | ||
|
|
99bc406c49 | ||
|
|
934123eef5 | ||
|
|
c531628ae3 |
@@ -1741,7 +1741,7 @@ abstract class CommonDocGenerator
|
||||
|
||||
|
||||
/**
|
||||
* display extrafields columns content
|
||||
* Display extrafields columns content on documents
|
||||
*
|
||||
* @param CommonObject|CommonObjectLine $object line of common object
|
||||
* @param Translate $outputlangs Output language
|
||||
@@ -1819,6 +1819,10 @@ abstract class CommonDocGenerator
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($extrafields->attributes[$object->table_element]['printable'][$key])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (empty($enabled)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1752,15 +1752,22 @@ class ExtraFields
|
||||
$tmpparamoptions = array_keys($param['options']);
|
||||
$paramoptions = preg_split('/[\r\n]+/', $tmpparamoptions[0]);
|
||||
|
||||
$InfoFieldList = explode(":", $paramoptions[0], 5);
|
||||
$InfoFieldList = explode(":", $paramoptions[0], 5); // We will extract field at position 6,7... later from the 5th one.
|
||||
// 0 : tableName
|
||||
// 1 : label field name
|
||||
// 2 : key fields name (if different of rowid)
|
||||
// optional parameters...
|
||||
// 2 : rowid field name (if different of rowid)
|
||||
// Optional parameters...
|
||||
// 3 : key field parent (for dependent lists). How this is used ?
|
||||
// 4 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value. Or use USF on the second line.
|
||||
// 5 : string category type. This replace the filter.
|
||||
// 6 : ids categories list separated by comma for category root. This replace the filter.
|
||||
|
||||
// To add a filter on category (not possible with USF restricted to table)
|
||||
// 5 : string category type ('product', 'customer', ...). This is added to the filter.
|
||||
// 6 : list of parent categories ids. This replace the filter.
|
||||
// 7 : sort field (not used here but used into format for commobject)
|
||||
|
||||
// For backward compatibility when tableName = 'category', so when we want a list of categories
|
||||
// 5 : string category type ('product', 'customer', ...). This replace the filter.
|
||||
// 6 : list of parent categories ids. This replace the filter.
|
||||
// 7 : sort field (not used here but used into format for commobject)
|
||||
|
||||
// Example with extrafield value = "societe:nom:rowid" or "categorie:label:rowid:::product"
|
||||
@@ -1797,6 +1804,7 @@ class ExtraFields
|
||||
|
||||
//$Usf = empty($paramoptions[1]) ? '' :$paramoptions[1];
|
||||
|
||||
|
||||
$parentName = '';
|
||||
$parentField = '';
|
||||
$keyList = (empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2].' as rowid');
|
||||
@@ -1813,13 +1821,18 @@ class ExtraFields
|
||||
}
|
||||
}
|
||||
|
||||
$InfoFieldList[5] = (string) $InfoFieldList[5];
|
||||
|
||||
$filter_categorie = false;
|
||||
if (count($InfoFieldList) > 5 && ((string) $InfoFieldList[5] != '')) {
|
||||
if (count($InfoFieldList) > 5 && ($InfoFieldList[5] != '')) {
|
||||
if ($InfoFieldList[0] == 'categorie') {
|
||||
$filter_categorie = true;
|
||||
$filter_categorie = true; // The combo list is a list of categories
|
||||
} else {
|
||||
$filter_categorie = false; // We have a filter on category for another table
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!$filter_categorie) {
|
||||
$fields_label = explode('|', $InfoFieldList[1]);
|
||||
if (is_array($fields_label)) {
|
||||
@@ -1871,6 +1884,20 @@ class ExtraFields
|
||||
$sqlwhere .= ' WHERE 1=1';
|
||||
}
|
||||
|
||||
|
||||
if ($InfoFieldList[5] != '') {
|
||||
// We have a filter on category for another table
|
||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
$tmpcategory = new Categorie($this->db);
|
||||
$tablesuffixcategory = empty($tmpcategory->MAP_CAT_TABLE[$InfoFieldList[5]]) ? $InfoFieldList[5] : $tmpcategory->MAP_CAT_TABLE[$InfoFieldList[5]];
|
||||
$fksuffixcategory = empty($tmpcategory->MAP_CAT_FK[$InfoFieldList[5]]) ? $InfoFieldList[5] : $tmpcategory->MAP_CAT_FK[$InfoFieldList[5]];
|
||||
|
||||
$sqlwhere .= ' AND EXISTS (SELECT fk_categorie as categid FROM '.MAIN_DB_PREFIX.'categorie_'.$this->db->sanitize($tablesuffixcategory);
|
||||
$sqlwhere .= ' WHERE fk_categorie IN ('.$this->db->sanitize($InfoFieldList[6]).')';
|
||||
$sqlwhere .= ' AND fk_'.$this->db->sanitize($fksuffixcategory).' = rowid)';
|
||||
//var_dump($sqlwhere);exit;
|
||||
}
|
||||
|
||||
// Add Usf filter on second line
|
||||
/*
|
||||
if ($Usf) {
|
||||
|
||||
@@ -318,7 +318,7 @@ class Form
|
||||
}
|
||||
if (preg_match('/^(string|safehtmlstring|email|phone|url)/', $typeofdata)) {
|
||||
$tmp = explode(':', $typeofdata);
|
||||
$ret .= '<input type="text" id="' . $htmlname . '" name="' . $htmlname . '" value="' . ($editvalue ? $editvalue : $value) . '"' . (empty($tmp[1]) ? '' : ' size="' . $tmp[1] . '"') . ' autofocus>';
|
||||
$ret .= '<input type="text" id="' . $htmlname . '" name="' . $htmlname . '" value="' . ($editvalue ? $editvalue : $value) . '"' . (empty($tmp[1]) ? '' : ' size="' . $tmp[1] . '"') . ' autofocus spellcheck="false">';
|
||||
} elseif (preg_match('/^(integer)/', $typeofdata)) {
|
||||
$tmp = explode(':', $typeofdata);
|
||||
$valuetoshow = price2num($editvalue ? $editvalue : $value, 0);
|
||||
|
||||
@@ -11727,7 +11727,7 @@ function verifCond($strToEvaluate, $onlysimplestring = '1')
|
||||
//var_dump($strToEvaluate);
|
||||
//$rep = dol_eval($strToEvaluate, 1, 0, '1'); // to show the error
|
||||
$rep = dol_eval($strToEvaluate, 1, 1, $onlysimplestring); // The dol_eval() must contains all the "global $xxx;" for all variables $xxx found into the string condition
|
||||
//var_dump($rep);
|
||||
//var_dump($strToEvaluate, $rep);
|
||||
$rights = (bool) $rep && (!is_string($rep) || strpos($rep, 'Bad string syntax to evaluate') === false);
|
||||
//var_dump($rights);
|
||||
}
|
||||
@@ -12172,6 +12172,7 @@ function dol_eval_standard($s, $hideerrors = 1, $onlysimplestring = '1')
|
||||
while ($scheck && $savescheck != $scheck) {
|
||||
$savescheck = $scheck;
|
||||
$scheck = preg_replace('/\$conf->[a-z\_]+->enabled/', '__VARCONFENABLED__', $scheck); // Remove this once $user->module->enabled has been replaced everywhere with isModEnabled.
|
||||
$scheck = preg_replace('/\$user->id/', '__VARUSERID__', $scheck);
|
||||
$scheck = preg_replace('/\$user->hasRight/', '__VARUSERHASRIGHT__', $scheck);
|
||||
$scheck = preg_replace('/\$user->rights/', '__VARUSERHASRIGHT__', $scheck); // Remove this once $user->rights->xxx is replaced everywhere with $user->hasRight()
|
||||
$scheck = preg_replace('/\$user->admin/', '__VARUSERISADMIN__', $scheck); // Remove this once $user->admin is replaced everywhere with $user->isAdmin()
|
||||
|
||||
Reference in New Issue
Block a user