From 574f84bb84755d522e40e604d0e97e8f31d8f71c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Thu, 22 Dec 2016 15:49:06 +0100 Subject: [PATCH] Fix warning for approval delay. --- htdocs/core/class/conf.class.php | 3 +++ htdocs/expensereport/card.php | 6 +++--- htdocs/expensereport/class/expensereport.class.php | 10 +++++----- htdocs/expensereport/list.php | 8 ++++---- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 4002f437ede..5dba9afda4b 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -543,10 +543,13 @@ class Conf $this->bank->cheque->warning_delay=(isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT)?$this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT:0)*24*60*60; } if (isset($this->expensereport)) { + $this->expensereport->approve = new stdClass(); + $this->expensereport->approve->warning_delay=(isset($this->global->MAIN_DELAY_EXPENSEREPORTS)?$this->global->MAIN_DELAY_EXPENSEREPORTS:0)*24*60*60; $this->expensereport->payment = new stdClass(); $this->expensereport->payment->warning_delay=(isset($this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY)?$this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY:0)*24*60*60; } + // For modules that want to disable top or left menu if (! empty($this->global->MAIN_HIDE_TOP_MENU)) $this->dol_hide_topmenu=$this->global->MAIN_HIDE_TOP_MENU; if (! empty($this->global->MAIN_HIDE_LEFT_MENU)) $this->dol_hide_leftmenu=$this->global->MAIN_HIDE_LEFT_MENU; diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 3f827de3540..a42a8ae5890 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1515,17 +1515,17 @@ else // Validation date print '<tr>'; print '<td>'.$langs->trans("DATE_SAVE").'</td>'; - print '<td>'.dol_print_date($object->date_create,'dayhour'); + print '<td>'.dol_print_date($object->date_valid,'dayhour'); if ($object->status == 2 && $object->hasDelay('toapprove')) print ' '.img_warning($langs->trans("Late")); if ($object->status == 5 && $object->hasDelay('topay')) print ' '.img_warning($langs->trans("Late")); print '</td></tr>'; print '</tr>'; - // User to inform + // User to inform for approval if ($object->fk_statut < 3) // informed { print '<tr>'; - print '<td>'.$langs->trans("VALIDATOR").'</td>'; + print '<td>'.$langs->trans("VALIDATOR").'</td>'; // approver print '<td>'; if ($object->fk_user_validator > 0) { diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 9349e0e72e0..3ec9705d247 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -907,7 +907,6 @@ class ExpenseReport extends CommonObject } } } - if ($this->fk_statut != 2) { $now = dol_now(); @@ -918,7 +917,7 @@ class ExpenseReport extends CommonObject $sql.= ", ref_number_int = ".$ref_number_int; } $sql.= ' WHERE rowid = '.$this->id; - + $resql=$this->db->query($sql); if ($resql) { @@ -1635,11 +1634,12 @@ class ExpenseReport extends CommonObject if ($option == 'topay' && $this->status != 5) return false; $now = dol_now(); - if ($option == 'toapprove') - return $this->datevalid < ($now - $conf->expensereport->approve->warning_delay); + { + return ($this->datevalid?$this->datevalid:$this->date_valid) < ($now - $conf->expensereport->approve->warning_delay); + } else - return $this->datevalid < ($now - $conf->expensereport->payment->warning_delay); + return ($this->datevalid?$this->datevalid:$this->date_valid) < ($now - $conf->expensereport->payment->warning_delay); } } diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 476ef2224f5..ead495bc1a0 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -141,7 +141,7 @@ if (!empty($sall)) } // Ref if(!empty($search_ref)){ - $sql.= " AND d.ref LIKE '%".$db->escape($search_ref)."%'"; + $sql.= natural_search("d.ref", $search_ref); } // Date Start if ($month_start > 0) @@ -325,9 +325,9 @@ if ($resql) $expensereportstatic->id=$objp->rowid; $expensereportstatic->ref=$objp->ref; $expensereportstatic->status=$objp->status; - $expensereportstatic->valid=$objp->date_valid; - $expensereportstatic->date_debut=$objp->date_debut; - $expensereportstatic->date_fin=$objp->date_fin; + $expensereportstatic->date_valid=$db->jdate($objp->date_valid); + $expensereportstatic->date_debut=$db->jdate($objp->date_debut); + $expensereportstatic->date_fin=$db->jdate($objp->date_fin); $var=!$var; print "<tr ".$bc[$var].">"; -- GitLab