浏览代码

New: Add number of expense reports to pay

aspangaro 9 年之前
父节点
当前提交
bd69d37c3a

+ 6 - 0
htdocs/admin/delais.php

@@ -97,6 +97,12 @@ $modules=array(
 						'img' => 'user'
 				)
 		),
+		'expensereport' => array(
+				array(
+						'code' => 'MAIN_DELAY_EXPENSEREPORTS',
+						'img' => 'trip'
+				)
+		),
 );
 
 if ($action == 'update')

+ 2 - 0
htdocs/core/class/conf.class.php

@@ -474,6 +474,7 @@ class Conf
 		$this->adherent->cotisation			= new stdClass();
 		$this->bank->rappro					= new stdClass();
 		$this->bank->cheque					= new stdClass();
+		$this->expensereport->payment		= new stdClass();
 		$this->actions->warning_delay=(isset($this->global->MAIN_DELAY_ACTIONS_TODO)?$this->global->MAIN_DELAY_ACTIONS_TODO:7)*24*60*60;
 		$this->commande->client->warning_delay=(isset($this->global->MAIN_DELAY_ORDERS_TO_PROCESS)?$this->global->MAIN_DELAY_ORDERS_TO_PROCESS:2)*24*60*60;
 		$this->commande->fournisseur->warning_delay=(isset($this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS)?$this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS:7)*24*60*60;
@@ -486,6 +487,7 @@ class Conf
 		$this->adherent->cotisation->warning_delay=(isset($this->global->MAIN_DELAY_MEMBERS)?$this->global->MAIN_DELAY_MEMBERS:0)*24*60*60;
 		$this->bank->rappro->warning_delay=(isset($this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE)?$this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE:0)*24*60*60;
 		$this->bank->cheque->warning_delay=(isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT)?$this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT:0)*24*60*60;
+		$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;

+ 83 - 0
htdocs/expensereport/class/expensereport.class.php

@@ -1465,6 +1465,89 @@ class ExpenseReport extends CommonObject
         return $ret;
     }
 
+	/**
+     *      Charge indicateurs this->nb pour le tableau de bord
+     *
+     *      @return     int         <0 if KO, >0 if OK
+     */
+    function load_state_board()
+    {
+        global $conf;
+
+        $this->nb=array();
+
+        $sql = "SELECT count(ex.rowid) as nb";
+        $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as ex";
+        $sql.= " WHERE ex.fk_statut > 0";
+        $sql.= " AND ex.entity IN (".getEntity('expensereport', 1).")";
+
+        $resql=$this->db->query($sql);
+        if ($resql)
+        {
+            while ($obj=$this->db->fetch_object($resql))
+            {
+                $this->nb["expensereports"]=$obj->nb;
+            }
+            $this->db->free($resql);
+            return 1;
+        }
+        else
+        {
+            dol_print_error($this->db);
+            $this->error=$this->db->error();
+            return -1;
+        }
+
+    }
+
+    /**
+     *      Load indicators for dashboard (this->nbtodo and this->nbtodolate)
+     *
+     *      @param	User	$user   		Objet user
+     *      @return WorkboardResponse|int 	<0 if KO, WorkboardResponse if OK
+     */
+    function load_board($user)
+    {
+        global $conf, $langs;
+
+        if ($user->societe_id) return -1;   // protection pour eviter appel par utilisateur externe
+
+	    $now=dol_now();
+
+        $sql = "SELECT ex.rowid, ex.date_valid";
+        $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as ex";
+        $sql.= " WHERE ex.fk_statut = 5";
+        $sql.= " AND ex.entity IN (".getEntity('expensereport', 1).")";
+
+        $resql=$this->db->query($sql);
+        if ($resql)
+        {
+	        $langs->load("members");
+
+	        $response = new WorkboardResponse();
+	        $response->warning_delay=$conf->expensereport->payment->warning_delay/60/60/24;
+	        $response->label=$langs->trans("ExpenseReportsToPay");
+	        $response->url=DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm&amp;statut=5';
+	        $response->img=img_object($langs->trans("ExpenseReports"),"user");
+
+            while ($obj=$this->db->fetch_object($resql))
+            {
+	            $response->nbtodo++;
+
+                if ($this->db->jdate($obj->datevalid) < ($now - $conf->expensereport->payment->warning_delay)) {
+	                $response->nbtodolate++;
+                }
+            }
+
+            return $response;
+        }
+        else
+        {
+            dol_print_error($this->db);
+            $this->error=$this->db->error();
+            return -1;
+        }
+    }
 }
 
 

+ 25 - 8
htdocs/index.php

@@ -158,7 +158,8 @@ if (empty($user->societe_id))
 	    ! empty($conf->facture->enabled) && $user->rights->facture->lire,
 	    ! empty($conf->contrat->enabled) && $user->rights->contrat->activer,
 		! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire,
-		! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire);
+		! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire,
+		! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire);
 	    // Class file containing the method load_state_board for each line
 	    $includes=array(DOL_DOCUMENT_ROOT."/societe/class/client.class.php",
 	    DOL_DOCUMENT_ROOT."/societe/class/client.class.php",
@@ -171,7 +172,8 @@ if (empty($user->societe_id))
 	    DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php",
 	    DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php",
 	    DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.commande.class.php",
-	    DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.facture.class.php");
+	    DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.facture.class.php",
+		DOL_DOCUMENT_ROOT."/expensereport/class/expensereport.class.php");
 	    // Name class containing the method load_state_board for each line
 	    $classes=array('Client',
 	                   'Client',
@@ -184,7 +186,8 @@ if (empty($user->societe_id))
 	                   'Facture',
 	                   'Contrat',
 	                   'CommandeFournisseur',
-	                   'FactureFournisseur');
+	                   'FactureFournisseur',
+					   'ExpenseReport');
 	    // Cle array returned by the method load_state_board for each line
 	    $keys=array('customers',
 	                'prospects',
@@ -197,7 +200,8 @@ if (empty($user->societe_id))
 	                'invoices',
 	                'Contracts',
 	                'supplier_orders',
-	                'supplier_invoices');
+	                'supplier_invoices',
+					'expensereports');
 	    // Dashboard Icon lines
 	    $icons=array('company',
 	                 'company',
@@ -210,7 +214,8 @@ if (empty($user->societe_id))
 	                 'bill',
 	                 'order',
 	                 'order',
-	                 'bill');
+	                 'bill',
+					 'trip');
 	    // Translation keyword
 	    $titres=array("ThirdPartyCustomersStats",
 	                  "ThirdPartyProspectsStats",
@@ -223,7 +228,8 @@ if (empty($user->societe_id))
 	                  "BillsCustomers",
 	                  "Contracts",
 	                  "SuppliersOrders",
-	                  "SuppliersInvoices");
+	                  "SuppliersInvoices",
+					  "ExpenseReports");
 	    // Dashboard Link lines
 	    $links=array(DOL_URL_ROOT.'/comm/list.php',
 	    DOL_URL_ROOT.'/comm/prospect/list.php',
@@ -236,7 +242,8 @@ if (empty($user->societe_id))
 	    DOL_URL_ROOT.'/compta/facture/list.php?mainmenu=accountancy',
 	    DOL_URL_ROOT.'/contrat/list.php',
 	    DOL_URL_ROOT.'/fourn/commande/list.php',
-	    DOL_URL_ROOT.'/fourn/facture/list.php');
+	    DOL_URL_ROOT.'/fourn/facture/list.php',
+		DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm');
 	    // Translation lang files
 	    $langfile=array("companies",
 	                    "prospects",
@@ -247,7 +254,8 @@ if (empty($user->societe_id))
 	                    "propal",
 	                    "orders",
 	                    "bills",
-						"contracts");
+						"contracts",
+						"trips");
 
 
 	    // Loop and displays each line of table
@@ -402,6 +410,15 @@ if (! empty($conf->adherent->enabled) && $user->rights->adherent->lire && ! $use
     $dashboardlines[] = $board->load_board($user);
 }
 
+// Number of expense reports to pay
+if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire)
+{
+    include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
+    $board=new ExpenseReport($db);
+
+	$dashboardlines[] = $board->load_board($user);
+}
+
 // Calculate total nb of late
 $totallate=0;
 $var=true;

+ 1 - 0
htdocs/install/mysql/data/llx_const.sql

@@ -75,6 +75,7 @@ insert into llx_const (name, value, type, note, visible) values ('MAIN_DELAY_NOT
 insert into llx_const (name, value, type, note, visible) values ('MAIN_DELAY_RUNNING_SERVICES','0','chaine','Tolérance de retard avant alerte (en jours) sur services expirés',0);
 insert into llx_const (name, value, type, note, visible) values ('MAIN_DELAY_MEMBERS','31','chaine','Tolérance de retard avant alerte (en jours) sur cotisations adhérent en retard',0);
 insert into llx_const (name, value, type, note, visible) values ('MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE','62','chaine','Tolérance de retard avant alerte (en jours) sur rapprochements bancaires à faire',0);
+insert into llx_const (name, value, type, note, visible) values ('MAIN_DELAY_EXPENSEREPORTS_TO_PAY','31','chaine','Tolérance de retard avant alerte (en jours) sur les notes de frais impayées',0);
 
 
 --

+ 22 - 0
htdocs/install/mysql/migration/3.8.0-3.9.0.sql

@@ -0,0 +1,22 @@
+--
+-- Be carefull to requests order.
+-- This file must be loaded by calling /install/index.php page
+-- when current version is 3.9.0 or higher.
+--
+-- To rename a table:       ALTER TABLE llx_table RENAME TO llx_table_new;
+-- To add a column:         ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol;
+-- To rename a column:      ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60);
+-- To drop a column:        ALTER TABLE llx_table DROP COLUMN oldname;
+-- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60);
+-- To drop a foreign key:   ALTER TABLE llx_table DROP FOREIGN KEY fk_name;
+-- To restrict request to Mysql version x.y use -- VMYSQLx.y
+-- To restrict request to Pgsql version x.y use -- VPGSQLx.y
+-- To make pk to be auto increment (mysql):    VMYSQL4.3 ALTER TABLE llx_c_shipment_mode CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT;
+-- To make pk to be auto increment (postgres): VPGSQL8.2 NOT POSSIBLE. MUST DELETE/CREATE TABLE
+-- To set a field as NULL:                     VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL;
+-- To set a field as default NULL:             VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL;
+-- -- VPGSQL8.2 DELETE FROM llx_usergroup_user      WHERE fk_user      NOT IN (SELECT rowid from llx_user);
+-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user      WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
+
+
+insert into llx_const (name, value, type, note, visible) values ('MAIN_DELAY_EXPENSEREPORTS_TO_PAY','31','chaine','Tolérance de retard avant alerte (en jours) sur les notes de frais impayées',0);

+ 2 - 0
htdocs/langs/en_US/trips.lang

@@ -102,3 +102,5 @@ ConfirmSaveTrip=Are you sure you want to validate this expense report ?
 
 NoTripsToExportCSV=No expense report to export for this period.
 ExpenseReportPayment=Expense report payment
+
+ExpenseReportsToPay=Expense reports to pay