productlot_card.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. <?php
  2. /* Copyright (C) 2007-2018 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2018 All-3kcis <contact@all-3kcis.fr>
  4. * Copyright (C) 2021 Noé Cendrier <noe.cendrier@altairis.fr>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file product/stock/productlot_card.php
  21. * \ingroup stock
  22. * \brief This file is an example of a php page
  23. * Initialy built by build_class_from_table on 2016-05-17 12:22
  24. */
  25. // Load Dolibarr environment
  26. require '../../main.inc.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  31. require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php';
  34. global $conf, $db, $langs, $user;
  35. // Load translation files required by the page
  36. $langs->loadLangs(array('stocks', 'other', 'productbatch'));
  37. // Get parameters
  38. $id = GETPOST('id', 'int');
  39. $lineid = GETPOST('lineid', 'int');
  40. $action = GETPOST('action', 'aZ09');
  41. $confirm = GETPOST('confirm', 'alpha');
  42. $cancel = GETPOST('cancel', 'aZ09');
  43. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'myobjectcard'; // To manage different context of search
  44. $backtopage = GETPOST('backtopage', 'alpha');
  45. // Initialize technical objects
  46. $object = new Productlot($db);
  47. $extrafields = new ExtraFields($db);
  48. $hookmanager->initHooks(array('productlotcard', 'globalcard')); // Note that conf->hooks_modules contains array
  49. // Fetch optionals attributes and labels
  50. $extrafields->fetch_name_optionals_label($object->table_element);
  51. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  52. // Initialize array of search criterias
  53. $search_all = GETPOST("search_all", 'alpha');
  54. $search = array();
  55. foreach ($object->fields as $key => $val) {
  56. if (GETPOST('search_'.$key, 'alpha')) {
  57. $search[$key] = GETPOST('search_'.$key, 'alpha');
  58. }
  59. }
  60. if (empty($action) && empty($id) && empty($ref)) {
  61. $action = 'view';
  62. }
  63. $batch = GETPOST('batch', 'alpha');
  64. $productid = GETPOST('productid', 'int');
  65. $ref = GETPOST('ref', 'alpha'); // ref is productid_batch
  66. $search_entity = GETPOST('search_entity', 'int');
  67. $search_fk_product = GETPOST('search_fk_product', 'int');
  68. $search_batch = GETPOST('search_batch', 'alpha');
  69. $search_fk_user_creat = GETPOST('search_fk_user_creat', 'int');
  70. $search_fk_user_modif = GETPOST('search_fk_user_modif', 'int');
  71. $search_import_key = GETPOST('search_import_key', 'int');
  72. if (empty($action) && empty($id) && empty($ref)) {
  73. $action = 'list';
  74. }
  75. // Load object
  76. //include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
  77. if ($id || $ref) {
  78. if ($ref) {
  79. $tmp = explode('_', $ref);
  80. $productid = $tmp[0];
  81. $batch = $tmp[1];
  82. }
  83. $object->fetch($id, $productid, $batch);
  84. $object->ref = $object->batch; // Old system for document management ( it uses $object->ref)
  85. $upload_dir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, $modulepart);
  86. $filearray = dol_dir_list($upload_dir, "files");
  87. if (empty($filearray)) {
  88. // If no files linked yet, use new system on lot id. (Batch is not unique and can be same on different product)
  89. $object->fetch($id, $productid, $batch);
  90. }
  91. }
  92. // Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array
  93. $hookmanager->initHooks(array('productlotcard', 'globalcard'));
  94. $permissionnote = $user->hasRight('stock', 'creer'); // Used by the include of actions_setnotes.inc.php
  95. $permissiondellink = $user->hasRight('stock', 'creer'); // Used by the include of actions_dellink.inc.php
  96. $permissiontoadd = $user->hasRight('stock', 'creer'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
  97. $usercanread = $user->hasRight('produit', 'lire');
  98. $usercancreate = $user->hasRight('produit', 'creer');
  99. $usercandelete = $user->hasRight('produit', 'supprimer');
  100. $upload_dir = $conf->productbatch->multidir_output[$conf->entity];
  101. $permissiontoread = $usercanread;
  102. $permissiontoadd = $usercancreate;
  103. $permissiontodelete = $usercandelete;
  104. // Security check
  105. if (!isModEnabled('productbatch')) {
  106. accessforbidden('Module not enabled');
  107. }
  108. $socid = 0;
  109. if ($user->socid > 0) { // Protection if external user
  110. //$socid = $user->socid;
  111. accessforbidden();
  112. }
  113. //$result = restrictedArea($user, 'productbatch');
  114. if (!$permissiontoread) {
  115. accessforbidden();
  116. }
  117. /*
  118. * Actions
  119. */
  120. $parameters = array();
  121. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  122. if ($reshook < 0) {
  123. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  124. }
  125. if (empty($reshook)) {
  126. $error = 0;
  127. $backurlforlist = dol_buildpath('/product/stock/productlot_list.php', 1);
  128. if ($action == 'seteatby' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) {
  129. $newvalue = dol_mktime(12, 0, 0, GETPOST('eatbymonth', 'int'), GETPOST('eatbyday', 'int'), GETPOST('eatbyyear', 'int'));
  130. $result = $object->setValueFrom('eatby', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY');
  131. if ($result < 0) {
  132. setEventMessages($object->error, null, 'errors');
  133. $action = 'editeatby';
  134. } else {
  135. $action = 'view';
  136. }
  137. }
  138. if ($action == 'setsellby' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) {
  139. $newvalue = dol_mktime(12, 0, 0, GETPOST('sellbymonth', 'int'), GETPOST('sellbyday', 'int'), GETPOST('sellbyyear', 'int'));
  140. $result = $object->setValueFrom('sellby', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY');
  141. if ($result < 0) {
  142. setEventMessages($object->error, null, 'errors');
  143. $action = 'editsellby';
  144. } else {
  145. $action = 'view';
  146. }
  147. }
  148. if ($action == 'seteol_date' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) {
  149. $newvalue = dol_mktime(12, 0, 0, GETPOST('eol_datemonth', 'int'), GETPOST('eol_dateday', 'int'), GETPOST('eol_dateyear', 'int'));
  150. $result = $object->setValueFrom('eol_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY');
  151. if ($result < 0) {
  152. setEventMessages($object->error, null, 'errors');
  153. $action = 'editeol_date';
  154. } else {
  155. $action = 'view';
  156. }
  157. }
  158. if ($action == 'setmanufacturing_date' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) {
  159. $newvalue = dol_mktime(12, 0, 0, GETPOST('manufacturing_datemonth', 'int'), GETPOST('manufacturing_dateday', 'int'), GETPOST('manufacturing_dateyear', 'int'));
  160. $result = $object->setValueFrom('manufacturing_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY');
  161. if ($result < 0) {
  162. setEventMessages($object->error, null, 'errors');
  163. $action = 'editmanufacturing_date';
  164. } else {
  165. $action = 'view';
  166. }
  167. }
  168. if ($action == 'setscrapping_date' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) {
  169. $newvalue = dol_mktime(12, 0, 0, GETPOST('scrapping_datemonth', 'int'), GETPOST('scrapping_dateday', 'int'), GETPOST('scrapping_dateyear', 'int'));
  170. $result = $object->setValueFrom('scrapping_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY');
  171. if ($result < 0) {
  172. setEventMessages($object->error, null, 'errors');
  173. $action = 'editscrapping_date';
  174. } else {
  175. $action = 'view';
  176. }
  177. }
  178. /* if ($action == 'setcommissionning_date' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) {
  179. $newvalue = dol_mktime(12, 0, 0, GETPOST('commissionning_datemonth', 'int'), GETPOST('commissionning_dateday', 'int'), GETPOST('commissionning_dateyear', 'int'));
  180. $result = $object->setValueFrom('commissionning_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY');
  181. if ($result < 0) {
  182. setEventMessages($object->error, null, 'errors');
  183. $action == 'editcommissionning_date';
  184. } else {
  185. $action = 'view';
  186. }
  187. } */
  188. if ($action == 'setqc_frequency' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) {
  189. $result = $object->setValueFrom('qc_frequency', GETPOST('qc_frequency'), '', null, 'int', '', $user, 'PRODUCT_MODIFY');
  190. if ($result < 0) { // Prévoir un test de format de durée
  191. setEventMessages($object->error, null, 'errors');
  192. $action = 'editqc_frequency';
  193. } else {
  194. $action = 'view';
  195. }
  196. }
  197. $triggermodname = 'PRODUCT_LOT_MODIFY'; // Name of trigger action code to execute when we modify record
  198. // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
  199. include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
  200. /*
  201. if ($action == 'update_extras') {
  202. $object->oldcopy = dol_clone($object, 2);
  203. // Fill array 'array_options' with data from update form
  204. $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml'));
  205. if ($ret < 0) $error++;
  206. if (!$error) {
  207. // Actions on extra fields
  208. $result = $object->insertExtraFields('PRODUCT_LOT_MODIFY');
  209. if ($result < 0) {
  210. setEventMessages($object->error, $object->errors, 'errors');
  211. $error++;
  212. }
  213. }
  214. if ($error) {
  215. $action = 'edit_extras';
  216. }
  217. }
  218. // Action to add record
  219. if ($action == 'add') {
  220. if (GETPOST('cancel', 'alpha')) {
  221. $urltogo = $backtopage ? $backtopage : dol_buildpath('/stock/list.php', 1);
  222. header("Location: ".$urltogo);
  223. exit;
  224. }
  225. $error = 0;
  226. $object->entity = GETPOST('entity', 'int');
  227. $object->fk_product = GETPOST('fk_product', 'int');
  228. $object->batch = GETPOST('batch', 'alpha');
  229. $object->fk_user_creat = GETPOST('fk_user_creat', 'int');
  230. $object->fk_user_modif = GETPOST('fk_user_modif', 'int');
  231. $object->import_key = GETPOST('import_key', 'int');
  232. if (empty($object->ref)) {
  233. $error++;
  234. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors');
  235. }
  236. if (!$error) {
  237. $result = $object->create($user);
  238. if ($result > 0) {
  239. // Creation OK
  240. $urltogo = $backtopage ? $backtopage : dol_buildpath('/stock/list.php', 1);
  241. header("Location: ".$urltogo);
  242. exit;
  243. }
  244. {
  245. // Creation KO
  246. if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
  247. else setEventMessages($object->error, null, 'errors');
  248. $action = 'create';
  249. }
  250. } else {
  251. $action = 'create';
  252. }
  253. }
  254. // Cancel
  255. if ($action == 'update' && GETPOST('cancel', 'alpha')) $action = 'view';
  256. // Action to update record
  257. if ($action == 'update' && !GETPOST('cancel', 'alpha')) {
  258. $error = 0;
  259. $object->entity = GETPOST('entity', 'int');
  260. $object->fk_product = GETPOST('fk_product', 'int');
  261. $object->batch = GETPOST('batch', 'alpha');
  262. $object->fk_user_creat = GETPOST('fk_user_creat', 'int');
  263. $object->fk_user_modif = GETPOST('fk_user_modif', 'int');
  264. $object->import_key = GETPOST('import_key', 'int');
  265. if (empty($object->ref)) {
  266. $error++;
  267. setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors');
  268. }
  269. if (!$error) {
  270. $result = $object->update($user);
  271. if ($result > 0) {
  272. $action = 'view';
  273. } else {
  274. // Creation KO
  275. if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
  276. else setEventMessages($object->error, null, 'errors');
  277. $action = 'edit';
  278. }
  279. } else {
  280. $action = 'edit';
  281. }
  282. }
  283. // Action to delete
  284. if ($action == 'confirm_delete') {
  285. $result = $object->delete($user);
  286. if ($result > 0) {
  287. // Delete OK
  288. setEventMessages("RecordDeleted", null, 'mesgs');
  289. header("Location: ".dol_buildpath('/stock/list.php', 1));
  290. exit;
  291. } else {
  292. if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
  293. else setEventMessages($object->error, null, 'errors');
  294. }
  295. }
  296. */
  297. // Action to build doc
  298. include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
  299. // Actions to send emails
  300. $triggersendname = 'PRODUCT_LOT_SENTBYMAIL';
  301. $autocopy = 'MAIN_MAIL_AUTOCOPY_PRODUCT_LOT_TO';
  302. $trackid = 'productlot'.$object->id;
  303. include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
  304. }
  305. /*
  306. * View
  307. */
  308. $form = new Form($db);
  309. $formfile = new FormFile($db);
  310. $title = $langs->trans("ProductLot");
  311. $help_url = '';
  312. llxHeader('', $title, $help_url);
  313. // Part to create
  314. if ($action == 'create') {
  315. print load_fiche_titre($langs->trans("Batch"), '', 'object_'.$object->picto);
  316. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  317. print '<input type="hidden" name="token" value="'.newToken().'">';
  318. print '<input type="hidden" name="action" value="add">';
  319. if ($backtopage) {
  320. print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
  321. }
  322. if ($backtopageforcancel) {
  323. print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
  324. }
  325. print dol_get_fiche_head(array(), '');
  326. print '<table class="border centpercent tableforfieldcreate">'."\n";
  327. // Common attributes
  328. include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
  329. // Other attributes
  330. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
  331. print '</table>'."\n";
  332. print dol_get_fiche_end();
  333. print $form->buttonsSaveCancel("Create");
  334. print '</form>';
  335. //dol_set_focus('input[name="ref"]');
  336. }
  337. // Part to show record
  338. if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
  339. $res = $object->fetch_optionals();
  340. $head = productlot_prepare_head($object);
  341. print dol_get_fiche_head($head, 'card', $langs->trans("Batch"), -1, $object->picto);
  342. $formconfirm = '';
  343. // Confirmation to delete
  344. if ($action == 'delete') {
  345. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBatch'), $langs->trans('ConfirmDeleteBatch'), 'confirm_delete', '', 0, 1);
  346. }
  347. // Call Hook formConfirm
  348. $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
  349. $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  350. if (empty($reshook)) {
  351. $formconfirm .= $hookmanager->resPrint;
  352. } elseif ($reshook > 0) {
  353. $formconfirm = $hookmanager->resPrint;
  354. }
  355. // Print form confirm
  356. print $formconfirm;
  357. // Object card
  358. // ------------------------------------------------------------
  359. $linkback = '<a href="'.DOL_URL_ROOT.'/product/stock/productlot_list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  360. $shownav = 1;
  361. if ($user->socid && !in_array('batch', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) {
  362. $shownav = 0;
  363. }
  364. $morehtmlref = '';
  365. dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'batch', $morehtmlref);
  366. print '<div class="fichecenter">';
  367. print '<div class="underbanner clearboth"></div>';
  368. print '<table class="border centpercent tableforfield">'."\n";
  369. // Product
  370. print '<tr><td class="titlefield">'.$langs->trans("Product").'</td><td>';
  371. $producttmp = new Product($db);
  372. $producttmp->fetch($object->fk_product);
  373. print $producttmp->getNomUrl(1, 'stock')." - ".$producttmp->label;
  374. print '</td></tr>';
  375. // Sell by
  376. if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) {
  377. print '<tr><td>';
  378. print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->hasRight('stock', 'creer'), 'datepicker');
  379. print '</td><td>';
  380. print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->hasRight('stock', 'creer'), 'datepicker', '', null, null, '', 1, '', 'id', 'auto', array(), $action);
  381. print '</td>';
  382. print '</tr>';
  383. }
  384. // Eat by
  385. if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) {
  386. print '<tr><td>';
  387. print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->hasRight('stock', 'creer'), 'datepicker');
  388. print '</td><td>';
  389. print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->hasRight('stock', 'creer'), 'datepicker', '', null, null, '', 1, '', 'id', 'auto', array(), $action);
  390. print '</td>';
  391. print '</tr>';
  392. }
  393. if (getDolGlobalString('PRODUCT_LOT_ENABLE_TRACEABILITY')) {
  394. print '<tr><td>'.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->hasRight('stock', 'creer')).'</td>';
  395. print '<td>'.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->hasRight('stock', 'creer'), 'datepicker').'</td>';
  396. print '</tr>';
  397. // print '<tr><td>'.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->hasRight('stock', 'creer')).'</td>';
  398. // print '<td>'.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->hasRight('stock', 'creer'), 'datepicker').'</td>';
  399. // print '</tr>';
  400. print '<tr><td>'.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->hasRight('stock', 'creer')).'</td>';
  401. print '<td>'.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->hasRight('stock', 'creer'), 'datepicker').'</td>';
  402. print '</tr>';
  403. }
  404. // Quality control
  405. if (getDolGlobalString('PRODUCT_LOT_ENABLE_QUALITY_CONTROL')) {
  406. print '<tr><td>'.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->hasRight('stock', 'creer')).'</td>';
  407. print '<td>'.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->hasRight('stock', 'creer'), 'datepicker').'</td>';
  408. print '</tr>';
  409. print '<tr><td>'.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->hasRight('stock', 'creer')).'</td>';
  410. print '<td>'.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->hasRight('stock', 'creer'), 'string').'</td>';
  411. print '</tr>';
  412. print '<tr><td>'.$form->editfieldkey($langs->trans('Lifetime'), 'lifetime', $object->lifetime, $object, $user->hasRight('stock', 'creer')).'</td>';
  413. print '<td>'.$form->editfieldval($langs->trans('Lifetime'), 'lifetime', $object->lifetime, $object, $user->hasRight('stock', 'creer'), 'string').'</td>';
  414. print '</tr>';
  415. }
  416. // Other attributes
  417. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
  418. print '</table>';
  419. print '</div>';
  420. print '<div class="clearboth"></div>';
  421. print dol_get_fiche_end();
  422. // Link to other lists
  423. print '<a href="'.DOL_URL_ROOT.'/product/reassortlot.php?sref='.urlencode($producttmp->ref).'&search_batch='.urlencode($object->batch).'">'.img_object('', 'stock', 'class="pictofixedwidth"').$langs->trans("ShowCurrentStockOfLot").'</a><br>';
  424. print '<br>';
  425. print '<a href="'.DOL_URL_ROOT.'/product/stock/movement_list.php?search_product_ref='.urlencode($producttmp->ref).'&search_batch='.urlencode($object->batch).'">'.img_object('', 'movement', 'class="pictofixedwidth"').$langs->trans("ShowLogOfMovementIfLot").'</a><br>';
  426. print '<br>';
  427. // Buttons for actions
  428. if ($action != 'presend' && $action != 'editline') {
  429. print '<div class="tabsAction">'."\n";
  430. $parameters = array();
  431. $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  432. if ($reshook < 0) {
  433. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  434. }
  435. if (empty($reshook)) {
  436. /*TODO
  437. if ($user->hasRight('stock', 'lire')) {
  438. print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a></div>'."\n";
  439. }
  440. */
  441. print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete);
  442. }
  443. print '</div>'."\n";
  444. }
  445. }
  446. /*
  447. * Generated documents
  448. */
  449. if ($action != 'presend') {
  450. print '<div class="fichecenter"><div class="fichehalfleft">';
  451. print '<a name="builddoc"></a>'; // ancre
  452. $includedocgeneration = 1;
  453. // Documents
  454. if ($includedocgeneration) {
  455. $objref = dol_sanitizeFileName($object->ref);
  456. $relativepath = $objref.'/'.$objref.'.pdf';
  457. $filedir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'product_batch');
  458. $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
  459. $genallowed = $usercanread; // If you can read, you can build the PDF to read content
  460. $delallowed = $usercancreate; // If you can create/edit, you can remove a file on card
  461. print $formfile->showdocuments('product_batch', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, '', 0, '', (empty($object->default_lang) ? '' : $object->default_lang), '', $object);
  462. }
  463. print '</div><div class="fichehalfright">';
  464. $MAXEVENT = 10;
  465. include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
  466. $formactions = new FormActions($db);
  467. $somethingshown = $formactions->showactions($object, 'productlot', 0, 1, '', $MAXEVENT);
  468. print '</div></div>';
  469. }
  470. // End of page
  471. llxFooter();
  472. $db->close();