Save search criteria when using "back to" on accounting account
Change type of foreign key to be an integer to avoid CAST in requests
This commit is contained in:
parent
0475cb8018
commit
a231074012
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||
* Copyright (C) 2016-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2016-2018 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -176,11 +176,10 @@ $sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.pcg_subtype, aa.acco
|
||||
$sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
|
||||
// Dirty hack wainting that foreign key account_parent is an integer to be compared correctly with rowid
|
||||
if ($db->type == 'pgsql') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = CAST(aa.account_parent AS INTEGER)";
|
||||
else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = CAST(aa.account_parent AS UNSIGNED)";
|
||||
if ($db->type == 'pgsql') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent";
|
||||
else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent";
|
||||
$sql .= " WHERE asy.rowid = " . $pcgver;
|
||||
|
||||
//print $sql;
|
||||
if (strlen(trim($search_account))) $sql .= natural_search("aa.account_number", $search_account);
|
||||
if (strlen(trim($search_label))) $sql .= natural_search("aa.label", $search_label);
|
||||
if (strlen(trim($search_accountparent))) $sql .= natural_search("aa.account_parent", $search_accountparent);
|
||||
@ -256,7 +255,7 @@ if ($resql)
|
||||
else dol_print_error($db);
|
||||
print "</select>";
|
||||
print ajax_combobox("chartofaccounts");
|
||||
print '<input type="submit" class="button" name="change_chart" value="'.dol_escape_htmltag($langs->trans("ChangeAndLoad")).'">';
|
||||
print '<input type="submit" class="button" name="change_chart" tabindex="-1" value="'.dol_escape_htmltag($langs->trans("ChangeAndLoad")).'">';
|
||||
|
||||
print '<br>';
|
||||
print '<br>';
|
||||
@ -275,7 +274,7 @@ if ($resql)
|
||||
if (! empty($arrayfields['aa.pcg_type']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgtype" value="' . $search_pcgtype . '"></td>';
|
||||
if (! empty($arrayfields['aa.pcg_subtype']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgsubtype" value="' . $search_pcgsubtype . '"></td>';
|
||||
if (! empty($arrayfields['aa.active']['checked'])) print '<td class="liste_titre"> </td>';
|
||||
print '<td align="right" colspan="2" class="liste_titre">';
|
||||
print '<td align="right" class="liste_titre">';
|
||||
$searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
|
||||
print $searchpicto;
|
||||
print '</td>';
|
||||
@ -309,7 +308,7 @@ if ($resql)
|
||||
if (! empty($arrayfields['aa.account_number']['checked']))
|
||||
{
|
||||
print "<td>";
|
||||
print $accountstatic->getNomUrl(1);
|
||||
print $accountstatic->getNomUrl(1, 0, 0, '', 0, 1);
|
||||
print "</td>\n";
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
@ -188,12 +188,10 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
$title = $langs->trans('AccountAccounting') ." - ". $langs->trans('Card');
|
||||
$helpurl = '';
|
||||
llxheader('', $title, $helpurl);
|
||||
|
||||
$form = new Form($db);
|
||||
$formaccounting = new FormAccounting($db);
|
||||
@ -201,6 +199,11 @@ $formaccounting = new FormAccounting($db);
|
||||
$accountsystem = new AccountancySystem($db);
|
||||
$accountsystem->fetch($conf->global->CHARTOFACCOUNTS);
|
||||
|
||||
$title = $langs->trans('AccountAccounting') ." - ". $langs->trans('Card');
|
||||
$helpurl = '';
|
||||
llxheader('', $title, $helpurl);
|
||||
|
||||
|
||||
// Create mode
|
||||
if ($action == 'create') {
|
||||
print load_fiche_titre($langs->trans('NewAccountingAccount'));
|
||||
@ -330,7 +333,7 @@ else if ($id > 0 || $ref) {
|
||||
print '</form>';
|
||||
} else {
|
||||
// View mode
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/account.php">' . $langs->trans("BackToList") . '</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/account.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), -1, 'billr');
|
||||
|
||||
|
||||
@ -384,14 +384,15 @@ class AccountingAccount extends CommonObject
|
||||
/**
|
||||
* Return clicable name (with picto eventually)
|
||||
*
|
||||
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
|
||||
* @param int $withlabel 0=No label, 1=Include label of account
|
||||
* @param int $nourl 1=Disable url
|
||||
* @param string $moretitle Add more text to title tooltip
|
||||
* @param int $notooltip 1=Disable tooltip
|
||||
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
|
||||
* @param int $withlabel 0=No label, 1=Include label of account
|
||||
* @param int $nourl 1=Disable url
|
||||
* @param string $moretitle Add more text to title tooltip
|
||||
* @param int $notooltip 1=Disable tooltip
|
||||
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
|
||||
* @return string String with URL
|
||||
*/
|
||||
function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle='',$notooltip=0)
|
||||
function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle='',$notooltip=0, $save_lastsearch_value=-1)
|
||||
{
|
||||
global $langs, $conf, $user;
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||
@ -402,6 +403,11 @@ class AccountingAccount extends CommonObject
|
||||
|
||||
$url = DOL_URL_ROOT . '/accountancy/admin/card.php?id=' . $this->id;
|
||||
|
||||
// Add param to save lastsearch_values or not
|
||||
$add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
|
||||
if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
|
||||
if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
|
||||
|
||||
$picto = 'billr';
|
||||
$label='';
|
||||
|
||||
|
||||
@ -406,3 +406,8 @@ create table llx_asset_type_extrafields
|
||||
ALTER TABLE llx_asset_type_extrafields ADD INDEX idx_asset_type_extrafields (fk_object);
|
||||
|
||||
INSERT INTO llx_accounting_journal (rowid, code, label, nature, active) VALUES (7,'INV', 'Inventory journal', 8, 1);
|
||||
|
||||
UPDATE llx_accounting_account set account_parent = 0 WHERE account_parent = '' OR account_parent IS NULL;
|
||||
ALTER TABLE llx_accounting_account MODIFY COLUMN account_parent integer DEFAULT 0;
|
||||
ALTER TABLE llx_accounting_account ADD INDEX idx_accounting_account_account_parent (account_parent);
|
||||
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
|
||||
|
||||
ALTER TABLE llx_accounting_account ADD INDEX idx_accounting_account_fk_pcg_version (fk_pcg_version);
|
||||
ALTER TABLE llx_accounting_account ADD INDEX idx_accounting_account_account_parent (account_parent);
|
||||
|
||||
ALTER TABLE llx_accounting_account ADD UNIQUE INDEX uk_accounting_account (account_number, entity, fk_pcg_version);
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ create table llx_accounting_account
|
||||
pcg_type varchar(20) NOT NULL, -- First part of Key for predefined groups
|
||||
pcg_subtype varchar(20) NOT NULL, -- Second part of Key for predefined groups
|
||||
account_number varchar(32) NOT NULL,
|
||||
account_parent varchar(32) DEFAULT '0', -- Hierarchic parent. TODO Move this as integer, it is a foreign key of llx_accounting_account.rowid
|
||||
account_parent integer DEFAULT 0, -- Hierarchic parent.
|
||||
label varchar(255) NOT NULL,
|
||||
fk_accounting_category integer DEFAULT 0, -- ID of personalized group for report
|
||||
fk_user_author integer DEFAULT NULL,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user