Skip to content

Commit

Permalink
#330 [Admin] add: update product_service_set for use new service
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Jul 19, 2023
1 parent 4e6b1de commit 497df7a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
13 changes: 7 additions & 6 deletions admin/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,20 +158,21 @@
}

if (GETPOST('product_service_set', 'alpha')) {
if ($conf->global->DOLISIRH_PRODUCT_SERVICE_SET == 0) {
if ($conf->global->DOLISIRH_PRODUCT_SERVICE_SET == 0 || $conf->global->DOLISIRH_PRODUCT_SERVICE_SET == 1) {
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';

$product = new Product($db);

$productOrServiceTimesheets = get_product_service_timesheet();

foreach ($productOrServiceTimesheets as $productOrServiceTimesheet) {
$product->ref = $productOrServiceTimesheet['name'];
$product->label = $productOrServiceTimesheet['name'];
$product->ref = $langs->transnoentities($productOrServiceTimesheet['name']);
$product->label = $langs->transnoentities($productOrServiceTimesheet['name']);
$product->type = $productOrServiceTimesheet['type'];
$product->create($user);
}

dolibarr_set_const($db, 'DOLISIRH_PRODUCT_SERVICE_SET', 1, 'integer', 0, '', $conf->entity);
dolibarr_set_const($db, 'DOLISIRH_PRODUCT_SERVICE_SET', 2, 'integer', 0, '', $conf->entity);
}
}

Expand Down Expand Up @@ -242,10 +243,10 @@
print $langs->transnoentities('ProductServiceSetHelp');
print '</td>';
print '<td class="center">';
print $conf->global->DOLISIRH_PRODUCT_SERVICE_SET ? $langs->transnoentities('AlreadyCreated') : $langs->transnoentities('NotCreated');
print (($conf->global->DOLISIRH_PRODUCT_SERVICE_SET == 2) ? $langs->transnoentities('AlreadyCreated') : $langs->transnoentities('NotCreated'));
print '</td>';
print '<td class="center">';
print $conf->global->DOLISIRH_PRODUCT_SERVICE_SET ? '<a class="butActionRefused">' . $langs->transnoentities('Create') . '</a>' : '<input type="submit" class="button" name="product_service_set" value="' . $langs->transnoentities('Create') . '">';
print (($conf->global->DOLISIRH_PRODUCT_SERVICE_SET == 2) ? '<a class="butActionRefused">' . $langs->transnoentities('Create') . '</a>' : '<input type="submit" class="button" name="product_service_set" value="' . $langs->transnoentities('Create') . '">');
print '</td>';
print '</tr>';

Expand Down
18 changes: 12 additions & 6 deletions lib/dolisirh.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,22 +135,28 @@ function get_product_service_timesheet(): array
{
return [
[
'name' => 'MealTicket'
'name' => 'MealTicket',
'type' => 0
],
[
'name' => 'JourneySubscription'
'name' => 'JourneySubscription',
'type' => 1
],
[
'name' => '13thMonthBonus'
'name' => '13thMonthBonus',
'type' => 1
],
[
'name' => 'SpecialBonus'
'name' => 'SpecialBonus',
'type' => 1
],
[
'name' => 'MealBaskets'
'name' => 'MealBaskets',
'type' => 1
],
[
'name' => 'TeleworkingPackage'
'name' => 'TeleworkingPackage',
'type' => 1
]
];
}

0 comments on commit 497df7a

Please sign in to comment.