Skip to content
Snippets Groups Projects
Commit e0f600f2 authored by aspangaro's avatar aspangaro
Browse files

FIX: Accountancy - Little fix et add page to assign massively the category

parent 77494254
No related branches found
No related tags found
No related merge requests found
......@@ -147,6 +147,7 @@ if ($result) {
print '<br/>';
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="./importaccounts.php">' . $langs->trans("ImportAccount") . '</a>';
// print '<a class="butAction" href="./productaccount.php">' . $langs->trans("CheckProductAccountancyCode") . '</a>';
print '<br/><br/>';
......
<?php
/* Copyright (C) 2016 Jamal Elbaz <jamelbaz@gmail.pro>
*
* 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 <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/accountancy/admin/categories.php
* \ingroup Advanced accountancy
* \brief Page to assign mass categories to accounts
*/
require '../../main.inc.php';
// Class
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 . '/core/class/html.formaccounting.class.php';
$error = 0;
// Langs
$langs->load("bills");
$langs->load("accountancy");
$mesg = '';
$action = GETPOST('action');
$cat_id = GETPOST('account_category');
$selectcpt = GETPOST('cpt_bk');
$cpt_id = GETPOST('cptid');
if($cat_id == 0){
$cat_id = null;
}
$id = GETPOST('id', 'int');
$rowid = GETPOST('rowid', 'int');
$cancel = GETPOST('cancel');
// Security check
if (! $user->admin)
accessforbidden();
$AccCat = new AccountancyCategory($db);
// si ajout de comptes
if(!empty($selectcpt)){
$cpts = array();
$i = 0;
foreach ($selectcpt as $selectedOption){
$cpts[$i] = "'".$selectedOption."'";
$i++;
}
if($AccCat->updateAccAcc($cat_id, $cpts)){
setEventMessages($langs->trans('Saved'), null, 'mesgs');
}else{
setEventMessages($langs->trans('errors'), null, 'errors');
}
}
if ($action == 'delete') {
if($cpt_id){
if($AccCat->deleteCptCat($cpt_id)){
setEventMessages($langs->trans('Deleted'), null, 'mesgs');
}else{
setEventMessages($langs->trans('errors'), null, 'errors');
}
}
}
/*
* View
*/
llxheader('', $langs->trans('AccountAccounting'));
$formaccounting = new FormAccounting($db);
$form = new Form($db);
print load_fiche_titre($langs->trans('Categories'));
print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="display">';
dol_fiche_head();
print '<table class="border" width="100%">';
// Category
print '<tr><td>' . $langs->trans("AccountingCategory") . '</td>';
print '<td>';
$formaccounting->select_accounting_category($cat_id, 'account_category', 1);
print '<input class="button" type="submit" value="' . $langs->trans("Display") . '">';
print '</td></tr>';
if(!empty($cat_id)){
$obj = $AccCat->getCptBK($cat_id);
print '<tr><td>' . $langs->trans("AddCompteFromBK") . '</td>';
print '<td>';
if(!empty($obj)){
print '<select size="'.count($obj).'" name="cpt_bk[]" multiple>';
foreach ( $obj as $cpt ) {
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 '</td></tr>';
}
print '</table>';
dol_fiche_end();
print '</form>';
if ($action == 'display' || $action == 'delete') {
print '<table class="noborder" width="100%">';
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>';
if(!empty($cat_id)){
$obj = $AccCat->display($cat_id);
$j=1;
if(!empty($obj)){
foreach ( $obj as $cpt ) {
$var = ! $var;
print "<tr $bc[$var]>";
print '<td>' . length_accountg($cpt->account_number) . '</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><input class="button" type="button" id="action-delete'.$j.'" value="' . $langs->trans("Delete") . '"></td>';
print "</tr>\n";
$j++;
}
}
}
print "</table>";
}
llxFooter();
$db->close();
\ No newline at end of file
......@@ -19,7 +19,7 @@
/**
* \file htdocs/accountancy/class/accountancycategory.class.php
* \ingroup Advanced accountancy
* \brief File of class to manage categories of an accounting account_category
* \brief File of class to manage categories of an accounting category_type
*/
// Class
......@@ -243,7 +243,7 @@ class AccountancyCategory
}
else
{
$sql = "SELECT c.rowid, c.code, c.label, c.account_category ";
$sql = "SELECT c.rowid, c.code, c.label, c.category_type ";
$sql.= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c, ".MAIN_DB_PREFIX."c_country as co";
$sql.= " WHERE c.active = 1 AND c.fk_country = co.rowid";
$sql.= " AND co.code = '".$mysoc->country_code."'";
......@@ -343,7 +343,7 @@ class AccountancyCategory
{
$sql = "SELECT c.rowid, c.code, c.label, c.formula, c.position";
$sql.= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c";
$sql.= " WHERE c.active = 1 AND c.account_category = 1 ";
$sql.= " WHERE c.active = 1 AND c.category_type = 1 ";
$sql.= " AND c.fk_country = ".$mysoc->country_id;
$sql.= " ORDER BY c.position ASC";
}
......@@ -351,7 +351,7 @@ class AccountancyCategory
{
$sql = "SELECT c.rowid, c.code, c.label, c.formula, c.position";
$sql.= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c, ".MAIN_DB_PREFIX."c_country as co";
$sql.= " WHERE c.active = 1 AND c.account_category = 1 AND c.fk_country = co.rowid";
$sql.= " WHERE c.active = 1 AND c.category_type = 1 AND c.fk_country = co.rowid";
$sql.= " AND co.code = '".$mysoc->country_code."'";
$sql.= " ORDER BY c.position ASC";
}
......
......@@ -149,6 +149,8 @@ FicheVentilation=Breakdown card
GeneralLedgerIsWritten=Operations are written in the general ledger
MvtNotCorrectlyBalanced=Mouvement not correctly balanced. Credit = %s. Debit = %s
## Admin
ApplyMassCategories=Apply mass categories
## Export
Exports=Exports
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment