mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-06 17:48:25 +01:00
Debug default value feature.
This commit is contained in:
@@ -271,6 +271,12 @@ if ($mode != 'focus')
|
|||||||
$texthelp.='__DAY__<br>';
|
$texthelp.='__DAY__<br>';
|
||||||
$texthelp.='__MONTH__<br>';
|
$texthelp.='__MONTH__<br>';
|
||||||
$texthelp.='__YEAR__<br>';
|
$texthelp.='__YEAR__<br>';
|
||||||
|
$texthelp.='__PREVIOUS_DAY__<br>';
|
||||||
|
$texthelp.='__PREVIOUS_MONTH__<br>';
|
||||||
|
$texthelp.='__PREVIOUS_YEAR__<br>';
|
||||||
|
$texthelp.='__NEXT_DAY__<br>';
|
||||||
|
$texthelp.='__NEXT_MONTH__<br>';
|
||||||
|
$texthelp.='__NEXT_YEAR__<br>';
|
||||||
if (! empty($conf->multicompany->enabled)) $texthelp.='__ENTITYID__<br>';
|
if (! empty($conf->multicompany->enabled)) $texthelp.='__ENTITYID__<br>';
|
||||||
$textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, '');
|
$textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, '');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ function dol_shutdown()
|
|||||||
* Return value of a param into GET or POST supervariable
|
* Return value of a param into GET or POST supervariable
|
||||||
*
|
*
|
||||||
* @param string $paramname Name of parameter to found
|
* @param string $paramname Name of parameter to found
|
||||||
* @param string $check Type of check (''=no check, 'int'=check it's numeric, 'alpha'=check it's text and sign, 'aZ'=check it's a-z only, 'array'=check it's array, 'san_alpha'=Use filter_var with FILTER_SANITIZE_STRING (do not use this for free text string), 'day', 'month', 'year', 'custom'= custom filter specify $filter and $options)
|
* @param string $check Type of check (''=no check, 'none'=no check, 'int'=check it's numeric, 'alpha'=check it's text and sign, 'aZ'=check it's a-z only, 'array'=check it's array, 'san_alpha'=Use filter_var with FILTER_SANITIZE_STRING (do not use this for free text string), 'day', 'month', 'year', 'custom'= custom filter specify $filter and $options)
|
||||||
* @param int $method Type of method (0 = get then post, 1 = only get, 2 = only post, 3 = post then get, 4 = post then get then cookie)
|
* @param int $method Type of method (0 = get then post, 1 = only get, 2 = only post, 3 = post then get, 4 = post then get then cookie)
|
||||||
* @param int $filter Filter to apply when $check is set to 'custom'. (See http://php.net/manual/en/filter.filters.php for détails)
|
* @param int $filter Filter to apply when $check is set to 'custom'. (See http://php.net/manual/en/filter.filters.php for détails)
|
||||||
* @param mixed $options Options to pass to filter_var when $check is set to 'custom'.
|
* @param mixed $options Options to pass to filter_var when $check is set to 'custom'.
|
||||||
@@ -249,6 +249,8 @@ function dol_shutdown()
|
|||||||
*/
|
*/
|
||||||
function GETPOST($paramname, $check='', $method=0, $filter=NULL, $options=NULL)
|
function GETPOST($paramname, $check='', $method=0, $filter=NULL, $options=NULL)
|
||||||
{
|
{
|
||||||
|
global $mysoc,$user,$conf;
|
||||||
|
|
||||||
if (empty($method)) $out = isset($_GET[$paramname])?$_GET[$paramname]:(isset($_POST[$paramname])?$_POST[$paramname]:'');
|
if (empty($method)) $out = isset($_GET[$paramname])?$_GET[$paramname]:(isset($_POST[$paramname])?$_POST[$paramname]:'');
|
||||||
elseif ($method==1) $out = isset($_GET[$paramname])?$_GET[$paramname]:'';
|
elseif ($method==1) $out = isset($_GET[$paramname])?$_GET[$paramname]:'';
|
||||||
elseif ($method==2) $out = isset($_POST[$paramname])?$_POST[$paramname]:'';
|
elseif ($method==2) $out = isset($_POST[$paramname])?$_POST[$paramname]:'';
|
||||||
@@ -258,8 +260,6 @@ function GETPOST($paramname, $check='', $method=0, $filter=NULL, $options=NULL)
|
|||||||
|
|
||||||
if (empty($method) || $method == 3 || $method == 4)
|
if (empty($method) || $method == 3 || $method == 4)
|
||||||
{
|
{
|
||||||
global $conf;
|
|
||||||
|
|
||||||
// Management of default values
|
// Management of default values
|
||||||
if (! isset($_GET['sortfield']) && ! empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) // If we did a click on a field to sort, we do no apply default values. Same if option MAIN_DISABLE_DEFAULT_VALUES is on
|
if (! isset($_GET['sortfield']) && ! empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) // If we did a click on a field to sort, we do no apply default values. Same if option MAIN_DISABLE_DEFAULT_VALUES is on
|
||||||
{
|
{
|
||||||
@@ -320,43 +320,41 @@ function GETPOST($paramname, $check='', $method=0, $filter=NULL, $options=NULL)
|
|||||||
if (! empty($check))
|
if (! empty($check))
|
||||||
{
|
{
|
||||||
// Replace vars like __DAY__, __MONTH__, __YEAR__, __MYCOUNTRYID__, __USERID__, __ENTITYID__
|
// Replace vars like __DAY__, __MONTH__, __YEAR__, __MYCOUNTRYID__, __USERID__, __ENTITYID__
|
||||||
// TODO Add more var like __PREVIOUSDAY__, __PREVIOUSMONTH__, __PREVIOUSYEAR__
|
if (! is_array($out))
|
||||||
if (! is_array($out) && preg_match('/^__([a-z0-9]+)__$/i', $out, $reg))
|
|
||||||
{
|
{
|
||||||
if ($reg[1] == 'DAY')
|
$maxloop=20; $loopnb=0; // Protection against infinite loop
|
||||||
|
while (preg_match('/__([A-Z0-9]+_?[A-Z0-9]+)__/i', $out, $reg) && ($loopnb < $maxloop)) // Detect '__ABCDEF__' as key 'ABCDEF' and '__ABC_DEF__' as key 'ABC_DEF'
|
||||||
{
|
{
|
||||||
$tmp=dol_getdate(dol_now(), true);
|
$loopnb++; $newout = '';
|
||||||
$out = $tmp['mday'];
|
|
||||||
}
|
if ($reg[1] == 'DAY') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['mday']; }
|
||||||
elseif ($reg[1] == 'MONTH')
|
elseif ($reg[1] == 'MONTH') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['mon']; }
|
||||||
{
|
elseif ($reg[1] == 'YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['year']; }
|
||||||
$tmp=dol_getdate(dol_now(), true);
|
elseif ($reg[1] == 'PREVIOUS_DAY') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; }
|
||||||
$out = $tmp['mon'];
|
elseif ($reg[1] == 'PREVIOUS_MONTH') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_prev_month($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['month']; }
|
||||||
}
|
elseif ($reg[1] == 'PREVIOUS_YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = ($tmp['year'] - 1); }
|
||||||
elseif ($reg[1] == 'YEAR')
|
elseif ($reg[1] == 'NEXT_DAY') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; }
|
||||||
{
|
elseif ($reg[1] == 'NEXT_MONTH') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_next_month($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['month']; }
|
||||||
$tmp=dol_getdate(dol_now(), true);
|
elseif ($reg[1] == 'NEXT_YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = ($tmp['year'] + 1); }
|
||||||
$out = $tmp['year'];
|
elseif ($reg[1] == 'MYCOUNTRYID')
|
||||||
}
|
{
|
||||||
elseif ($reg[1] == 'MYCOUNTRYID')
|
$newout = $mysoc->country_id;
|
||||||
{
|
}
|
||||||
global $mysoc;
|
elseif ($reg[1] == 'USERID')
|
||||||
$out = $mysoc->country_id;
|
{
|
||||||
}
|
$newout = $user->id;
|
||||||
elseif ($reg[1] == 'USERID')
|
}
|
||||||
{
|
elseif ($reg[1] == 'SUPERVISORID')
|
||||||
global $user;
|
{
|
||||||
$out = $user->id;
|
$newout = $user->fk_user;
|
||||||
}
|
}
|
||||||
elseif ($reg[1] == 'SUPERVISORID')
|
elseif ($reg[1] == 'ENTITYID')
|
||||||
{
|
{
|
||||||
global $user;
|
$newout = $conf->entity;
|
||||||
$out = $user->fk_user;
|
}
|
||||||
}
|
else $newout = ''; // Key not found, we replace with empty string
|
||||||
elseif ($reg[1] == 'ENTITYID')
|
//var_dump('__'.$reg[1].'__ -> '.$newout);
|
||||||
{
|
$out = preg_replace('/__'.preg_quote($reg[1],'/').'__/', $newout, $out);
|
||||||
global $conf;
|
|
||||||
$out = $conf->entity;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -142,9 +142,9 @@ if (empty($reshook))
|
|||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
$object->ref = GETPOST('ref','alpha');
|
$object->ref = GETPOST('ref','alpha');
|
||||||
$object->title = GETPOST('title'); // Do not use 'alpha' here, we want field as it is
|
$object->title = GETPOST('title','none'); // Do not use 'alpha' here, we want field as it is
|
||||||
$object->socid = GETPOST('socid','int');
|
$object->socid = GETPOST('socid','int');
|
||||||
$object->description = GETPOST('description'); // Do not use 'alpha' here, we want field as it is
|
$object->description = GETPOST('description','none'); // Do not use 'alpha' here, we want field as it is
|
||||||
$object->public = GETPOST('public','alpha');
|
$object->public = GETPOST('public','alpha');
|
||||||
$object->opp_amount = price2num(GETPOST('opp_amount'));
|
$object->opp_amount = price2num(GETPOST('opp_amount'));
|
||||||
$object->budget_amount = price2num(GETPOST('budget_amount'));
|
$object->budget_amount = price2num(GETPOST('budget_amount'));
|
||||||
@@ -243,9 +243,9 @@ if (empty($reshook))
|
|||||||
$old_start_date = $object->date_start;
|
$old_start_date = $object->date_start;
|
||||||
|
|
||||||
$object->ref = GETPOST('ref','alpha');
|
$object->ref = GETPOST('ref','alpha');
|
||||||
$object->title = GETPOST('title'); // Do not use 'alpha' here, we want field as it is
|
$object->title = GETPOST('title','none'); // Do not use 'alpha' here, we want field as it is
|
||||||
$object->socid = GETPOST('socid','int');
|
$object->socid = GETPOST('socid','int');
|
||||||
$object->description = GETPOST('description'); // Do not use 'alpha' here, we want field as it is
|
$object->description = GETPOST('description','none'); // Do not use 'alpha' here, we want field as it is
|
||||||
$object->public = GETPOST('public','alpha');
|
$object->public = GETPOST('public','alpha');
|
||||||
$object->date_start = empty($_POST["projectstart"])?'':$date_start;
|
$object->date_start = empty($_POST["projectstart"])?'':$date_start;
|
||||||
$object->date_end = empty($_POST["projectend"])?'':$date_end;
|
$object->date_end = empty($_POST["projectend"])?'':$date_end;
|
||||||
@@ -509,7 +509,7 @@ if ($action == 'create' && $user->rights->projet->creer)
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Label
|
// Label
|
||||||
print '<tr><td><span class="fieldrequired">'.$langs->trans("Label").'</span></td><td><input size="80" type="text" name="title" value="'.GETPOST("title").'"></td></tr>';
|
print '<tr><td><span class="fieldrequired">'.$langs->trans("Label").'</span></td><td><input size="80" type="text" name="title" value="'.GETPOST("title",'none').'"></td></tr>';
|
||||||
|
|
||||||
// Thirdparty
|
// Thirdparty
|
||||||
if ($conf->societe->enabled)
|
if ($conf->societe->enabled)
|
||||||
@@ -588,7 +588,7 @@ if ($action == 'create' && $user->rights->projet->creer)
|
|||||||
// Description
|
// Description
|
||||||
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>';
|
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print '<textarea name="description" wrap="soft" class="centpercent" rows="'.ROWS_3.'">'.GETPOST("description").'</textarea>';
|
print '<textarea name="description" wrap="soft" class="centpercent" rows="'.ROWS_3.'">'.dol_escape_htmltag(GETPOST("description",'none')).'</textarea>';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
if ($conf->categorie->enabled) {
|
if ($conf->categorie->enabled) {
|
||||||
|
|||||||
Reference in New Issue
Block a user