diff --git a/admin/setup.php b/admin/setup.php index 821231c..70a3d88 100644 --- a/admin/setup.php +++ b/admin/setup.php @@ -158,7 +158,7 @@ } 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); @@ -166,12 +166,13 @@ $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); } } @@ -242,10 +243,10 @@ print $langs->transnoentities('ProductServiceSetHelp'); print ''; print ''; -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 ''; print ''; -print $conf->global->DOLISIRH_PRODUCT_SERVICE_SET ? '' . $langs->transnoentities('Create') . '' : ''; +print (($conf->global->DOLISIRH_PRODUCT_SERVICE_SET == 2) ? '' . $langs->transnoentities('Create') . '' : ''); print ''; print ''; diff --git a/lib/dolisirh.lib.php b/lib/dolisirh.lib.php index 4a01d2b..cbc4cfc 100644 --- a/lib/dolisirh.lib.php +++ b/lib/dolisirh.lib.php @@ -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 ] ]; }