Skip to content

Commit 6e00374

Browse files
committed
first commit
0 parents  commit 6e00374

File tree

14,328 files changed

+3395418
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

14,328 files changed

+3395418
-0
lines changed

accountancy/admin/account.php

Lines changed: 819 additions & 0 deletions
Large diffs are not rendered by default.

accountancy/admin/accountmodel.php

Lines changed: 801 additions & 0 deletions
Large diffs are not rendered by default.

accountancy/admin/card.php

Lines changed: 443 additions & 0 deletions
Large diffs are not rendered by default.

accountancy/admin/categories.php

Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
<?php
2+
/* Copyright (C) 2016 Jamal Elbaz <[email protected]>
3+
* Copyright (C) 2017-2024 Alexandre Spangaro <[email protected]>
4+
* Copyright (C) 2022 Laurent Destailleur <[email protected]>
5+
*
6+
* This program is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
20+
/**
21+
* \file htdocs/accountancy/admin/categories.php
22+
* \ingroup Accountancy (Double entries)
23+
* \brief Page to assign mass categories to accounts
24+
*/
25+
26+
// Load Dolibarr environment
27+
require '../../main.inc.php';
28+
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
29+
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancycategory.class.php';
30+
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
31+
32+
$error = 0;
33+
34+
// Load translation files required by the page
35+
$langs->loadLangs(array("bills", "accountancy", "compta"));
36+
37+
$id = GETPOST('id', 'int');
38+
$cancel = GETPOST('cancel', 'alpha');
39+
$action = GETPOST('action', 'aZ09');
40+
$cat_id = GETPOST('account_category', 'int');
41+
$selectcpt = GETPOST('cpt_bk', 'array');
42+
$cpt_id = GETPOST('cptid', 'int');
43+
44+
if ($cat_id == 0) {
45+
$cat_id = null;
46+
}
47+
48+
// Load variable for pagination
49+
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
50+
$sortfield = GETPOST('sortfield', 'aZ09comma');
51+
$sortorder = GETPOST('sortorder', 'aZ09comma');
52+
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
53+
if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
54+
// If $page is not defined, or '' or -1 or if we click on clear filters
55+
$page = 0;
56+
}
57+
$offset = $limit * $page;
58+
$pageprev = $page - 1;
59+
$pagenext = $page + 1;
60+
61+
if (empty($sortfield)) {
62+
$sortfield = 'account_number';
63+
}
64+
if (empty($sortorder)) {
65+
$sortorder = 'ASC';
66+
}
67+
68+
// Security check
69+
if (!$user->hasRight('accounting', 'chartofaccount')) {
70+
accessforbidden();
71+
}
72+
73+
$accountingcategory = new AccountancyCategory($db);
74+
75+
76+
/*
77+
* Actions
78+
*/
79+
80+
// If we add account
81+
if (!empty($selectcpt)) {
82+
$cpts = array();
83+
foreach ($selectcpt as $selectedoption) {
84+
if (!array_key_exists($selectedoption, $cpts)) {
85+
$cpts[$selectedoption] = "'".$selectedoption."'";
86+
}
87+
}
88+
89+
$return = $accountingcategory->updateAccAcc($cat_id, $cpts);
90+
91+
if ($return < 0) {
92+
setEventMessages($langs->trans('errors'), $accountingcategory->errors, 'errors');
93+
} else {
94+
setEventMessages($langs->trans('RecordModifiedSuccessfully'), null, 'mesgs');
95+
}
96+
}
97+
98+
if ($action == 'delete') {
99+
if ($cpt_id) {
100+
if ($accountingcategory->deleteCptCat($cpt_id)) {
101+
setEventMessages($langs->trans('AccountRemovedFromGroup'), null, 'mesgs');
102+
} else {
103+
setEventMessages($langs->trans('errors'), null, 'errors');
104+
}
105+
}
106+
}
107+
108+
109+
/*
110+
* View
111+
*/
112+
113+
$form = new Form($db);
114+
$formaccounting = new FormAccounting($db);
115+
116+
$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilit&eacute;_en_Partie_Double#Configuration';
117+
118+
llxHeader('', $langs->trans('AccountingCategory'), $help_url);
119+
120+
$linkback = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/categories_list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
121+
$titlepicto = 'setup';
122+
123+
print load_fiche_titre($langs->trans('AccountingCategory'), $linkback, $titlepicto);
124+
125+
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
126+
print '<input type="hidden" name="token" value="'.newToken().'">';
127+
print '<input type="hidden" name="action" value="display">';
128+
129+
print dol_get_fiche_head();
130+
131+
print '<table class="border centpercent">';
132+
133+
// Select the category
134+
print '<tr><td class="titlefield">'.$langs->trans("AccountingCategory").'</td>';
135+
print '<td>';
136+
$s = $formaccounting->select_accounting_category($cat_id, 'account_category', 1, 0, 0, 0);
137+
if ($formaccounting->nbaccounts_category <= 0) {
138+
print '<span class="opacitymedium">'.$s.'</span>';
139+
} else {
140+
print $s;
141+
print '<input type="submit" class="button small" value="'.$langs->trans("Select").'">';
142+
}
143+
print '</td></tr>';
144+
145+
print '</table>';
146+
147+
print dol_get_fiche_end();
148+
149+
150+
// Select the accounts
151+
if (!empty($cat_id)) {
152+
$return = $accountingcategory->getAccountsWithNoCategory($cat_id);
153+
if ($return < 0) {
154+
setEventMessages(null, $accountingcategory->errors, 'errors');
155+
}
156+
print '<br>';
157+
158+
$arraykeyvalue = array();
159+
foreach ($accountingcategory->lines_cptbk as $key => $val) {
160+
$doc_ref = !empty($val->doc_ref) ? $val->doc_ref : '';
161+
$arraykeyvalue[length_accountg($val->numero_compte)] = length_accountg($val->numero_compte) . ' - ' . $val->label_compte . ($doc_ref ? ' '.$doc_ref : '');
162+
}
163+
164+
if (is_array($accountingcategory->lines_cptbk) && count($accountingcategory->lines_cptbk) > 0) {
165+
print img_picto($langs->trans("AccountingAccount"), 'accounting_account', 'class="pictofixedwith"');
166+
print $form->multiselectarray('cpt_bk', $arraykeyvalue, GETPOST('cpt_bk', 'array'), null, null, '', 0, "80%", '', '', $langs->transnoentitiesnoconv("AddAccountFromBookKeepingWithNoCategories"));
167+
print '<input type="submit" class="button button-add small" id="" class="action-delete" value="'.$langs->trans("Add").'"> ';
168+
}
169+
}
170+
171+
print '</form>';
172+
173+
174+
if ((empty($action) || $action == 'display' || $action == 'delete') && $cat_id > 0) {
175+
$param = 'account_category='.((int) $cat_id);
176+
177+
print '<br>';
178+
print '<table class="noborder centpercent">'."\n";
179+
print '<tr class="liste_titre">';
180+
print getTitleFieldOfList('AccountAccounting', 0, $_SERVER['PHP_SELF'], 'account_number', '', $param, '', $sortfield, $sortorder, '')."\n";
181+
print getTitleFieldOfList('Label', 0, $_SERVER['PHP_SELF'], 'label', '', $param, '', $sortfield, $sortorder, '')."\n";
182+
print getTitleFieldOfList('', 0, $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, '')."\n";
183+
print '</tr>'."\n";
184+
185+
if (!empty($cat_id)) {
186+
$return = $accountingcategory->display($cat_id); // This load ->lines_display
187+
if ($return < 0) {
188+
setEventMessages(null, $accountingcategory->errors, 'errors');
189+
}
190+
191+
if (is_array($accountingcategory->lines_display) && count($accountingcategory->lines_display) > 0) {
192+
$accountingcategory->lines_display = dol_sort_array($accountingcategory->lines_display, $sortfield, $sortorder, -1, 0, 1);
193+
194+
foreach ($accountingcategory->lines_display as $cpt) {
195+
print '<tr class="oddeven">';
196+
print '<td>'.length_accountg($cpt->account_number).'</td>';
197+
print '<td>'.$cpt->label.'</td>';
198+
print '<td class="right">';
199+
print '<a href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&account_category='.$cat_id.'&cptid='.$cpt->rowid.'">';
200+
print $langs->trans("DeleteFromCat");
201+
print img_picto($langs->trans("DeleteFromCat"), 'unlink', 'class="paddingleft"');
202+
print "</a>";
203+
print "</td>";
204+
print "</tr>\n";
205+
}
206+
} else {
207+
print '<tr><td colspan="3"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
208+
}
209+
}
210+
211+
print "</table>";
212+
}
213+
214+
// End of page
215+
llxFooter();
216+
$db->close();

0 commit comments

Comments
 (0)