diff --git a/class/actions_gmao.class.php b/class/actions_gmao.class.php index fd867d2..6e6ce17 100644 --- a/class/actions_gmao.class.php +++ b/class/actions_gmao.class.php @@ -86,6 +86,26 @@ public function addHtmlHeader(array $parameters): int return 0; // or return 1 to replace standard code } + /** + * Overloading the formObjectOptions function : replacing the parent's function with the one below + * + * @param array $parameters Hook metadatas (context, etc...) + * @return int 0 < on error, 0 on success, 1 to replace standard code + * @throws Exception + */ + public function formObjectOptions(array $parameters, $object, $action): int + { + global $extrafields, $langs; + + if (strpos($parameters['context'], 'productlotcard') !== false) { + $pictoPath = dol_buildpath('/gmao/img/gmao_color.png', 1); + $picto = img_picto('', $pictoPath, '', 1, 0, 0, '', 'pictoModule marginrightonly'); + + $extrafields->attributes['product_lot']['label']['warehouse'] = $picto . $langs->transnoentities('Warehouse'); + } + return 0; + } + /** * Overloading the doActions function : replacing the parent's function with the one below * @@ -315,6 +335,27 @@ public function addMoreActionsButtons(array $parameters, &$object, &$action): in return 0; // or return 1 to replace standard code } + /** + * Overloading the printFieldListOption function : replacing the parent's function with the one below + * + * @param array $parameters Hook metadatas (context, etc...) + * @return int 0 < on error, 0 on success, 1 to replace standard code + * @throws Exception + */ + public function printFieldListOption(array $parameters): int + { + global $extrafields, $langs; + + if (strpos($parameters['context'], 'product_lotlist') !== false) { + $pictoPath = dol_buildpath('/gmao/img/gmao_color.png', 1); + $picto = img_picto('', $pictoPath, '', 1, 0, 0, '', 'pictoModule'); + + $extrafields->attributes['product_lot']['label']['warehouse'] = $picto . $langs->transnoentities('Warehouse'); + } + + return 0; + } + /** * Overloading the printCommonFooter function : replacing the parent's function with the one below * @@ -326,6 +367,7 @@ public function printCommonFooter(array $parameters): int { global $conf, $langs, $object; + if (strpos($parameters['context'], 'ticketcard') !== false) { if (getDolGlobalInt('TICKET_ENABLE_PUBLIC_INTERFACE')) { require_once __DIR__ . '/../../saturne/lib/medias.lib.php'; diff --git a/core/modules/modGMAO.class.php b/core/modules/modGMAO.class.php index 5592467..516b791 100644 --- a/core/modules/modGMAO.class.php +++ b/core/modules/modGMAO.class.php @@ -67,7 +67,6 @@ public function __construct($db) $this->familyinfo = ['Evarisk' => ['position' => '01', 'label' => 'Evarisk']]; // Module label (no space allowed), used if translation string 'ModuleGMAOName' not found (GMAO is name of module) $this->name = preg_replace('/^mod/i', '', get_class($this)); - // Module description, used if translation string 'ModuleGMAODesc' not found (GMAO is name of module) $this->description = $langs->trans('GMAODescription'); // Used only if file README.md and README-LL.md not found @@ -120,7 +119,9 @@ public function __construct($db) 'hooks' => [ 'ticketcard', 'gmaoadmindocuments', - 'inventorycard' + 'inventorycard', + 'product_lotlist', + 'productlotcard' ], // Set this to 1 if features of module are opened to external users 'moduleforexternal' => 0 @@ -268,7 +269,7 @@ public function __construct($db) */ public function init($options = ''): int { - global $conf, $db, $langs; + global $conf, $db, $langs, $user; // Permissions $this->remove($options); @@ -284,6 +285,14 @@ public function init($options = ''): int addDocumentModel('gmaoticketdocument_odt', 'gmaoticketdocument', 'ODT templates', 'GMAO_GMAOTICKETDOCUMENT_ADDON_ODT_PATH'); + // Create extrafields during init + include_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; + + $extra_fields = new ExtraFields($this->db); + + $extra_fields->update('warehouse', 'WareHouse', 'link', '', 'product_lot', 0, 0, $this->numero . 10, ['options' => ['Entrepot:product/stock/class/entrepot.class.php' => NULL]], 1, $user->hasRight('stock', 'lire'), 1, '', '', '', 0, 'stocks', "isModEnabled('gmao') && isModEnabled('stock') && isModEnabled('productbatch')", 0, 0, ['csslist' => 'minwidth100 maxwidth300']); + $extra_fields->addExtraField('warehouse', 'WareHouse', 'link', $this->numero . 10, '', 'product_lot ', 0, 0, '', ['options' => ['Entrepot:product/stock/class/entrepot.class.php' => NULL]], 1, $user->hasRight('stock', 'lire'), 1, '', '', 0, 'stocks', "isModEnabled('gmao') && isModEnabled('stock') && isModEnabled('productbatch')", 0, 0, ['csslist' => 'minwidth100 maxwidth300']); + return $this->_init($sql, $options); }