diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 02ccd13b97c..114648fdf14 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -2140,7 +2140,7 @@ abstract class CommonObject
$fieldstatus="fk_statut";
if ($elementTable == 'user') $fieldstatus="statut";
- if ($elementTable == 'expensereport') $fieldstatus="fk_c_expensereport_statuts";
+ if ($elementTable == 'expensereport') $fieldstatus="fk_statut";
if ($elementTable == 'commande_fournisseur_dispatch') $fieldstatus="status";
$sql = "UPDATE ".MAIN_DB_PREFIX.$elementTable;
diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php
index bdb19778c87..d2cdb71e429 100755
--- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php
+++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php
@@ -508,7 +508,7 @@ class pdf_standard extends ModeleExpenseReport
*/
// Filligrane brouillon
- if ($object->fk_c_expensereport_statuts==1 && ! empty($conf->global->EXPENSEREPORT_FREE_TEXT))
+ if ($object->fk_statut==1 && ! empty($conf->global->EXPENSEREPORT_FREE_TEXT))
{
pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->EXPENSEREPORT_FREE_TEXT);
}
@@ -640,7 +640,7 @@ class pdf_standard extends ModeleExpenseReport
$pdf->MultiCell(96,4,$outputlangs->transnoentities("DateCreation")." : ".dol_print_date($object->date_create,"day",false,$outpulangs),0,'L');
}
- if ($object->fk_c_expensereport_statuts==99)
+ if ($object->fk_statut==99)
{
if ($object->fk_user_refuse > 0)
{
@@ -656,7 +656,7 @@ class pdf_standard extends ModeleExpenseReport
$pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_REFUS")." : ".dol_print_date($object->date_refuse,"day",false,$outpulangs),0,'L');
}
}
- else if($object->fk_c_expensereport_statuts==4)
+ else if($object->fk_statut==4)
{
if ($object->fk_user_cancel > 0)
{
@@ -686,7 +686,7 @@ class pdf_standard extends ModeleExpenseReport
}
}
- if($object->fk_c_expensereport_statuts==6)
+ if($object->fk_statut==6)
{
if ($object->fk_user_paid > 0)
{
diff --git a/htdocs/core/modules/modExpenseReport.class.php b/htdocs/core/modules/modExpenseReport.class.php
index cf106fa4588..53289c512ff 100755
--- a/htdocs/core/modules/modExpenseReport.class.php
+++ b/htdocs/core/modules/modExpenseReport.class.php
@@ -270,7 +270,7 @@ class modExpenseReport extends DolibarrModules
'titre'=>'ListToApprove',
'mainmenu'=>'hrm',
'leftmenu'=>'expensereport_detaillist_approve',
- 'url'=>'/expensereport/list.php?search_state=2',
+ 'url'=>'/expensereport/list.php?search_status=2',
'langs'=>'trips', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>100,
'enabled'=>'$conf->expensereport->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php
index 02d899def0a..c71705628b6 100755
--- a/htdocs/expensereport/card.php
+++ b/htdocs/expensereport/card.php
@@ -1712,17 +1712,17 @@ else
print '
';
- // Sélection date
+ // Select date
print '| ';
$form->select_date($date?$date:-1,'date');
print ' | ';
- // Sélection projet
+ // Select project
print '';
$formproject->select_projects(-1, GETPOST('fk_projet'), 'fk_projet', 0, 0, 1, 1);
print ' | ';
- // Sélection type
+ // Select type
print '';
select_type_fees_id(GETPOST('fk_c_type_fees'),'fk_c_type_fees',1);
print ' | ';
@@ -1732,7 +1732,7 @@ else
print '';
print '';
- // Sélection TVA
+ // Select VAT
print '';
$defaultvat=-1;
if (! empty($conf->global->EXPENSEREPORT_NO_DEFAULT_VAT)) $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS = 'none';
@@ -1747,7 +1747,7 @@ else
print '';
print ' | ';
- // Quantité
+ // Quantity
print '';
print '';
print ' | ';
diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php
index 5d82aa1be4e..864c169c11c 100755
--- a/htdocs/expensereport/class/expensereport.class.php
+++ b/htdocs/expensereport/class/expensereport.class.php
@@ -335,7 +335,7 @@ class ExpenseReport extends CommonObject
if ($this->fk_user_validator > 0) $user_approver->fetch($this->fk_user_validator);
$this->user_validator_infos = dolGetFirstLastname($user_approver->firstname, $user_approver->lastname);
- $this->fk_statut = $obj->status;
+ $this->fk_statut = $obj->status;
$this->status = $obj->status;
$this->fk_c_paiement = $obj->fk_c_paiement;
diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php
index f48a0111a46..6d82b86e4af 100755
--- a/htdocs/expensereport/list.php
+++ b/htdocs/expensereport/list.php
@@ -21,12 +21,13 @@
/**
* \file htdocs/expensereport/index.php
- * \brief Page liste des expensereports
+ * \brief list of expense reports
*/
require "../main.inc.php";
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
+require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
$langs->load("companies");
$langs->load("users");
@@ -39,7 +40,7 @@ $result = restrictedArea($user, 'expensereport','','');
$search_ref = GETPOST('search_ref');
$search_user = GETPOST('search_user','int');
-$search_state = GETPOST('search_state','int');
+$search_status = GETPOST('search_status','int');
$month_start = GETPOST("month_start","int");
$year_start = GETPOST("year_start","int");
$month_end = GETPOST("month_end","int");
@@ -49,7 +50,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both
{
$search_ref="";
$search_user="";
- $search_state="";
+ $search_status="";
$month_start="";
$year_start="";
$month_end="";
@@ -69,13 +70,12 @@ llxHeader('', $langs->trans("ListOfTrips"));
$max_year = 5;
$min_year = 5;
-$sortorder = $_GET["sortorder"];
-$sortfield = $_GET["sortfield"];
-$page = $_GET["page"];
+$sortorder = GETPOST("sortorder");
+$sortfield = GETPOST("sortfield");
+$page = GETPOST("page");
if (!$sortorder) $sortorder="DESC";
if (!$sortfield) $sortfield="d.date_debut";
-
if ($page == -1) {
$page = 0 ;
}
@@ -91,73 +91,47 @@ $sql.= " u.rowid as id_user, u.firstname, u.lastname";
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON d.fk_user_author = u.rowid";
-
-
-// WHERE
+// Where
if(!empty($search_ref)){
$sql.= " WHERE d.ref LIKE '%".$db->escape($search_ref)."%'";
}else{
$sql.= " WHERE 1 = 1";
}
-// DATE START
-if ($month_start > 0) {
- if ($year_start > 0) {
- if($month_end > 0) {
- if($year_end > 0) {
- $sql.= " AND date_format(d.date_debut, '%Y-%m') >= '$year_start-$month_start'";
- $sql.= " AND date_format(d.date_fin, '%Y-%m') <= '$year_end-$month_end'";
- } else {
- $sql.= " AND date_format(d.date_debut, '%Y-%m') >= '$year_start-$month_start'";
- $sql.= " AND date_format(d.date_fin, '%m') <= '$month_end'";
- }
- } else {
- if($year_end > 0) {
- $sql.= " AND date_format(d.date_debut, '%Y-%m') >= '$year_start-$month_start'";
- $sql.= " AND date_format(d.date_fin, '%Y') <= '$year_end'";
- } else {
- $sql.= " AND date_format(d.date_debut, '%Y-%m') >= '$year_start-$month_start'";
- }
- }
- } else {
- $sql.= " AND date_format(d.date_debut, '%m') >= '$month_start'";
- }
-} else {
- if ($year_start > 0) {
- if($month_end > 0) {
- if($year_end > 0) {
- $sql.= " AND date_format(d.date_debut, '%Y') >= '$year_start'";
- $sql.= " AND date_format(d.date_fin, '%Y-%m') <= '$year_end-$month_end'";
- } else {
- $sql.= " AND date_format(d.date_debut, '%Y') >= '$year_start'";
- $sql.= " AND date_format(d.date_fin, '%m') <= '$month_end'";
- }
- } else {
- if($year_end > 0) {
- $sql.= " AND date_format(d.date_debut, '%Y') >= '$year_start'";
- $sql.= " AND date_format(d.date_fin, '%Y') <= '$year_end'";
- } else {
- $sql.= " AND date_format(d.date_debut, '%Y') >= '$year_start'";
- }
- }
- } else {
- if($month_end > 0) {
- if($year_end > 0) {
- $sql.= " AND date_format(d.date_debut, '%Y') >= '$year_start'";
- $sql.= " AND date_format(d.date_fin, '%Y-%m') <= '$year_end-$month_end'";
- } else {
- $sql.= " AND date_format(d.date_debut, '%Y') >= '$year_start'";
- $sql.= " AND date_format(d.date_fin, '%m') <= '$month_end'";
- }
- } else {
- if($year_end > 0) {
- $sql.= " AND date_format(d.date_debut, '%Y') >= '$year_start'";
- $sql.= " AND date_format(d.date_fin, '%Y') <= '$year_end'";
- }
- }
- }
+// Date Start
+if ($month_start > 0)
+{
+ if ($year_start > 0 && empty($day))
+ $sql.= " AND d.date_debut BETWEEN '".$db->idate(dol_get_first_day($year_start,$month_start,false))."' AND '".$db->idate(dol_get_last_day($year_start,$month_start,false))."'";
+ else if ($year_start > 0 && ! empty($day))
+ $sql.= " AND d.date_debut BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_start, $day, $year_start))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month_start, $day, $year_start))."'";
+ else
+ $sql.= " AND date_format(d.date_debut, '%m') = '".$month_start."'";
}
-if (!empty($search_user) && $search_user > 0) $sql.= " AND d.fk_user_author = '".$search_user."'";
-if($search_state != '') $sql.= " AND d.fk_statut = '$search_state'\n";
+else if ($year_start > 0)
+{
+ $sql.= " AND d.date_debut BETWEEN '".$db->idate(dol_get_first_day($year_start,1,false))."' AND '".$db->idate(dol_get_last_day($year_start,12,false))."'";
+}
+// Date Start
+if ($month_end > 0)
+{
+ if ($year_end > 0 && empty($day))
+ $sql.= " AND d.date_fin BETWEEN '".$db->idate(dol_get_first_day($year_end,$month_end,false))."' AND '".$db->idate(dol_get_last_day($year_end,$month_end,false))."'";
+ else if ($year_end > 0 && ! empty($day))
+ $sql.= " AND d.date_fin BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_end, $day, $year_end))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month_end, $day, $year_end))."'";
+ else
+ $sql.= " AND date_format(d.date_fin, '%m') = '".$month_end."'";
+}
+else if ($year_end > 0)
+{
+ $sql.= " AND d.date_fin BETWEEN '".$db->idate(dol_get_first_day($year_end,1,false))."' AND '".$db->idate(dol_get_last_day($year_end,12,false))."'";
+}
+// User
+if ($search_name)
+{
+ $sql .= natural_search('u.lastname', $search_name);
+}
+// Status
+if($search_status != '') $sql.= " AND d.fk_statut = '".$search_status."'";
// RESTRICT RIGHTS
if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous))
@@ -219,17 +193,13 @@ if ($resql)
print ' | ';
}
-
print ' | ';
-
print ' | ';
-
- print '';
- print " | ";
+ print ' | ';
// Status
print '';
- select_expensereport_statut($search_state,'search_state');
+ select_expensereport_statut($search_status,'search_status');
print ' | ';
print '';
@@ -257,10 +227,6 @@ if ($resql)
print ' | '.($objp->date_debut > 0 ? dol_print_date($objp->date_debut, 'day') : '').' | ';
print ''.($objp->date_fin > 0 ? dol_print_date($objp->date_fin, 'day') : '').' | ';
print ''.img_object($langs->trans("ShowUser"),"user").' '.dolGetFirstLastname($objp->firstname, $objp->lastname).' | ';
- /*print ''.price($objp->total_tva, '', $langs, 0, 'MT', 0, $conf->currency).' | ';
- print ''.price($objp->total_ht, '', $langs, 0, 'MT', 0, $conf->currency).' | ';
- print ''.price($objp->total_ttc, '', $langs, 0, 'MT', 0, $conf->currency).' | ';
- */
print ''.price($objp->total_ht).' | ';
print ''.price($objp->total_tva).' | ';
print ''.price($objp->total_ttc).' | ';
@@ -281,11 +247,7 @@ if ($resql)
print '
';
print '| '.$langs->trans("Total").' | ';
- /*
- print ''.price($total_total_tva, '', $langs, 0, 'MT', 0, $conf->currency).' | ';
- print ''.price($total_total_ht, '', $langs, 0, 'MT', 0, $conf->currency).' | ';
- print ''.price($total_total_ttc, '', $langs, 0, 'MT', 0, $conf->currency).' | ';
- */
+
print ''.$total_total_ht.' | ';
print ''.$total_total_tva.' | ';
print ''.$total_total_ttc.' | ';