parent
fe735d4e67
commit
d9e9364ddf
@ -87,81 +87,17 @@ $usercanread = (($user->rights->stock->lire));
|
|||||||
$usercancreate = (($user->rights->stock->creer));
|
$usercancreate = (($user->rights->stock->creer));
|
||||||
$usercandelete = (($user->rights->stock->supprimer));
|
$usercandelete = (($user->rights->stock->supprimer));
|
||||||
|
|
||||||
// Ajout entrepot
|
$parameters=array('id'=>$id, 'ref'=>$ref);
|
||||||
if ($action == 'add' && $user->rights->stock->creer)
|
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
if (empty($reshook))
|
||||||
{
|
{
|
||||||
$object->ref = GETPOST("ref");
|
// Ajout entrepot
|
||||||
$object->fk_parent = GETPOST("fk_parent");
|
if ($action == 'add' && $user->rights->stock->creer)
|
||||||
$object->libelle = GETPOST("libelle");
|
|
||||||
$object->description = GETPOST("desc");
|
|
||||||
$object->statut = GETPOST("statut");
|
|
||||||
$object->lieu = GETPOST("lieu");
|
|
||||||
$object->address = GETPOST("address");
|
|
||||||
$object->zip = GETPOST("zipcode");
|
|
||||||
$object->town = GETPOST("town");
|
|
||||||
$object->country_id = GETPOST("country_id");
|
|
||||||
|
|
||||||
if (! empty($object->libelle))
|
|
||||||
{
|
{
|
||||||
// Fill array 'array_options' with data from add form
|
$object->ref = GETPOST("ref");
|
||||||
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
|
|
||||||
if ($ret < 0) {
|
|
||||||
$error++;
|
|
||||||
$action = 'create';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $error) {
|
|
||||||
$id = $object->create($user);
|
|
||||||
if ($id > 0) {
|
|
||||||
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
|
|
||||||
|
|
||||||
$categories = GETPOST('categories', 'array');
|
|
||||||
$object->setCategories($categories);
|
|
||||||
if (!empty($backtopage)) {
|
|
||||||
header("Location: " . $backtopage);
|
|
||||||
exit;
|
|
||||||
} else {
|
|
||||||
header("Location: card.php?id=" . $id);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$action = 'create';
|
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("ErrorWarehouseRefRequired"), null, 'errors');
|
|
||||||
$action="create"; // Force retour sur page creation
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete warehouse
|
|
||||||
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->stock->supprimer)
|
|
||||||
{
|
|
||||||
$object->fetch(GETPOST('id', 'int'));
|
|
||||||
$result=$object->delete($user);
|
|
||||||
if ($result > 0)
|
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
|
|
||||||
header("Location: ".DOL_URL_ROOT.'/product/stock/list.php?restore_lastsearch_values=1');
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
|
||||||
$action='';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Modification entrepot
|
|
||||||
if ($action == 'update' && $cancel <> $langs->trans("Cancel"))
|
|
||||||
{
|
|
||||||
if ($object->fetch($id))
|
|
||||||
{
|
|
||||||
$object->libelle = GETPOST("libelle");
|
|
||||||
$object->fk_parent = GETPOST("fk_parent");
|
$object->fk_parent = GETPOST("fk_parent");
|
||||||
|
$object->libelle = GETPOST("libelle");
|
||||||
$object->description = GETPOST("desc");
|
$object->description = GETPOST("desc");
|
||||||
$object->statut = GETPOST("statut");
|
$object->statut = GETPOST("statut");
|
||||||
$object->lieu = GETPOST("lieu");
|
$object->lieu = GETPOST("lieu");
|
||||||
@ -170,57 +106,127 @@ if ($action == 'update' && $cancel <> $langs->trans("Cancel"))
|
|||||||
$object->town = GETPOST("town");
|
$object->town = GETPOST("town");
|
||||||
$object->country_id = GETPOST("country_id");
|
$object->country_id = GETPOST("country_id");
|
||||||
|
|
||||||
// Fill array 'array_options' with data from add form
|
if (! empty($object->libelle))
|
||||||
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
|
{
|
||||||
if ($ret < 0) $error++;
|
// Fill array 'array_options' with data from add form
|
||||||
|
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
|
||||||
|
if ($ret < 0) {
|
||||||
|
$error++;
|
||||||
|
$action = 'create';
|
||||||
|
}
|
||||||
|
|
||||||
if (! $error) {
|
if (! $error) {
|
||||||
$ret = $object->update($id, $user);
|
$id = $object->create($user);
|
||||||
if ($ret < 0) $error++;
|
if ($id > 0) {
|
||||||
}
|
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
|
||||||
|
|
||||||
if ($error) {
|
$categories = GETPOST('categories', 'array');
|
||||||
|
$object->setCategories($categories);
|
||||||
|
if (!empty($backtopage)) {
|
||||||
|
header("Location: " . $backtopage);
|
||||||
|
exit;
|
||||||
|
} else {
|
||||||
|
header("Location: card.php?id=" . $id);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$action = 'create';
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEventMessages($langs->trans("ErrorWarehouseRefRequired"), null, 'errors');
|
||||||
|
$action="create"; // Force retour sur page creation
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete warehouse
|
||||||
|
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->stock->supprimer)
|
||||||
|
{
|
||||||
|
$object->fetch(GETPOST('id', 'int'));
|
||||||
|
$result=$object->delete($user);
|
||||||
|
if ($result > 0)
|
||||||
|
{
|
||||||
|
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
|
||||||
|
header("Location: ".DOL_URL_ROOT.'/product/stock/list.php?restore_lastsearch_values=1');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
$action='';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Modification entrepot
|
||||||
|
if ($action == 'update' && $cancel <> $langs->trans("Cancel"))
|
||||||
|
{
|
||||||
|
if ($object->fetch($id))
|
||||||
|
{
|
||||||
|
$object->libelle = GETPOST("libelle");
|
||||||
|
$object->fk_parent = GETPOST("fk_parent");
|
||||||
|
$object->description = GETPOST("desc");
|
||||||
|
$object->statut = GETPOST("statut");
|
||||||
|
$object->lieu = GETPOST("lieu");
|
||||||
|
$object->address = GETPOST("address");
|
||||||
|
$object->zip = GETPOST("zipcode");
|
||||||
|
$object->town = GETPOST("town");
|
||||||
|
$object->country_id = GETPOST("country_id");
|
||||||
|
|
||||||
|
// Fill array 'array_options' with data from add form
|
||||||
|
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
|
||||||
|
if ($ret < 0) $error++;
|
||||||
|
|
||||||
|
if (! $error) {
|
||||||
|
$ret = $object->update($id, $user);
|
||||||
|
if ($ret < 0) $error++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($error) {
|
||||||
|
$action = 'edit';
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
} else {
|
||||||
|
$categories = GETPOST('categories', 'array');
|
||||||
|
$object->setCategories($categories);
|
||||||
|
$action = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$action = 'edit';
|
$action = 'edit';
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
} else {
|
}
|
||||||
$categories = GETPOST('categories', 'array');
|
|
||||||
$object->setCategories($categories);
|
|
||||||
$action = '';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
elseif ($action == 'update_extras') {
|
||||||
|
$object->oldcopy = dol_clone($object);
|
||||||
|
|
||||||
|
// Fill array 'array_options' with data from update form
|
||||||
|
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
|
||||||
|
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none'));
|
||||||
|
if ($ret < 0) $error++;
|
||||||
|
if (! $error) {
|
||||||
|
$result = $object->insertExtraFields();
|
||||||
|
if ($result < 0) {
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($error) $action = 'edit_extras';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($cancel == $langs->trans("Cancel"))
|
||||||
{
|
{
|
||||||
$action = 'edit';
|
$action = '';
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Actions to build doc
|
||||||
|
$upload_dir = $conf->stock->dir_output;
|
||||||
|
$permissioncreate = $user->rights->stock->creer;
|
||||||
|
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
|
||||||
}
|
}
|
||||||
elseif ($action == 'update_extras') {
|
|
||||||
$object->oldcopy = dol_clone($object);
|
|
||||||
|
|
||||||
// Fill array 'array_options' with data from update form
|
|
||||||
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
|
|
||||||
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none'));
|
|
||||||
if ($ret < 0) $error++;
|
|
||||||
if (! $error) {
|
|
||||||
$result = $object->insertExtraFields();
|
|
||||||
if ($result < 0) {
|
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($error) $action = 'edit_extras';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($cancel == $langs->trans("Cancel"))
|
|
||||||
{
|
|
||||||
$action = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Actions to build doc
|
|
||||||
$upload_dir = $conf->stock->dir_output;
|
|
||||||
$permissioncreate = $user->rights->stock->creer;
|
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user