Browse Source

Fix navigation in accounting account card

Laurent Destailleur 7 years ago
parent
commit
15ed7584b8

+ 16 - 22
htdocs/accountancy/admin/card.php

@@ -39,6 +39,7 @@ $mesg = '';
 $action = GETPOST('action','aZ09');
 $backtopage = GETPOST('backtopage','alpha');
 $id = GETPOST('id', 'int');
+$ref = GETPOST('ref', 'alpha');
 $rowid = GETPOST('rowid', 'int');
 $cancel = GETPOST('cancel','alpha');
 
@@ -261,8 +262,10 @@ if ($action == 'create') {
 	print '</div>';
 
 	print '</form>';
-} else if ($id) {
-	$result = $object->fetch($id);
+}
+else if ($id > 0 || $ref) {
+
+	$result = $object->fetch($id, $ref, 1);
 
 	if ($result > 0) {
 		dol_htmloutput_mesg($mesg);
@@ -329,17 +332,18 @@ if ($action == 'create') {
 			// View mode
 			$linkback = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/account.php">' . $langs->trans("BackToList") . '</a>';
 
-			dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr');
+			dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), -1, 'billr');
 
-			print '<table class="border" width="100%">';
+			dol_banner_tab($object, 'ref', $linkback, 1, 'account_number', 'ref');
 
-			// Account number
-			print '<tr><td class="titlefield">' . $langs->trans("AccountNumber") . '</td>';
-			print '<td>' . $object->account_number . '</td>';
-			print '<td align="right" width="25%">' . $linkback . '</td></tr>';
+
+			print '<div class="fichecenter">';
+			print '<div class="underbanner clearboth"></div>';
+
+			print '<table class="border" width="100%">';
 
 			// Label
-			print '<tr><td>' . $langs->trans("Label") . '</td>';
+			print '<tr><td class="titlefield">' . $langs->trans("Label") . '</td>';
 			print '<td colspan="2">' . $object->label . '</td></tr>';
 
 			// Account parent
@@ -361,20 +365,10 @@ if ($action == 'create') {
 			print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
 			print '<td colspan="2">' . $object->pcg_subtype . '</td></tr>';
 
-			// Active
-			print '<tr><td>' . $langs->trans("Status") . '</td>';
-			print '<td colspan="2">';
-			print $object->getLibStatut(4);
-			/*if (empty($object->active)) {
-				print img_picto($langs->trans("Disabled"), 'switch_off');
-			} else {
-				print img_picto($langs->trans("Activated"), 'switch_on');
-			}*/
-
-			print '</td></tr>';
-
 			print '</table>';
 
+			print '</div>';
+
 			dol_fiche_end();
 
 			/*
@@ -397,7 +391,7 @@ if ($action == 'create') {
 			print '</div>';
 		}
 	} else {
-		dol_print_error($db);
+		dol_print_error($db, $object->error, $object->errors);
 	}
 }
 

+ 20 - 0
htdocs/accountancy/class/accountingaccount.class.php

@@ -30,6 +30,21 @@
  */
 class AccountingAccount extends CommonObject
 {
+	public $element='accounting_account';
+	public $table_element='accounting_account';
+	public $picto = 'billr';
+
+	/**
+	 * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
+	 * @var int
+	 */
+	public $ismultientitymanaged = 1;
+	/**
+	 * 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user
+	 * @var integer
+	 */
+	public $restrictiononfksoc = 1;
+
 	var $db;
 	var $error;
 	var $errors;
@@ -48,13 +63,17 @@ class AccountingAccount extends CommonObject
 	var $active;       // duplicate with status
 	var $status;
 
+
 	/**
 	 * Constructor
 	 *
 	 * @param DoliDB $db Database handle
 	 */
 	function __construct($db) {
+		global $conf;
+
 		$this->db = $db;
+		$this->next_prev_filter='fk_pcg_version IN (SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS . ')';		// Used to add a filter in Form::showrefnav method
 	}
 
 	/**
@@ -91,6 +110,7 @@ class AccountingAccount extends CommonObject
 				if ($obj) {
 					$this->id = $obj->rowid;
 					$this->rowid = $obj->rowid;
+					$this->ref = $obj->account_number;
 					$this->datec = $obj->datec;
 					$this->tms = $obj->tms;
 					$this->fk_pcg_version = $obj->fk_pcg_version;

+ 0 - 1
htdocs/core/class/html.form.class.php

@@ -6234,7 +6234,6 @@ class Form
 			$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters, $object);    // Note that $action and $object may have been modified by hook
 			$object->next_prev_filter.=$hookmanager->resPrint;
 		}
-
 		$previous_ref = $next_ref = '';
 		if ($shownav)
 		{

+ 4 - 0
htdocs/install/mysql/migration/6.0.0-7.0.0.sql

@@ -25,6 +25,10 @@
 -- -- VMYSQL4.1 DELETE FROM llx_usergroup_user      WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
 
 
+-- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_account MODIFY fk_pcg_version VARCHAR(20) CHARACTER SET utf8;
+-- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_account MODIFY fk_pcg_version VARCHAR(20) COLLATE utf8_unicode_ci;
+-- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_system MODIFY pcg_version VARCHAR(20) CHARACTER SET utf8;
+-- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_system MODIFY pcg_version VARCHAR(20) COLLATE utf8_unicode_ci;
 -- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) CHARACTER SET utf8;
 -- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) COLLATE utf8_unicode_ci;
 -- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_bookkeeping MODIFY numero_compte VARCHAR(20) CHARACTER SET utf8;

+ 4 - 1
htdocs/install/repair.php

@@ -1036,10 +1036,13 @@ if ($ok && GETPOST('force_utf8_on_tables','alpha'))
             print '<tr><td colspan="2">';
             print $table;
             $sql='ALTER TABLE '.$table.' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci';
+            print $sql;
             if (GETPOST('force_utf8_on_tables','alpha') == 'confirmed')
             {
-                $db->query($sql);
+            	$resql = $db->query($sql);
+            	print ' - Done ('.$resql.')';
             }
+            else print ' - Disabled';
             print '</td></tr>';
         }
     }