Просмотр исходного кода

Fix MAIN_USE_EXPENSE_RULE is now stable

Maxime Kohlhaas 3 лет назад
Родитель
Сommit
ae6cae0313

+ 4 - 6
htdocs/core/lib/expensereport.lib.php

@@ -140,12 +140,10 @@ function expensereport_admin_prepare_head()
 	$head[$h][2] = 'expensereport';
 	$h++;
 
-	if (!empty($conf->global->MAIN_USE_EXPENSE_RULE)) {
-		$head[$h][0] = DOL_URL_ROOT."/admin/expensereport_rules.php";
-		$head[$h][1] = $langs->trans("ExpenseReportsRules");
-		$head[$h][2] = 'expenserules';
-		$h++;
-	}
+	$head[$h][0] = DOL_URL_ROOT."/admin/expensereport_rules.php";
+	$head[$h][1] = $langs->trans("ExpenseReportsRules");
+	$head[$h][2] = 'expenserules';
+	$h++;
 
 	if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
 		$head[$h][0] = DOL_URL_ROOT."/admin/expensereport_ik.php";

+ 15 - 2
htdocs/expensereport/card.php

@@ -2050,6 +2050,11 @@ if ($action == 'create') {
 				// Picture
 				print '<td>';
 				print '</td>';
+
+				// Information if theres a rule restriction
+				print '<td>';
+				print '</td>';
+
 				// Ajout des boutons de modification/suppression
 				if (($object->status < 2 || $object->status == 99) && $user->rights->expensereport->creer) {
 					print '<td class="right"></td>';
@@ -2190,6 +2195,10 @@ if ($action == 'create') {
 						}
 						print '</td>';
 
+						print '<td class="nowrap right">';
+						print !empty($line->rule_warning_message) ? img_info(html_entity_decode($line->rule_warning_message)) : '&nbsp;';
+						print '</td>';
+
 						// Ajout des boutons de modification/suppression
 						if (($object->status < ExpenseReport::STATUS_VALIDATED || $object->status == ExpenseReport::STATUS_REFUSED) && $user->rights->expensereport->creer) {
 							print '<td class="nowrap right">';
@@ -2209,7 +2218,7 @@ if ($action == 'create') {
 
 					if ($action == 'editline' && $line->rowid == GETPOST('rowid', 'int')) {
 						// Add line with link to add new file or attach line to an existing file
-						$colspan = 10;
+						$colspan = 11;
 						if (!empty($conf->projet->enabled)) {
 							$colspan++;
 						}
@@ -2336,6 +2345,9 @@ if ($action == 'create') {
 						print '<td class="center">';
 						//print $line->fk_ecm_files;
 						print '</td>';
+						// Information if theres a rule restriction
+						print '<td class="center">';
+						print '</td>';
 
 						print '<td>';
 						print '<input type="hidden" name="rowid" value="'.$line->rowid.'">';
@@ -2351,7 +2363,7 @@ if ($action == 'create') {
 
 			 // Add a new line
 			if (($object->status == ExpenseReport::STATUS_DRAFT || $object->status == ExpenseReport::STATUS_REFUSED) && $action != 'editline' && $user->rights->expensereport->creer) {
-				$colspan = 11;
+				$colspan = 12;
 				if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
 					$colspan++;
 				}
@@ -2448,6 +2460,7 @@ if ($action == 'create') {
 				print '<td></td>';
 				print '<td></td>';
 				print '<td></td>';
+				print '<td></td>';
 				print '</tr>';
 
 				print '<tr class="oddeven nohover">';

+ 9 - 7
htdocs/expensereport/class/expensereport.class.php

@@ -998,7 +998,7 @@ class ExpenseReport extends CommonObject
 		$sql .= ' de.localtax1_tx, de.localtax2_tx, de.localtax1_type, de.localtax2_type,';
 		$sql .= ' de.fk_ecm_files,';
 		$sql .= ' de.total_ht, de.total_tva, de.total_ttc,';
-		$sql .= ' de.total_localtax1, de.total_localtax2,';
+		$sql .= ' de.total_localtax1, de.total_localtax2, de.rule_warning_message,';
 		$sql .= ' ctf.code as code_type_fees, ctf.label as libelle_type_fees,';
 		$sql .= ' p.ref as ref_projet, p.title as title_projet';
 		$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line.' as de';
@@ -1055,6 +1055,8 @@ class ExpenseReport extends CommonObject
 				$deplig->projet_ref         = $objp->ref_projet;
 				$deplig->projet_title       = $objp->title_projet;
 
+				$deplig->rule_warning_message = $objp->rule_warning_message;
+
 				$deplig->rang               = $objp->rang;
 
 				$this->lines[$i] = $deplig;
@@ -1874,10 +1876,6 @@ class ExpenseReport extends CommonObject
 
 		$langs->load('trips');
 
-		if (empty($conf->global->MAIN_USE_EXPENSE_RULE)) {
-			return true; // if don't use rules
-		}
-
 		// We don't know seller and buyer for expense reports
 		if (!is_object($seller)) {
 			$seller = $mysoc;			// We use same than current company (expense report are often done in same country)
@@ -1975,7 +1973,7 @@ class ExpenseReport extends CommonObject
 		}
 		//$buyer = new Societe($this->db);
 
-		$expenseik = new ExpenseReportIk($db);
+		$expenseik = new ExpenseReportIk($this->db);
 		$range = $expenseik->getRangeByUser($userauthor, $this->line->fk_c_exp_tax_cat);
 
 		if (empty($range)) {
@@ -2603,6 +2601,8 @@ class ExpenseReportLine
 	 */
 	public $fk_ecm_files;
 
+	public $rule_warning_message;
+
 
 	/**
 	 * Constructor
@@ -2624,7 +2624,7 @@ class ExpenseReportLine
 	{
 		$sql = 'SELECT fde.rowid, fde.fk_expensereport, fde.fk_c_type_fees, fde.fk_c_exp_tax_cat, fde.fk_projet as fk_project, fde.date,';
 		$sql .= ' fde.tva_tx as vatrate, fde.vat_src_code, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc, fde.fk_ecm_files,';
-		$sql .= ' fde.localtax1_tx, fde.localtax2_tx, fde.localtax1_type, fde.localtax2_type, fde.total_localtax1, fde.total_localtax2,';
+		$sql .= ' fde.localtax1_tx, fde.localtax2_tx, fde.localtax1_type, fde.localtax2_type, fde.total_localtax1, fde.total_localtax2, fde.rule_warning_message,';
 		$sql .= ' ctf.code as type_fees_code, ctf.label as type_fees_libelle,';
 		$sql .= ' pjt.rowid as projet_id, pjt.title as projet_title, pjt.ref as projet_ref';
 		$sql .= ' FROM '.MAIN_DB_PREFIX.'expensereport_det as fde';
@@ -2670,6 +2670,8 @@ class ExpenseReportLine
 
 			$this->fk_ecm_files = $objp->fk_ecm_files;
 
+			$this->rule_warning_message = $objp->rule_warning_message;
+
 			$this->db->free($result);
 		} else {
 			dol_print_error($this->db);

+ 1 - 1
htdocs/expensereport/class/expensereport_ik.class.php

@@ -165,7 +165,7 @@ class ExpenseReportIk extends CoreObject
 			$sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'c_exp_tax_cat c ON (r.fk_c_exp_tax_cat = c.rowid)';
 		}
 		$sql .= ' WHERE r.fk_c_exp_tax_cat = '.((int) $fk_c_exp_tax_cat);
-		$sql .= " AND entity IN(0, ".getEntity($this->element).")";
+		$sql .= " AND r.entity IN(0, ".getEntity($this->element).")";
 		if ($active) {
 			$sql .= ' AND r.active = 1 AND c.active = 1';
 		}