Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
cd6f5fb8cb
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
|
/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
|
||||||
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||||
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -41,6 +41,7 @@ $action = GETPOST('action');
|
|||||||
$cancel = GETPOST('cancel');
|
$cancel = GETPOST('cancel');
|
||||||
$id = GETPOST('id', 'int');
|
$id = GETPOST('id', 'int');
|
||||||
$rowid = GETPOST('rowid', 'int');
|
$rowid = GETPOST('rowid', 'int');
|
||||||
|
|
||||||
$search_account = GETPOST("search_account");
|
$search_account = GETPOST("search_account");
|
||||||
$search_label = GETPOST("search_label");
|
$search_label = GETPOST("search_label");
|
||||||
$search_accountparent = GETPOST("search_accountparent");
|
$search_accountparent = GETPOST("search_accountparent");
|
||||||
@ -68,6 +69,15 @@ if (! $sortfield)
|
|||||||
if (! $sortorder)
|
if (! $sortorder)
|
||||||
$sortorder = "ASC";
|
$sortorder = "ASC";
|
||||||
|
|
||||||
|
$arrayfields=array(
|
||||||
|
'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1),
|
||||||
|
'aa.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
|
||||||
|
'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>0),
|
||||||
|
'aa.pcg_type'=>array('label'=>$langs->trans("Pcgtype"), 'checked'=>0),
|
||||||
|
'aa.pcg_subtype'=>array('label'=>$langs->trans("Pcgsubtype"), 'checked'=>0),
|
||||||
|
'aa.active'=>array('label'=>$langs->trans("Activated"), 'checked'=>1)
|
||||||
|
);
|
||||||
|
|
||||||
$accounting = new AccountingAccount($db);
|
$accounting = new AccountingAccount($db);
|
||||||
|
|
||||||
|
|
||||||
@ -95,6 +105,7 @@ if (empty($reshook))
|
|||||||
$search_accountparent = "";
|
$search_accountparent = "";
|
||||||
$search_pcgtype = "";
|
$search_pcgtype = "";
|
||||||
$search_pcgsubtype = "";
|
$search_pcgsubtype = "";
|
||||||
|
$search_array_options=array();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GETPOST('change_chart'))
|
if (GETPOST('change_chart'))
|
||||||
@ -135,6 +146,7 @@ if (empty($reshook))
|
|||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
$form=new Form($db);
|
||||||
|
|
||||||
llxHeader('', $langs->trans("ListAccounts"));
|
llxHeader('', $langs->trans("ListAccounts"));
|
||||||
|
|
||||||
@ -145,8 +157,6 @@ if ($action == 'delete') {
|
|||||||
|
|
||||||
$pcgver = $conf->global->CHARTOFACCOUNTS;
|
$pcgver = $conf->global->CHARTOFACCOUNTS;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.pcg_subtype, aa.account_number, aa.account_parent , aa.label, aa.active, ";
|
$sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.pcg_subtype, aa.account_number, aa.account_parent , aa.label, aa.active, ";
|
||||||
$sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2";
|
$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 .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
|
||||||
@ -154,21 +164,12 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_vers
|
|||||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON aa.account_parent = a2.rowid";
|
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON aa.account_parent = a2.rowid";
|
||||||
$sql .= " WHERE asy.rowid = " . $pcgver;
|
$sql .= " WHERE asy.rowid = " . $pcgver;
|
||||||
|
|
||||||
if (strlen(trim($search_account))) {
|
if (strlen(trim($search_account))) $sql .= natural_search("aa.account_number", $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);
|
||||||
if (strlen(trim($search_label))) {
|
if (strlen(trim($search_pcgtype))) $sql .= natural_search("aa.pcg_type", $search_pcgtype);
|
||||||
$sql .= natural_search("aa.label", $search_label);
|
if (strlen(trim($search_pcgsubtype))) $sql .= natural_search("aa.pcg_subtype", $search_pcgsubtype);
|
||||||
}
|
|
||||||
if (strlen(trim($search_accountparent))) {
|
|
||||||
$sql .= natural_search("aa.account_parent", $search_accountparent);
|
|
||||||
}
|
|
||||||
if (strlen(trim($search_pcgtype))) {
|
|
||||||
$sql .= natural_search("aa.pcg_type", $search_pcgtype);
|
|
||||||
}
|
|
||||||
if (strlen(trim($search_pcgsubtype))) {
|
|
||||||
$sql .= natural_search("aa.pcg_subtype", $search_pcgsubtype);
|
|
||||||
}
|
|
||||||
$sql .= $db->order($sortfield, $sortorder);
|
$sql .= $db->order($sortfield, $sortorder);
|
||||||
|
|
||||||
// Count total nb of records
|
// Count total nb of records
|
||||||
@ -184,18 +185,19 @@ $sql .= $db->plimit($limit + 1, $offset);
|
|||||||
dol_syslog('accountancy/admin/account.php:: $sql=' . $sql);
|
dol_syslog('accountancy/admin/account.php:: $sql=' . $sql);
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
|
|
||||||
if ($resql) {
|
if ($resql)
|
||||||
|
{
|
||||||
$num = $db->num_rows($resql);
|
$num = $db->num_rows($resql);
|
||||||
|
|
||||||
$params='';
|
$params='';
|
||||||
if ($search_account != "") $params.= '&search_account='.urlencode($search_account);
|
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||||
if ($search_label != "") $params.= '&search_label='.urlencode($search_label);
|
if ($search_account) $params.= '&search_account='.urlencode($search_account);
|
||||||
if ($search_accountparent != "") $params.= '&search_accountparent='.urlencode($search_accountparent);
|
if ($search_label) $params.= '&search_label='.urlencode($search_label);
|
||||||
if ($search_pcgtype != "") $params.= '&search_pcgtype='.urlencode($search_pcgtype);
|
if ($search_accountparent) $params.= '&search_accountparent='.urlencode($search_accountparent);
|
||||||
if ($search_pcgsubtype != "") $params.= '&search_pcgsubtype='.urlencode($search_pcgsubtype);
|
if ($search_pcgtype) $params.= '&search_pcgtype='.urlencode($search_pcgtype);
|
||||||
if ($optioncss != '') $param.='&optioncss='.$optioncss;
|
if ($search_pcgsubtype) $params.= '&search_pcgsubtype='.urlencode($search_pcgsubtype);
|
||||||
|
if ($optioncss) $param.='&optioncss='.$optioncss;
|
||||||
|
|
||||||
print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy');
|
print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy');
|
||||||
|
|
||||||
print '<form method="GET" action="' . $_SERVER["PHP_SELF"] . '">';
|
print '<form method="GET" action="' . $_SERVER["PHP_SELF"] . '">';
|
||||||
@ -207,7 +209,7 @@ if ($resql) {
|
|||||||
$sql = "SELECT rowid, pcg_version, label, active";
|
$sql = "SELECT rowid, pcg_version, label, active";
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_system";
|
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_system";
|
||||||
$sql .= " WHERE active = 1";
|
$sql .= " WHERE active = 1";
|
||||||
dol_syslog('accountancy/admin/index.php:: $sql=' . $sql);
|
dol_syslog('accountancy/admin/account.php:: $sql=' . $sql);
|
||||||
$resqlchart = $db->query($sql);
|
$resqlchart = $db->query($sql);
|
||||||
$var = true;
|
$var = true;
|
||||||
if ($resqlchart) {
|
if ($resqlchart) {
|
||||||
@ -228,34 +230,53 @@ if ($resql) {
|
|||||||
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" value="'.dol_escape_htmltag($langs->trans("ChangeAndLoad")).'">';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
print "<br>\n";
|
print "<br>\n";
|
||||||
|
|
||||||
|
print '</form>';
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
|
||||||
|
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||||
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
|
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||||
|
print '<input type="hidden" name="action" value="list">';
|
||||||
|
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||||
|
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||||
|
|
||||||
print '<a class="butAction" href="./card.php?action=create">' . $langs->trans("Addanaccount") . '</a>';
|
print '<a class="butAction" href="./card.php?action=create">' . $langs->trans("Addanaccount") . '</a>';
|
||||||
print '<a class="butAction" href="./categories.php">' . $langs->trans("ApplyMassCategories") . '</a>';
|
print '<a class="butAction" href="./categories.php">' . $langs->trans("ApplyMassCategories") . '</a>';
|
||||||
// print '<a class="butAction" href="./importaccounts.php">' . $langs->trans("ImportAccount") . '</a>';
|
// print '<a class="butAction" href="./importaccounts.php">' . $langs->trans("ImportAccount") . '</a>';
|
||||||
// print '<a class="butAction" href="./productaccount.php">' . $langs->trans("CheckProductAccountancyCode") . '</a>';
|
// print '<a class="butAction" href="./productaccount.php">' . $langs->trans("CheckProductAccountancyCode") . '</a>';
|
||||||
print '<br><br>';
|
print '<br><br>';
|
||||||
|
|
||||||
print '<table class="noborder" width="100%">';
|
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
|
||||||
print '<tr class="liste_titre">';
|
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||||
print_liste_field_titre($langs->trans("AccountNumber"), $_SERVER["PHP_SELF"], "aa.account_number", "", $params, "", $sortfield, $sortorder);
|
|
||||||
print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "aa.label", "", $params, "", $sortfield, $sortorder);
|
|
||||||
print_liste_field_titre($langs->trans("Accountparent"), $_SERVER["PHP_SELF"], "aa.account_parent", "", $params, "", $sortfield, $sortorder);
|
|
||||||
print_liste_field_titre($langs->trans("Pcgtype"), $_SERVER["PHP_SELF"], "aa.pcg_type", "", $params, "", $sortfield, $sortorder);
|
|
||||||
print_liste_field_titre($langs->trans("Pcgsubtype"), $_SERVER["PHP_SELF"], "aa.pcg_subtype", "", $params, "", $sortfield, $sortorder);
|
|
||||||
print_liste_field_titre($langs->trans("Activated"), $_SERVER["PHP_SELF"], "aa.active", "", $params, "", $sortfield, $sortorder);
|
|
||||||
print_liste_field_titre('', $_SERVER["PHP_SELF"], "", $params, "", 'width="60" align="center"', $sortfield, $sortorder);
|
|
||||||
print '</tr>';
|
|
||||||
|
|
||||||
|
print '<div class="div-table-responsive">';
|
||||||
|
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
|
||||||
|
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_account" value="' . $search_account . '"></td>';
|
|
||||||
print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="' . $search_label . '"></td>';
|
if (! empty($arrayfields['aa.account_number']['checked'])) print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"],"aa.account_number","",$param,'',$sortfield,$sortorder);
|
||||||
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_accountparent" value="' . $search_accountparent . '"></td>';
|
if (! empty($arrayfields['aa.label']['checked'])) print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"],"aa.label","",$param,'',$sortfield,$sortorder);
|
||||||
print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgtype" value="' . $search_pcgtype . '"></td>';
|
if (! empty($arrayfields['aa.account_parent']['checked'])) print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"],"aa.account_parent", "", $param,'align="left"',$sortfield,$sortorder);
|
||||||
print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_pcgsubtype" value="' . $search_pcgsubtype . '"></td>';
|
if (! empty($arrayfields['aa.pcg_type']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_type']['label'],$_SERVER["PHP_SELF"],'aa.pcg_type','',$param,'',$sortfield,$sortorder);
|
||||||
print '<td class="liste_titre"> </td>';
|
if (! empty($arrayfields['aa.pcg_subtype']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_subtype']['label'],$_SERVER["PHP_SELF"],'aa.pcg_subtype','',$param,'',$sortfield,$sortorder);
|
||||||
|
if (! empty($arrayfields['aa.active']['checked'])) print_liste_field_titre($arrayfields['aa.active']['label'],$_SERVER["PHP_SELF"],'aa.active','',$param,'',$sortfield,$sortorder);
|
||||||
|
|
||||||
|
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch ');
|
||||||
|
print "</tr>\n";
|
||||||
|
|
||||||
|
// Line for search fields
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
if (! empty($arrayfields['aa.account_number']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_account" value="' . $search_account . '"></td>';
|
||||||
|
if (! empty($arrayfields['aa.label']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="' . $search_label . '"></td>';
|
||||||
|
if (! empty($arrayfields['aa.account_parent']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_accountparent" value="' . $search_accountparent . '"></td>';
|
||||||
|
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" colspan="2" class="liste_titre">';
|
||||||
$searchpitco=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
|
$searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
|
||||||
print $searchpitco;
|
print $searchpicto;
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
@ -263,8 +284,7 @@ if ($resql) {
|
|||||||
|
|
||||||
$accountstatic = new AccountingAccount($db);
|
$accountstatic = new AccountingAccount($db);
|
||||||
$accountparent = new AccountingAccount($db);
|
$accountparent = new AccountingAccount($db);
|
||||||
|
|
||||||
$i = 0;
|
|
||||||
while ( $i < min($num, $limit) )
|
while ( $i < min($num, $limit) )
|
||||||
{
|
{
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
@ -274,35 +294,81 @@ if ($resql) {
|
|||||||
$accountstatic->account_number = $obj->account_number;
|
$accountstatic->account_number = $obj->account_number;
|
||||||
|
|
||||||
print '<tr ' . $bc[$var] . '>';
|
print '<tr ' . $bc[$var] . '>';
|
||||||
print '<td>' . $accountstatic->getNomUrl(1) . '</td>';
|
|
||||||
print '<td>' . $obj->label . '</td>';
|
|
||||||
|
|
||||||
if (! empty($obj->account_parent))
|
// Account number
|
||||||
{
|
if (! empty($arrayfields['aa.account_number']['checked']))
|
||||||
$accountparent->id = $obj->rowid2;
|
|
||||||
$accountparent->label = $obj->label2;
|
|
||||||
$accountparent->account_number = $obj->account_number2;
|
|
||||||
|
|
||||||
print '<td>' . $accountparent->getNomUrl(1) . '</td>';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
print '<td> </td>';
|
print "<td>";
|
||||||
|
print $accountstatic->getNomUrl(1);
|
||||||
|
print "</td>\n";
|
||||||
|
if (! $i) $totalarray['nbfield']++;
|
||||||
}
|
}
|
||||||
print '<td>' . $obj->pcg_type . '</td>';
|
|
||||||
print '<td>' . $obj->pcg_subtype . '</td>';
|
// Account label
|
||||||
print '<td>';
|
if (! empty($arrayfields['aa.label']['checked']))
|
||||||
if (empty($obj->active)) {
|
{
|
||||||
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $obj->rowid . '&action=enable">';
|
print "<td>";
|
||||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
print $obj->label;
|
||||||
print '</a>';
|
print "</td>\n";
|
||||||
} else {
|
if (! $i) $totalarray['nbfield']++;
|
||||||
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $obj->rowid . '&action=disable">';
|
|
||||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
|
||||||
print '</a>';
|
|
||||||
}
|
}
|
||||||
print '</td>';
|
|
||||||
|
// Account parent
|
||||||
|
if (! empty($arrayfields['aa.account_parent']['checked']))
|
||||||
|
{
|
||||||
|
if (! empty($obj->account_parent))
|
||||||
|
{
|
||||||
|
$accountparent->id = $obj->rowid2;
|
||||||
|
$accountparent->label = $obj->label2;
|
||||||
|
$accountparent->account_number = $obj->account_number2;
|
||||||
|
|
||||||
|
print "<td>";
|
||||||
|
print $accountparent->getNomUrl(1);
|
||||||
|
print "</td>\n";
|
||||||
|
if (! $i) $totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<td> </td>';
|
||||||
|
if (! $i) $totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Chart of accounts type
|
||||||
|
if (! empty($arrayfields['aa.pcg_type']['checked']))
|
||||||
|
{
|
||||||
|
print "<td>";
|
||||||
|
print $obj->pcg_type;
|
||||||
|
print "</td>\n";
|
||||||
|
if (! $i) $totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Chart of accounts subtype
|
||||||
|
if (! empty($arrayfields['aa.pcg_subtype']['checked']))
|
||||||
|
{
|
||||||
|
print "<td>";
|
||||||
|
print $obj->pcg_subtype;
|
||||||
|
print "</td>\n";
|
||||||
|
if (! $i) $totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Activated or not
|
||||||
|
if (! empty($arrayfields['aa.active']['checked']))
|
||||||
|
{
|
||||||
|
print '<td>';
|
||||||
|
if (empty($obj->active)) {
|
||||||
|
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $obj->rowid . '&action=enable">';
|
||||||
|
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||||
|
print '</a>';
|
||||||
|
} else {
|
||||||
|
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $obj->rowid . '&action=disable">';
|
||||||
|
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||||
|
print '</a>';
|
||||||
|
}
|
||||||
|
print '</td>';
|
||||||
|
if (! $i) $totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
|
||||||
// Action
|
// Action
|
||||||
print '<td align="center">';
|
print '<td align="center">';
|
||||||
if ($user->admin) {
|
if ($user->admin) {
|
||||||
@ -315,6 +381,7 @@ if ($resql) {
|
|||||||
print '</a>';
|
print '</a>';
|
||||||
}
|
}
|
||||||
print '</td>' . "\n";
|
print '</td>' . "\n";
|
||||||
|
if (! $i) $totalarray['nbfield']++;
|
||||||
|
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
$var = ! $var;
|
$var = ! $var;
|
||||||
@ -322,6 +389,7 @@ if ($resql) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
print "</table>";
|
print "</table>";
|
||||||
|
print "</div>";
|
||||||
print '</form>';
|
print '</form>';
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2016 Jamal Elbaz <jamelbaz@gmail.pro>
|
/* Copyright (C) 2016 Jamal Elbaz <jamelbaz@gmail.pro>
|
||||||
|
* Copyright (C) 2017 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -16,24 +17,24 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file htdocs/accountancy/admin/categories.php
|
* \file htdocs/accountancy/admin/categories.php
|
||||||
* \ingroup Advanced accountancy
|
* \ingroup Advanced accountancy
|
||||||
* \brief Page to assign mass categories to accounts
|
* \brief Page to assign mass categories to accounts
|
||||||
*/
|
*/
|
||||||
require '../../main.inc.php';
|
require '../../main.inc.php';
|
||||||
|
|
||||||
// Class
|
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancycategory.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancycategory.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
|
||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
// Langs
|
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
$langs->load("accountancy");
|
$langs->load("accountancy");
|
||||||
|
|
||||||
$mesg = '';
|
$mesg = '';
|
||||||
|
$id = GETPOST('id', 'int');
|
||||||
|
$rowid = GETPOST('rowid', 'int');
|
||||||
|
$cancel = GETPOST('cancel');
|
||||||
$action = GETPOST('action');
|
$action = GETPOST('action');
|
||||||
$cat_id = GETPOST('account_category');
|
$cat_id = GETPOST('account_category');
|
||||||
$selectcpt = GETPOST('cpt_bk', 'array');
|
$selectcpt = GETPOST('cpt_bk', 'array');
|
||||||
@ -43,36 +44,31 @@ if ($cat_id == 0) {
|
|||||||
$cat_id = null;
|
$cat_id = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = GETPOST('id', 'int');
|
|
||||||
$rowid = GETPOST('rowid', 'int');
|
|
||||||
$cancel = GETPOST('cancel');
|
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
if (! $user->admin)
|
if (! $user->admin) accessforbidden();
|
||||||
accessforbidden();
|
|
||||||
|
|
||||||
$AccCat = new AccountancyCategory($db);
|
$accountingcategory = new AccountancyCategory($db);
|
||||||
|
|
||||||
// si ajout de comptes
|
// si ajout de comptes
|
||||||
if (! empty($selectcpt)) {
|
if (! empty($selectcpt)) {
|
||||||
$cpts = array ();
|
$cpts = array ();
|
||||||
foreach ( $selectcpt as $selectedOption ) {
|
foreach ( $selectcpt as $selectedoption ) {
|
||||||
if (! array_key_exists($selectedOption, $cpts))
|
if (! array_key_exists($selectedoption, $cpts))
|
||||||
$cpts[$selectedOption] = "'" . $selectedOption . "'";
|
$cpts[$selectedoption] = "'" . $selectedoption . "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
$return= $AccCat->updateAccAcc($cat_id, $cpts);
|
$return= $accountingcategory->updateAccAcc($cat_id, $cpts);
|
||||||
|
|
||||||
if ($return<0) {
|
if ($return<0) {
|
||||||
setEventMessages($langs->trans('errors'), $AccCat->errors, 'errors');
|
setEventMessages($langs->trans('errors'), $accountingcategory->errors, 'errors');
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($langs->trans('Saved'), null, 'mesgs');
|
setEventMessages($langs->trans('Saved'), null, 'mesgs');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($action == 'delete') {
|
if ($action == 'delete') {
|
||||||
if ($cpt_id) {
|
if ($cpt_id) {
|
||||||
if ($AccCat->deleteCptCat($cpt_id)) {
|
if ($accountingcategory->deleteCptCat($cpt_id)) {
|
||||||
setEventMessages($langs->trans('Deleted'), null, 'mesgs');
|
setEventMessages($langs->trans('CategoryDeleted'), null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($langs->trans('errors'), null, 'errors');
|
setEventMessages($langs->trans('errors'), null, 'errors');
|
||||||
}
|
}
|
||||||
@ -83,12 +79,11 @@ if ($action == 'delete') {
|
|||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
$form = new Form($db);
|
||||||
|
$formaccounting = new FormAccounting($db);
|
||||||
|
|
||||||
llxheader('', $langs->trans('AccountAccounting'));
|
llxheader('', $langs->trans('AccountAccounting'));
|
||||||
|
|
||||||
$formaccounting = new FormAccounting($db);
|
|
||||||
$form = new Form($db);
|
|
||||||
|
|
||||||
print load_fiche_titre($langs->trans('Categories'));
|
print load_fiche_titre($langs->trans('Categories'));
|
||||||
|
|
||||||
print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
|
print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
|
||||||
@ -102,22 +97,23 @@ print '<table class="border" width="100%">';
|
|||||||
print '<tr><td>' . $langs->trans("AccountingCategory") . '</td>';
|
print '<tr><td>' . $langs->trans("AccountingCategory") . '</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
$formaccounting->select_accounting_category($cat_id, 'account_category', 1);
|
$formaccounting->select_accounting_category($cat_id, 'account_category', 1);
|
||||||
print '<input class="button" type="submit" value="' . $langs->trans("Display") . '">';
|
print '<input class="button" type="submit" value="' . $langs->trans("Show") . '">';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
if (! empty($cat_id)) {
|
if (! empty($cat_id)) {
|
||||||
$return = $AccCat->getCptBK($cat_id);
|
$return = $accountingcategory->getCptBK($cat_id);
|
||||||
if ($return < 0) {
|
if ($return < 0) {
|
||||||
setEventMessages(null, $AccCat->errors, 'errors');
|
setEventMessages(null, $accountingcategory->errors, 'errors');
|
||||||
}
|
}
|
||||||
print '<tr><td>' . $langs->trans("AddCompteFromBK") . '</td>';
|
print '<tr><td>' . $langs->trans("AddAccountFromBookKeepingWithNoCategories") . '</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
if (is_array($AccCat->lines_cptbk) && count($AccCat->lines_cptbk) > 0) {
|
if (is_array($accountingcategory->lines_cptbk) && count($accountingcategory->lines_cptbk) > 0) {
|
||||||
print '<select size="' . count($obj) . '" name="cpt_bk[]" multiple>';
|
print '<select size="' . count($obj) . '" name="cpt_bk[]" multiple>';
|
||||||
foreach ( $AccCat->lines_cptbk as $cpt ) {
|
foreach ( $accountingcategory->lines_cptbk as $cpt ) {
|
||||||
print '<option value="' . length_accountg($cpt->numero_compte) . '">' . length_accountg($cpt->numero_compte) . ' (' . $cpt->label_compte . ' ' . $cpt->doc_ref . ')</option>';
|
print '<option value="' . length_accountg($cpt->numero_compte) . '">' . length_accountg($cpt->numero_compte) . ' (' . $cpt->label_compte . ' ' . $cpt->doc_ref . ')</option>';
|
||||||
}
|
}
|
||||||
print '</select> - <input class="button" type="submit" id="" class="action-delete" value="' . $langs->trans("add") . '"> ';
|
print '</select>';
|
||||||
|
print '<input class="button" type="submit" id="" class="action-delete" value="' . $langs->trans("Add") . '"> ';
|
||||||
}
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
@ -131,26 +127,30 @@ print '</form>';
|
|||||||
|
|
||||||
if ($action == 'display' || $action == 'delete') {
|
if ($action == 'display' || $action == 'delete') {
|
||||||
|
|
||||||
print '<table class="noborder" width="100%">';
|
print "<table class='noborder' width='100%'>\n";
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
print '<tr class="liste_titre"><th class="liste_titre">' . $langs->trans("Numerocompte") . '</th><th class="liste_titre">' . $langs->trans("Description") . '</th><th class="liste_titre" width="60" align="center">Action</th></tr>';
|
print '<td>'.$langs->trans("AccountAccounting")."</td>";
|
||||||
|
print '<td colspan="2">'.$langs->trans("Label")."</td>";
|
||||||
|
print "</tr>\n";
|
||||||
|
|
||||||
if (! empty($cat_id)) {
|
if (! empty($cat_id)) {
|
||||||
$return = $AccCat->display($cat_id);
|
$return = $accountingcategory->display($cat_id);
|
||||||
if ($return < 0) {
|
if ($return < 0) {
|
||||||
setEventMessages(null, $AccCat->errors, 'errors');
|
setEventMessages(null, $accountingcategory->errors, 'errors');
|
||||||
}
|
}
|
||||||
$j = 1;
|
|
||||||
if (is_array($AccCat->lines_display) && count($AccCat->lines_display) > 0) {
|
if (is_array($accountingcategory->lines_display) && count($accountingcategory->lines_display) > 0) {
|
||||||
foreach ( $AccCat->lines_display as $cpt ) {
|
foreach ( $accountingcategory->lines_display as $cpt ) {
|
||||||
$var = ! $var;
|
$var = ! $var;
|
||||||
print '<tr' . $bc[$var] . '>';
|
print '<tr' . $bc[$var] . '>';
|
||||||
print '<td>' . length_accountg($cpt->account_number) . '</td>';
|
print '<td>' . length_accountg($cpt->account_number) . '</td>';
|
||||||
print '<td>' . $cpt->label . '</td>';
|
print '<td>' . $cpt->label . '</td>';
|
||||||
print $form->formconfirm($_SERVER["PHP_SELF"] . "?account_category=$cat_id&cptid=" . $cpt->rowid, $langs->trans("DeleteCptCategory"), $langs->trans("ConfirmDeleteCptCategory"), "delete", '', 0, "action-delete" . $j);
|
print '<td align="right">';
|
||||||
print '<td><input class="button" type="button" id="action-delete' . $j . '" value="' . $langs->trans("Delete") . '"></td>';
|
print "<a href= '".$_SERVER['PHP_SELF']."?action=delete&account_category=" . $cat_id . "&cptid=" . $cpt->rowid."'>";
|
||||||
|
print img_delete($langs->trans("DeleteFromCat")).' ';
|
||||||
|
print $langs->trans("DeleteFromCat")."</a>";
|
||||||
|
print "</td>";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
$j ++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2016 Jamal Elbaz <jamelbaz@gmail.pro>
|
/* Copyright (C) 2016 Jamal Elbaz <jamelbaz@gmail.pro>
|
||||||
* Copyright (C) 2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
* Copyright (C) 2016-2017 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -17,9 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file htdocs/accountancy/class/accountancycategory.class.php
|
* \file htdocs/accountancy/class/accountancycategory.class.php
|
||||||
* \ingroup Advanced accountancy
|
* \ingroup Advanced accountancy
|
||||||
* \brief File of class to manage categories of an accounting category_type
|
* \brief File of class to manage categories of an accounting category_type
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Class
|
// Class
|
||||||
@ -72,7 +72,6 @@ class AccountancyCategory
|
|||||||
$this->lines_display[] = $obj;
|
$this->lines_display[] = $obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $num;
|
return $num;
|
||||||
} else {
|
} else {
|
||||||
$this->error = "Error " . $this->db->lasterror();
|
$this->error = "Error " . $this->db->lasterror();
|
||||||
@ -84,7 +83,7 @@ class AccountancyCategory
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to select accountiing category of an accounting account present in chart of accounts
|
* Function to select accounting category of an accounting account present in chart of accounts
|
||||||
*
|
*
|
||||||
* @param int $id Id category
|
* @param int $id Id category
|
||||||
*
|
*
|
||||||
|
|||||||
@ -412,8 +412,8 @@ class DoliDBPgsql extends DoliDB
|
|||||||
{
|
{
|
||||||
$this->database_name = $name;
|
$this->database_name = $name;
|
||||||
pg_set_error_verbosity($this->db, PGSQL_ERRORS_VERBOSE); // Set verbosity to max
|
pg_set_error_verbosity($this->db, PGSQL_ERRORS_VERBOSE); // Set verbosity to max
|
||||||
|
pg_query($this->db, "set datestyle = 'ISO, YMD';");
|
||||||
}
|
}
|
||||||
pg_query($this->db, "set datestyle = 'ISO, YMD';");
|
|
||||||
|
|
||||||
return $this->db;
|
return $this->db;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1445,6 +1445,19 @@ if ($action=='create')
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
print $form->select_company((empty($socid)?'':$socid), 'socid', 's.fournisseur = 1', 'SelectThirdParty');
|
print $form->select_company((empty($socid)?'':$socid), 'socid', 's.fournisseur = 1', 'SelectThirdParty');
|
||||||
|
// reload page to retrieve customer informations
|
||||||
|
if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE))
|
||||||
|
{
|
||||||
|
print '<script type="text/javascript">
|
||||||
|
$(document).ready(function() {
|
||||||
|
$("#socid").change(function() {
|
||||||
|
var socid = $(this).val();
|
||||||
|
// reload page
|
||||||
|
window.location.href = "'.$_SERVER["PHP_SELF"].'?action=create&socid="+socid;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
|
|||||||
@ -1446,6 +1446,19 @@ if ($action == 'create')
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
print $form->select_company($societe->id, 'socid', 's.fournisseur = 1', 'SelectThirdParty');
|
print $form->select_company($societe->id, 'socid', 's.fournisseur = 1', 'SelectThirdParty');
|
||||||
|
// reload page to retrieve supplier informations
|
||||||
|
if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE))
|
||||||
|
{
|
||||||
|
print '<script type="text/javascript">
|
||||||
|
$(document).ready(function() {
|
||||||
|
$("#socid").change(function() {
|
||||||
|
var socid = $(this).val();
|
||||||
|
// reload page
|
||||||
|
window.location.href = "'.$_SERVER["PHP_SELF"].'?action=create&socid="+socid;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
|
|||||||
@ -194,6 +194,8 @@ ChangeBinding=Change the binding
|
|||||||
|
|
||||||
## Admin
|
## Admin
|
||||||
ApplyMassCategories=Apply mass categories
|
ApplyMassCategories=Apply mass categories
|
||||||
|
AddAccountFromBookKeepingWithNoCategories=Add acccount already used with no categories
|
||||||
|
CategoryDeleted=Category for the accounting account has been removed
|
||||||
|
|
||||||
## Export
|
## Export
|
||||||
Exports=Exports
|
Exports=Exports
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user