Skip to content

Commit

Permalink
Merge pull request #614 from nicolas-eoxia/fix_fatal_qty_and_fk_user_…
Browse files Browse the repository at this point in the history
…assign

#613 [TimeSheet] fix: missing qty check and fk_user_assign
  • Loading branch information
nicolas-eoxia authored Sep 27, 2024
2 parents 51de216 + b9669fe commit d9c5df5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
6 changes: 3 additions & 3 deletions class/timesheet.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ class TimeSheet extends SaturneObject
'note_private' => ['type' => 'html', 'label' => 'NotePrivate', 'enabled' => 1, 'position' => 150, 'notnull' => 0, 'visible' => 0, 'cssview' => 'wordbreak', 'validate' => 1],
'fk_user_creat' => ['type' => 'integer:User:user/class/user.class.php', 'label' => 'UserAuthor', 'picto' => 'user', 'enabled' => 1, 'position' => 160, 'notnull' => 1, 'visible' => 0, 'foreignkey' => 'user.rowid'],
'fk_user_modif' => ['type' => 'integer:User:user/class/user.class.php', 'label' => 'UserModif', 'picto' => 'user', 'enabled' => 1, 'position' => 170, 'notnull' => 0, 'visible' => 0, 'foreignkey' => 'user.rowid'],
'fk_user_assign' => ['type' => 'integer:User:user/class/user.class.php:1:(t.employee:=:1:AND:t.fk_soc:IS:NULL:AND:t.statut:=:1)', 'label' => 'UserAssign', 'picto' => 'user', 'enabled' => 1, 'position' => 90, 'notnull' => 1, 'visible' => 1, 'index' => 1, 'css' => 'maxwidth500 widthcentpercentminusxx', 'validate' => 1, 'foreignkey' => 'user.rowid'],
'fk_project' => ['type' => 'integer:Project:projet/class/project.class.php:1', 'label' => 'Project', 'picto' => 'project', 'enabled' => '$conf->project->enabled', 'position' => 80, 'notnull' => 0, 'visible' => 1, 'index' => 1, 'css' => 'maxwidth500 widthcentpercentminusxx', 'validate' => 1, 'foreignkey' => 'projet.rowid'],
'fk_soc' => ['type' => 'integer:Societe:societe/class/societe.class.php:1', 'label' => 'ThirdParty', 'picto' => 'company', 'enabled' => '$conf->societe->enabled', 'position' => 120, 'notnull' => 0, 'visible' => 1, 'index' => 1, 'css' => 'maxwidth500 widthcentpercentminusxx', 'validate' => 1, 'foreignkey' => 'societe.rowid'],
'fk_user_assign' => ['type' => 'integer:User:user/class/user.class.php:1:(t.employee:=:1:AND:t.fk_soc:IS:NULL:AND:t.statut:=:1)', 'label' => 'UserAssign', 'picto' => 'user', 'enabled' => 1, 'position' => 90, 'notnull' => 1, 'visible' => 1, 'index' => 1, 'required' => 1, 'css' => 'maxwidth500 widthcentpercentminusxx', 'validate' => 1, 'foreignkey' => 'user.rowid'],
'fk_project' => ['type' => 'integer:Project:projet/class/project.class.php:1', 'label' => 'Project', 'picto' => 'project', 'enabled' => '$conf->project->enabled', 'position' => 80, 'notnull' => 0, 'visible' => 1, 'index' => 1, 'css' => 'maxwidth500 widthcentpercentminusxx', 'validate' => 1, 'foreignkey' => 'projet.rowid'],
'fk_soc' => ['type' => 'integer:Societe:societe/class/societe.class.php:1', 'label' => 'ThirdParty', 'picto' => 'company', 'enabled' => '$conf->societe->enabled', 'position' => 120, 'notnull' => 0, 'visible' => 1, 'index' => 1, 'css' => 'maxwidth500 widthcentpercentminusxx', 'validate' => 1, 'foreignkey' => 'societe.rowid'],
];

/**
Expand Down
1 change: 1 addition & 0 deletions langs/fr_FR/dolisirh.lang
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ ErrorConfigWorkingHours = Erreur : configuration des heure
GoToWorkingHours = Aller sur la page Horaire de travail de l'utilisateur %s
ErrorConfigProjectPage = Erreur : configuration des projets et tâches ressources humaines manquantes. <br> Impossible de génerer la navette.
GoToConfigProjectPage = Aller sur la page de configuration du projet Ressources Humaines
ErrorQtyProductServiceTimeSheet = Erreur : quantité de produit ou service nulle/incorrecte

# Data - Donnée
TimeSheet = Navette
Expand Down
41 changes: 25 additions & 16 deletions view/timesheet/timesheet_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
}

if (($action == 'add' || $action == 'update') && $permissiontoadd && !$cancel) {
$userTmp->fetch(GETPOST('fk_user_assign'));
$userTmp->fetch(GETPOST('fk_user_assign', 'int'));
$dateStart = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int'));
$dateEnd = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int'));
$versionEighteenOrMore = 0;
Expand Down Expand Up @@ -204,9 +204,13 @@
// Action to add line.
if ($action == 'addline' && $permissiontoadd) {
// Get parameters.
$qty = GETPOST('qty');
$prodEntryMode = GETPOST('prod_entry_mode');
$qty = GETPOST('qty', 'int');
if ($qty === null || $qty === '' || $qty < 0) {
setEventMessages($langs->trans('ErrorQtyProductServiceTimeSheet'), [], 'errors');
$error++;
}

$prodEntryMode = GETPOST('prod_entry_mode');
if ($prodEntryMode == 'free') {
$productType = GETPOST('type');
$description = GETPOST('dp_desc', 'restricthtml');
Expand Down Expand Up @@ -236,14 +240,14 @@
$error++;
}

// Initialize object timesheet line.
$objectLine->date_creation = $object->db->idate($now);
$objectLine->qty = $qty;
$objectLine->rang = 0;
$objectLine->fk_timesheet = $id;
$objectLine->fk_parent_line = 0;

if (!$error) {
// Initialize object timesheet line.
$objectLine->date_creation = $object->db->idate($now);
$objectLine->qty = $qty;
$objectLine->rang = 0;
$objectLine->fk_timesheet = $id;
$objectLine->fk_parent_line = 0;

$result = $objectLine->create($user);
if ($result > 0) {
// Creation timesheet line OK.
Expand All @@ -263,16 +267,21 @@
// Action to edit line.
if ($action == 'updateline' && $permissiontoadd) {
// Get parameters.
$qty = GETPOST('qty');
$description = GETPOST('product_desc', 'restricthtml');
$qty = GETPOST('qty', 'int');
if ($qty === null || $qty === '' || $qty < 0) {
setEventMessages($langs->trans('ErrorQtyProductServiceTimeSheet'), [], 'errors');
$error++;
}

$objectLine->fetch($lineid);
$description = GETPOST('product_desc', 'restricthtml');

// Initialize object timesheet line.
$objectLine->qty = $qty;
$objectLine->description = $description;
$objectLine->fetch($lineid);

if (!$error) {
// Initialize object timesheet line.
$objectLine->qty = $qty;
$objectLine->description = $description;

$result = $objectLine->update($user);
if ($result > 0) {
// Update timesheet line OK.
Expand Down

0 comments on commit d9c5df5

Please sign in to comment.