Merge branch 'develop' into extrafields
This commit is contained in:
commit
60e72a770a
@ -81,6 +81,9 @@ $result = restrictedArea($user, 'propal', $id);
|
|||||||
$object = new Propal($db);
|
$object = new Propal($db);
|
||||||
$extrafields = new ExtraFields($db);
|
$extrafields = new ExtraFields($db);
|
||||||
|
|
||||||
|
// fetch optionals attributes and labels
|
||||||
|
$extralabels=$extrafields->fetch_name_optionals_label('propal');
|
||||||
|
|
||||||
// Load object
|
// Load object
|
||||||
if ($id > 0 || ! empty($ref))
|
if ($id > 0 || ! empty($ref))
|
||||||
{
|
{
|
||||||
@ -338,14 +341,8 @@ else if ($action == 'add' && $user->rights->propal->creer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get extra fields
|
// Fill array 'array_options' with data from add form
|
||||||
foreach($_POST as $key => $value)
|
$ret = setOptionalsFromPost($extralabels,$object);*
|
||||||
{
|
|
||||||
if (preg_match("/^options_/",$key))
|
|
||||||
{
|
|
||||||
$object->array_options[$key]=GETPOST($key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$id = $object->create($user);
|
$id = $object->create($user);
|
||||||
}
|
}
|
||||||
@ -1108,13 +1105,22 @@ else if ($action == 'down' && $user->rights->propal->creer)
|
|||||||
else if ($action == 'update_extras')
|
else if ($action == 'update_extras')
|
||||||
{
|
{
|
||||||
// Get extra fields
|
// Get extra fields
|
||||||
foreach($_POST as $key => $value)
|
foreach ($extralabels as $key => $value)
|
||||||
{
|
{
|
||||||
if (preg_match("/^options_/",$key))
|
$key_type = $extrafields->attribute_type[$key];
|
||||||
|
|
||||||
|
if (in_array($key_type,array('date','datetime')))
|
||||||
{
|
{
|
||||||
$object->array_options[$key]=$_POST[$key];
|
// Clean parameters
|
||||||
|
$value_key=dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$value_key=GETPOST("options_".$key);
|
||||||
|
}
|
||||||
|
$object->array_options["options_".$key]=$value_key;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions on extra fields (by external module or standard code)
|
// Actions on extra fields (by external module or standard code)
|
||||||
// FIXME le hook fait double emploi avec le trigger !!
|
// FIXME le hook fait double emploi avec le trigger !!
|
||||||
$hookmanager->initHooks(array('propaldao'));
|
$hookmanager->initHooks(array('propaldao'));
|
||||||
@ -1208,9 +1214,6 @@ $formfile = new FormFile($db);
|
|||||||
$formpropal = new FormPropal($db);
|
$formpropal = new FormPropal($db);
|
||||||
$companystatic=new Societe($db);
|
$companystatic=new Societe($db);
|
||||||
|
|
||||||
// fetch optionals attributes and labels
|
|
||||||
$extralabels=$extrafields->fetch_name_optionals_label('propal');
|
|
||||||
|
|
||||||
$now=dol_now();
|
$now=dol_now();
|
||||||
|
|
||||||
// Add new proposal
|
// Add new proposal
|
||||||
|
|||||||
@ -761,5 +761,42 @@ class ExtraFields
|
|||||||
$out = '<tr class="liste_titre"><td colspan="4"><strong>'.$this->attribute_label[$key].'</strong></td></tr>';
|
$out = '<tr class="liste_titre"><td colspan="4"><strong>'.$this->attribute_label[$key].'</strong></td></tr>';
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill array_options array for object by extrafields value (using for data send by forms)
|
||||||
|
*
|
||||||
|
* @param array $extralabels $array of extrafields
|
||||||
|
* @param object $object object
|
||||||
|
* @return int 1 if array_options set / 0 if no value
|
||||||
|
*/
|
||||||
|
function setOptionalsFromPost($extralabels,&$object)
|
||||||
|
{
|
||||||
|
global $_POST;
|
||||||
|
|
||||||
|
if (is_array($extralabels))
|
||||||
|
{
|
||||||
|
// Get extra fields
|
||||||
|
foreach ($extralabels as $key => $value)
|
||||||
|
{
|
||||||
|
$key_type = $this->attribute_type[$key];
|
||||||
|
|
||||||
|
if (in_array($key_type,array('date','datetime')))
|
||||||
|
{
|
||||||
|
// Clean parameters
|
||||||
|
$value_key=dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$value_key=GETPOST("options_".$key);
|
||||||
|
}
|
||||||
|
$object->array_options["options_".$key]=$value_key;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user