Factor save
This commit is contained in:
parent
3e4cd251ea
commit
8b248c75f2
@ -1605,53 +1605,26 @@ if (!$error && ($massaction == 'disable' || ($action == 'disable' && $confirm ==
|
|||||||
if (!$error && $action == 'confirm_edit_value_extrafields' && $confirm == 'yes' && $permissiontoadd) {
|
if (!$error && $action == 'confirm_edit_value_extrafields' && $confirm == 'yes' && $permissiontoadd) {
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
|
$nbok = 0;
|
||||||
|
|
||||||
|
$extrafieldKeyToUpdate = GETPOST('extrafield-key-yo-update'); // TODO A FAIRE coté formulaire : ajouter le select de l'extrafield a utiliser
|
||||||
|
$extrafieldKeyToUpdate = 'code_tva_achat'; // TODO A FAIRE coté formulaire : ajouter le select de l'extrafield a utiliser
|
||||||
|
|
||||||
|
// TODO vérifier que $extrafieldKeyToUpdate correspond bien a un extrafield
|
||||||
|
foreach ($toselect as $toselectid) {
|
||||||
/** @var CommonObject $objecttmp */
|
/** @var CommonObject $objecttmp */
|
||||||
$objecttmp = new $objectclass($db);
|
$objecttmp = new $objectclass($db);
|
||||||
|
|
||||||
$nbok = 0;
|
|
||||||
$e = new ExtraFields($db);
|
|
||||||
$e->fetch_name_optionals_label($objecttmp->table_element);
|
|
||||||
|
|
||||||
foreach ($toselect as $toselectid) {
|
|
||||||
$result = $objecttmp->fetch($toselectid);
|
$result = $objecttmp->fetch($toselectid);
|
||||||
|
|
||||||
if ($result>0) {
|
if ($result>0) {
|
||||||
|
// Fill array 'array_options' with data from add form
|
||||||
if (isset($e->attributes[$objecttmp->table_element]['type']) && is_array($e->attributes[$objecttmp->table_element]['type'])) {
|
$e = new ExtraFields($db);
|
||||||
foreach ($e->attributes[$objecttmp->table_element]['type'] as $key => $type){
|
$ret = $e->setOptionalsFromPost(null, $objecttmp, $extrafieldKeyToUpdate);
|
||||||
|
if ($ret > 0) {
|
||||||
//Permet de gérer les types d'extrafields
|
$objecttmp->insertExtraFields(); // TODO gérer l'erreur
|
||||||
if (in_array($type, array('price', 'double'))) {
|
|
||||||
$value_arr = GETPOST("options_".$key, 'alpha');
|
|
||||||
if(empty($value_arr)){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$value_key = price2num($value_arr);
|
|
||||||
//var_dump($value_key);exit;
|
|
||||||
}else if (in_array($type, array('date'))) {
|
|
||||||
// Clean parameters
|
|
||||||
$value_key = dol_mktime(12, 0, 0, GETPOST("options_" . $key . "month", 'int'), GETPOST("options_" . $key . "day", 'int'), GETPOST("options_" . $key . "year", 'int'));
|
|
||||||
//var_dump($value_key);exit;
|
|
||||||
if(empty($value_key)){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}else if (in_array($type, array('datetime'))) {
|
|
||||||
// Clean parameters
|
|
||||||
$value_key = dol_mktime(GETPOST("options_".$key."hour", 'int'), GETPOST("options_".$key."min", 'int'), GETPOST("options_".$key."sec", 'int'), GETPOST("options_".$key."month", 'int'), GETPOST("options_".$key."day", 'int'), GETPOST("options_".$key."year", 'int'), 'tzuserrel');
|
|
||||||
if(empty($value_key)){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$value_key = GETPOST("options_".$key);
|
$error++;
|
||||||
if ((in_array($type, array('link')) && $key == '-1') || empty($value_key)) {
|
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$objecttmp->array_options["options_".$key] = $value_key;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$objecttmp->insertExtraFields();
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
|
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
@ -1669,7 +1642,6 @@ if (!$error && $action == 'confirm_edit_value_extrafields' && $confirm == 'yes'
|
|||||||
} else {
|
} else {
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Approve for leave only
|
// Approve for leave only
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user