diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 90df912e69d..96650c034f3 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -95,7 +95,8 @@ class Productlot extends CommonObject 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>500), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510, 'foreignkey'=>'llx_user.rowid'), - 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511) + 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), + 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000), ); /** diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 64902b02e86..0fd29543c6c 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -36,8 +36,35 @@ $langs->loadLangs(array('stocks', 'other', 'productbatch')); // Get parameters $id = GETPOST('id', 'int'); -$action = GETPOST('action', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'myobjectcard'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); + +// Initialize technical objects +$object = new ProductLot($db); +$extrafields = new ExtraFields($db); +$hookmanager->initHooks(array('productlotcard', 'globalcard')); // Note that conf->hooks_modules contains array + +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + +// Initialize array of search criterias +$search_all = GETPOST("search_all", 'alpha'); +$search = array(); +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha')) { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } +} + +if (empty($action) && empty($id) && empty($ref)) { + $action = 'view'; +} + $batch = GETPOST('batch', 'alpha'); $productid = GETPOST('productid', 'int'); $ref = GETPOST('ref', 'alpha'); // ref is productid_batch @@ -51,22 +78,6 @@ $search_import_key = GETPOST('search_import_key', 'int'); if (empty($action) && empty($id) && empty($ref)) $action = 'list'; - -// Protection if external user -if ($user->socid > 0) -{ - //accessforbidden(); -} -//$result = restrictedArea($user, 'mymodule', $id); - - -$object = new ProductLot($db); -$extrafields = new ExtraFields($db); -$formfile = new FormFile($db); - -// fetch optionals attributes and labels -$extrafields->fetch_name_optionals_label($object->table_element); - // Load object //include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals if ($id || $ref) @@ -81,6 +92,15 @@ if ($id || $ref) $object->ref = $object->batch; // For document management ( it use $object->ref) } +// Protection if external user +if ($user->socid > 0) +{ + //accessforbidden(); +} +//$result = restrictedArea($user, 'mymodule', $id); + + + // Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('productlotcard', 'globalcard')); @@ -93,16 +113,26 @@ $usercanread = $user->rights->produit->lire; $usercancreate = $user->rights->produit->creer; $usercandelete = $user->rights->produit->supprimer; +$upload_dir = $conf->productbatch->multidir_output[$conf->entity]; + +$permissiontoadd = $usercancreate; + + /* * Actions */ $parameters = array(); $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 ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} + +if (empty($reshook)) { + $error = 0; + + $backurlforlist = dol_buildpath('/product/stock/productlot_list.php', 1); -if (empty($reshook)) -{ if ($action == 'seteatby' && $user->rights->stock->creer) { $newvalue = dol_mktime(12, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); @@ -117,6 +147,11 @@ if (empty($reshook)) if ($result < 0) dol_print_error($db, $object->error); } + $triggermodname = 'PRODUCT_LOT_MODIFY'; // Name of trigger action code to execute when we modify record + + // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen + include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; + /* if ($action == 'update_extras') { $object->oldcopy = dol_clone($object); @@ -152,8 +187,6 @@ if (empty($reshook)) $error = 0; - /* object_prop_getpost_prop */ - $object->entity = GETPOST('entity', 'int'); $object->fk_product = GETPOST('fk_product', 'int'); $object->batch = GETPOST('batch', 'alpha'); @@ -241,11 +274,15 @@ if (empty($reshook)) else setEventMessages($object->error, null, 'errors'); } } - - // Actions to build doc - $upload_dir = $conf->productbatch->multidir_output[$conf->entity]; - $permissiontoadd = $usercancreate; +*/ + // Action to build doc include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + + // Actions to send emails + $triggersendname = 'PRODUCT_LOT_SENTBYMAIL'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_PRODUCT_LOT_TO'; + $trackid = 'productlot'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; } @@ -255,69 +292,98 @@ if (empty($reshook)) * View */ -llxHeader('', 'ProductLot', ''); - $form = new Form($db); +$formfile = new FormFile($db); + +$title = $langs->trans("ProductLot"); +$help_url = ''; +llxHeader('', $title, $help_url); + // Part to create -if ($action == 'create') -{ - print load_fiche_titre($langs->trans("Batch")); +if ($action == 'create') { + print load_fiche_titre($langs->trans("Batch"), '', 'object_'.$object->picto); print '