productlot_card.php 21 KB

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