forked from Wavyzz/dolibarr
Work on mandatory form fields
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2017-2018 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2017-2018 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -19,6 +19,11 @@
|
||||
/**
|
||||
* \file htdocs/admin/defaultvalues.php
|
||||
* \brief Page to set default values used used in a create form
|
||||
* Default values are stored into $user->default_values[url]['createform']['querystring'|'_noquery_'][paramkey]=paramvalue
|
||||
* Default filters are stored into $user->default_values[url]['filters']['querystring'|'_noquery_'][paramkey]=paramvalue
|
||||
* Default sort order are stored into $user->default_values[url]['sortorder']['querystring'|'_noquery_'][paramkey]=paramvalue
|
||||
* Default focus are stored into $user->default_values[url]['focus']['querystring'|'_noquery_'][paramkey]=paramvalue
|
||||
* Mandatory fields are stored into $user->default_values[url]['mandatory']['querystring'|'_noquery_'][paramkey]=paramvalue
|
||||
*/
|
||||
|
||||
require '../main.inc.php';
|
||||
@@ -234,6 +239,10 @@ if ($mode == 'focus')
|
||||
{
|
||||
print info_admin($langs->trans("FeatureNotYetAvailable")).'<br>';
|
||||
}
|
||||
if ($mode == 'mandatory')
|
||||
{
|
||||
print info_admin($langs->trans("FeatureNotYetAvailable")).'<br>';
|
||||
}
|
||||
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" id="action" name="action" value="">';
|
||||
@@ -261,7 +270,7 @@ else
|
||||
}
|
||||
print_liste_field_titre($textkey,$_SERVER["PHP_SELF"],'param','',$param,'',$sortfield,$sortorder);
|
||||
// Value
|
||||
if ($mode != 'focus')
|
||||
if ($mode != 'focus' && $mode != 'mandatory')
|
||||
{
|
||||
if ($mode != 'sortorder')
|
||||
{
|
||||
@@ -301,7 +310,7 @@ print '<td>';
|
||||
print '<input type="text" class="flat maxwidth100onsmartphone" name="defaultkey" value="">';
|
||||
print '</td>';
|
||||
// Value
|
||||
if ($mode != 'focus')
|
||||
if ($mode != 'focus' && $mode != 'mandatory')
|
||||
{
|
||||
print '<td>';
|
||||
print '<input type="text" class="flat maxwidth100onsmartphone" name="defaultvalue" value="">';
|
||||
@@ -313,13 +322,14 @@ if (! empty($conf->multicompany->enabled) && !$user->entity)
|
||||
print '<td>';
|
||||
print '<input type="text" class="flat" size="1" name="entity" value="'.$conf->entity.'">';
|
||||
print '</td>';
|
||||
print '<td align="center">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="center">';
|
||||
print '<input type="hidden" name="entity" value="'.$conf->entity.'">';
|
||||
print '</td>';
|
||||
}
|
||||
print '<td align="center">';
|
||||
$disabled='';
|
||||
if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) $disabled=' disabled="disabled"';
|
||||
print '<input type="submit" class="button"'.$disabled.' value="'.$langs->trans("Add").'" name="add">';
|
||||
@@ -363,7 +373,7 @@ if ($result)
|
||||
print '</td>'."\n";
|
||||
|
||||
// Value
|
||||
if ($mode != 'focus')
|
||||
if ($mode != 'focus' && $mode != 'mandatory')
|
||||
{
|
||||
print '<td>';
|
||||
/*print '<input type="hidden" name="const['.$i.'][rowid]" value="'.$obj->rowid.'">';
|
||||
@@ -376,6 +386,9 @@ if ($result)
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Multicompany
|
||||
print '<td></td>';
|
||||
|
||||
// Actions
|
||||
print '<td align="center">';
|
||||
if ($action != 'edit' || GETPOST('rowid') != $obj->rowid)
|
||||
|
||||
@@ -729,6 +729,11 @@ function defaultvalues_prepare_head()
|
||||
$head[$h][2] = 'focus';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/defaultvalues.php?mode=mandatory";
|
||||
$head[$h][1] = $langs->trans("DefaultMandatory");
|
||||
$head[$h][2] = 'mandatory';
|
||||
$h++;
|
||||
|
||||
/*$head[$h][0] = DOL_URL_ROOT."/admin/translation.php?mode=searchkey";
|
||||
$head[$h][1] = $langs->trans("TranslationKeySearch");
|
||||
$head[$h][2] = 'searchkey';
|
||||
|
||||
@@ -430,7 +430,7 @@ function GETPOST($paramname, $check='none', $method=0, $filter=null, $options=nu
|
||||
}
|
||||
elseif (isset($user->default_values[$relativepathstring]['filters']))
|
||||
{
|
||||
foreach($user->default_values[$relativepathstring]['filters'] as $defkey => $defval)
|
||||
foreach($user->default_values[$relativepathstring]['filters'] as $defkey => $defval) // $defkey is a querystring like 'a=b&c=d', $defval is key of user
|
||||
{
|
||||
$qualified = 0;
|
||||
if ($defkey != '_noquery_')
|
||||
@@ -586,7 +586,6 @@ function GETPOST($paramname, $check='none', $method=0, $filter=null, $options=nu
|
||||
// Save data into session if key start with 'search_' or is 'smonth', 'syear', 'month', 'year'
|
||||
if (empty($method) || $method == 3 || $method == 4)
|
||||
{
|
||||
//if (preg_match('/^search_/', $paramname) || in_array($paramname, array('sortorder', 'sortfield", 'smonth', 'syear', 'month', 'year')))
|
||||
if (preg_match('/^search_/', $paramname) || in_array($paramname, array('sortorder','sortfield')))
|
||||
{
|
||||
//var_dump($paramname.' - '.$out.' '.$user->default_values[$relativepathstring]['filters'][$paramname]);
|
||||
@@ -595,8 +594,7 @@ function GETPOST($paramname, $check='none', $method=0, $filter=null, $options=nu
|
||||
// - posted value not empty, or
|
||||
// - if posted value is empty and a default value exists that is not empty (it means we did a filter to an empty value when default was not).
|
||||
|
||||
//if (! empty($out) || ! empty($user->default_values[$relativepathstring]['filters'][$paramname]))
|
||||
if ($out != '') // $out = '0' like 'abc' is a search criteria to keep
|
||||
if ($out != '') // $out = '0' or 'abc', it is a search criteria to keep
|
||||
{
|
||||
$user->lastsearch_values_tmp[$relativepathstring][$paramname]=$out;
|
||||
}
|
||||
|
||||
@@ -1437,6 +1437,7 @@ DefaultCreateForm=Default values (on forms to create)
|
||||
DefaultSearchFilters=Default search filters
|
||||
DefaultSortOrder=Default sort orders
|
||||
DefaultFocus=Default focus fields
|
||||
DefaultMandatory=Mandatory form fields
|
||||
##### Products #####
|
||||
ProductSetup=Products module setup
|
||||
ServiceSetup=Services module setup
|
||||
|
||||
Reference in New Issue
Block a user