Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#50 [Extrafield] add: extrafield for inventory on product lot #53

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions class/actions_gmao.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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
*
Expand All @@ -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';
Expand Down
15 changes: 12 additions & 3 deletions core/modules/modGMAO.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}

Expand Down