* Copyright (C) 2013-2015 Alexandre Spangaro * * 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 * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/accountancy/admin/account.php * \ingroup Accounting Expert * \brief List accounting account */ require '../../main.inc.php'; // Class require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; // Langs $langs->load("compta"); $langs->load("accountancy"); $mesg = ''; $action = GETPOST('action'); $id = GETPOST('id', 'int'); $rowid = GETPOST('rowid', 'int'); $search_account = GETPOST("search_account"); $search_label = GETPOST("search_label"); $search_accountparent = GETPOST("search_accountparent"); $search_pcgtype = GETPOST("search_pcgtype"); $search_pcgsubtype = GETPOST("search_pcgsubtype"); // Security check if (!$user->admin) accessforbidden(); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'sortorder'); $limit = $conf->liste_limit; $page = GETPOST("page", 'int'); if ($page == - 1) { $page = 0; } $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortfield) $sortfield = "aa.account_number"; if (! $sortorder) $sortorder = "ASC"; if ($action == 'delete') { $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id, $langs->trans('DeleteAccount'), $langs->trans('ConfirmDeleteAccount'), 'confirm_delete', '', 0, 1); print $formconfirm; } $accounting = new AccountingAccount($db); if ($action == 'disable') { if ($accounting->fetch($id)) { $result = $accounting->account_desactivate($id); } $action = 'update'; if ($result < 0) { setEventMessage($accounting->error, 'errors'); } } else if ($action == 'enable') { if ($accounting->fetch($id)) { $result = $accounting->account_activate($id); } $action = 'update'; if ($result < 0) { setEventMessage($accounting->error, 'errors'); } } if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_account=""; $search_label=""; $search_accountparent=""; $search_pcgtype=""; $search_pcgsubtype=""; } /* * View * */ llxHeader('', $langs->trans("ListAccounts")); $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 .= " FROM " . MAIN_DB_PREFIX . "accountingaccount as aa, " . MAIN_DB_PREFIX . "accounting_system as asy"; $sql .= " WHERE aa.fk_pcg_version = asy.pcg_version"; $sql .= " AND asy.rowid = " . $pcgver; if (strlen(trim($search_account))) { $sql .= " AND aa.account_number like '%" . $search_account . "%'"; } if (strlen(trim($search_label))) { $sql .= " AND aa.label like '%" . $search_label . "%'"; } if (strlen(trim($search_accountparent))) { $sql .= " AND aa.account_parent like '%" . $search_accountparent . "%'"; } if (strlen(trim($search_pcgtype))) { $sql .= " AND aa.pcg_type like '%" . $search_pcgtype . "%'"; } if (strlen(trim($search_pcgsubtype))) { $sql .= " AND aa.pcg_subtype like '%" . $search_pcgsubtype . "%'"; } $sql .= $db->order($sortfield, $sortorder); $sql .= $db->plimit($limit + 1, $offset); dol_syslog('accountancy/admin/account.php:: $sql=' . $sql); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num); $i = 0; print '
'; print '
'; print '' . $langs->trans("Addanaccount") . ''; print '' . $langs->trans("ImportAccount") . ''; print '' . $langs->trans("CheckProductAccountancyCode") . ''; print '

'; print ''; print ''; print_liste_field_titre($langs->trans("AccountNumber"), $_SERVER["PHP_SELF"], "aa.account_number", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "aa.label", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Accountparent"), $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Pcgtype"), $_SERVER["PHP_SELF"], "aa.pcg_type", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Pcgsubtype"), $_SERVER["PHP_SELF"], "aa.pcg_subtype", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Activated"), $_SERVER["PHP_SELF"], "aa.active", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"",$param,"",'width="60" align="center"',$sortfield,$sortorder); print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; $var = false; $accountstatic=new AccountingAccount($db); while ( $i < min($num, $limit) ) { $obj = $db->fetch_object($resql); $accountstatic->id=$obj->rowid; $accountstatic->label=$obj->label; $accountstatic->account_number=$obj->account_number; print ''; print ''; print ''; print ''; print ''; print ''; print ''; // Action print '' . "\n"; print "\n"; $var=!$var; $i ++; } print "
 '; print ''; print ' '; print ''; print '
' . $accountstatic->getNomUrl(1) . '' . $obj->label . '' . $obj->account_parent . '' . $obj->pcg_type . '' . $obj->pcg_subtype . ''; if (empty($obj->active)) { print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print ''; } else { print ''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; } print ''; if ($user->admin) { print ''; print img_edit(); print ''; print ' '; print ''; print img_delete(); print ''; } print '
"; print '
'; } else { dol_print_error($db); } llxFooter(); $db->close();