Skip to content

Commit

Permalink
#330 [Triggers] fix: getDolGlobalInt and timesheetline class access
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Jul 12, 2023
1 parent d6ca2e8 commit 4e6b1de
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions class/timesheet.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ class TimeSheetLine extends SaturneObject
* @var int Does this object support multicompany module ?
* 0 = No test on entity, 1 = Test with field entity, 'field@table' = Test with link by field@table.
*/
public int $ismultientitymanaged = 1;
public int $ismultientitymanaged = 0;

/**
* @var int Does object support extrafields ? 0 = No, 1 = Yes.
Expand Down Expand Up @@ -459,9 +459,9 @@ class TimeSheetLine extends SaturneObject
public $date_creation;

/**
* @var float Quantity.
* @var float|null Quantity.
*/
public float $qty;
public ?float $qty;

/**
* @var int Rang.
Expand All @@ -471,7 +471,7 @@ class TimeSheetLine extends SaturneObject
/**
* @var string Description.
*/
public string $description;
public string $description = '';

/**
* @var int|null Product type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf
$actioncomm->userownerid = $user->id;
$actioncomm->percentage = -1;

if (getDolGlobalInt($conf->global->DOLISIRH_ADVANCED_TRIGGER) && !empty($object->fields)) {
if (getDolGlobalInt('DOLISIRH_ADVANCED_TRIGGER') && !empty($object->fields)) {
$actioncomm->note_private = method_exists($object, 'getTriggerDescription') ? $object->getTriggerDescription($object) : '';
}

Expand Down Expand Up @@ -222,7 +222,7 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf
if ($object->src_object_type == 'dolisirh_timesheet') {
require_once __DIR__ . '/../../../saturne/class/saturnesignature.class.php';

$signatory = new SaturneSignature($this->db);
$signatory = new SaturneSignature($this->db, 'dolisirh');

$signatories = $signatory->fetchSignatories($object->src_object_id, 'timesheet');
if (!empty($signatories) && $signatories > 0) {
Expand All @@ -243,15 +243,15 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf
if (!empty($object->fk_user_assign)) {
require_once __DIR__ . '/../../../saturne/class/saturnesignature.class.php';

$signatory = new SaturneSignature($this->db);
$signatory = new SaturneSignature($this->db, 'dolisirh', $object->element);
$usertmp = new User($this->db);

$usertmp->fetch($object->fk_user_assign);
$signatory->setSignatory($object->id, $object->element, 'user', [$object->fk_user_assign], 'Signatory');
$signatory->setSignatory($object->id, $object->element, 'user', [$usertmp->fk_user], 'Responsible');
}

if (getDolGlobalInt($conf->global->DOLISIRH_PRODUCT_SERVICE_SET)) {
if (getDolGlobalInt('DOLISIRH_PRODUCT_SERVICE_SET')) {
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';

$product = new Product($this->db);
Expand Down
4 changes: 2 additions & 2 deletions view/timesheet/timesheet_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
// Initialize technical objects
$object = new TimeSheet($db);
$objectline = new TimeSheetLine($db);
$signatory = new SaturneSignature($db);
$signatory = new SaturneSignature($db, 'dolisirh');
$timesheetdocument = new TimeSheetDocument($db);
$extrafields = new ExtraFields($db);
$project = new Project($db);
Expand Down Expand Up @@ -924,7 +924,7 @@
$genallowed = $permissiontoadd; // If you can read, you can build the PDF to read content
$delallowed = $permissiontodelete; // If you can create/edit, you can remove a file on card

print doliSirhShowDocuments('dolisirh:TimeSheetDocument', $dir_files, $filedir, $urlsource, $genallowed, $object->status == $object::STATUS_LOCKED ? $delallowed : 0, $conf->global->DOLISIRH_TIMESHEETDOCUMENT_DEFAULT_MODEL, 1, 0, 0, 0, 0, '', '', '', $langs->defaultlang, $object, 0, 'removefile', $object->status == $object::STATUS_LOCKED && empty(dol_dir_list($filedir)), $langs->trans('TimeSheetMustBeLocked'));
print saturne_show_documents('dolisirh:TimeSheetDocument', $dir_files, $filedir, $urlsource, $genallowed, $object->status == $object::STATUS_LOCKED ? $delallowed : 0, $conf->global->DOLISIRH_TIMESHEETDOCUMENT_DEFAULT_MODEL, 1, 0, 0, 0, 0, '', '', '', $langs->defaultlang, $object, 0, 'removefile', $object->status == $object::STATUS_LOCKED && empty(dol_dir_list($filedir)), $langs->trans('TimeSheetMustBeLocked'));
}

print '</div><div class="fichehalfright">';
Expand Down

0 comments on commit 4e6b1de

Please sign in to comment.