1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* Copyright (C) 2013-2016 Olivier Geffroy <[email protected]> |
4
|
|
|
* Copyright (C) 2013-2020 Florian Henry <[email protected]> |
5
|
|
|
* Copyright (C) 2013-2024 Alexandre Spangaro <[email protected]> |
6
|
|
|
* Copyright (C) 2016 Neil Orley <[email protected]> |
7
|
|
|
* Copyright (C) 2016-2017 Laurent Destailleur <[email protected]> |
8
|
|
|
* Copyright (C) 2018-2021 Frédéric France <[email protected]> |
9
|
|
|
* Copyright (C) 2022 Progiseize <[email protected]> |
10
|
|
|
* Copyright (C) 2022 Lionel Vessiller <[email protected]> |
11
|
|
|
* Copyright (C) 2024 Rafael San José <[email protected]> |
12
|
|
|
* |
13
|
|
|
* This program is free software; you can redistribute it and/or modify |
14
|
|
|
* it under the terms of the GNU General Public License as published by |
15
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
16
|
|
|
* (at your option) any later version. |
17
|
|
|
* |
18
|
|
|
* This program is distributed in the hope that it will be useful, |
19
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
20
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
21
|
|
|
* GNU General Public License for more details. |
22
|
|
|
* |
23
|
|
|
* You should have received a copy of the GNU General Public License |
24
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
25
|
|
|
*/ |
26
|
|
|
|
27
|
|
|
namespace DoliModules\Accounting\Controller; |
28
|
|
|
|
29
|
|
|
global $conf; |
30
|
|
|
global $db; |
31
|
|
|
global $user; |
32
|
|
|
global $hookmanager; |
33
|
|
|
global $user; |
34
|
|
|
global $menumanager; |
35
|
|
|
global $langs; |
36
|
|
|
global $mysoc; |
37
|
|
|
|
38
|
|
|
// Load Dolibarr environment |
39
|
|
|
require BASE_PATH . '/main.inc.php'; |
40
|
|
|
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; |
41
|
|
|
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; |
42
|
|
|
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; |
43
|
|
|
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; |
44
|
|
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; |
45
|
|
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; |
46
|
|
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; |
47
|
|
|
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; |
48
|
|
|
|
49
|
|
|
use AccountancyExport; |
50
|
|
|
use AccountingAccount; |
51
|
|
|
use BookKeeping; |
52
|
|
|
use BookKeepingLine; |
53
|
|
|
use DoliCore\Base\DolibarrController; |
54
|
|
|
use Form; |
55
|
|
|
use FormAccounting; |
56
|
|
|
use FormFile; |
57
|
|
|
use FormOther; |
58
|
|
|
|
59
|
|
|
class AccountingBookkeepingController extends DolibarrController |
|
|
|
|
60
|
|
|
{ |
61
|
|
|
public function index() |
62
|
|
|
{ |
63
|
|
|
$this->list(); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* \file htdocs/accountancy/bookkeeping/balance.php |
68
|
|
|
* \ingroup Accountancy (Double entries) |
69
|
|
|
* \brief Balance of book keeping |
70
|
|
|
*/ |
71
|
|
|
public function balance() |
72
|
|
|
{ |
73
|
|
|
global $conf; |
74
|
|
|
global $db; |
75
|
|
|
global $user; |
76
|
|
|
global $hookmanager; |
77
|
|
|
global $user; |
78
|
|
|
global $menumanager; |
79
|
|
|
global $langs; |
80
|
|
|
|
81
|
|
|
// Load translation files required by the page |
82
|
|
|
$langs->loadLangs(array("accountancy", "compta")); |
83
|
|
|
|
84
|
|
|
$action = GETPOST('action', 'aZ09'); |
85
|
|
|
$optioncss = GETPOST('optioncss', 'alpha'); |
86
|
|
|
$type = GETPOST('type', 'alpha'); |
87
|
|
|
if ($type == 'sub') { |
88
|
|
|
$context_default = 'balancesubaccountlist'; |
89
|
|
|
} else { |
90
|
|
|
$context_default = 'balancelist'; |
91
|
|
|
} |
92
|
|
|
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : $context_default; |
93
|
|
|
$show_subgroup = GETPOST('show_subgroup', 'alpha'); |
94
|
|
|
$search_date_start = dol_mktime(0, 0, 0, GETPOSTINT('date_startmonth'), GETPOSTINT('date_startday'), GETPOSTINT('date_startyear')); |
95
|
|
|
$search_date_end = dol_mktime(23, 59, 59, GETPOSTINT('date_endmonth'), GETPOSTINT('date_endday'), GETPOSTINT('date_endyear')); |
96
|
|
|
$search_ledger_code = GETPOST('search_ledger_code', 'array'); |
97
|
|
|
$search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); |
98
|
|
|
if ($search_accountancy_code_start == - 1) { |
99
|
|
|
$search_accountancy_code_start = ''; |
100
|
|
|
} |
101
|
|
|
$search_accountancy_code_end = GETPOST('search_accountancy_code_end', 'alpha'); |
102
|
|
|
if ($search_accountancy_code_end == - 1) { |
103
|
|
|
$search_accountancy_code_end = ''; |
104
|
|
|
} |
105
|
|
|
$search_not_reconciled = GETPOST('search_not_reconciled', 'alpha'); |
106
|
|
|
|
107
|
|
|
// Load variable for pagination |
108
|
|
|
$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; |
109
|
|
|
$sortfield = GETPOST('sortfield', 'aZ09comma'); |
110
|
|
|
$sortorder = GETPOST('sortorder', 'aZ09comma'); |
111
|
|
|
$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); |
112
|
|
|
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { |
|
|
|
|
113
|
|
|
$page = 0; |
114
|
|
|
} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action |
115
|
|
|
$offset = $limit * $page; |
116
|
|
|
$pageprev = $page - 1; |
117
|
|
|
$pagenext = $page + 1; |
118
|
|
|
if ($sortorder == "") { |
119
|
|
|
$sortorder = "ASC"; |
120
|
|
|
} |
121
|
|
|
if ($sortfield == "") { |
122
|
|
|
$sortfield = "t.numero_compte"; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
126
|
|
|
$object = new BookKeeping($db); |
127
|
|
|
$hookmanager->initHooks(array($contextpage)); // Note that conf->hooks_modules contains array |
128
|
|
|
|
129
|
|
|
$formaccounting = new FormAccounting($db); |
130
|
|
|
$formother = new FormOther($db); |
131
|
|
|
$form = new Form($db); |
132
|
|
|
|
133
|
|
|
if (empty($search_date_start) && !GETPOSTISSET('formfilteraction')) { |
134
|
|
|
$sql = "SELECT date_start, date_end from " . MAIN_DB_PREFIX . "accounting_fiscalyear "; |
135
|
|
|
$sql .= " WHERE date_start < '" . $db->idate(dol_now()) . "' AND date_end > '" . $db->idate(dol_now()) . "'"; |
136
|
|
|
$sql .= $db->plimit(1); |
137
|
|
|
$res = $db->query($sql); |
138
|
|
|
|
139
|
|
|
if ($res->num_rows > 0) { |
140
|
|
|
$fiscalYear = $db->fetch_object($res); |
141
|
|
|
$search_date_start = strtotime($fiscalYear->date_start); |
142
|
|
|
$search_date_end = strtotime($fiscalYear->date_end); |
143
|
|
|
} else { |
144
|
|
|
$month_start = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); |
145
|
|
|
$year_start = dol_print_date(dol_now(), '%Y'); |
146
|
|
|
if (dol_print_date(dol_now(), '%m') < $month_start) { |
147
|
|
|
$year_start--; // If current month is lower that starting fiscal month, we start last year |
148
|
|
|
} |
149
|
|
|
$year_end = $year_start + 1; |
150
|
|
|
$month_end = $month_start - 1; |
151
|
|
|
if ($month_end < 1) { |
152
|
|
|
$month_end = 12; |
153
|
|
|
$year_end--; |
154
|
|
|
} |
155
|
|
|
$search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start); |
156
|
|
|
$search_date_end = dol_get_last_day($year_end, $month_end); |
157
|
|
|
} |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
if (!isModEnabled('accounting')) { |
161
|
|
|
accessforbidden(); |
162
|
|
|
} |
163
|
|
|
if ($user->socid > 0) { |
164
|
|
|
accessforbidden(); |
165
|
|
|
} |
166
|
|
|
if (!$user->hasRight('accounting', 'mouvements', 'lire')) { |
167
|
|
|
accessforbidden(); |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/* |
171
|
|
|
* Action |
172
|
|
|
*/ |
173
|
|
|
|
174
|
|
|
$param = ''; |
175
|
|
|
|
176
|
|
|
$parameters = array(); |
177
|
|
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
178
|
|
|
if ($reshook < 0) { |
179
|
|
|
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
if (empty($reshook)) { |
183
|
|
|
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers |
184
|
|
|
$show_subgroup = ''; |
185
|
|
|
$search_date_start = ''; |
186
|
|
|
$search_date_end = ''; |
187
|
|
|
$search_date_startyear = ''; |
188
|
|
|
$search_date_startmonth = ''; |
189
|
|
|
$search_date_startday = ''; |
190
|
|
|
$search_date_endyear = ''; |
191
|
|
|
$search_date_endmonth = ''; |
192
|
|
|
$search_date_endday = ''; |
193
|
|
|
$search_accountancy_code_start = ''; |
194
|
|
|
$search_accountancy_code_end = ''; |
195
|
|
|
$search_not_reconciled = ''; |
196
|
|
|
$search_ledger_code = array(); |
197
|
|
|
$filter = array(); |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
// Must be after the remove filter action, before the export. |
201
|
|
|
$filter = array(); |
202
|
|
|
|
203
|
|
|
if (!empty($search_date_start)) { |
204
|
|
|
$filter['t.doc_date>='] = $search_date_start; |
205
|
|
|
$param .= '&date_startmonth=' . GETPOSTINT('date_startmonth') . '&date_startday=' . GETPOSTINT('date_startday') . '&date_startyear=' . GETPOSTINT('date_startyear'); |
206
|
|
|
} |
207
|
|
|
if (!empty($search_date_end)) { |
208
|
|
|
$filter['t.doc_date<='] = $search_date_end; |
209
|
|
|
$param .= '&date_endmonth=' . GETPOSTINT('date_endmonth') . '&date_endday=' . GETPOSTINT('date_endday') . '&date_endyear=' . GETPOSTINT('date_endyear'); |
210
|
|
|
} |
211
|
|
|
if (!empty($search_doc_date)) { |
|
|
|
|
212
|
|
|
$filter['t.doc_date'] = $search_doc_date; |
213
|
|
|
$param .= '&doc_datemonth=' . GETPOSTINT('doc_datemonth') . '&doc_dateday=' . GETPOSTINT('doc_dateday') . '&doc_dateyear=' . GETPOSTINT('doc_dateyear'); |
214
|
|
|
} |
215
|
|
|
if (!empty($search_accountancy_code_start)) { |
216
|
|
|
if ($type == 'sub') { |
217
|
|
|
$filter['t.subledger_account>='] = $search_accountancy_code_start; |
218
|
|
|
} else { |
219
|
|
|
$filter['t.numero_compte>='] = $search_accountancy_code_start; |
220
|
|
|
} |
221
|
|
|
$param .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start); |
222
|
|
|
} |
223
|
|
|
if (!empty($search_accountancy_code_end)) { |
224
|
|
|
if ($type == 'sub') { |
225
|
|
|
$filter['t.subledger_account<='] = $search_accountancy_code_end; |
226
|
|
|
} else { |
227
|
|
|
$filter['t.numero_compte<='] = $search_accountancy_code_end; |
228
|
|
|
} |
229
|
|
|
$param .= '&search_accountancy_code_end=' . urlencode($search_accountancy_code_end); |
230
|
|
|
} |
231
|
|
|
if (!empty($search_ledger_code)) { |
232
|
|
|
$filter['t.code_journal'] = $search_ledger_code; |
233
|
|
|
foreach ($search_ledger_code as $code) { |
234
|
|
|
$param .= '&search_ledger_code[]=' . urlencode($code); |
235
|
|
|
} |
236
|
|
|
} |
237
|
|
|
if (!empty($search_not_reconciled)) { |
238
|
|
|
$filter['t.reconciled_option'] = $search_not_reconciled; |
239
|
|
|
$param .= '&search_not_reconciled=' . urlencode($search_not_reconciled); |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
// param with type of list |
243
|
|
|
$url_param = substr($param, 1); // remove first "&" |
244
|
|
|
if (!empty($type)) { |
245
|
|
|
$param = '&type=' . $type . $param; |
246
|
|
|
} |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
if ($action == 'export_csv') { |
250
|
|
|
$sep = getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV'); |
251
|
|
|
|
252
|
|
|
$filename = 'balance'; |
253
|
|
|
$type_export = 'balance'; |
254
|
|
|
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; |
255
|
|
|
|
256
|
|
|
if ($type == 'sub') { |
257
|
|
|
$result = $object->fetchAllBalance($sortorder, $sortfield, $limit, 0, $filter, 'AND', 1); |
258
|
|
|
} else { |
259
|
|
|
$result = $object->fetchAllBalance($sortorder, $sortfield, $limit, 0, $filter); |
260
|
|
|
} |
261
|
|
|
if ($result < 0) { |
262
|
|
|
setEventMessages($object->error, $object->errors, 'errors'); |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
foreach ($object->lines as $line) { |
266
|
|
|
if ($type == 'sub') { |
267
|
|
|
print '"' . length_accounta($line->subledger_account) . '"' . $sep; |
268
|
|
|
print '"' . $line->subledger_label . '"' . $sep; |
269
|
|
|
} else { |
270
|
|
|
print '"' . length_accountg($line->numero_compte) . '"' . $sep; |
271
|
|
|
print '"' . $object->get_compte_desc($line->numero_compte) . '"' . $sep; |
272
|
|
|
} |
273
|
|
|
print '"' . price($line->debit) . '"' . $sep; |
274
|
|
|
print '"' . price($line->credit) . '"' . $sep; |
275
|
|
|
print '"' . price($line->debit - $line->credit) . '"' . $sep; |
276
|
|
|
print "\n"; |
277
|
|
|
} |
278
|
|
|
|
279
|
|
|
exit; |
|
|
|
|
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
|
283
|
|
|
/* |
284
|
|
|
* View |
285
|
|
|
*/ |
286
|
|
|
|
287
|
|
|
if ($type == 'sub') { |
288
|
|
|
$title_page = $langs->trans("AccountBalanceSubAccount"); |
289
|
|
|
} else { |
290
|
|
|
$title_page = $langs->trans("AccountBalance"); |
291
|
|
|
} |
292
|
|
|
|
293
|
|
|
$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double'; |
294
|
|
|
|
295
|
|
|
llxHeader('', $title_page, $help_url); |
296
|
|
|
|
297
|
|
|
|
298
|
|
|
if ($action != 'export_csv') { |
299
|
|
|
// List |
300
|
|
|
$nbtotalofrecords = ''; |
301
|
|
|
if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { |
302
|
|
|
if ($type == 'sub') { |
303
|
|
|
$nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter, 'AND', 1); |
304
|
|
|
} else { |
305
|
|
|
$nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter); |
306
|
|
|
} |
307
|
|
|
|
308
|
|
|
if ($nbtotalofrecords < 0) { |
309
|
|
|
setEventMessages($object->error, $object->errors, 'errors'); |
310
|
|
|
} |
311
|
|
|
} |
312
|
|
|
|
313
|
|
|
if ($type == 'sub') { |
314
|
|
|
$result = $object->fetchAllBalance($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 1); |
315
|
|
|
} else { |
316
|
|
|
$result = $object->fetchAllBalance($sortorder, $sortfield, $limit, $offset, $filter); |
317
|
|
|
} |
318
|
|
|
|
319
|
|
|
if ($result < 0) { |
320
|
|
|
setEventMessages($object->error, $object->errors, 'errors'); |
321
|
|
|
} |
322
|
|
|
|
323
|
|
|
print '<form method="POST" id="searchFormList" action="' . $_SERVER['PHP_SELF'] . '">'; |
324
|
|
|
print '<input type="hidden" name="token" value="' . newToken() . '">'; |
325
|
|
|
print '<input type="hidden" name="action" id="action" value="list">'; |
326
|
|
|
if ($optioncss != '') { |
327
|
|
|
print '<input type="hidden" name="optioncss" value="' . $optioncss . '">'; |
328
|
|
|
} |
329
|
|
|
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
330
|
|
|
print '<input type="hidden" name="type" value="' . $type . '">'; |
331
|
|
|
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">'; |
332
|
|
|
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">'; |
333
|
|
|
print '<input type="hidden" name="contextpage" value="' . $contextpage . '">'; |
334
|
|
|
print '<input type="hidden" name="page" value="' . $page . '">'; |
335
|
|
|
|
336
|
|
|
|
337
|
|
|
$parameters = array(); |
338
|
|
|
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
339
|
|
|
|
340
|
|
|
if ($reshook < 0) { |
341
|
|
|
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
342
|
|
|
} |
343
|
|
|
|
344
|
|
|
$newcardbutton = empty($hookmanager->resPrint) ? '' : $hookmanager->resPrint; |
345
|
|
|
|
346
|
|
|
if (empty($reshook)) { |
347
|
|
|
$newcardbutton = '<input type="button" id="exportcsvbutton" name="exportcsvbutton" class="butAction" value="' . $langs->trans("Export") . ' (' . getDolGlobalString('ACCOUNTING_EXPORT_FORMAT') . ')" />'; |
348
|
|
|
|
349
|
|
|
print '<script type="text/javascript"> |
350
|
|
|
jQuery(document).ready(function() { |
351
|
|
|
jQuery("#exportcsvbutton").click(function(event) { |
352
|
|
|
event.preventDefault(); |
353
|
|
|
console.log("Set action to export_csv"); |
354
|
|
|
jQuery("#action").val("export_csv"); |
355
|
|
|
jQuery("#searchFormList").submit(); |
356
|
|
|
jQuery("#action").val("list"); |
357
|
|
|
}); |
358
|
|
|
}); |
359
|
|
|
</script>'; |
360
|
|
|
|
361
|
|
|
if ($type == 'sub') { |
362
|
|
|
$newcardbutton .= dolGetButtonTitle($langs->trans('AccountBalance') . " - " . $langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/balance.php?' . $url_param, '', 1, array('morecss' => 'marginleftonly')); |
363
|
|
|
$newcardbutton .= dolGetButtonTitle($langs->trans('AccountBalance') . " - " . $langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/balance.php?type=sub&' . $url_param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); |
364
|
|
|
} else { |
365
|
|
|
$newcardbutton .= dolGetButtonTitle($langs->trans('AccountBalance') . " - " . $langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/balance.php?' . $url_param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); |
366
|
|
|
$newcardbutton .= dolGetButtonTitle($langs->trans('AccountBalance') . " - " . $langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/balance.php?type=sub&' . $url_param, '', 1, array('morecss' => 'marginleftonly')); |
367
|
|
|
} |
368
|
|
|
$newcardbutton .= dolGetButtonTitleSeparator(); |
369
|
|
|
$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT . '/accountancy/bookkeeping/card.php?action=create'); |
370
|
|
|
} |
371
|
|
|
if (!empty($contextpage) && $contextpage != $_SERVER['PHP_SELF']) { |
372
|
|
|
$param .= '&contextpage=' . urlencode($contextpage); |
373
|
|
|
} |
374
|
|
|
if ($limit > 0 && $limit != $conf->liste_limit) { |
375
|
|
|
$param .= '&limit=' . ((int) $limit); |
376
|
|
|
} |
377
|
|
|
|
378
|
|
|
print_barre_liste($title_page, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); |
379
|
|
|
|
380
|
|
|
$selectedfields = ''; |
381
|
|
|
|
382
|
|
|
// Warning to explain why list of record is not consistent with the other list view (missing a lot of lines) |
383
|
|
|
if ($type == 'sub') { |
384
|
|
|
print info_admin($langs->trans("WarningRecordWithoutSubledgerAreExcluded")); |
385
|
|
|
} |
386
|
|
|
|
387
|
|
|
$moreforfilter = ''; |
388
|
|
|
|
389
|
|
|
$moreforfilter .= '<div class="divsearchfield">'; |
390
|
|
|
$moreforfilter .= $langs->trans('DateStart') . ': '; |
391
|
|
|
$moreforfilter .= $form->selectDate($search_date_start ? $search_date_start : -1, 'date_start', 0, 0, 1, '', 1, 0); |
392
|
|
|
$moreforfilter .= $langs->trans('DateEnd') . ': '; |
393
|
|
|
$moreforfilter .= $form->selectDate($search_date_end ? $search_date_end : -1, 'date_end', 0, 0, 1, '', 1, 0); |
394
|
|
|
$moreforfilter .= '</div>'; |
395
|
|
|
|
396
|
|
|
$moreforfilter .= '<div class="divsearchfield">'; |
397
|
|
|
$moreforfilter .= '<label for="show_subgroup">' . $langs->trans('ShowSubtotalByGroup') . '</label>: '; |
398
|
|
|
$moreforfilter .= '<input type="checkbox" name="show_subgroup" id="show_subgroup" value="show_subgroup"' . ($show_subgroup == 'show_subgroup' ? ' checked' : '') . '>'; |
399
|
|
|
$moreforfilter .= '</div>'; |
400
|
|
|
|
401
|
|
|
$moreforfilter .= '<div class="divsearchfield">'; |
402
|
|
|
$moreforfilter .= $langs->trans("Journals") . ': '; |
403
|
|
|
$moreforfilter .= $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1); |
404
|
|
|
$moreforfilter .= '</div>'; |
405
|
|
|
|
406
|
|
|
//$moreforfilter .= '<br>'; |
407
|
|
|
$moreforfilter .= '<div class="divsearchfield">'; |
408
|
|
|
// Accountancy account |
409
|
|
|
$moreforfilter .= $langs->trans('AccountAccounting') . ': '; |
410
|
|
|
if ($type == 'sub') { |
411
|
|
|
$moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), 'maxwidth200'); |
412
|
|
|
} else { |
413
|
|
|
$moreforfilter .= $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, 'maxwidth200', 'accounts'); |
414
|
|
|
} |
415
|
|
|
$moreforfilter .= ' '; |
416
|
|
|
if ($type == 'sub') { |
417
|
|
|
$moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), 'maxwidth200'); |
418
|
|
|
} else { |
419
|
|
|
$moreforfilter .= $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, 'maxwidth200', 'accounts'); |
420
|
|
|
} |
421
|
|
|
$moreforfilter .= '</div>'; |
422
|
|
|
|
423
|
|
|
if (getDolGlobalString('ACCOUNTING_ENABLE_LETTERING')) { |
424
|
|
|
$moreforfilter .= '<div class="divsearchfield">'; |
425
|
|
|
$moreforfilter .= '<label for="notreconciled">' . $langs->trans('NotReconciled') . '</label>: '; |
426
|
|
|
$moreforfilter .= '<input type="checkbox" name="search_not_reconciled" id="notreconciled" value="notreconciled"' . ($search_not_reconciled == 'notreconciled' ? ' checked' : '') . '>'; |
427
|
|
|
$moreforfilter .= '</div>'; |
428
|
|
|
} |
429
|
|
|
|
430
|
|
|
if (!empty($moreforfilter)) { |
431
|
|
|
print '<div class="liste_titre liste_titre_bydiv centpercent">'; |
432
|
|
|
print $moreforfilter; |
433
|
|
|
$parameters = array(); |
434
|
|
|
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook |
435
|
|
|
print $hookmanager->resPrint; |
436
|
|
|
print '</div>'; |
437
|
|
|
} |
438
|
|
|
|
439
|
|
|
|
440
|
|
|
$colspan = (getDolGlobalString('ACCOUNTANCY_SHOW_OPENING_BALANCE') ? 5 : 4); |
441
|
|
|
|
442
|
|
|
print '<table class="liste ' . ($moreforfilter ? "listwithfilterbefore" : "") . '">'; |
443
|
|
|
|
444
|
|
|
print '<tr class="liste_titre_filter">'; |
445
|
|
|
|
446
|
|
|
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
447
|
|
|
print '<td class="liste_titre maxwidthsearch">'; |
448
|
|
|
$searchpicto = $form->showFilterButtons(); |
449
|
|
|
print $searchpicto; |
450
|
|
|
print '</td>'; |
451
|
|
|
} |
452
|
|
|
|
453
|
|
|
print '<td class="liste_titre" colspan="' . $colspan . '">'; |
454
|
|
|
print '</td>'; |
455
|
|
|
|
456
|
|
|
// Fields from hook |
457
|
|
|
$parameters = array(); |
458
|
|
|
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook |
459
|
|
|
print $hookmanager->resPrint; |
460
|
|
|
|
461
|
|
|
// Action column |
462
|
|
|
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
463
|
|
|
print '<td class="liste_titre maxwidthsearch">'; |
464
|
|
|
$searchpicto = $form->showFilterButtons(); |
465
|
|
|
print $searchpicto; |
466
|
|
|
print '</td>'; |
467
|
|
|
} |
468
|
|
|
print '</tr>' . "\n"; |
469
|
|
|
|
470
|
|
|
print '<tr class="liste_titre">'; |
471
|
|
|
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
472
|
|
|
print getTitleFieldOfList($selectedfields, 0, $_SERVER['PHP_SELF'], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ') . "\n"; |
473
|
|
|
} |
474
|
|
|
print_liste_field_titre("AccountAccounting", $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder); |
475
|
|
|
// TODO : Retrieve the type of third party: Customer / Supplier / Employee |
476
|
|
|
//if ($type == 'sub') { |
477
|
|
|
// print_liste_field_titre("Type", $_SERVER['PHP_SELF'], "t.type", "", $param, "", $sortfield, $sortorder); |
478
|
|
|
//} |
479
|
|
|
if (getDolGlobalString('ACCOUNTANCY_SHOW_OPENING_BALANCE')) { |
480
|
|
|
print_liste_field_titre("OpeningBalance", $_SERVER['PHP_SELF'], "", $param, "", 'class="right"', $sortfield, $sortorder); |
481
|
|
|
} |
482
|
|
|
print_liste_field_titre("AccountingDebit", $_SERVER['PHP_SELF'], "t.debit", "", $param, 'class="right"', $sortfield, $sortorder); |
483
|
|
|
print_liste_field_titre("AccountingCredit", $_SERVER['PHP_SELF'], "t.credit", "", $param, 'class="right"', $sortfield, $sortorder); |
484
|
|
|
print_liste_field_titre("Balance", $_SERVER['PHP_SELF'], "", $param, "", 'class="right"', $sortfield, $sortorder); |
485
|
|
|
|
486
|
|
|
// Hook fields |
487
|
|
|
$parameters = array('param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder); |
488
|
|
|
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook |
489
|
|
|
print $hookmanager->resPrint; |
490
|
|
|
// Action column |
491
|
|
|
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
492
|
|
|
print getTitleFieldOfList($selectedfields, 0, $_SERVER['PHP_SELF'], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ') . "\n"; |
493
|
|
|
} |
494
|
|
|
print '</tr>' . "\n"; |
495
|
|
|
|
496
|
|
|
$total_debit = 0; |
497
|
|
|
$total_credit = 0; |
498
|
|
|
$sous_total_debit = 0; |
499
|
|
|
$sous_total_credit = 0; |
500
|
|
|
$total_opening_balance = 0; |
501
|
|
|
$sous_total_opening_balance = 0; |
502
|
|
|
$displayed_account = ""; |
503
|
|
|
|
504
|
|
|
$accountingaccountstatic = new AccountingAccount($db); |
505
|
|
|
|
506
|
|
|
// TODO Debug - This feature is dangerous, it takes all the entries and adds all the accounts |
507
|
|
|
// without time and class limits (Class 6 and 7 accounts ???) and does not take into account the "a-nouveau" journal. |
508
|
|
|
if (getDolGlobalString('ACCOUNTANCY_SHOW_OPENING_BALANCE')) { |
509
|
|
|
$sql = "SELECT t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance"; |
510
|
|
|
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as t"; |
511
|
|
|
$sql .= " WHERE t.entity = " . $conf->entity; // Never do sharing into accounting features |
512
|
|
|
$sql .= " AND t.doc_date < '" . $db->idate($search_date_start) . "'"; |
513
|
|
|
$sql .= " GROUP BY t.numero_compte"; |
514
|
|
|
|
515
|
|
|
$resql = $db->query($sql); |
516
|
|
|
$nrows = $resql->num_rows; |
517
|
|
|
$opening_balances = array(); |
518
|
|
|
for ($i = 0; $i < $nrows; $i++) { |
519
|
|
|
$arr = $resql->fetch_array(); |
520
|
|
|
$opening_balances["'" . $arr['numero_compte'] . "'"] = $arr['opening_balance']; |
521
|
|
|
} |
522
|
|
|
} |
523
|
|
|
|
524
|
|
|
foreach ($object->lines as $line) { |
525
|
|
|
// reset before the fetch (in case of the fetch fails) |
526
|
|
|
$accountingaccountstatic->id = 0; |
527
|
|
|
$accountingaccountstatic->account_number = ''; |
528
|
|
|
|
529
|
|
|
if ($type != 'sub') { |
530
|
|
|
$accountingaccountstatic->fetch(null, $line->numero_compte, true); |
531
|
|
|
if (!empty($accountingaccountstatic->account_number)) { |
532
|
|
|
$accounting_account = $accountingaccountstatic->getNomUrl(0, 1, 1); |
533
|
|
|
} else { |
534
|
|
|
$accounting_account = length_accountg($line->numero_compte); |
535
|
|
|
} |
536
|
|
|
} |
537
|
|
|
|
538
|
|
|
$link = ''; |
539
|
|
|
$total_debit += $line->debit; |
540
|
|
|
$total_credit += $line->credit; |
541
|
|
|
$opening_balance = isset($opening_balances["'" . $line->numero_compte . "'"]) ? $opening_balances["'" . $line->numero_compte . "'"] : 0; |
542
|
|
|
$total_opening_balance += $opening_balance; |
543
|
|
|
|
544
|
|
|
$tmparrayforrootaccount = $object->getRootAccount($line->numero_compte); |
545
|
|
|
$root_account_description = $tmparrayforrootaccount['label']; |
546
|
|
|
$root_account_number = $tmparrayforrootaccount['account_number']; |
547
|
|
|
|
548
|
|
|
//var_dump($tmparrayforrootaccount); |
549
|
|
|
//var_dump($accounting_account); |
550
|
|
|
//var_dump($accountingaccountstatic); |
551
|
|
|
if (empty($accountingaccountstatic->label) && $accountingaccountstatic->id > 0) { |
552
|
|
|
$link = '<a class="editfielda reposition" href="' . DOL_URL_ROOT . '/accountancy/admin/card.php?action=update&token=' . newToken() . '&id=' . $accountingaccountstatic->id . '">' . img_edit() . '</a>'; |
553
|
|
|
} elseif ($accounting_account == 'NotDefined') { |
554
|
|
|
$link = '<a href="' . DOL_URL_ROOT . '/accountancy/admin/card.php?action=create&token=' . newToken() . '&accountingaccount=' . length_accountg($line->numero_compte) . '">' . img_edit_add() . '</a>'; |
555
|
|
|
} elseif (empty($tmparrayforrootaccount['label'])) { |
556
|
|
|
// $tmparrayforrootaccount['label'] not defined = the account has not parent with a parent. |
557
|
|
|
// This is useless, we should not create a new account when an account has no parent, we must edit it to fix its parent. |
558
|
|
|
// BUG 1: Accounts on level root or level 1 must not have a parent 2 level higher, so should not show a link to create another account. |
559
|
|
|
// BUG 2: Adding a link to create a new accounting account here is useless because it is not add as parent of the orphelin. |
560
|
|
|
//$link = '<a href="' . DOL_URL_ROOT . '/accountancy/admin/card.php?action=create&token=' . newToken() . '&accountingaccount=' . length_accountg($line->numero_compte) . '">' . img_edit_add() . '</a>'; |
561
|
|
|
} |
562
|
|
|
|
563
|
|
|
if (!empty($show_subgroup)) { |
564
|
|
|
// Show accounting account |
565
|
|
|
if (empty($displayed_account) || $root_account_number != $displayed_account) { |
566
|
|
|
// Show subtotal per accounting account |
567
|
|
|
if ($displayed_account != "") { |
568
|
|
|
print '<tr class="liste_total">'; |
569
|
|
|
print '<td class="right">' . $langs->trans("SubTotal") . ':</td>'; |
570
|
|
|
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
571
|
|
|
print '<td></td>'; |
572
|
|
|
} |
573
|
|
|
if (getDolGlobalString('ACCOUNTANCY_SHOW_OPENING_BALANCE')) { |
574
|
|
|
print '<td class="right nowraponall amount">' . price($sous_total_opening_balance) . '</td>'; |
575
|
|
|
} |
576
|
|
|
print '<td class="right nowraponall amount">' . price($sous_total_debit) . '</td>'; |
577
|
|
|
print '<td class="right nowraponall amount">' . price($sous_total_credit) . '</td>'; |
578
|
|
|
if (getDolGlobalString('ACCOUNTANCY_SHOW_OPENING_BALANCE')) { |
579
|
|
|
print '<td class="right nowraponall amount">' . price(price2num($sous_total_opening_balance + $sous_total_debit - $sous_total_credit)) . '</td>'; |
580
|
|
|
} else { |
581
|
|
|
print '<td class="right nowraponall amount">' . price(price2num($sous_total_debit - $sous_total_credit)) . '</td>'; |
582
|
|
|
} |
583
|
|
|
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
584
|
|
|
print "<td></td>\n"; |
585
|
|
|
} |
586
|
|
|
print '</tr>'; |
587
|
|
|
} |
588
|
|
|
|
589
|
|
|
// Show first line of a break |
590
|
|
|
print '<tr class="trforbreak">'; |
591
|
|
|
print '<td colspan="' . ($colspan + 1) . '" class="tdforbreak">' . $root_account_number . ($root_account_description ? ' - ' . $root_account_description : '') . '</td>'; |
592
|
|
|
print '</tr>'; |
593
|
|
|
|
594
|
|
|
$displayed_account = $root_account_number; |
595
|
|
|
$sous_total_debit = 0; |
596
|
|
|
$sous_total_credit = 0; |
597
|
|
|
$sous_total_opening_balance = 0; |
598
|
|
|
} |
599
|
|
|
} |
600
|
|
|
|
601
|
|
|
print '<tr class="oddeven">'; |
602
|
|
|
|
603
|
|
|
// Action column |
604
|
|
|
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
605
|
|
|
print '<td class="center">'; |
606
|
|
|
print $link; |
607
|
|
|
print '</td>'; |
608
|
|
|
} |
609
|
|
|
|
610
|
|
|
// Accounting account |
611
|
|
|
if ($type == 'sub') { |
612
|
|
|
print '<td>' . $line->subledger_account . ' <span class="opacitymedium">(' . $line->subledger_label . ')</span></td>'; |
613
|
|
|
} else { |
614
|
|
|
print '<td>' . $accounting_account . '</td>'; |
615
|
|
|
} |
616
|
|
|
|
617
|
|
|
// Type |
618
|
|
|
// TODO Retrieve the type of third party: Customer / Supplier / Employee |
619
|
|
|
//if ($type == 'sub') { |
620
|
|
|
// print '<td></td>'; |
621
|
|
|
//} |
622
|
|
|
|
623
|
|
|
if (getDolGlobalString('ACCOUNTANCY_SHOW_OPENING_BALANCE')) { |
624
|
|
|
print '<td class="right nowraponall amount">' . price(price2num($opening_balance, 'MT')) . '</td>'; |
625
|
|
|
} |
626
|
|
|
|
627
|
|
|
$urlzoom = ''; |
628
|
|
|
if ($type == 'sub') { |
629
|
|
|
if ($line->subledger_account) { |
630
|
|
|
$urlzoom = DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?type=sub&search_accountancy_code_start=' . urlencode($line->subledger_account) . '&search_accountancy_code_end=' . urlencode($line->subledger_account); |
631
|
|
|
if (GETPOSTISSET('date_startmonth')) { |
632
|
|
|
$urlzoom .= '&search_date_startmonth=' . GETPOSTINT('date_startmonth') . '&search_date_startday=' . GETPOSTINT('date_startday') . '&search_date_startyear=' . GETPOSTINT('date_startyear'); |
633
|
|
|
} |
634
|
|
|
if (GETPOSTISSET('date_endmonth')) { |
635
|
|
|
$urlzoom .= '&search_date_endmonth=' . GETPOSTINT('date_endmonth') . '&search_date_endday=' . GETPOSTINT('date_endday') . '&search_date_endyear=' . GETPOSTINT('date_endyear'); |
636
|
|
|
} |
637
|
|
|
} |
638
|
|
|
} else { |
639
|
|
|
if ($line->numero_compte) { |
640
|
|
|
$urlzoom = DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?search_accountancy_code_start=' . urlencode($line->numero_compte) . '&search_accountancy_code_end=' . urlencode($line->numero_compte); |
641
|
|
|
if (GETPOSTISSET('date_startmonth')) { |
642
|
|
|
$urlzoom .= '&search_date_startmonth=' . GETPOSTINT('date_startmonth') . '&search_date_startday=' . GETPOSTINT('date_startday') . '&search_date_startyear=' . GETPOSTINT('date_startyear'); |
643
|
|
|
} |
644
|
|
|
if (GETPOSTISSET('date_endmonth')) { |
645
|
|
|
$urlzoom .= '&search_date_endmonth=' . GETPOSTINT('date_endmonth') . '&search_date_endday=' . GETPOSTINT('date_endday') . '&search_date_endyear=' . GETPOSTINT('date_endyear'); |
646
|
|
|
} |
647
|
|
|
} |
648
|
|
|
} |
649
|
|
|
// Debit |
650
|
|
|
print '<td class="right nowraponall amount"><a href="' . $urlzoom . '">' . price(price2num($line->debit, 'MT')) . '</a></td>'; |
651
|
|
|
// Credit |
652
|
|
|
print '<td class="right nowraponall amount"><a href="' . $urlzoom . '">' . price(price2num($line->credit, 'MT')) . '</a></td>'; |
653
|
|
|
|
654
|
|
|
if (getDolGlobalString('ACCOUNTANCY_SHOW_OPENING_BALANCE')) { |
655
|
|
|
print '<td class="right nowraponall amount">' . price(price2num($opening_balance + $line->debit - $line->credit, 'MT')) . '</td>'; |
656
|
|
|
} else { |
657
|
|
|
print '<td class="right nowraponall amount">' . price(price2num($line->debit - $line->credit, 'MT')) . '</td>'; |
658
|
|
|
} |
659
|
|
|
|
660
|
|
|
// Action column |
661
|
|
|
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
662
|
|
|
print '<td class="center">'; |
663
|
|
|
print $link; |
664
|
|
|
print '</td>'; |
665
|
|
|
} |
666
|
|
|
|
667
|
|
|
print "</tr>\n"; |
668
|
|
|
|
669
|
|
|
// Records the sub-total |
670
|
|
|
$sous_total_debit += $line->debit; |
671
|
|
|
$sous_total_credit += $line->credit; |
672
|
|
|
$sous_total_opening_balance += $opening_balance; |
673
|
|
|
} |
674
|
|
|
|
675
|
|
|
if (!empty($show_subgroup)) { |
676
|
|
|
print '<tr class="liste_total">'; |
677
|
|
|
// Action column |
678
|
|
|
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
679
|
|
|
print "<td></td>\n"; |
680
|
|
|
} |
681
|
|
|
print '<td class="right">' . $langs->trans("SubTotal") . ':</td>'; |
682
|
|
|
if (getDolGlobalString('ACCOUNTANCY_SHOW_OPENING_BALANCE')) { |
683
|
|
|
print '<td class="right nowraponall amount">' . price(price2num($sous_total_opening_balance, 'MT')) . '</td>'; |
684
|
|
|
} |
685
|
|
|
print '<td class="right nowraponall amount">' . price(price2num($sous_total_debit, 'MT')) . '</td>'; |
686
|
|
|
print '<td class="right nowraponall amount">' . price(price2num($sous_total_credit, 'MT')) . '</td>'; |
687
|
|
|
if (getDolGlobalString('ACCOUNTANCY_SHOW_OPENING_BALANCE')) { |
688
|
|
|
print '<td class="right nowraponall amount">' . price(price2num($sous_total_opening_balance + $sous_total_debit - $sous_total_credit, 'MT')) . '</td>'; |
689
|
|
|
} else { |
690
|
|
|
print '<td class="right nowraponall amount">' . price(price2num($sous_total_debit - $sous_total_credit, 'MT')) . '</td>'; |
691
|
|
|
} |
692
|
|
|
// Action column |
693
|
|
|
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
694
|
|
|
print "<td></td>\n"; |
695
|
|
|
} |
696
|
|
|
print '</tr>'; |
697
|
|
|
} |
698
|
|
|
|
699
|
|
|
print '<tr class="liste_total">'; |
700
|
|
|
// Action column |
701
|
|
|
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
702
|
|
|
print "<td></td>\n"; |
703
|
|
|
} |
704
|
|
|
print '<td class="right">' . $langs->trans("AccountBalance") . ':</td>'; |
705
|
|
|
if (getDolGlobalString('ACCOUNTANCY_SHOW_OPENING_BALANCE')) { |
706
|
|
|
print '<td class="nowrap right">' . price(price2num($total_opening_balance, 'MT')) . '</td>'; |
707
|
|
|
} |
708
|
|
|
print '<td class="right nowraponall amount">' . price(price2num($total_debit, 'MT')) . '</td>'; |
709
|
|
|
print '<td class="right nowraponall amount">' . price(price2num($total_credit, 'MT')) . '</td>'; |
710
|
|
|
if (getDolGlobalString('ACCOUNTANCY_SHOW_OPENING_BALANCE')) { |
711
|
|
|
print '<td class="right nowraponall amount">' . price(price2num($total_opening_balance + $total_debit - $total_credit, 'MT')) . '</td>'; |
712
|
|
|
} else { |
713
|
|
|
print '<td class="right nowraponall amount">' . price(price2num($total_debit - $total_credit, 'MT')) . '</td>'; |
714
|
|
|
} |
715
|
|
|
// Action column |
716
|
|
|
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
717
|
|
|
print "<td></td>\n"; |
718
|
|
|
} |
719
|
|
|
print '</tr>'; |
720
|
|
|
|
721
|
|
|
// Accounting result |
722
|
|
|
if (getDolGlobalString('ACCOUNTING_CLOSURE_ACCOUNTING_GROUPS_USED_FOR_INCOME_STATEMENT')) { |
723
|
|
|
print '<tr class="liste_total">'; |
724
|
|
|
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
725
|
|
|
print "<td></td>\n"; |
726
|
|
|
} |
727
|
|
|
print '<td class="right">' . $langs->trans("AccountingResult") . ':</td>'; |
728
|
|
|
if (getDolGlobalString('ACCOUNTANCY_SHOW_OPENING_BALANCE')) { |
729
|
|
|
print '<td></td>'; |
730
|
|
|
} |
731
|
|
|
|
732
|
|
|
$accountingResult = $object->accountingResult($search_date_start, $search_date_end); |
733
|
|
|
if ($accountingResult < 0) { |
734
|
|
|
$accountingResultDebit = price(price2num(abs($accountingResult), 'MT')); |
735
|
|
|
$accountingResultClassCSS = ' error'; |
736
|
|
|
} else { |
737
|
|
|
$accountingResultCredit = price(price2num($accountingResult, 'MT')); |
738
|
|
|
$accountingResultClassCSS = ' green'; |
739
|
|
|
} |
740
|
|
|
print '<td class="right nowraponall amount' . $accountingResultClassCSS . '">' . $accountingResultDebit . '</td>'; |
741
|
|
|
print '<td class="right nowraponall amount' . $accountingResultClassCSS . '">' . $accountingResultCredit . '</td>'; |
742
|
|
|
|
743
|
|
|
print '<td></td>'; |
744
|
|
|
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
745
|
|
|
print "<td></td>\n"; |
746
|
|
|
} |
747
|
|
|
print '</tr>'; |
748
|
|
|
} |
749
|
|
|
|
750
|
|
|
$parameters = array(); |
751
|
|
|
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
752
|
|
|
print $hookmanager->resPrint; |
753
|
|
|
|
754
|
|
|
print "</table>"; |
755
|
|
|
print '</form>'; |
756
|
|
|
} |
757
|
|
|
|
758
|
|
|
// End of page |
759
|
|
|
llxFooter(); |
760
|
|
|
$db->close(); |
761
|
|
|
} |
762
|
|
|
|
763
|
|
|
/** |
764
|
|
|
* \file htdocs/accountancy/bookkeeping/card.php |
765
|
|
|
* \ingroup Accountancy (Double entries) |
766
|
|
|
* \brief Page to show book-entry |
767
|
|
|
*/ |
768
|
|
|
public function card() |
769
|
|
|
{ |
770
|
|
|
global $conf; |
771
|
|
|
global $db; |
772
|
|
|
global $user; |
773
|
|
|
global $hookmanager; |
774
|
|
|
global $user; |
775
|
|
|
global $menumanager; |
776
|
|
|
global $langs; |
777
|
|
|
// Load translation files required by the page |
778
|
|
|
$langs->loadLangs(array("accountancy", "bills", "compta")); |
779
|
|
|
|
780
|
|
|
$action = GETPOST('action', 'aZ09'); |
781
|
|
|
$cancel = GETPOST('cancel', 'aZ09'); |
782
|
|
|
|
783
|
|
|
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') |
784
|
|
|
|
785
|
|
|
$id = GETPOSTINT('id'); // id of record |
786
|
|
|
$mode = GETPOST('mode', 'aZ09'); // '' or '_tmp' |
787
|
|
|
$piece_num = GETPOSTINT("piece_num"); // id of transaction (several lines share the same transaction id) |
788
|
|
|
|
789
|
|
|
$accountingaccount = new AccountingAccount($db); |
790
|
|
|
$accountingjournal = new AccountingJournal($db); |
791
|
|
|
|
792
|
|
|
$accountingaccount_number = GETPOST('accountingaccount_number', 'alphanohtml'); |
793
|
|
|
$accountingaccount->fetch(null, $accountingaccount_number, true); |
794
|
|
|
$accountingaccount_label = $accountingaccount->label; |
795
|
|
|
|
796
|
|
|
$journal_code = GETPOST('code_journal', 'alpha'); |
797
|
|
|
$accountingjournal->fetch(null, $journal_code); |
798
|
|
|
$journal_label = $accountingjournal->label; |
799
|
|
|
|
800
|
|
|
$subledger_account = GETPOST('subledger_account', 'alphanohtml'); |
801
|
|
|
if ($subledger_account == -1) { |
802
|
|
|
$subledger_account = null; |
803
|
|
|
} |
804
|
|
|
$subledger_label = GETPOST('subledger_label', 'alphanohtml'); |
805
|
|
|
|
806
|
|
|
$label_operation = GETPOST('label_operation', 'alphanohtml'); |
807
|
|
|
$debit = (float) price2num(GETPOST('debit', 'alpha')); |
808
|
|
|
$credit = (float) price2num(GETPOST('credit', 'alpha')); |
809
|
|
|
|
810
|
|
|
$save = GETPOST('save', 'alpha'); |
811
|
|
|
if (!empty($save)) { |
812
|
|
|
$action = 'add'; |
813
|
|
|
} |
814
|
|
|
$update = GETPOST('update', 'alpha'); |
815
|
|
|
if (!empty($update)) { |
816
|
|
|
$action = 'confirm_update'; |
817
|
|
|
} |
818
|
|
|
|
819
|
|
|
$object = new BookKeeping($db); |
820
|
|
|
|
821
|
|
|
// Security check |
822
|
|
|
if (!isModEnabled('accounting')) { |
823
|
|
|
accessforbidden(); |
824
|
|
|
} |
825
|
|
|
if ($user->socid > 0) { |
826
|
|
|
accessforbidden(); |
827
|
|
|
} |
828
|
|
|
if (!$user->hasRight('accounting', 'mouvements', 'lire')) { |
829
|
|
|
accessforbidden(); |
830
|
|
|
} |
831
|
|
|
|
832
|
|
|
|
833
|
|
|
/* |
834
|
|
|
* Actions |
835
|
|
|
*/ |
836
|
|
|
|
837
|
|
|
if ($cancel) { |
838
|
|
|
header("Location: " . DOL_URL_ROOT . '/accountancy/bookkeeping/list.php'); |
839
|
|
|
exit; |
840
|
|
|
} |
841
|
|
|
|
842
|
|
|
if ($action == "confirm_update") { |
843
|
|
|
$error = 0; |
844
|
|
|
|
845
|
|
|
if (((float) $debit != 0.0) && ((float) $credit != 0.0)) { |
846
|
|
|
$error++; |
847
|
|
|
setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); |
848
|
|
|
$action = 'update'; |
849
|
|
|
} |
850
|
|
|
if (empty($accountingaccount_number) || $accountingaccount_number == '-1') { |
851
|
|
|
$error++; |
852
|
|
|
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors'); |
853
|
|
|
$action = 'update'; |
854
|
|
|
} |
855
|
|
|
|
856
|
|
|
if (!$error) { |
857
|
|
|
$object = new BookKeeping($db); |
858
|
|
|
|
859
|
|
|
$result = $object->fetch($id, null, $mode); |
860
|
|
|
if ($result < 0) { |
861
|
|
|
$error++; |
862
|
|
|
setEventMessages($object->error, $object->errors, 'errors'); |
863
|
|
|
} else { |
864
|
|
|
$object->numero_compte = $accountingaccount_number; |
865
|
|
|
$object->subledger_account = $subledger_account; |
866
|
|
|
$object->subledger_label = $subledger_label; |
867
|
|
|
$object->label_compte = $accountingaccount_label; |
868
|
|
|
$object->label_operation = $label_operation; |
869
|
|
|
$object->debit = $debit; |
870
|
|
|
$object->credit = $credit; |
871
|
|
|
|
872
|
|
|
if ((float) $debit != 0.0) { |
873
|
|
|
$object->montant = $debit; // deprecated |
874
|
|
|
$object->amount = $debit; |
875
|
|
|
$object->sens = 'D'; |
876
|
|
|
} |
877
|
|
|
if ((float) $credit != 0.0) { |
878
|
|
|
$object->montant = $credit; // deprecated |
879
|
|
|
$object->amount = $credit; |
880
|
|
|
$object->sens = 'C'; |
881
|
|
|
} |
882
|
|
|
|
883
|
|
|
$result = $object->update($user, false, $mode); |
884
|
|
|
if ($result < 0) { |
885
|
|
|
setEventMessages($object->error, $object->errors, 'errors'); |
886
|
|
|
} else { |
887
|
|
|
if ($mode != '_tmp') { |
888
|
|
|
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); |
889
|
|
|
} |
890
|
|
|
|
891
|
|
|
$debit = 0; |
892
|
|
|
$credit = 0; |
893
|
|
|
|
894
|
|
|
$action = ''; |
895
|
|
|
} |
896
|
|
|
} |
897
|
|
|
} |
898
|
|
|
} elseif ($action == "add") { |
899
|
|
|
$error = 0; |
900
|
|
|
|
901
|
|
|
if (((float) $debit != 0.0) && ((float) $credit != 0.0)) { |
902
|
|
|
$error++; |
903
|
|
|
setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); |
904
|
|
|
$action = ''; |
905
|
|
|
} |
906
|
|
|
if (empty($accountingaccount_number) || $accountingaccount_number == '-1') { |
907
|
|
|
$error++; |
908
|
|
|
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors'); |
909
|
|
|
$action = ''; |
910
|
|
|
} |
911
|
|
|
|
912
|
|
|
if (!$error) { |
913
|
|
|
$object = new BookKeeping($db); |
914
|
|
|
|
915
|
|
|
$object->numero_compte = $accountingaccount_number; |
916
|
|
|
$object->subledger_account = $subledger_account; |
917
|
|
|
$object->subledger_label = $subledger_label; |
918
|
|
|
$object->label_compte = $accountingaccount_label; |
919
|
|
|
$object->label_operation = $label_operation; |
920
|
|
|
$object->debit = $debit; |
921
|
|
|
$object->credit = $credit; |
922
|
|
|
$object->doc_date = (string) GETPOST('doc_date', 'alpha'); |
923
|
|
|
$object->doc_type = (string) GETPOST('doc_type', 'alpha'); |
924
|
|
|
$object->piece_num = $piece_num; |
925
|
|
|
$object->doc_ref = (string) GETPOST('doc_ref', 'alpha'); |
926
|
|
|
$object->code_journal = $journal_code; |
927
|
|
|
$object->journal_label = $journal_label; |
928
|
|
|
$object->fk_doc = GETPOSTINT('fk_doc'); |
929
|
|
|
$object->fk_docdet = GETPOSTINT('fk_docdet'); |
930
|
|
|
|
931
|
|
|
if ((float) $debit != 0.0) { |
932
|
|
|
$object->montant = $debit; // deprecated |
933
|
|
|
$object->amount = $debit; |
934
|
|
|
$object->sens = 'D'; |
935
|
|
|
} |
936
|
|
|
|
937
|
|
|
if ((float) $credit != 0.0) { |
938
|
|
|
$object->montant = $credit; // deprecated |
939
|
|
|
$object->amount = $credit; |
940
|
|
|
$object->sens = 'C'; |
941
|
|
|
} |
942
|
|
|
|
943
|
|
|
$result = $object->createStd($user, false, $mode); |
944
|
|
|
if ($result < 0) { |
945
|
|
|
setEventMessages($object->error, $object->errors, 'errors'); |
946
|
|
|
} else { |
947
|
|
|
if ($mode != '_tmp') { |
948
|
|
|
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); |
949
|
|
|
} |
950
|
|
|
|
951
|
|
|
$debit = 0; |
952
|
|
|
$credit = 0; |
953
|
|
|
|
954
|
|
|
$action = ''; |
955
|
|
|
} |
956
|
|
|
} |
957
|
|
|
} elseif ($action == "confirm_delete") { |
958
|
|
|
$object = new BookKeeping($db); |
959
|
|
|
|
960
|
|
|
$result = $object->fetch($id, null, $mode); |
961
|
|
|
$piece_num = $object->piece_num; |
962
|
|
|
|
963
|
|
|
if ($result < 0) { |
964
|
|
|
setEventMessages($object->error, $object->errors, 'errors'); |
965
|
|
|
} else { |
966
|
|
|
$result = $object->delete($user, false, $mode); |
967
|
|
|
if ($result < 0) { |
968
|
|
|
setEventMessages($object->error, $object->errors, 'errors'); |
969
|
|
|
} |
970
|
|
|
} |
971
|
|
|
$action = ''; |
972
|
|
|
} elseif ($action == "confirm_create") { |
973
|
|
|
$error = 0; |
974
|
|
|
|
975
|
|
|
$object = new BookKeeping($db); |
976
|
|
|
|
977
|
|
|
if (!$journal_code || $journal_code == '-1') { |
978
|
|
|
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Journal")), null, 'errors'); |
979
|
|
|
$action = 'create'; |
980
|
|
|
$error++; |
981
|
|
|
} |
982
|
|
|
if (!GETPOST('doc_ref', 'alpha')) { |
983
|
|
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Piece")), null, 'errors'); |
984
|
|
|
$action = 'create'; |
985
|
|
|
$error++; |
986
|
|
|
} |
987
|
|
|
|
988
|
|
|
if (!$error) { |
989
|
|
|
$object->label_compte = ''; |
990
|
|
|
$object->debit = 0; |
991
|
|
|
$object->credit = 0; |
992
|
|
|
$object->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOSTINT('doc_datemonth'), GETPOSTINT('doc_dateday'), GETPOSTINT('doc_dateyear')); |
993
|
|
|
$object->doc_type = GETPOST('doc_type', 'alpha'); |
994
|
|
|
$object->piece_num = GETPOSTINT('next_num_mvt'); |
995
|
|
|
$object->doc_ref = GETPOST('doc_ref', 'alpha'); |
996
|
|
|
$object->code_journal = $journal_code; |
997
|
|
|
$object->journal_label = $journal_label; |
998
|
|
|
$object->fk_doc = 0; |
999
|
|
|
$object->fk_docdet = 0; |
1000
|
|
|
$object->montant = 0; // deprecated |
1001
|
|
|
$object->amount = 0; |
1002
|
|
|
|
1003
|
|
|
$result = $object->createStd($user, 0, $mode); |
1004
|
|
|
if ($result < 0) { |
1005
|
|
|
setEventMessages($object->error, $object->errors, 'errors'); |
1006
|
|
|
} else { |
1007
|
|
|
if ($mode != '_tmp') { |
1008
|
|
|
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); |
1009
|
|
|
} |
1010
|
|
|
$action = ''; |
1011
|
|
|
$id = $object->id; |
1012
|
|
|
$piece_num = $object->piece_num; |
1013
|
|
|
} |
1014
|
|
|
} |
1015
|
|
|
} |
1016
|
|
|
|
1017
|
|
|
if ($action == 'setdate') { |
1018
|
|
|
$datedoc = dol_mktime(0, 0, 0, GETPOSTINT('doc_datemonth'), GETPOSTINT('doc_dateday'), GETPOSTINT('doc_dateyear')); |
1019
|
|
|
$result = $object->updateByMvt($piece_num, 'doc_date', $db->idate($datedoc), $mode); |
1020
|
|
|
if ($result < 0) { |
1021
|
|
|
setEventMessages($object->error, $object->errors, 'errors'); |
1022
|
|
|
} else { |
1023
|
|
|
if ($mode != '_tmp') { |
1024
|
|
|
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); |
1025
|
|
|
} |
1026
|
|
|
$action = ''; |
1027
|
|
|
} |
1028
|
|
|
} |
1029
|
|
|
|
1030
|
|
|
if ($action == 'setjournal') { |
1031
|
|
|
$result = $object->updateByMvt($piece_num, 'code_journal', $journal_code, $mode); |
1032
|
|
|
$result = $object->updateByMvt($piece_num, 'journal_label', $journal_label, $mode); |
1033
|
|
|
if ($result < 0) { |
1034
|
|
|
setEventMessages($object->error, $object->errors, 'errors'); |
1035
|
|
|
} else { |
1036
|
|
|
if ($mode != '_tmp') { |
1037
|
|
|
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); |
1038
|
|
|
} |
1039
|
|
|
$action = ''; |
1040
|
|
|
} |
1041
|
|
|
} |
1042
|
|
|
|
1043
|
|
|
if ($action == 'setdocref') { |
1044
|
|
|
$refdoc = GETPOST('doc_ref', 'alpha'); |
1045
|
|
|
$result = $object->updateByMvt($piece_num, 'doc_ref', $refdoc, $mode); |
1046
|
|
|
if ($result < 0) { |
1047
|
|
|
setEventMessages($object->error, $object->errors, 'errors'); |
1048
|
|
|
} else { |
1049
|
|
|
if ($mode != '_tmp') { |
1050
|
|
|
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); |
1051
|
|
|
} |
1052
|
|
|
$action = ''; |
1053
|
|
|
} |
1054
|
|
|
} |
1055
|
|
|
|
1056
|
|
|
// Validate transaction |
1057
|
|
|
if ($action == 'valid') { |
1058
|
|
|
$result = $object->transformTransaction(0, $piece_num); |
1059
|
|
|
if ($result < 0) { |
1060
|
|
|
setEventMessages($object->error, $object->errors, 'errors'); |
1061
|
|
|
} else { |
1062
|
|
|
header("Location: list.php?sortfield=t.piece_num&sortorder=asc"); |
1063
|
|
|
exit; |
1064
|
|
|
} |
1065
|
|
|
} |
1066
|
|
|
|
1067
|
|
|
|
1068
|
|
|
/* |
1069
|
|
|
* View |
1070
|
|
|
*/ |
1071
|
|
|
|
1072
|
|
|
$form = new Form($db); |
1073
|
|
|
$formaccounting = new FormAccounting($db); |
1074
|
|
|
|
1075
|
|
|
$title = $langs->trans("CreateMvts"); |
1076
|
|
|
$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double'; |
1077
|
|
|
llxHeader('', $title, $help_url); |
1078
|
|
|
|
1079
|
|
|
// Confirmation to delete the command |
1080
|
|
|
if ($action == 'delete') { |
1081
|
|
|
$formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $id . '&mode=' . $mode, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'confirm_delete', '', 0, 1); |
1082
|
|
|
print $formconfirm; |
1083
|
|
|
} |
1084
|
|
|
|
1085
|
|
|
if ($action == 'create') { |
1086
|
|
|
print load_fiche_titre($title); |
1087
|
|
|
|
1088
|
|
|
$object = new BookKeeping($db); |
1089
|
|
|
$next_num_mvt = $object->getNextNumMvt('_tmp'); |
1090
|
|
|
|
1091
|
|
|
if (empty($next_num_mvt)) { |
1092
|
|
|
dol_print_error(null, 'Failed to get next piece number'); |
1093
|
|
|
} |
1094
|
|
|
|
1095
|
|
|
print '<form action="' . $_SERVER['PHP_SELF'] . '" name="create_mvt" method="POST">'; |
1096
|
|
|
if ($optioncss != '') { |
1097
|
|
|
print '<input type="hidden" name="optioncss" value="' . $optioncss . '">'; |
1098
|
|
|
} |
1099
|
|
|
print '<input type="hidden" name="token" value="' . newToken() . '">'; |
1100
|
|
|
print '<input type="hidden" name="action" value="confirm_create">' . "\n"; |
1101
|
|
|
print '<input type="hidden" name="next_num_mvt" value="' . $next_num_mvt . '">' . "\n"; |
1102
|
|
|
print '<input type="hidden" name="mode" value="_tmp">' . "\n"; |
1103
|
|
|
|
1104
|
|
|
print dol_get_fiche_head(); |
1105
|
|
|
|
1106
|
|
|
print '<table class="border centpercent">'; |
1107
|
|
|
|
1108
|
|
|
/*print '<tr>'; |
1109
|
|
|
print '<td class="titlefieldcreate fieldrequired">' . $langs->trans("NumPiece") . '</td>'; |
1110
|
|
|
print '<td>' . $next_num_mvt . '</td>'; |
1111
|
|
|
print '</tr>';*/ |
1112
|
|
|
|
1113
|
|
|
print '<tr>'; |
1114
|
|
|
print '<td class="titlefieldcreate fieldrequired">' . $langs->trans("Docdate") . '</td>'; |
1115
|
|
|
print '<td>'; |
1116
|
|
|
print $form->selectDate('', 'doc_date', 0, 0, 0, "create_mvt", 1, 1); |
1117
|
|
|
print '</td>'; |
1118
|
|
|
print '</tr>'; |
1119
|
|
|
|
1120
|
|
|
print '<tr>'; |
1121
|
|
|
print '<td class="fieldrequired">' . $langs->trans("Codejournal") . '</td>'; |
1122
|
|
|
print '<td>' . $formaccounting->select_journal($journal_code, 'code_journal', 0, 0, 1, 1) . '</td>'; |
1123
|
|
|
print '</tr>'; |
1124
|
|
|
|
1125
|
|
|
print '<tr>'; |
1126
|
|
|
print '<td class="fieldrequired">' . $langs->trans("Piece") . '</td>'; |
1127
|
|
|
print '<td><input type="text" class="minwidth200" name="doc_ref" value="' . GETPOST('doc_ref', 'alpha') . '"></td>'; |
1128
|
|
|
print '</tr>'; |
1129
|
|
|
|
1130
|
|
|
/* |
1131
|
|
|
print '<tr>'; |
1132
|
|
|
print '<td>' . $langs->trans("Doctype") . '</td>'; |
1133
|
|
|
print '<td><input type="text" class="minwidth200 name="doc_type" value=""/></td>'; |
1134
|
|
|
print '</tr>'; |
1135
|
|
|
*/ |
1136
|
|
|
|
1137
|
|
|
print '</table>'; |
1138
|
|
|
|
1139
|
|
|
print dol_get_fiche_end(); |
1140
|
|
|
|
1141
|
|
|
print $form->buttonsSaveCancel("Create"); |
1142
|
|
|
|
1143
|
|
|
print '</form>'; |
1144
|
|
|
} else { |
1145
|
|
|
$object = new BookKeeping($db); |
1146
|
|
|
$result = $object->fetchPerMvt($piece_num, $mode); |
1147
|
|
|
if ($result < 0) { |
1148
|
|
|
setEventMessages($object->error, $object->errors, 'errors'); |
1149
|
|
|
} |
1150
|
|
|
|
1151
|
|
|
if (!empty($object->piece_num)) { |
1152
|
|
|
$backlink = '<a href="' . DOL_URL_ROOT . '/accountancy/bookkeeping/list.php?restore_lastsearch_values=1">' . $langs->trans('BackToList') . '</a>'; |
1153
|
|
|
|
1154
|
|
|
if ($mode == '_tmp') { |
1155
|
|
|
print load_fiche_titre($langs->trans("CreateMvts"), $backlink); |
1156
|
|
|
} else { |
1157
|
|
|
print load_fiche_titre($langs->trans("UpdateMvts"), $backlink); |
1158
|
|
|
} |
1159
|
|
|
|
1160
|
|
|
$head = array(); |
1161
|
|
|
$h = 0; |
1162
|
|
|
$head[$h][0] = $_SERVER['PHP_SELF'] . '?piece_num=' . $object->piece_num . ($mode ? '&mode=' . $mode : ''); |
1163
|
|
|
$head[$h][1] = $langs->trans("Transaction"); |
1164
|
|
|
$head[$h][2] = 'transaction'; |
1165
|
|
|
$h++; |
1166
|
|
|
|
1167
|
|
|
print dol_get_fiche_head($head, 'transaction', '', -1); |
1168
|
|
|
|
1169
|
|
|
//dol_banner_tab($object, '', $backlink); |
1170
|
|
|
|
1171
|
|
|
print '<div class="fichecenter">'; |
1172
|
|
|
print '<div class="fichehalfleft">'; |
1173
|
|
|
|
1174
|
|
|
print '<div class="underbanner clearboth"></div>'; |
1175
|
|
|
print '<table class="border tableforfield" width="100%">'; |
1176
|
|
|
|
1177
|
|
|
// Account movement |
1178
|
|
|
print '<tr>'; |
1179
|
|
|
print '<td class="titlefield">' . $langs->trans("NumMvts") . '</td>'; |
1180
|
|
|
print '<td>' . ($mode == '_tmp' ? '<span class="opacitymedium" title="Id tmp ' . $object->piece_num . '">' . $langs->trans("Draft") . '</span>' : $object->piece_num) . '</td>'; |
1181
|
|
|
print '</tr>'; |
1182
|
|
|
|
1183
|
|
|
// Date |
1184
|
|
|
print '<tr><td>'; |
1185
|
|
|
print '<table class="nobordernopadding centpercent"><tr><td>'; |
1186
|
|
|
print $langs->trans('Docdate'); |
1187
|
|
|
print '</td>'; |
1188
|
|
|
if ($action != 'editdate') { |
1189
|
|
|
print '<td class="right"><a class="editfielda reposition" href="' . $_SERVER['PHP_SELF'] . '?action=editdate&token=' . newToken() . '&piece_num=' . urlencode((string) ($object->piece_num)) . '&mode=' . urlencode((string) ($mode)) . '">' . img_edit($langs->transnoentitiesnoconv('SetDate'), 1) . '</a></td>'; |
1190
|
|
|
} |
1191
|
|
|
print '</tr></table>'; |
1192
|
|
|
print '</td><td colspan="3">'; |
1193
|
|
|
if ($action == 'editdate') { |
1194
|
|
|
print '<form name="setdate" action="' . $_SERVER['PHP_SELF'] . '?piece_num=' . $object->piece_num . '" method="post">'; |
1195
|
|
|
if ($optioncss != '') { |
1196
|
|
|
print '<input type="hidden" name="optioncss" value="' . $optioncss . '">'; |
1197
|
|
|
} |
1198
|
|
|
print '<input type="hidden" name="token" value="' . newToken() . '">'; |
1199
|
|
|
print '<input type="hidden" name="action" value="setdate">'; |
1200
|
|
|
print '<input type="hidden" name="mode" value="' . $mode . '">'; |
1201
|
|
|
print $form->selectDate($object->doc_date ? $object->doc_date : - 1, 'doc_date', 0, 0, 0, "setdate"); |
1202
|
|
|
print '<input type="submit" class="button button-edit" value="' . $langs->trans('Modify') . '">'; |
1203
|
|
|
print '</form>'; |
1204
|
|
|
} else { |
1205
|
|
|
print $object->doc_date ? dol_print_date($object->doc_date, 'day') : ' '; |
1206
|
|
|
} |
1207
|
|
|
print '</td>'; |
1208
|
|
|
print '</tr>'; |
1209
|
|
|
|
1210
|
|
|
// Journal |
1211
|
|
|
print '<tr><td>'; |
1212
|
|
|
print '<table class="nobordernopadding" width="100%"><tr><td>'; |
1213
|
|
|
print $langs->trans('Codejournal'); |
1214
|
|
|
print '</td>'; |
1215
|
|
|
if ($action != 'editjournal') { |
1216
|
|
|
print '<td class="right"><a class="editfielda reposition" href="' . $_SERVER['PHP_SELF'] . '?action=editjournal&token=' . newToken() . '&piece_num=' . urlencode((string) ($object->piece_num)) . '&mode=' . urlencode((string) ($mode)) . '">' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . '</a></td>'; |
1217
|
|
|
} |
1218
|
|
|
print '</tr></table>'; |
1219
|
|
|
print '</td><td>'; |
1220
|
|
|
if ($action == 'editjournal') { |
1221
|
|
|
print '<form name="setjournal" action="' . $_SERVER['PHP_SELF'] . '?piece_num=' . $object->piece_num . '" method="post">'; |
1222
|
|
|
if ($optioncss != '') { |
1223
|
|
|
print '<input type="hidden" name="optioncss" value="' . $optioncss . '">'; |
1224
|
|
|
} |
1225
|
|
|
print '<input type="hidden" name="token" value="' . newToken() . '">'; |
1226
|
|
|
print '<input type="hidden" name="action" value="setjournal">'; |
1227
|
|
|
print '<input type="hidden" name="mode" value="' . $mode . '">'; |
1228
|
|
|
print $formaccounting->select_journal($object->code_journal, 'code_journal', 0, 0, array(), 1, 1); |
1229
|
|
|
print '<input type="submit" class="button button-edit" value="' . $langs->trans('Modify') . '">'; |
1230
|
|
|
print '</form>'; |
1231
|
|
|
} else { |
1232
|
|
|
print $object->code_journal; |
1233
|
|
|
} |
1234
|
|
|
print '</td>'; |
1235
|
|
|
print '</tr>'; |
1236
|
|
|
|
1237
|
|
|
// Ref document |
1238
|
|
|
print '<tr><td>'; |
1239
|
|
|
print '<table class="nobordernopadding centpercent"><tr><td>'; |
1240
|
|
|
print $langs->trans('Piece'); |
1241
|
|
|
print '</td>'; |
1242
|
|
|
if ($action != 'editdocref') { |
1243
|
|
|
print '<td class="right"><a class="editfielda reposition" href="' . $_SERVER['PHP_SELF'] . '?action=editdocref&token=' . newToken() . '&piece_num=' . urlencode((string) ($object->piece_num)) . '&mode=' . urlencode((string) ($mode)) . '">' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . '</a></td>'; |
1244
|
|
|
} |
1245
|
|
|
print '</tr></table>'; |
1246
|
|
|
print '</td><td>'; |
1247
|
|
|
if ($action == 'editdocref') { |
1248
|
|
|
print '<form name="setdocref" action="' . $_SERVER['PHP_SELF'] . '?piece_num=' . $object->piece_num . '" method="post">'; |
1249
|
|
|
if ($optioncss != '') { |
1250
|
|
|
print '<input type="hidden" name="optioncss" value="' . $optioncss . '">'; |
1251
|
|
|
} |
1252
|
|
|
print '<input type="hidden" name="token" value="' . newToken() . '">'; |
1253
|
|
|
print '<input type="hidden" name="action" value="setdocref">'; |
1254
|
|
|
print '<input type="hidden" name="mode" value="' . $mode . '">'; |
1255
|
|
|
print '<input type="text" size="20" name="doc_ref" value="' . dol_escape_htmltag($object->doc_ref) . '">'; |
1256
|
|
|
print '<input type="submit" class="button button-edit" value="' . $langs->trans('Modify') . '">'; |
1257
|
|
|
print '</form>'; |
1258
|
|
|
} else { |
1259
|
|
|
print $object->doc_ref; |
1260
|
|
|
} |
1261
|
|
|
print '</td>'; |
1262
|
|
|
print '</tr>'; |
1263
|
|
|
|
1264
|
|
|
print '</table>'; |
1265
|
|
|
|
1266
|
|
|
print '</div>'; |
1267
|
|
|
|
1268
|
|
|
print '<div class="fichehalfright">'; |
1269
|
|
|
|
1270
|
|
|
print '<div class="underbanner clearboth"></div>'; |
1271
|
|
|
print '<table class="border tableforfield centpercent">'; |
1272
|
|
|
|
1273
|
|
|
// Doc type |
1274
|
|
|
if (!empty($object->doc_type)) { |
1275
|
|
|
print '<tr>'; |
1276
|
|
|
print '<td class="titlefield">' . $langs->trans("Doctype") . '</td>'; |
1277
|
|
|
print '<td>' . $object->doc_type . '</td>'; |
1278
|
|
|
print '</tr>'; |
1279
|
|
|
} |
1280
|
|
|
|
1281
|
|
|
// Date document creation |
1282
|
|
|
print '<tr>'; |
1283
|
|
|
print '<td class="titlefield">' . $langs->trans("DateCreation") . '</td>'; |
1284
|
|
|
print '<td>'; |
1285
|
|
|
print $object->date_creation ? dol_print_date($object->date_creation, 'day') : ' '; |
1286
|
|
|
print '</td>'; |
1287
|
|
|
print '</tr>'; |
1288
|
|
|
|
1289
|
|
|
// Don't show in tmp mode, inevitably empty |
1290
|
|
|
if ($mode != "_tmp") { |
1291
|
|
|
// Date document export |
1292
|
|
|
print '<tr>'; |
1293
|
|
|
print '<td class="titlefield">' . $langs->trans("DateExport") . '</td>'; |
1294
|
|
|
print '<td>'; |
1295
|
|
|
print $object->date_export ? dol_print_date($object->date_export, 'dayhour') : ' '; |
1296
|
|
|
print '</td>'; |
1297
|
|
|
print '</tr>'; |
1298
|
|
|
|
1299
|
|
|
// Date document validation |
1300
|
|
|
print '<tr>'; |
1301
|
|
|
print '<td class="titlefield">' . $langs->trans("DateValidation") . '</td>'; |
1302
|
|
|
print '<td>'; |
1303
|
|
|
print $object->date_validation ? dol_print_date($object->date_validation, 'dayhour') : ' '; |
1304
|
|
|
print '</td>'; |
1305
|
|
|
print '</tr>'; |
1306
|
|
|
} |
1307
|
|
|
|
1308
|
|
|
// Validate |
1309
|
|
|
/* |
1310
|
|
|
print '<tr>'; |
1311
|
|
|
print '<td class="titlefield">' . $langs->trans("Status") . '</td>'; |
1312
|
|
|
print '<td>'; |
1313
|
|
|
if (empty($object->validated)) { |
1314
|
|
|
print '<a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?piece_num=' . $line->id . '&action=enable&token='.newToken().'">'; |
1315
|
|
|
print img_picto($langs->trans("Disabled"), 'switch_off'); |
1316
|
|
|
print '</a>'; |
1317
|
|
|
} else { |
1318
|
|
|
print '<a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?piece_num=' . $line->id . '&action=disable&token='.newToken().'">'; |
1319
|
|
|
print img_picto($langs->trans("Activated"), 'switch_on'); |
1320
|
|
|
print '</a>'; |
1321
|
|
|
} |
1322
|
|
|
print '</td>'; |
1323
|
|
|
print '</tr>'; |
1324
|
|
|
*/ |
1325
|
|
|
|
1326
|
|
|
// check data |
1327
|
|
|
/* |
1328
|
|
|
print '<tr>'; |
1329
|
|
|
print '<td class="titlefield">' . $langs->trans("Control") . '</td>'; |
1330
|
|
|
if ($object->doc_type == 'customer_invoice') |
1331
|
|
|
{ |
1332
|
|
|
$sqlmid = 'SELECT rowid as ref'; |
1333
|
|
|
$sqlmid .= " FROM ".MAIN_DB_PREFIX."facture as fac"; |
1334
|
|
|
$sqlmid .= " WHERE fac.rowid=" . ((int) $object->fk_doc); |
1335
|
|
|
dol_syslog("accountancy/bookkeeping/card.php::sqlmid=" . $sqlmid, LOG_DEBUG); |
1336
|
|
|
$resultmid = $db->query($sqlmid); |
1337
|
|
|
if ($resultmid) { |
1338
|
|
|
$objmid = $db->fetch_object($resultmid); |
1339
|
|
|
$invoicestatic = new Facture($db); |
1340
|
|
|
$invoicestatic->fetch($objmid->ref); |
1341
|
|
|
$ref=$langs->trans("Invoice").' '.$invoicestatic->getNomUrl(1); |
1342
|
|
|
} |
1343
|
|
|
else dol_print_error($db); |
1344
|
|
|
} |
1345
|
|
|
print '<td>' . $ref .'</td>'; |
1346
|
|
|
print '</tr>'; |
1347
|
|
|
*/ |
1348
|
|
|
print "</table>\n"; |
1349
|
|
|
|
1350
|
|
|
print '</div>'; |
1351
|
|
|
|
1352
|
|
|
print dol_get_fiche_end(); |
1353
|
|
|
|
1354
|
|
|
print '<div class="clearboth"></div>'; |
1355
|
|
|
|
1356
|
|
|
print '<br>'; |
1357
|
|
|
|
1358
|
|
|
$result = $object->fetchAllPerMvt($piece_num, $mode); // This load $object->linesmvt |
1359
|
|
|
|
1360
|
|
|
if ($result < 0) { |
1361
|
|
|
setEventMessages($object->error, $object->errors, 'errors'); |
1362
|
|
|
} else { |
1363
|
|
|
// List of movements |
1364
|
|
|
print load_fiche_titre($langs->trans("ListeMvts"), '', ''); |
1365
|
|
|
|
1366
|
|
|
print '<form action="' . $_SERVER['PHP_SELF'] . '?piece_num=' . $object->piece_num . '" method="post">'; |
1367
|
|
|
if ($optioncss != '') { |
1368
|
|
|
print '<input type="hidden" name="optioncss" value="' . $optioncss . '">'; |
1369
|
|
|
} |
1370
|
|
|
print '<input type="hidden" name="token" value="' . newToken() . '">'; |
1371
|
|
|
print '<input type="hidden" name="doc_date" value="' . $object->doc_date . '">' . "\n"; |
1372
|
|
|
print '<input type="hidden" name="doc_type" value="' . $object->doc_type . '">' . "\n"; |
1373
|
|
|
print '<input type="hidden" name="doc_ref" value="' . $object->doc_ref . '">' . "\n"; |
1374
|
|
|
print '<input type="hidden" name="code_journal" value="' . $object->code_journal . '">' . "\n"; |
1375
|
|
|
print '<input type="hidden" name="fk_doc" value="' . $object->fk_doc . '">' . "\n"; |
1376
|
|
|
print '<input type="hidden" name="fk_docdet" value="' . $object->fk_docdet . '">' . "\n"; |
1377
|
|
|
print '<input type="hidden" name="mode" value="' . $mode . '">' . "\n"; |
1378
|
|
|
|
1379
|
|
|
if (count($object->linesmvt) > 0) { |
1380
|
|
|
print '<div class="div-table-responsive-no-min">'; |
1381
|
|
|
print '<table class="noborder centpercent">'; |
1382
|
|
|
|
1383
|
|
|
$total_debit = 0; |
1384
|
|
|
$total_credit = 0; |
1385
|
|
|
|
1386
|
|
|
print '<tr class="liste_titre">'; |
1387
|
|
|
|
1388
|
|
|
print_liste_field_titre("AccountAccountingShort"); |
1389
|
|
|
print_liste_field_titre("SubledgerAccount"); |
1390
|
|
|
print_liste_field_titre("LabelOperation"); |
1391
|
|
|
print_liste_field_titre("AccountingDebit", "", "", "", "", 'class="right"'); |
1392
|
|
|
print_liste_field_titre("AccountingCredit", "", "", "", "", 'class="right"'); |
1393
|
|
|
if (empty($object->date_validation)) { |
1394
|
|
|
print_liste_field_titre("Action", "", "", "", "", 'width="60"', "", "", 'center '); |
1395
|
|
|
} else { |
1396
|
|
|
print_liste_field_titre(""); |
1397
|
|
|
} |
1398
|
|
|
|
1399
|
|
|
print "</tr>\n"; |
1400
|
|
|
|
1401
|
|
|
// Add an empty line if there is not yet |
1402
|
|
|
if (!empty($object->linesmvt[0])) { |
1403
|
|
|
$tmpline = $object->linesmvt[0]; |
1404
|
|
|
if (!empty($tmpline->numero_compte)) { |
1405
|
|
|
$line = new BookKeepingLine($db); |
1406
|
|
|
$object->linesmvt[] = $line; |
1407
|
|
|
} |
1408
|
|
|
} |
1409
|
|
|
|
1410
|
|
|
foreach ($object->linesmvt as $line) { |
1411
|
|
|
print '<tr class="oddeven" data-lineid="' . ((int) $line->id) . '">'; |
1412
|
|
|
$total_debit += $line->debit; |
1413
|
|
|
$total_credit += $line->credit; |
1414
|
|
|
|
1415
|
|
|
if ($action == 'update' && $line->id == $id) { |
1416
|
|
|
print '<!-- td columns in edit mode -->'; |
1417
|
|
|
print '<td>'; |
1418
|
|
|
print $formaccounting->select_account((GETPOSTISSET("accountingaccount_number") ? GETPOST("accountingaccount_number", "alpha") : $line->numero_compte), 'accountingaccount_number', 1, array(), 1, 1, 'minwidth200 maxwidth500'); |
1419
|
|
|
print '</td>'; |
1420
|
|
|
print '<td>'; |
1421
|
|
|
// TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because: |
1422
|
|
|
// It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases. |
1423
|
|
|
// Also, it is not possible to use a value that is not in the list. |
1424
|
|
|
// Also, the label is not automatically filled when a value is selected. |
1425
|
|
|
if (getDolGlobalString('ACCOUNTANCY_COMBO_FOR_AUX')) { |
1426
|
|
|
print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1, 'maxwidth250', '', 'subledger_label'); |
1427
|
|
|
} else { |
1428
|
|
|
print '<input type="text" class="maxwidth150" name="subledger_account" value="' . (GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account) . '" placeholder="' . dol_escape_htmltag($langs->trans("SubledgerAccount")) . '">'; |
1429
|
|
|
} |
1430
|
|
|
// Add also input for subledger label |
1431
|
|
|
print '<br><input type="text" class="maxwidth150" name="subledger_label" value="' . (GETPOSTISSET("subledger_label") ? GETPOST("subledger_label", "alpha") : $line->subledger_label) . '" placeholder="' . dol_escape_htmltag($langs->trans("SubledgerAccountLabel")) . '">'; |
1432
|
|
|
print '</td>'; |
1433
|
|
|
print '<td><input type="text" class="minwidth200" name="label_operation" value="' . (GETPOSTISSET("label_operation") ? GETPOST("label_operation", "alpha") : $line->label_operation) . '"></td>'; |
1434
|
|
|
print '<td class="right"><input type="text" size="6" class="right" name="debit" value="' . (GETPOSTISSET("debit") ? GETPOST("debit", "alpha") : price($line->debit)) . '"></td>'; |
1435
|
|
|
print '<td class="right"><input type="text" size="6" class="right" name="credit" value="' . (GETPOSTISSET("credit") ? GETPOST("credit", "alpha") : price($line->credit)) . '"></td>'; |
1436
|
|
|
print '<td>'; |
1437
|
|
|
print '<input type="hidden" name="id" value="' . $line->id . '">' . "\n"; |
1438
|
|
|
print '<input type="submit" class="button" name="update" value="' . $langs->trans("Update") . '">'; |
1439
|
|
|
print '</td>'; |
1440
|
|
|
} elseif (empty($line->numero_compte) || (empty($line->debit) && empty($line->credit))) { |
1441
|
|
|
if ($action == "" || $action == 'add') { |
1442
|
|
|
print '<!-- td columns in add mode -->'; |
1443
|
|
|
print '<td>'; |
1444
|
|
|
print $formaccounting->select_account('', 'accountingaccount_number', 1, array(), 1, 1, 'minwidth200 maxwidth500'); |
1445
|
|
|
print '</td>'; |
1446
|
|
|
print '<td>'; |
1447
|
|
|
// TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because: |
1448
|
|
|
// It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases. |
1449
|
|
|
// Also, it is not possible to use a value that is not in the list. |
1450
|
|
|
// Also, the label is not automatically filled when a value is selected. |
1451
|
|
|
if (getDolGlobalString('ACCOUNTANCY_COMBO_FOR_AUX')) { |
1452
|
|
|
print $formaccounting->select_auxaccount('', 'subledger_account', 1, 'maxwidth250', '', 'subledger_label'); |
1453
|
|
|
} else { |
1454
|
|
|
print '<input type="text" class="maxwidth150" name="subledger_account" value="" placeholder="' . dol_escape_htmltag($langs->trans("SubledgerAccount")) . '">'; |
1455
|
|
|
} |
1456
|
|
|
print '<br><input type="text" class="maxwidth150" name="subledger_label" value="" placeholder="' . dol_escape_htmltag($langs->trans("SubledgerAccountLabel")) . '">'; |
1457
|
|
|
print '</td>'; |
1458
|
|
|
print '<td><input type="text" class="minwidth200" name="label_operation" value="' . $label_operation . '"/></td>'; |
1459
|
|
|
print '<td class="right"><input type="text" size="6" class="right" name="debit" value=""/></td>'; |
1460
|
|
|
print '<td class="right"><input type="text" size="6" class="right" name="credit" value=""/></td>'; |
1461
|
|
|
print '<td class="center"><input type="submit" class="button small" name="save" value="' . $langs->trans("Add") . '"></td>'; |
1462
|
|
|
} |
1463
|
|
|
} else { |
1464
|
|
|
print '<!-- td columns in display mode -->'; |
1465
|
|
|
$resultfetch = $accountingaccount->fetch(null, $line->numero_compte, true); |
1466
|
|
|
print '<td>'; |
1467
|
|
|
if ($resultfetch > 0) { |
1468
|
|
|
print $accountingaccount->getNomUrl(0, 1, 1, '', 0); |
1469
|
|
|
} else { |
1470
|
|
|
print $line->numero_compte . ' <span class="warning">(' . $langs->trans("AccountRemovedFromCurrentChartOfAccount") . ')</span>'; |
1471
|
|
|
} |
1472
|
|
|
print '</td>'; |
1473
|
|
|
print '<td>' . length_accounta($line->subledger_account); |
1474
|
|
|
if ($line->subledger_label) { |
1475
|
|
|
print ' - <span class="opacitymedium">' . $line->subledger_label . '</span>'; |
1476
|
|
|
} |
1477
|
|
|
print '</td>'; |
1478
|
|
|
print '<td>' . $line->label_operation . '</td>'; |
1479
|
|
|
print '<td class="right nowraponall amount">' . ($line->debit != 0 ? price($line->debit) : '') . '</td>'; |
1480
|
|
|
print '<td class="right nowraponall amount">' . ($line->credit != 0 ? price($line->credit) : '') . '</td>'; |
1481
|
|
|
|
1482
|
|
|
print '<td class="center nowraponall">'; |
1483
|
|
|
if (empty($line->date_export) && empty($line->date_validation)) { |
1484
|
|
|
print '<a class="editfielda reposition" href="' . $_SERVER['PHP_SELF'] . '?action=update&id=' . $line->id . '&piece_num=' . urlencode($line->piece_num) . '&mode=' . urlencode($mode) . '&token=' . urlencode(newToken()) . '">'; |
1485
|
|
|
print img_edit('', 0, 'class="marginrightonly"'); |
1486
|
|
|
print '</a> '; |
1487
|
|
|
} else { |
1488
|
|
|
print '<a class="editfielda nohover cursornotallowed reposition disabled" href="#" title="' . dol_escape_htmltag($langs->trans("ForbiddenTransactionAlreadyExported")) . '">'; |
1489
|
|
|
print img_edit($langs->trans("ForbiddenTransactionAlreadyExported"), 0, 'class="marginrightonly"'); |
1490
|
|
|
print '</a> '; |
1491
|
|
|
} |
1492
|
|
|
|
1493
|
|
|
if (empty($line->date_validation)) { |
1494
|
|
|
$actiontodelete = 'delete'; |
1495
|
|
|
if ($mode == '_tmp' || $action != 'delmouv') { |
1496
|
|
|
$actiontodelete = 'confirm_delete'; |
1497
|
|
|
} |
1498
|
|
|
|
1499
|
|
|
print '<a href="' . $_SERVER['PHP_SELF'] . '?action=' . $actiontodelete . '&id=' . $line->id . '&piece_num=' . urlencode($line->piece_num) . '&mode=' . urlencode($mode) . '&token=' . urlencode(newToken()) . '">'; |
1500
|
|
|
print img_delete(); |
1501
|
|
|
print '</a>'; |
1502
|
|
|
} else { |
1503
|
|
|
print '<a class="editfielda nohover cursornotallowed disabled" href="#" title="' . dol_escape_htmltag($langs->trans("ForbiddenTransactionAlreadyExported")) . '">'; |
1504
|
|
|
print img_delete($langs->trans("ForbiddenTransactionAlreadyValidated")); |
1505
|
|
|
print '</a>'; |
1506
|
|
|
} |
1507
|
|
|
|
1508
|
|
|
print '</td>'; |
1509
|
|
|
} |
1510
|
|
|
print "</tr>\n"; |
1511
|
|
|
} |
1512
|
|
|
|
1513
|
|
|
$total_debit = price2num($total_debit, 'MT'); |
1514
|
|
|
$total_credit = price2num($total_credit, 'MT'); |
1515
|
|
|
|
1516
|
|
|
if ($total_debit != $total_credit) { |
1517
|
|
|
setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_debit, $total_credit)), 'warnings'); |
1518
|
|
|
} |
1519
|
|
|
|
1520
|
|
|
print '</table>'; |
1521
|
|
|
print '</div>'; |
1522
|
|
|
|
1523
|
|
|
if ($mode == '_tmp' && $action == '') { |
1524
|
|
|
print '<br>'; |
1525
|
|
|
print '<div class="center">'; |
1526
|
|
|
if ($total_debit == $total_credit) { |
1527
|
|
|
print '<a class="button" href="' . $_SERVER['PHP_SELF'] . '?piece_num=' . $object->piece_num . '&action=valid">' . $langs->trans("ValidTransaction") . '</a>'; |
1528
|
|
|
} else { |
1529
|
|
|
print '<input type="submit" class="button" disabled="disabled" href="#" title="' . dol_escape_htmltag($langs->trans("MvtNotCorrectlyBalanced", $debit, $credit)) . '" value="' . dol_escape_htmltag($langs->trans("ValidTransaction")) . '">'; |
1530
|
|
|
} |
1531
|
|
|
|
1532
|
|
|
print ' '; |
1533
|
|
|
print '<a class="button button-cancel" href="' . DOL_URL_ROOT . '/accountancy/bookkeeping/list.php">' . $langs->trans("Cancel") . '</a>'; |
1534
|
|
|
|
1535
|
|
|
print "</div>"; |
1536
|
|
|
} |
1537
|
|
|
} |
1538
|
|
|
|
1539
|
|
|
print '</form>'; |
1540
|
|
|
} |
1541
|
|
|
} else { |
1542
|
|
|
print load_fiche_titre($langs->trans("NoRecords")); |
1543
|
|
|
} |
1544
|
|
|
} |
1545
|
|
|
|
1546
|
|
|
print dol_get_fiche_end(); |
1547
|
|
|
|
1548
|
|
|
// End of page |
1549
|
|
|
llxFooter(); |
1550
|
|
|
$db->close(); |
1551
|
|
|
} |
1552
|
|
|
|
1553
|
|
|
/** |
1554
|
|
|
* \file htdocs/accountancy/bookkeeping/export.php |
1555
|
|
|
* \ingroup Accountancy (Double entries) |
1556
|
|
|
* \brief Export operation of book keeping |
1557
|
|
|
*/ |
1558
|
|
|
public function export() |
1559
|
|
|
{ |
1560
|
|
|
global $conf; |
1561
|
|
|
global $db; |
1562
|
|
|
global $user; |
1563
|
|
|
global $hookmanager; |
1564
|
|
|
global $user; |
1565
|
|
|
global $menumanager; |
1566
|
|
|
global $langs; |
1567
|
|
|
|
1568
|
|
|
// Load translation files required by the page |
1569
|
|
|
$langs->loadLangs(array("accountancy", "compta")); |
1570
|
|
|
|
1571
|
|
|
$socid = GETPOSTINT('socid'); |
1572
|
|
|
|
1573
|
|
|
$action = GETPOST('action', 'aZ09'); |
1574
|
|
|
$massaction = GETPOST('massaction', 'alpha'); |
1575
|
|
|
$confirm = GETPOST('confirm', 'alpha'); |
1576
|
|
|
$toselect = GETPOST('toselect', 'array'); |
1577
|
|
|
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'bookkeepinglist'; |
1578
|
|
|
$search_mvt_num = GETPOSTINT('search_mvt_num'); |
1579
|
|
|
$search_doc_type = GETPOST("search_doc_type", 'alpha'); |
1580
|
|
|
$search_doc_ref = GETPOST("search_doc_ref", 'alpha'); |
1581
|
|
|
$search_date_startyear = GETPOSTINT('search_date_startyear'); |
1582
|
|
|
$search_date_startmonth = GETPOSTINT('search_date_startmonth'); |
1583
|
|
|
$search_date_startday = GETPOSTINT('search_date_startday'); |
1584
|
|
|
$search_date_endyear = GETPOSTINT('search_date_endyear'); |
1585
|
|
|
$search_date_endmonth = GETPOSTINT('search_date_endmonth'); |
1586
|
|
|
$search_date_endday = GETPOSTINT('search_date_endday'); |
1587
|
|
|
$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); |
1588
|
|
|
$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); |
1589
|
|
|
$search_doc_date = dol_mktime(0, 0, 0, GETPOSTINT('doc_datemonth'), GETPOSTINT('doc_dateday'), GETPOSTINT('doc_dateyear')); |
1590
|
|
|
$search_date_creation_startyear = GETPOSTINT('search_date_creation_startyear'); |
1591
|
|
|
$search_date_creation_startmonth = GETPOSTINT('search_date_creation_startmonth'); |
1592
|
|
|
$search_date_creation_startday = GETPOSTINT('search_date_creation_startday'); |
1593
|
|
|
$search_date_creation_endyear = GETPOSTINT('search_date_creation_endyear'); |
1594
|
|
|
$search_date_creation_endmonth = GETPOSTINT('search_date_creation_endmonth'); |
1595
|
|
|
$search_date_creation_endday = GETPOSTINT('search_date_creation_endday'); |
1596
|
|
|
$search_date_creation_start = dol_mktime(0, 0, 0, $search_date_creation_startmonth, $search_date_creation_startday, $search_date_creation_startyear); |
1597
|
|
|
$search_date_creation_end = dol_mktime(23, 59, 59, $search_date_creation_endmonth, $search_date_creation_endday, $search_date_creation_endyear); |
1598
|
|
|
$search_date_modification_startyear = GETPOSTINT('search_date_modification_startyear'); |
1599
|
|
|
$search_date_modification_startmonth = GETPOSTINT('search_date_modification_startmonth'); |
1600
|
|
|
$search_date_modification_startday = GETPOSTINT('search_date_modification_startday'); |
1601
|
|
|
$search_date_modification_endyear = GETPOSTINT('search_date_modification_endyear'); |
1602
|
|
|
$search_date_modification_endmonth = GETPOSTINT('search_date_modification_endmonth'); |
1603
|
|
|
$search_date_modification_endday = GETPOSTINT('search_date_modification_endday'); |
1604
|
|
|
$search_date_modification_start = dol_mktime(0, 0, 0, $search_date_modification_startmonth, $search_date_modification_startday, $search_date_modification_startyear); |
1605
|
|
|
$search_date_modification_end = dol_mktime(23, 59, 59, $search_date_modification_endmonth, $search_date_modification_endday, $search_date_modification_endyear); |
1606
|
|
|
$search_date_export_startyear = GETPOSTINT('search_date_export_startyear'); |
1607
|
|
|
$search_date_export_startmonth = GETPOSTINT('search_date_export_startmonth'); |
1608
|
|
|
$search_date_export_startday = GETPOSTINT('search_date_export_startday'); |
1609
|
|
|
$search_date_export_endyear = GETPOSTINT('search_date_export_endyear'); |
1610
|
|
|
$search_date_export_endmonth = GETPOSTINT('search_date_export_endmonth'); |
1611
|
|
|
$search_date_export_endday = GETPOSTINT('search_date_export_endday'); |
1612
|
|
|
$search_date_export_start = dol_mktime(0, 0, 0, $search_date_export_startmonth, $search_date_export_startday, $search_date_export_startyear); |
1613
|
|
|
$search_date_export_end = dol_mktime(23, 59, 59, $search_date_export_endmonth, $search_date_export_endday, $search_date_export_endyear); |
1614
|
|
|
$search_date_validation_startyear = GETPOSTINT('search_date_validation_startyear'); |
1615
|
|
|
$search_date_validation_startmonth = GETPOSTINT('search_date_validation_startmonth'); |
1616
|
|
|
$search_date_validation_startday = GETPOSTINT('search_date_validation_startday'); |
1617
|
|
|
$search_date_validation_endyear = GETPOSTINT('search_date_validation_endyear'); |
1618
|
|
|
$search_date_validation_endmonth = GETPOSTINT('search_date_validation_endmonth'); |
1619
|
|
|
$search_date_validation_endday = GETPOSTINT('search_date_validation_endday'); |
1620
|
|
|
$search_date_validation_start = dol_mktime(0, 0, 0, $search_date_validation_startmonth, $search_date_validation_startday, $search_date_validation_startyear); |
1621
|
|
|
$search_date_validation_end = dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear); |
1622
|
|
|
$search_import_key = GETPOST("search_import_key", 'alpha'); |
1623
|
|
|
|
1624
|
|
|
//var_dump($search_date_start);exit; |
1625
|
|
|
if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_delmvt")) { |
1626
|
|
|
$action = 'delbookkeepingyear'; |
1627
|
|
|
} |
1628
|
|
|
if (GETPOST("button_export_file_x") || GETPOST("button_export_file.x") || GETPOST("button_export_file")) { |
1629
|
|
|
$action = 'export_file'; |
1630
|
|
|
} |
1631
|
|
|
|
1632
|
|
|
$search_account_category = GETPOSTINT('search_account_category'); |
1633
|
|
|
|
1634
|
|
|
$search_accountancy_code = GETPOST("search_accountancy_code", 'alpha'); |
1635
|
|
|
$search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); |
1636
|
|
|
if ($search_accountancy_code_start == - 1) { |
1637
|
|
|
$search_accountancy_code_start = ''; |
1638
|
|
|
} |
1639
|
|
|
$search_accountancy_code_end = GETPOST('search_accountancy_code_end', 'alpha'); |
1640
|
|
|
if ($search_accountancy_code_end == - 1) { |
1641
|
|
|
$search_accountancy_code_end = ''; |
1642
|
|
|
} |
1643
|
|
|
|
1644
|
|
|
$search_accountancy_aux_code = GETPOST("search_accountancy_aux_code", 'alpha'); |
1645
|
|
|
$search_accountancy_aux_code_start = GETPOST('search_accountancy_aux_code_start', 'alpha'); |
1646
|
|
|
if ($search_accountancy_aux_code_start == - 1) { |
1647
|
|
|
$search_accountancy_aux_code_start = ''; |
1648
|
|
|
} |
1649
|
|
|
$search_accountancy_aux_code_end = GETPOST('search_accountancy_aux_code_end', 'alpha'); |
1650
|
|
|
if ($search_accountancy_aux_code_end == - 1) { |
1651
|
|
|
$search_accountancy_aux_code_end = ''; |
1652
|
|
|
} |
1653
|
|
|
$search_mvt_label = GETPOST('search_mvt_label', 'alpha'); |
1654
|
|
|
$search_direction = GETPOST('search_direction', 'alpha'); |
1655
|
|
|
$search_debit = GETPOST('search_debit', 'alpha'); |
1656
|
|
|
$search_credit = GETPOST('search_credit', 'alpha'); |
1657
|
|
|
$search_ledger_code = GETPOST('search_ledger_code', 'array'); |
1658
|
|
|
$search_lettering_code = GETPOST('search_lettering_code', 'alpha'); |
1659
|
|
|
$search_not_reconciled = GETPOST('search_not_reconciled', 'alpha'); |
1660
|
|
|
|
1661
|
|
|
// Load variable for pagination |
1662
|
|
|
$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION', $conf->liste_limit); |
1663
|
|
|
$sortfield = GETPOST('sortfield', 'aZ09comma'); |
1664
|
|
|
$sortorder = GETPOST('sortorder', 'aZ09comma'); |
1665
|
|
|
$optioncss = GETPOST('optioncss', 'alpha'); |
1666
|
|
|
$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); |
1667
|
|
|
if (empty($page) || $page < 0) { |
1668
|
|
|
$page = 0; |
1669
|
|
|
} |
1670
|
|
|
$offset = $limit * $page; |
1671
|
|
|
$pageprev = $page - 1; |
1672
|
|
|
$pagenext = $page + 1; |
1673
|
|
|
if ($sortorder == "") { |
1674
|
|
|
$sortorder = "ASC"; |
1675
|
|
|
} |
1676
|
|
|
if ($sortfield == "") { |
1677
|
|
|
$sortfield = "t.piece_num,t.rowid"; |
1678
|
|
|
} |
1679
|
|
|
|
1680
|
|
|
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
1681
|
|
|
$object = new BookKeeping($db); |
1682
|
|
|
$hookmanager->initHooks(array('bookkeepingexport')); |
1683
|
|
|
|
1684
|
|
|
$formaccounting = new FormAccounting($db); |
1685
|
|
|
$form = new Form($db); |
1686
|
|
|
|
1687
|
|
|
if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !GETPOSTISSET('begin') && !GETPOSTISSET('formfilteraction') && GETPOSTINT('page') == '' && !GETPOSTINT('noreset') && $user->hasRight('accounting', 'mouvements', 'export')) { |
1688
|
|
|
if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values') && !GETPOST('search_accountancy_code_start')) { |
1689
|
|
|
$query = "SELECT date_start, date_end from " . MAIN_DB_PREFIX . "accounting_fiscalyear "; |
1690
|
|
|
$query .= " where date_start < '" . $db->idate(dol_now()) . "' and date_end > '" . $db->idate(dol_now()) . "' limit 1"; |
1691
|
|
|
$res = $db->query($query); |
1692
|
|
|
|
1693
|
|
|
if ($res->num_rows > 0) { |
1694
|
|
|
$fiscalYear = $db->fetch_object($res); |
1695
|
|
|
$search_date_start = strtotime($fiscalYear->date_start); |
1696
|
|
|
$search_date_end = strtotime($fiscalYear->date_end); |
1697
|
|
|
} else { |
1698
|
|
|
$month_start = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); |
1699
|
|
|
$year_start = dol_print_date(dol_now(), '%Y'); |
1700
|
|
|
if (dol_print_date(dol_now(), '%m') < $month_start) { |
1701
|
|
|
$year_start--; // If current month is lower that starting fiscal month, we start last year |
1702
|
|
|
} |
1703
|
|
|
$year_end = $year_start + 1; |
1704
|
|
|
$month_end = $month_start - 1; |
1705
|
|
|
if ($month_end < 1) { |
1706
|
|
|
$month_end = 12; |
1707
|
|
|
$year_end--; |
1708
|
|
|
} |
1709
|
|
|
$search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start); |
1710
|
|
|
$search_date_end = dol_get_last_day($year_end, $month_end); |
1711
|
|
|
} |
1712
|
|
|
} |
1713
|
|
|
} |
1714
|
|
|
|
1715
|
|
|
|
1716
|
|
|
$arrayfields = array( |
1717
|
|
|
't.piece_num' => array('label' => $langs->trans("TransactionNumShort"), 'checked' => 1), |
1718
|
|
|
't.code_journal' => array('label' => $langs->trans("Codejournal"), 'checked' => 1), |
1719
|
|
|
't.doc_date' => array('label' => $langs->trans("Docdate"), 'checked' => 1), |
1720
|
|
|
't.doc_ref' => array('label' => $langs->trans("Piece"), 'checked' => 1), |
1721
|
|
|
't.numero_compte' => array('label' => $langs->trans("AccountAccountingShort"), 'checked' => 1), |
1722
|
|
|
't.subledger_account' => array('label' => $langs->trans("SubledgerAccount"), 'checked' => 1), |
1723
|
|
|
't.label_operation' => array('label' => $langs->trans("Label"), 'checked' => 1), |
1724
|
|
|
't.debit' => array('label' => $langs->trans("AccountingDebit"), 'checked' => 1), |
1725
|
|
|
't.credit' => array('label' => $langs->trans("AccountingCredit"), 'checked' => 1), |
1726
|
|
|
't.lettering_code' => array('label' => $langs->trans("LetteringCode"), 'checked' => 1), |
1727
|
|
|
't.date_creation' => array('label' => $langs->trans("DateCreation"), 'checked' => 0), |
1728
|
|
|
't.tms' => array('label' => $langs->trans("DateModification"), 'checked' => 0), |
1729
|
|
|
't.date_export' => array('label' => $langs->trans("DateExport"), 'checked' => 1), |
1730
|
|
|
't.date_validated' => array('label' => $langs->trans("DateValidationAndLock"), 'checked' => 1, 'enabled' => !getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")), |
1731
|
|
|
't.import_key' => array('label' => $langs->trans("ImportId"), 'checked' => 0, 'position' => 1100), |
1732
|
|
|
); |
1733
|
|
|
|
1734
|
|
|
if (!getDolGlobalString('ACCOUNTING_ENABLE_LETTERING')) { |
1735
|
|
|
unset($arrayfields['t.lettering_code']); |
1736
|
|
|
} |
1737
|
|
|
|
1738
|
|
|
$accountancyexport = new AccountancyExport($db); |
1739
|
|
|
$listofformat = $accountancyexport->getType(); |
1740
|
|
|
$formatexportset = getDolGlobalString('ACCOUNTING_EXPORT_MODELCSV'); |
1741
|
|
|
if (empty($listofformat[$formatexportset])) { |
1742
|
|
|
$formatexportset = 1; |
1743
|
|
|
} |
1744
|
|
|
|
1745
|
|
|
$error = 0; |
1746
|
|
|
|
1747
|
|
|
if (!isModEnabled('accounting')) { |
1748
|
|
|
accessforbidden(); |
1749
|
|
|
} |
1750
|
|
|
if ($user->socid > 0) { |
1751
|
|
|
accessforbidden(); |
1752
|
|
|
} |
1753
|
|
|
if (!$user->hasRight('accounting', 'mouvements', 'lire')) { |
1754
|
|
|
accessforbidden(); |
1755
|
|
|
} |
1756
|
|
|
|
1757
|
|
|
|
1758
|
|
|
/* |
1759
|
|
|
* Actions |
1760
|
|
|
*/ |
1761
|
|
|
|
1762
|
|
|
$param = ''; |
1763
|
|
|
|
1764
|
|
|
if (GETPOST('cancel', 'alpha')) { |
1765
|
|
|
$action = 'list'; |
1766
|
|
|
$massaction = ''; |
1767
|
|
|
} |
1768
|
|
|
if (!GETPOST('confirmmassaction', 'alpha')) { |
1769
|
|
|
$massaction = ''; |
1770
|
|
|
} |
1771
|
|
|
|
1772
|
|
|
$parameters = array('socid' => $socid); |
1773
|
|
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
1774
|
|
|
if ($reshook < 0) { |
1775
|
|
|
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
1776
|
|
|
} |
1777
|
|
|
|
1778
|
|
|
if (empty($reshook)) { |
1779
|
|
|
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php'; |
1780
|
|
|
|
1781
|
|
|
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers |
1782
|
|
|
$search_mvt_num = ''; |
1783
|
|
|
$search_doc_type = ''; |
1784
|
|
|
$search_doc_ref = ''; |
1785
|
|
|
$search_doc_date = ''; |
1786
|
|
|
$search_account_category = ''; |
1787
|
|
|
$search_accountancy_code = ''; |
1788
|
|
|
$search_accountancy_code_start = ''; |
1789
|
|
|
$search_accountancy_code_end = ''; |
1790
|
|
|
$search_accountancy_aux_code = ''; |
1791
|
|
|
$search_accountancy_aux_code_start = ''; |
1792
|
|
|
$search_accountancy_aux_code_end = ''; |
1793
|
|
|
$search_mvt_label = ''; |
1794
|
|
|
$search_direction = ''; |
1795
|
|
|
$search_ledger_code = array(); |
1796
|
|
|
$search_date_startyear = ''; |
1797
|
|
|
$search_date_startmonth = ''; |
1798
|
|
|
$search_date_startday = ''; |
1799
|
|
|
$search_date_endyear = ''; |
1800
|
|
|
$search_date_endmonth = ''; |
1801
|
|
|
$search_date_endday = ''; |
1802
|
|
|
$search_date_start = ''; |
1803
|
|
|
$search_date_end = ''; |
1804
|
|
|
$search_date_creation_startyear = ''; |
1805
|
|
|
$search_date_creation_startmonth = ''; |
1806
|
|
|
$search_date_creation_startday = ''; |
1807
|
|
|
$search_date_creation_endyear = ''; |
1808
|
|
|
$search_date_creation_endmonth = ''; |
1809
|
|
|
$search_date_creation_endday = ''; |
1810
|
|
|
$search_date_creation_start = ''; |
1811
|
|
|
$search_date_creation_end = ''; |
1812
|
|
|
$search_date_modification_startyear = ''; |
1813
|
|
|
$search_date_modification_startmonth = ''; |
1814
|
|
|
$search_date_modification_startday = ''; |
1815
|
|
|
$search_date_modification_endyear = ''; |
1816
|
|
|
$search_date_modification_endmonth = ''; |
1817
|
|
|
$search_date_modification_endday = ''; |
1818
|
|
|
$search_date_modification_start = ''; |
1819
|
|
|
$search_date_modification_end = ''; |
1820
|
|
|
$search_date_export_startyear = ''; |
1821
|
|
|
$search_date_export_startmonth = ''; |
1822
|
|
|
$search_date_export_startday = ''; |
1823
|
|
|
$search_date_export_endyear = ''; |
1824
|
|
|
$search_date_export_endmonth = ''; |
1825
|
|
|
$search_date_export_endday = ''; |
1826
|
|
|
$search_date_export_start = ''; |
1827
|
|
|
$search_date_export_end = ''; |
1828
|
|
|
$search_date_validation_startyear = ''; |
1829
|
|
|
$search_date_validation_startmonth = ''; |
1830
|
|
|
$search_date_validation_startday = ''; |
1831
|
|
|
$search_date_validation_endyear = ''; |
1832
|
|
|
$search_date_validation_endmonth = ''; |
1833
|
|
|
$search_date_validation_endday = ''; |
1834
|
|
|
$search_date_validation_start = ''; |
1835
|
|
|
$search_date_validation_end = ''; |
1836
|
|
|
$search_debit = ''; |
1837
|
|
|
$search_credit = ''; |
1838
|
|
|
$search_lettering_code = ''; |
1839
|
|
|
$search_not_reconciled = ''; |
1840
|
|
|
$search_import_key = ''; |
1841
|
|
|
$toselect = array(); |
1842
|
|
|
} |
1843
|
|
|
|
1844
|
|
|
// Must be after the remove filter action, before the export. |
1845
|
|
|
$filter = array(); |
1846
|
|
|
if (!empty($search_date_start)) { |
1847
|
|
|
$filter['t.doc_date>='] = $search_date_start; |
1848
|
|
|
$tmp = dol_getdate($search_date_start); |
1849
|
|
|
$param .= '&search_date_startmonth=' . urlencode($tmp['mon']) . '&search_date_startday=' . urlencode($tmp['mday']) . '&search_date_startyear=' . urlencode($tmp['year']); |
1850
|
|
|
} |
1851
|
|
|
if (!empty($search_date_end)) { |
1852
|
|
|
$filter['t.doc_date<='] = $search_date_end; |
1853
|
|
|
$tmp = dol_getdate($search_date_end); |
1854
|
|
|
$param .= '&search_date_endmonth=' . urlencode($tmp['mon']) . '&search_date_endday=' . urlencode($tmp['mday']) . '&search_date_endyear=' . urlencode($tmp['year']); |
1855
|
|
|
} |
1856
|
|
|
if (!empty($search_doc_date)) { |
1857
|
|
|
$filter['t.doc_date'] = $search_doc_date; |
1858
|
|
|
$tmp = dol_getdate($search_doc_date); |
1859
|
|
|
$param .= '&doc_datemonth=' . urlencode($tmp['mon']) . '&doc_dateday=' . urlencode($tmp['mday']) . '&doc_dateyear=' . urlencode($tmp['year']); |
1860
|
|
|
} |
1861
|
|
|
if (!empty($search_doc_type)) { |
1862
|
|
|
$filter['t.doc_type'] = $search_doc_type; |
1863
|
|
|
$param .= '&search_doc_type=' . urlencode($search_doc_type); |
1864
|
|
|
} |
1865
|
|
|
if (!empty($search_doc_ref)) { |
1866
|
|
|
$filter['t.doc_ref'] = $search_doc_ref; |
1867
|
|
|
$param .= '&search_doc_ref=' . urlencode($search_doc_ref); |
1868
|
|
|
} |
1869
|
|
|
if ($search_account_category != '-1' && !empty($search_account_category)) { |
1870
|
|
|
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancycategory.class.php'; |
1871
|
|
|
$accountingcategory = new AccountancyCategory($db); |
1872
|
|
|
|
1873
|
|
|
$listofaccountsforgroup = $accountingcategory->getCptsCat(0, 'fk_accounting_category = ' . ((int) $search_account_category)); |
1874
|
|
|
$listofaccountsforgroup2 = array(); |
1875
|
|
|
if (is_array($listofaccountsforgroup)) { |
1876
|
|
|
foreach ($listofaccountsforgroup as $tmpval) { |
1877
|
|
|
$listofaccountsforgroup2[] = "'" . $db->escape($tmpval['id']) . "'"; |
1878
|
|
|
} |
1879
|
|
|
} |
1880
|
|
|
$filter['t.search_accounting_code_in'] = implode(',', $listofaccountsforgroup2); |
1881
|
|
|
$param .= '&search_account_category=' . urlencode((string) ($search_account_category)); |
1882
|
|
|
} |
1883
|
|
|
if (!empty($search_accountancy_code)) { |
1884
|
|
|
$filter['t.numero_compte'] = $search_accountancy_code; |
1885
|
|
|
$param .= '&search_accountancy_code=' . urlencode($search_accountancy_code); |
1886
|
|
|
} |
1887
|
|
|
if (!empty($search_accountancy_code_start)) { |
1888
|
|
|
$filter['t.numero_compte>='] = $search_accountancy_code_start; |
1889
|
|
|
$param .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start); |
1890
|
|
|
} |
1891
|
|
|
if (!empty($search_accountancy_code_end)) { |
1892
|
|
|
$filter['t.numero_compte<='] = $search_accountancy_code_end; |
1893
|
|
|
$param .= '&search_accountancy_code_end=' . urlencode($search_accountancy_code_end); |
1894
|
|
|
} |
1895
|
|
|
if (!empty($search_accountancy_aux_code)) { |
1896
|
|
|
$filter['t.subledger_account'] = $search_accountancy_aux_code; |
1897
|
|
|
$param .= '&search_accountancy_aux_code=' . urlencode($search_accountancy_aux_code); |
1898
|
|
|
} |
1899
|
|
|
if (!empty($search_accountancy_aux_code_start)) { |
1900
|
|
|
$filter['t.subledger_account>='] = $search_accountancy_aux_code_start; |
1901
|
|
|
$param .= '&search_accountancy_aux_code_start=' . urlencode($search_accountancy_aux_code_start); |
1902
|
|
|
} |
1903
|
|
|
if (!empty($search_accountancy_aux_code_end)) { |
1904
|
|
|
$filter['t.subledger_account<='] = $search_accountancy_aux_code_end; |
1905
|
|
|
$param .= '&search_accountancy_aux_code_end=' . urlencode($search_accountancy_aux_code_end); |
1906
|
|
|
} |
1907
|
|
|
if (!empty($search_mvt_label)) { |
1908
|
|
|
$filter['t.label_operation'] = $search_mvt_label; |
1909
|
|
|
$param .= '&search_mvt_label=' . urlencode($search_mvt_label); |
1910
|
|
|
} |
1911
|
|
|
if (!empty($search_direction)) { |
1912
|
|
|
$filter['t.sens'] = $search_direction; |
1913
|
|
|
$param .= '&search_direction=' . urlencode($search_direction); |
1914
|
|
|
} |
1915
|
|
|
if (!empty($search_ledger_code)) { |
1916
|
|
|
$filter['t.code_journal'] = $search_ledger_code; |
1917
|
|
|
foreach ($search_ledger_code as $code) { |
1918
|
|
|
$param .= '&search_ledger_code[]=' . urlencode($code); |
1919
|
|
|
} |
1920
|
|
|
} |
1921
|
|
|
if (!empty($search_mvt_num)) { |
1922
|
|
|
$filter['t.piece_num'] = $search_mvt_num; |
1923
|
|
|
$param .= '&search_mvt_num=' . urlencode((string) ($search_mvt_num)); |
1924
|
|
|
} |
1925
|
|
|
if (!empty($search_date_creation_start)) { |
1926
|
|
|
$filter['t.date_creation>='] = $search_date_creation_start; |
1927
|
|
|
$tmp = dol_getdate($search_date_creation_start); |
1928
|
|
|
$param .= '&search_date_creation_startmonth=' . urlencode($tmp['mon']) . '&search_date_creation_startday=' . urlencode($tmp['mday']) . '&search_date_creation_startyear=' . urlencode($tmp['year']); |
1929
|
|
|
} |
1930
|
|
|
if (!empty($search_date_creation_end)) { |
1931
|
|
|
$filter['t.date_creation<='] = $search_date_creation_end; |
1932
|
|
|
$tmp = dol_getdate($search_date_creation_end); |
1933
|
|
|
$param .= '&search_date_creation_endmonth=' . urlencode($tmp['mon']) . '&search_date_creation_endday=' . urlencode($tmp['mday']) . '&search_date_creation_endyear=' . urlencode($tmp['year']); |
1934
|
|
|
} |
1935
|
|
|
if (!empty($search_date_modification_start)) { |
1936
|
|
|
$filter['t.tms>='] = $search_date_modification_start; |
1937
|
|
|
$tmp = dol_getdate($search_date_modification_start); |
1938
|
|
|
$param .= '&search_date_modification_startmonth=' . urlencode($tmp['mon']) . '&search_date_modification_startday=' . urlencode($tmp['mday']) . '&search_date_modification_startyear=' . urlencode($tmp['year']); |
1939
|
|
|
} |
1940
|
|
|
if (!empty($search_date_modification_end)) { |
1941
|
|
|
$filter['t.tms<='] = $search_date_modification_end; |
1942
|
|
|
$tmp = dol_getdate($search_date_modification_end); |
1943
|
|
|
$param .= '&search_date_modification_endmonth=' . urlencode($tmp['mon']) . '&search_date_modification_endday=' . urlencode($tmp['mday']) . '&search_date_modification_endyear=' . urlencode($tmp['year']); |
1944
|
|
|
} |
1945
|
|
|
if (!empty($search_date_export_start)) { |
1946
|
|
|
$filter['t.date_export>='] = $search_date_export_start; |
1947
|
|
|
$tmp = dol_getdate($search_date_export_start); |
1948
|
|
|
$param .= '&search_date_export_startmonth=' . urlencode($tmp['mon']) . '&search_date_export_startday=' . urlencode($tmp['mday']) . '&search_date_export_startyear=' . urlencode($tmp['year']); |
1949
|
|
|
} |
1950
|
|
|
if (!empty($search_date_export_end)) { |
1951
|
|
|
$filter['t.date_export<='] = $search_date_export_end; |
1952
|
|
|
$tmp = dol_getdate($search_date_export_end); |
1953
|
|
|
$param .= '&search_date_export_endmonth=' . urlencode($tmp['mon']) . '&search_date_export_endday=' . urlencode($tmp['mday']) . '&search_date_export_endyear=' . urlencode($tmp['year']); |
1954
|
|
|
} |
1955
|
|
|
if (!empty($search_date_validation_start)) { |
1956
|
|
|
$filter['t.date_validated>='] = $search_date_validation_start; |
1957
|
|
|
$tmp = dol_getdate($search_date_validation_start); |
1958
|
|
|
$param .= '&search_date_validation_startmonth=' . urlencode($tmp['mon']) . '&search_date_validation_startday=' . urlencode($tmp['mday']) . '&search_date_validation_startyear=' . urlencode($tmp['year']); |
1959
|
|
|
} |
1960
|
|
|
if (!empty($search_date_validation_end)) { |
1961
|
|
|
$filter['t.date_validated<='] = $search_date_validation_end; |
1962
|
|
|
$tmp = dol_getdate($search_date_validation_end); |
1963
|
|
|
$param .= '&search_date_validation_endmonth=' . urlencode($tmp['mon']) . '&search_date_validation_endday=' . urlencode($tmp['mday']) . '&search_date_validation_endyear=' . urlencode($tmp['year']); |
1964
|
|
|
} |
1965
|
|
|
if (!empty($search_debit)) { |
1966
|
|
|
$filter['t.debit'] = $search_debit; |
1967
|
|
|
$param .= '&search_debit=' . urlencode($search_debit); |
1968
|
|
|
} |
1969
|
|
|
if (!empty($search_credit)) { |
1970
|
|
|
$filter['t.credit'] = $search_credit; |
1971
|
|
|
$param .= '&search_credit=' . urlencode($search_credit); |
1972
|
|
|
} |
1973
|
|
|
if (!empty($search_lettering_code)) { |
1974
|
|
|
$filter['t.lettering_code'] = $search_lettering_code; |
1975
|
|
|
$param .= '&search_lettering_code=' . urlencode($search_lettering_code); |
1976
|
|
|
} |
1977
|
|
|
if (!empty($search_not_reconciled)) { |
1978
|
|
|
$filter['t.reconciled_option'] = $search_not_reconciled; |
1979
|
|
|
$param .= '&search_not_reconciled=' . urlencode($search_not_reconciled); |
1980
|
|
|
} |
1981
|
|
|
if (!empty($search_import_key)) { |
1982
|
|
|
$filter['t.import_key'] = $search_import_key; |
1983
|
|
|
$param .= '&search_import_key=' . urlencode($search_import_key); |
1984
|
|
|
} |
1985
|
|
|
|
1986
|
|
|
if ($action == 'setreexport') { |
1987
|
|
|
$setreexport = GETPOSTINT('value'); |
1988
|
|
|
if (!dolibarr_set_const($db, "ACCOUNTING_REEXPORT", $setreexport, 'yesno', 0, '', $conf->entity)) { |
1989
|
|
|
$error++; |
1990
|
|
|
} |
1991
|
|
|
|
1992
|
|
|
if (!$error) { |
1993
|
|
|
if (!getDolGlobalString('ACCOUNTING_REEXPORT')) { |
1994
|
|
|
setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsDisable"), null, 'mesgs'); |
1995
|
|
|
} else { |
1996
|
|
|
setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsEnable"), null, 'warnings'); |
1997
|
|
|
} |
1998
|
|
|
} else { |
1999
|
|
|
setEventMessages($langs->trans("Error"), null, 'errors'); |
2000
|
|
|
} |
2001
|
|
|
} |
2002
|
|
|
|
2003
|
|
|
// Mass actions |
2004
|
|
|
$objectclass = 'Bookkeeping'; |
2005
|
|
|
$objectlabel = 'Bookkeeping'; |
2006
|
|
|
$permissiontoread = $user->hasRight('societe', 'lire'); |
2007
|
|
|
$permissiontodelete = $user->hasRight('societe', 'supprimer'); |
2008
|
|
|
$permissiontoadd = $user->hasRight('societe', 'creer'); |
2009
|
|
|
$uploaddir = $conf->societe->dir_output; |
2010
|
|
|
include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php'; |
2011
|
|
|
} |
2012
|
|
|
|
2013
|
|
|
// Build and execute select (used by page and export action) |
2014
|
|
|
// must de set after the action that set $filter |
2015
|
|
|
// -------------------------------------------------------------------- |
2016
|
|
|
|
2017
|
|
|
$sql = 'SELECT'; |
2018
|
|
|
$sql .= ' t.rowid,'; |
2019
|
|
|
$sql .= " t.doc_date,"; |
2020
|
|
|
$sql .= " t.doc_type,"; |
2021
|
|
|
$sql .= " t.doc_ref,"; |
2022
|
|
|
$sql .= " t.fk_doc,"; |
2023
|
|
|
$sql .= " t.fk_docdet,"; |
2024
|
|
|
$sql .= " t.thirdparty_code,"; |
2025
|
|
|
$sql .= " t.subledger_account,"; |
2026
|
|
|
$sql .= " t.subledger_label,"; |
2027
|
|
|
$sql .= " t.numero_compte,"; |
2028
|
|
|
$sql .= " t.label_compte,"; |
2029
|
|
|
$sql .= " t.label_operation,"; |
2030
|
|
|
$sql .= " t.debit,"; |
2031
|
|
|
$sql .= " t.credit,"; |
2032
|
|
|
$sql .= " t.lettering_code,"; |
2033
|
|
|
$sql .= " t.date_lettering,"; |
2034
|
|
|
$sql .= " t.montant as amount,"; |
2035
|
|
|
$sql .= " t.sens,"; |
2036
|
|
|
$sql .= " t.fk_user_author,"; |
2037
|
|
|
$sql .= " t.import_key,"; |
2038
|
|
|
$sql .= " t.code_journal,"; |
2039
|
|
|
$sql .= " t.journal_label,"; |
2040
|
|
|
$sql .= " t.piece_num,"; |
2041
|
|
|
$sql .= " t.date_creation,"; |
2042
|
|
|
$sql .= " t.date_lim_reglement,"; |
2043
|
|
|
$sql .= " t.tms as date_modification,"; |
2044
|
|
|
$sql .= " t.date_export,"; |
2045
|
|
|
$sql .= " t.date_validated as date_validation,"; |
2046
|
|
|
$sql .= " t.import_key"; |
2047
|
|
|
|
2048
|
|
|
$sqlfields = $sql; // $sql fields to remove for count total |
2049
|
|
|
|
2050
|
|
|
$sql .= ' FROM ' . MAIN_DB_PREFIX . $object->table_element . ' as t'; |
2051
|
|
|
// Manage filter |
2052
|
|
|
$sqlwhere = array(); |
2053
|
|
|
if (count($filter) > 0) { |
2054
|
|
|
foreach ($filter as $key => $value) { |
2055
|
|
|
if ($key == 't.doc_date') { |
2056
|
|
|
$sqlwhere[] = $db->sanitize($key) . " = '" . $db->idate($value) . "'"; |
2057
|
|
|
} elseif ($key == 't.doc_date>=') { |
2058
|
|
|
$sqlwhere[] = "t.doc_date >= '" . $db->idate($value) . "'"; |
2059
|
|
|
} elseif ($key == 't.doc_date<=') { |
2060
|
|
|
$sqlwhere[] = "t.doc_date <= '" . $db->idate($value) . "'"; |
2061
|
|
|
} elseif ($key == 't.doc_date>') { |
2062
|
|
|
$sqlwhere[] = "t.doc_date > '" . $db->idate($value) . "'"; |
2063
|
|
|
} elseif ($key == 't.doc_date<') { |
2064
|
|
|
$sqlwhere[] = "t.doc_date < '" . $db->idate($value) . "'"; |
2065
|
|
|
} elseif ($key == 't.numero_compte>=') { |
2066
|
|
|
$sqlwhere[] = "t.numero_compte >= '" . $db->escape($value) . "'"; |
2067
|
|
|
} elseif ($key == 't.numero_compte<=') { |
2068
|
|
|
$sqlwhere[] = "t.numero_compte <= '" . $db->escape($value) . "'"; |
2069
|
|
|
} elseif ($key == 't.subledger_account>=') { |
2070
|
|
|
$sqlwhere[] = "t.subledger_account >= '" . $db->escape($value) . "'"; |
2071
|
|
|
} elseif ($key == 't.subledger_account<=') { |
2072
|
|
|
$sqlwhere[] = "t.subledger_account <= '" . $db->escape($value) . "'"; |
2073
|
|
|
} elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { |
2074
|
|
|
$sqlwhere[] = $db->sanitize($key) . '=' . ((int) $value); |
2075
|
|
|
} elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { |
2076
|
|
|
$sqlwhere[] = $db->sanitize($key) . " LIKE '" . $db->escape($db->escapeforlike($value)) . "%'"; |
2077
|
|
|
} elseif ($key == 't.subledger_account') { |
2078
|
|
|
$sqlwhere[] = natural_search($key, $value, 0, 1); |
2079
|
|
|
} elseif ($key == 't.tms>=') { |
2080
|
|
|
$sqlwhere[] = "t.tms >= '" . $db->idate($value) . "'"; |
2081
|
|
|
} elseif ($key == 't.tms<=') { |
2082
|
|
|
$sqlwhere[] = "t.tms <= '" . $db->idate($value) . "'"; |
2083
|
|
|
} elseif ($key == 't.date_creation>=') { |
2084
|
|
|
$sqlwhere[] = "t.date_creation >= '" . $db->idate($value) . "'"; |
2085
|
|
|
} elseif ($key == 't.date_creation<=') { |
2086
|
|
|
$sqlwhere[] = "t.date_creation <= '" . $db->idate($value) . "'"; |
2087
|
|
|
} elseif ($key == 't.date_export>=') { |
2088
|
|
|
$sqlwhere[] = "t.date_export >= '" . $db->idate($value) . "'"; |
2089
|
|
|
} elseif ($key == 't.date_export<=') { |
2090
|
|
|
$sqlwhere[] = "t.date_export <= '" . $db->idate($value) . "'"; |
2091
|
|
|
} elseif ($key == 't.date_validated>=') { |
2092
|
|
|
$sqlwhere[] = "t;date_validate >= '" . $db->idate($value) . "'"; |
2093
|
|
|
} elseif ($key == 't.date_validated<=') { |
2094
|
|
|
$sqlwhere[] = "t;date_validate <= '" . $db->idate($value) . "'"; |
2095
|
|
|
} elseif ($key == 't.credit' || $key == 't.debit') { |
2096
|
|
|
$sqlwhere[] = natural_search($key, $value, 1, 1); |
2097
|
|
|
} elseif ($key == 't.reconciled_option') { |
2098
|
|
|
$sqlwhere[] = 't.lettering_code IS NULL'; |
2099
|
|
|
} elseif ($key == 't.code_journal' && !empty($value)) { |
2100
|
|
|
if (is_array($value)) { |
2101
|
|
|
$sqlwhere[] = natural_search("t.code_journal", implode(',', $value), 3, 1); |
2102
|
|
|
} else { |
2103
|
|
|
$sqlwhere[] = natural_search("t.code_journal", $value, 3, 1); |
2104
|
|
|
} |
2105
|
|
|
} elseif ($key == 't.search_accounting_code_in' && !empty($value)) { |
2106
|
|
|
$sqlwhere[] = 't.numero_compte IN (' . $db->sanitize($value, 1) . ')'; |
2107
|
|
|
} else { |
2108
|
|
|
$sqlwhere[] = natural_search($key, $value, 0, 1); |
2109
|
|
|
} |
2110
|
|
|
} |
2111
|
|
|
} |
2112
|
|
|
$sql .= ' WHERE t.entity IN (' . getEntity('accountancy') . ')'; |
2113
|
|
|
if (!getDolGlobalString('ACCOUNTING_REEXPORT')) { // Reexport not enabled (default mode) |
2114
|
|
|
$sql .= " AND t.date_export IS NULL"; |
2115
|
|
|
} |
2116
|
|
|
if (count($sqlwhere) > 0) { |
2117
|
|
|
$sql .= ' AND ' . implode(' AND ', $sqlwhere); |
2118
|
|
|
} |
2119
|
|
|
//print $sql; |
2120
|
|
|
|
2121
|
|
|
|
2122
|
|
|
// Export into a file with format defined into setup (FEC, CSV, ...) |
2123
|
|
|
// Must be after definition of $sql |
2124
|
|
|
if ($action == 'export_fileconfirm' && $user->hasRight('accounting', 'mouvements', 'export')) { |
2125
|
|
|
// Export files then exit |
2126
|
|
|
$accountancyexport = new AccountancyExport($db); |
2127
|
|
|
|
2128
|
|
|
$error = 0; |
2129
|
|
|
$nbtotalofrecords = 0; |
2130
|
|
|
|
2131
|
|
|
// Open transaction to read lines to export, export them and update field date_export or date_validated |
2132
|
|
|
$db->begin(); |
2133
|
|
|
|
2134
|
|
|
/* The fast and low memory method to get and count full list converts the sql into a sql count */ |
2135
|
|
|
$sqlforcount = preg_replace('/^' . preg_quote($sqlfields, '/') . '/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); |
2136
|
|
|
$sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); |
2137
|
|
|
$resql = $db->query($sqlforcount); |
2138
|
|
|
if ($resql) { |
2139
|
|
|
$objforcount = $db->fetch_object($resql); |
2140
|
|
|
$nbtotalofrecords = $objforcount->nbtotalofrecords; |
2141
|
|
|
} else { |
2142
|
|
|
dol_print_error($db); |
2143
|
|
|
} |
2144
|
|
|
|
2145
|
|
|
$db->free($resql); |
2146
|
|
|
|
2147
|
|
|
//$sqlforexport = $sql; |
2148
|
|
|
//$sqlforexport .= $db->order($sortfield, $sortorder); |
2149
|
|
|
|
2150
|
|
|
|
2151
|
|
|
// TODO Call the fetchAll for a $limit and $offset |
2152
|
|
|
// Replace the fetchAll to get all ->line followed by call to ->export(). fetchAll() currently consumes too much memory on large export. |
2153
|
|
|
// Replace this with the query($sqlforexport) on a limited block and loop on each line to export them. |
2154
|
|
|
$limit = 0; |
2155
|
|
|
$offset = 0; |
2156
|
|
|
$result = $object->fetchAll($sortorder, $sortfield, $limit, $offset, $filter, 'AND', (getDolGlobalString('ACCOUNTING_REEXPORT') ? 1 : 0)); |
2157
|
|
|
|
2158
|
|
|
if ($result < 0) { |
2159
|
|
|
$error++; |
2160
|
|
|
setEventMessages($object->error, $object->errors, 'errors'); |
2161
|
|
|
} else { |
2162
|
|
|
$formatexport = GETPOSTINT('formatexport'); |
2163
|
|
|
$notexportlettering = GETPOST('notexportlettering', 'alpha'); |
2164
|
|
|
|
2165
|
|
|
|
2166
|
|
|
if (!empty($notexportlettering)) { |
2167
|
|
|
if (is_array($object->lines)) { |
2168
|
|
|
foreach ($object->lines as $k => $movement) { |
2169
|
|
|
unset($object->lines[$k]->lettering_code); |
2170
|
|
|
unset($object->lines[$k]->date_lettering); |
2171
|
|
|
} |
2172
|
|
|
} |
2173
|
|
|
} |
2174
|
|
|
|
2175
|
|
|
$notifiedexportdate = GETPOST('notifiedexportdate', 'alpha'); |
2176
|
|
|
$notifiedvalidationdate = GETPOST('notifiedvalidationdate', 'alpha'); |
2177
|
|
|
$withAttachment = !empty(trim(GETPOST('notifiedexportfull', 'alphanohtml'))) ? 1 : 0; |
2178
|
|
|
|
2179
|
|
|
// Output data on screen or download |
2180
|
|
|
//$result = $accountancyexport->export($object->lines, $formatexport, $withAttachment); |
2181
|
|
|
$result = $accountancyexport->export($object->lines, $formatexport, $withAttachment, 1, 1, 1); |
2182
|
|
|
|
2183
|
|
|
if ($result < 0) { |
2184
|
|
|
$error++; |
2185
|
|
|
} else { |
2186
|
|
|
if (!empty($notifiedexportdate) || !empty($notifiedvalidationdate)) { |
2187
|
|
|
if (is_array($object->lines)) { |
2188
|
|
|
dol_syslog("/accountancy/bookkeeping/list.php Function export_file Specify movements as exported", LOG_DEBUG); |
2189
|
|
|
|
2190
|
|
|
// TODO Merge update for each line into one global using rowid IN (list of movement ids) |
2191
|
|
|
foreach ($object->lines as $movement) { |
2192
|
|
|
// Update the line to set date_export and/or date_validated (if not already set !) |
2193
|
|
|
$now = dol_now(); |
2194
|
|
|
|
2195
|
|
|
$setfields = ''; |
2196
|
|
|
if (!empty($notifiedexportdate) && empty($movement->date_export)) { |
2197
|
|
|
$setfields .= ($setfields ? "," : "") . " date_export = '" . $db->idate($now) . "'"; |
2198
|
|
|
} |
2199
|
|
|
if (!empty($notifiedvalidationdate) && empty($movement->date_validation)) { |
2200
|
|
|
$setfields .= ($setfields ? "," : "") . " date_validated = '" . $db->idate($now) . "'"; |
2201
|
|
|
} |
2202
|
|
|
|
2203
|
|
|
if ($setfields) { |
2204
|
|
|
$sql = " UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping"; |
2205
|
|
|
$sql .= " SET " . $db->sanitize($setfields); |
2206
|
|
|
$sql .= " WHERE rowid = " . ((int) $movement->id); |
2207
|
|
|
|
2208
|
|
|
$result = $db->query($sql); |
2209
|
|
|
if (!$result) { |
2210
|
|
|
$error++; |
2211
|
|
|
break; |
2212
|
|
|
} |
2213
|
|
|
} |
2214
|
|
|
} |
2215
|
|
|
|
2216
|
|
|
if ($error) { |
2217
|
|
|
$accountancyexport->errors[] = $langs->trans('NotAllExportedMovementsCouldBeRecordedAsExportedOrValidated'); |
2218
|
|
|
} |
2219
|
|
|
} |
2220
|
|
|
} |
2221
|
|
|
} |
2222
|
|
|
} |
2223
|
|
|
|
2224
|
|
|
if (!$error) { |
2225
|
|
|
$db->commit(); |
2226
|
|
|
|
2227
|
|
|
$downloadFilePath = $accountancyexport->generatedfiledata['downloadFilePath']; |
2228
|
|
|
$downloadFileMimeType = $accountancyexport->generatedfiledata['downloadFileMimeType']; |
2229
|
|
|
$downloadFileFullName = $accountancyexport->generatedfiledata['downloadFileFullName']; |
2230
|
|
|
|
2231
|
|
|
// No error, we can output the file |
2232
|
|
|
top_httphead($downloadFileMimeType); |
2233
|
|
|
|
2234
|
|
|
header('Content-Description: File Transfer'); |
2235
|
|
|
// Add MIME Content-Disposition from RFC 2183 (inline=automatically displayed, attachment=need user action to open) |
2236
|
|
|
$attachment = 1; |
2237
|
|
|
if ($attachment) { |
2238
|
|
|
header('Content-Disposition: attachment; filename="' . $downloadFileFullName . '"'); |
2239
|
|
|
} else { |
2240
|
|
|
header('Content-Disposition: inline; filename="' . $downloadFileFullName . '"'); |
2241
|
|
|
} |
2242
|
|
|
// Ajout directives pour resoudre bug IE |
2243
|
|
|
header('Cache-Control: Public, must-revalidate'); |
2244
|
|
|
header('Pragma: public'); |
2245
|
|
|
header('Content-Length: ' . dol_filesize($downloadFilePath)); |
2246
|
|
|
|
2247
|
|
|
readfileLowMemory($downloadFilePath); |
2248
|
|
|
} else { |
2249
|
|
|
$db->rollback(); |
2250
|
|
|
|
2251
|
|
|
setEventMessages('', $accountancyexport->errors, 'errors'); |
2252
|
|
|
header('Location: ' . $_SERVER['PHP_SELF']); |
2253
|
|
|
} |
2254
|
|
|
exit(); // download or show errors |
|
|
|
|
2255
|
|
|
} |
2256
|
|
|
|
2257
|
|
|
|
2258
|
|
|
/* |
2259
|
|
|
* View |
2260
|
|
|
*/ |
2261
|
|
|
|
2262
|
|
|
$formother = new FormOther($db); |
2263
|
|
|
$formfile = new FormFile($db); |
2264
|
|
|
|
2265
|
|
|
$title_page = $langs->trans("Operations") . ' - ' . $langs->trans("ExportAccountancy"); |
2266
|
|
|
|
2267
|
|
|
// Count total nb of records |
2268
|
|
|
$nbtotalofrecords = ''; |
2269
|
|
|
if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { |
2270
|
|
|
/* The fast and low memory method to get and count full list converts the sql into a sql count */ |
2271
|
|
|
$sqlforcount = preg_replace('/^' . preg_quote($sqlfields, '/') . '/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); |
2272
|
|
|
$sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); |
2273
|
|
|
$resql = $db->query($sqlforcount); |
2274
|
|
|
if ($resql) { |
2275
|
|
|
$objforcount = $db->fetch_object($resql); |
2276
|
|
|
$nbtotalofrecords = $objforcount->nbtotalofrecords; |
2277
|
|
|
} else { |
2278
|
|
|
dol_print_error($db); |
2279
|
|
|
} |
2280
|
|
|
|
2281
|
|
|
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 |
2282
|
|
|
$page = 0; |
2283
|
|
|
$offset = 0; |
2284
|
|
|
} |
2285
|
|
|
$db->free($resql); |
2286
|
|
|
} |
2287
|
|
|
|
2288
|
|
|
// Complete request and execute it with limit |
2289
|
|
|
$sql .= $db->order($sortfield, $sortorder); |
2290
|
|
|
if ($limit) { |
2291
|
|
|
$sql .= $db->plimit($limit + 1, $offset); |
2292
|
|
|
} |
2293
|
|
|
|
2294
|
|
|
$resql = $db->query($sql); |
2295
|
|
|
if (!$resql) { |
2296
|
|
|
dol_print_error($db); |
2297
|
|
|
exit; |
|
|
|
|
2298
|
|
|
} |
2299
|
|
|
|
2300
|
|
|
$num = $db->num_rows($resql); |
2301
|
|
|
|
2302
|
|
|
$arrayofselected = is_array($toselect) ? $toselect : array(); |
2303
|
|
|
|
2304
|
|
|
// Output page |
2305
|
|
|
// -------------------------------------------------------------------- |
2306
|
|
|
$help_url = 'EN:Module_Double_Entry_Accounting#Exports|FR:Module_Comptabilité_en_Partie_Double#Exports'; |
2307
|
|
|
|
2308
|
|
|
llxHeader('', $title_page, $help_url); |
2309
|
|
|
|
2310
|
|
|
$formconfirm = ''; |
2311
|
|
|
|
2312
|
|
|
if ($action == 'export_file') { |
2313
|
|
|
$form_question = array(); |
2314
|
|
|
|
2315
|
|
|
$form_question['formatexport'] = array( |
2316
|
|
|
'name' => 'formatexport', |
2317
|
|
|
'type' => 'select', |
2318
|
|
|
'label' => $langs->trans('Modelcsv'), // TODO Use Selectmodelcsv and show a select combo |
2319
|
|
|
'values' => $listofformat, |
2320
|
|
|
'default' => $formatexportset, |
2321
|
|
|
'morecss' => 'minwidth200 maxwidth200' |
2322
|
|
|
); |
2323
|
|
|
|
2324
|
|
|
$form_question['separator0'] = array('name' => 'separator0', 'type' => 'separator'); |
2325
|
|
|
|
2326
|
|
|
if (getDolGlobalInt("ACCOUNTING_ENABLE_LETTERING")) { |
2327
|
|
|
// If 1, we check by default. |
2328
|
|
|
$checked = getDolGlobalString('ACCOUNTING_DEFAULT_NOT_EXPORT_LETTERING') ? 'true' : 'false'; |
2329
|
|
|
$form_question['notexportlettering'] = array( |
2330
|
|
|
'name' => 'notexportlettering', |
2331
|
|
|
'type' => 'checkbox', |
2332
|
|
|
'label' => $langs->trans('NotExportLettering'), |
2333
|
|
|
'value' => $checked, |
2334
|
|
|
); |
2335
|
|
|
|
2336
|
|
|
$form_question['separator1'] = array('name' => 'separator1', 'type' => 'separator'); |
2337
|
|
|
} |
2338
|
|
|
|
2339
|
|
|
// If 1 or not set, we check by default. |
2340
|
|
|
$checked = (!isset($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE) || getDolGlobalString('ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE')); |
2341
|
|
|
$form_question['notifiedexportdate'] = array( |
2342
|
|
|
'name' => 'notifiedexportdate', |
2343
|
|
|
'type' => 'checkbox', |
2344
|
|
|
'label' => $langs->trans('NotifiedExportDate'), |
2345
|
|
|
'value' => (getDolGlobalString('ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE') ? 'false' : 'true'), |
2346
|
|
|
); |
2347
|
|
|
|
2348
|
|
|
$form_question['separator2'] = array('name' => 'separator2', 'type' => 'separator'); |
2349
|
|
|
|
2350
|
|
|
if (!getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")) { |
2351
|
|
|
// If 0 or not set, we NOT check by default. |
2352
|
|
|
$checked = (isset($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_VALIDATION_DATE) || getDolGlobalString('ACCOUNTING_DEFAULT_NOT_NOTIFIED_VALIDATION_DATE')); |
2353
|
|
|
$form_question['notifiedvalidationdate'] = array( |
2354
|
|
|
'name' => 'notifiedvalidationdate', |
2355
|
|
|
'type' => 'checkbox', |
2356
|
|
|
'label' => $langs->trans('NotifiedValidationDate', $langs->transnoentitiesnoconv("MenuAccountancyClosure")), |
2357
|
|
|
'value' => $checked, |
2358
|
|
|
); |
2359
|
|
|
|
2360
|
|
|
$form_question['separator3'] = array('name' => 'separator3', 'type' => 'separator'); |
2361
|
|
|
} |
2362
|
|
|
|
2363
|
|
|
// add documents in an archive for accountancy export (Quadratus) |
2364
|
|
|
if (getDolGlobalString('ACCOUNTING_EXPORT_MODELCSV') == AccountancyExport::$EXPORT_TYPE_QUADRATUS) { |
2365
|
|
|
$form_question['notifiedexportfull'] = array( |
2366
|
|
|
'name' => 'notifiedexportfull', |
2367
|
|
|
'type' => 'checkbox', |
2368
|
|
|
'label' => $langs->trans('NotifiedExportFull'), |
2369
|
|
|
'value' => 'false', |
2370
|
|
|
); |
2371
|
|
|
} |
2372
|
|
|
|
2373
|
|
|
$formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?' . $param, $langs->trans("ExportFilteredList") . '...', $langs->trans('ConfirmExportFile'), 'export_fileconfirm', $form_question, '', 1, 420, 600); |
2374
|
|
|
} |
2375
|
|
|
|
2376
|
|
|
// Print form confirm |
2377
|
|
|
print $formconfirm; |
2378
|
|
|
|
2379
|
|
|
//$param=''; param started before |
2380
|
|
|
if (!empty($contextpage) && $contextpage != $_SERVER['PHP_SELF']) { |
2381
|
|
|
$param .= '&contextpage=' . urlencode($contextpage); |
2382
|
|
|
} |
2383
|
|
|
if ($limit > 0 && $limit != $conf->liste_limit) { |
2384
|
|
|
$param .= '&limit=' . urlencode($limit); |
2385
|
|
|
} |
2386
|
|
|
|
2387
|
|
|
// List of mass actions available |
2388
|
|
|
$arrayofmassactions = array(); |
2389
|
|
|
$massactionbutton = $form->selectMassAction($massaction, $arrayofmassactions); |
2390
|
|
|
|
2391
|
|
|
print '<form method="POST" id="searchFormList" action="' . $_SERVER['PHP_SELF'] . '">'; |
2392
|
|
|
print '<input type="hidden" name="token" value="' . newToken() . '">'; |
2393
|
|
|
print '<input type="hidden" name="action" value="list">'; |
2394
|
|
|
if ($optioncss != '') { |
2395
|
|
|
print '<input type="hidden" name="optioncss" value="' . urlencode($optioncss) . '">'; |
2396
|
|
|
} |
2397
|
|
|
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
2398
|
|
|
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">'; |
2399
|
|
|
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">'; |
2400
|
|
|
print '<input type="hidden" name="contextpage" value="' . $contextpage . '">'; |
2401
|
|
|
|
2402
|
|
|
if (count($filter)) { |
2403
|
|
|
$buttonLabel = $langs->trans("ExportFilteredList"); |
2404
|
|
|
} else { |
2405
|
|
|
$buttonLabel = $langs->trans("ExportList"); |
2406
|
|
|
} |
2407
|
|
|
|
2408
|
|
|
$parameters = array('param' => $param); |
2409
|
|
|
$reshook = $hookmanager->executeHooks('addMoreActionsButtonsList', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
2410
|
|
|
if ($reshook < 0) { |
2411
|
|
|
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
2412
|
|
|
} |
2413
|
|
|
|
2414
|
|
|
$newcardbutton = empty($hookmanager->resPrint) ? '' : $hookmanager->resPrint; |
2415
|
|
|
if (empty($reshook)) { |
2416
|
|
|
// Button re-export |
2417
|
|
|
if (!getDolGlobalString('ACCOUNTING_REEXPORT')) { |
2418
|
|
|
$newcardbutton .= '<a class="valignmiddle" href="' . $_SERVER['PHP_SELF'] . '?action=setreexport&token=' . newToken() . '&value=1' . ($param ? '&' . $param : '') . '&sortfield=' . urlencode($sortfield) . '&sortorder=' . urlencode($sortorder) . '">' . img_picto($langs->trans("ClickToShowAlreadyExportedLines"), 'switch_off', 'class="small size15x valignmiddle"'); |
2419
|
|
|
$newcardbutton .= '<span class="valignmiddle marginrightonly paddingleft">' . $langs->trans("ClickToShowAlreadyExportedLines") . '</span>'; |
2420
|
|
|
$newcardbutton .= '</a>'; |
2421
|
|
|
} else { |
2422
|
|
|
$newcardbutton .= '<a class="valignmiddle" href="' . $_SERVER['PHP_SELF'] . '?action=setreexport&token=' . newToken() . '&value=0' . ($param ? '&' . $param : '') . '&sortfield=' . urlencode($sortfield) . '&sortorder=' . urlencode($sortorder) . '">' . img_picto($langs->trans("DocsAlreadyExportedAreIncluded"), 'switch_on', 'class="warning size15x valignmiddle"'); |
2423
|
|
|
$newcardbutton .= '<span class="valignmiddle marginrightonly paddingleft">' . $langs->trans("DocsAlreadyExportedAreIncluded") . '</span>'; |
2424
|
|
|
$newcardbutton .= '</a>'; |
2425
|
|
|
} |
2426
|
|
|
|
2427
|
|
|
if ($user->hasRight('accounting', 'mouvements', 'export')) { |
2428
|
|
|
$newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList"), 'fa fa-file-export paddingleft', $_SERVER['PHP_SELF'] . '?action=export_file&token=' . newToken() . ($param ? '&' . $param : '') . '&sortfield=' . urlencode($sortfield) . '&sortorder=' . urlencode($sortorder), $user->hasRight('accounting', 'mouvements', 'export')); |
2429
|
|
|
} |
2430
|
|
|
} |
2431
|
|
|
|
2432
|
|
|
print_barre_liste($title_page, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); |
2433
|
|
|
|
2434
|
|
|
// Not display message when all the list of docs are included |
2435
|
|
|
if (!getDolGlobalString('ACCOUNTING_REEXPORT')) { |
2436
|
|
|
print info_admin($langs->trans("WarningDataDisappearsWhenDataIsExported"), 0, 0, 0, 'hideonsmartphone info'); |
2437
|
|
|
} |
2438
|
|
|
|
2439
|
|
|
//$topicmail = "Information"; |
2440
|
|
|
//$modelmail = "accountingbookkeeping"; |
2441
|
|
|
//$objecttmp = new BookKeeping($db); |
2442
|
|
|
//$trackid = 'bk'.$object->id; |
2443
|
|
|
include DOL_DOCUMENT_ROOT . '/core/tpl/massactions_pre.tpl.php'; |
2444
|
|
|
|
2445
|
|
|
$varpage = empty($contextpage) ? $_SERVER['PHP_SELF'] : $contextpage; |
2446
|
|
|
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields |
2447
|
|
|
if ($massactionbutton && $contextpage != 'poslist') { |
2448
|
|
|
$selectedfields .= $form->showCheckAddButtons('checkforselect', 1); |
2449
|
|
|
} |
2450
|
|
|
|
2451
|
|
|
$moreforfilter = ''; |
2452
|
|
|
$moreforfilter .= '<div class="divsearchfield">'; |
2453
|
|
|
$moreforfilter .= $langs->trans('AccountingCategory') . ': '; |
2454
|
|
|
$moreforfilter .= '<div class="nowrap inline-block">'; |
2455
|
|
|
$moreforfilter .= $formaccounting->select_accounting_category($search_account_category, 'search_account_category', 1, 0, 0, 0); |
2456
|
|
|
$moreforfilter .= '</div>'; |
2457
|
|
|
$moreforfilter .= '</div>'; |
2458
|
|
|
|
2459
|
|
|
$parameters = array(); |
2460
|
|
|
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
2461
|
|
|
if (empty($reshook)) { |
2462
|
|
|
$moreforfilter .= $hookmanager->resPrint; |
2463
|
|
|
} else { |
2464
|
|
|
$moreforfilter = $hookmanager->resPrint; |
2465
|
|
|
} |
2466
|
|
|
|
2467
|
|
|
print '<div class="liste_titre liste_titre_bydiv centpercent">'; |
2468
|
|
|
print $moreforfilter; |
2469
|
|
|
print '</div>'; |
2470
|
|
|
|
2471
|
|
|
print '<div class="div-table-responsive">'; |
2472
|
|
|
print '<table class="tagtable liste' . ($moreforfilter ? " listwithfilterbefore" : "") . '">'; |
2473
|
|
|
|
2474
|
|
|
// Filters lines |
2475
|
|
|
print '<tr class="liste_titre_filter">'; |
2476
|
|
|
// Action column |
2477
|
|
|
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
2478
|
|
|
print '<td class="liste_titre center">'; |
2479
|
|
|
$searchpicto = $form->showFilterButtons('left'); |
2480
|
|
|
print $searchpicto; |
2481
|
|
|
print '</td>'; |
2482
|
|
|
} |
2483
|
|
|
// Movement number |
2484
|
|
|
if (!empty($arrayfields['t.piece_num']['checked'])) { |
2485
|
|
|
print '<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="' . dol_escape_htmltag($search_mvt_num) . '"></td>'; |
2486
|
|
|
} |
2487
|
|
|
// Code journal |
2488
|
|
|
if (!empty($arrayfields['t.code_journal']['checked'])) { |
2489
|
|
|
print '<td class="liste_titre center">'; |
2490
|
|
|
print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1, 'small maxwidth75'); |
2491
|
|
|
print '</td>'; |
2492
|
|
|
} |
2493
|
|
|
// Date document |
2494
|
|
|
if (!empty($arrayfields['t.doc_date']['checked'])) { |
2495
|
|
|
print '<td class="liste_titre center">'; |
2496
|
|
|
print '<div class="nowrapfordate">'; |
2497
|
|
|
print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); |
2498
|
|
|
print '</div>'; |
2499
|
|
|
print '<div class="nowrapfordate">'; |
2500
|
|
|
print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); |
2501
|
|
|
print '</div>'; |
2502
|
|
|
print '</td>'; |
2503
|
|
|
} |
2504
|
|
|
// Ref document |
2505
|
|
|
if (!empty($arrayfields['t.doc_ref']['checked'])) { |
2506
|
|
|
print '<td class="liste_titre"><input type="text" name="search_doc_ref" size="8" value="' . dol_escape_htmltag($search_doc_ref) . '"></td>'; |
2507
|
|
|
} |
2508
|
|
|
// Accountancy account |
2509
|
|
|
if (!empty($arrayfields['t.numero_compte']['checked'])) { |
2510
|
|
|
print '<td class="liste_titre">'; |
2511
|
|
|
print '<div class="nowrap">'; |
2512
|
|
|
print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, 'maxwidth150', 'account'); |
2513
|
|
|
print '</div>'; |
2514
|
|
|
print '<div class="nowrap">'; |
2515
|
|
|
print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, 'maxwidth150', 'account'); |
2516
|
|
|
print '</div>'; |
2517
|
|
|
print '</td>'; |
2518
|
|
|
} |
2519
|
|
|
// Subledger account |
2520
|
|
|
if (!empty($arrayfields['t.subledger_account']['checked'])) { |
2521
|
|
|
print '<td class="liste_titre">'; |
2522
|
|
|
// TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not |
2523
|
|
|
// use setup of keypress to select thirdparty and this hang browser on large database. |
2524
|
|
|
if (getDolGlobalString('ACCOUNTANCY_COMBO_FOR_AUX')) { |
2525
|
|
|
print '<div class="nowrap">'; |
2526
|
|
|
//print $langs->trans('From').' '; |
2527
|
|
|
print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', $langs->trans('From'), 'maxwidth250', 'subledgeraccount'); |
2528
|
|
|
print '</div>'; |
2529
|
|
|
print '<div class="nowrap">'; |
2530
|
|
|
print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', $langs->trans('to'), 'maxwidth250', 'subledgeraccount'); |
2531
|
|
|
print '</div>'; |
2532
|
|
|
} else { |
2533
|
|
|
print '<input type="text" class="maxwidth75" name="search_accountancy_aux_code" value="' . dol_escape_htmltag($search_accountancy_aux_code) . '">'; |
2534
|
|
|
} |
2535
|
|
|
print '</td>'; |
2536
|
|
|
} |
2537
|
|
|
// Label operation |
2538
|
|
|
if (!empty($arrayfields['t.label_operation']['checked'])) { |
2539
|
|
|
print '<td class="liste_titre">'; |
2540
|
|
|
print '<input type="text" size="7" class="flat" name="search_mvt_label" value="' . dol_escape_htmltag($search_mvt_label) . '"/>'; |
2541
|
|
|
print '</td>'; |
2542
|
|
|
} |
2543
|
|
|
// Debit |
2544
|
|
|
if (!empty($arrayfields['t.debit']['checked'])) { |
2545
|
|
|
print '<td class="liste_titre right">'; |
2546
|
|
|
print '<input type="text" class="flat" name="search_debit" size="4" value="' . dol_escape_htmltag($search_debit) . '">'; |
2547
|
|
|
print '</td>'; |
2548
|
|
|
} |
2549
|
|
|
// Credit |
2550
|
|
|
if (!empty($arrayfields['t.credit']['checked'])) { |
2551
|
|
|
print '<td class="liste_titre right">'; |
2552
|
|
|
print '<input type="text" class="flat" name="search_credit" size="4" value="' . dol_escape_htmltag($search_credit) . '">'; |
2553
|
|
|
print '</td>'; |
2554
|
|
|
} |
2555
|
|
|
// Lettering code |
2556
|
|
|
if (!empty($arrayfields['t.lettering_code']['checked'])) { |
2557
|
|
|
print '<td class="liste_titre center">'; |
2558
|
|
|
print '<input type="text" size="3" class="flat" name="search_lettering_code" value="' . dol_escape_htmltag($search_lettering_code) . '"/>'; |
2559
|
|
|
print '<br><span class="nowrap"><input type="checkbox" id="search_not_reconciled" name="search_not_reconciled" value="notreconciled"' . ($search_not_reconciled == 'notreconciled' ? ' checked' : '') . '><label for="search_not_reconciled">' . $langs->trans("NotReconciled") . '</label></span>'; |
2560
|
|
|
print '</td>'; |
2561
|
|
|
} |
2562
|
|
|
|
2563
|
|
|
// Fields from hook |
2564
|
|
|
$parameters = array('arrayfields' => $arrayfields); |
2565
|
|
|
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook |
2566
|
|
|
print $hookmanager->resPrint; |
2567
|
|
|
|
2568
|
|
|
// Date creation |
2569
|
|
|
if (!empty($arrayfields['t.date_creation']['checked'])) { |
2570
|
|
|
print '<td class="liste_titre center">'; |
2571
|
|
|
print '<div class="nowrapfordate">'; |
2572
|
|
|
print $form->selectDate($search_date_creation_start, 'search_date_creation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); |
2573
|
|
|
print '</div>'; |
2574
|
|
|
print '<div class="nowrapfordate">'; |
2575
|
|
|
print $form->selectDate($search_date_creation_end, 'search_date_creation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); |
2576
|
|
|
print '</div>'; |
2577
|
|
|
print '</td>'; |
2578
|
|
|
} |
2579
|
|
|
// Date modification |
2580
|
|
|
if (!empty($arrayfields['t.tms']['checked'])) { |
2581
|
|
|
print '<td class="liste_titre center">'; |
2582
|
|
|
print '<div class="nowrapfordate">'; |
2583
|
|
|
print $form->selectDate($search_date_modification_start, 'search_date_modification_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); |
2584
|
|
|
print '</div>'; |
2585
|
|
|
print '<div class="nowrapfordate">'; |
2586
|
|
|
print $form->selectDate($search_date_modification_end, 'search_date_modification_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); |
2587
|
|
|
print '</div>'; |
2588
|
|
|
print '</td>'; |
2589
|
|
|
} |
2590
|
|
|
// Date export |
2591
|
|
|
if (!empty($arrayfields['t.date_export']['checked'])) { |
2592
|
|
|
print '<td class="liste_titre center">'; |
2593
|
|
|
print '<div class="nowrapfordate">'; |
2594
|
|
|
print $form->selectDate($search_date_export_start, 'search_date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); |
2595
|
|
|
print '</div>'; |
2596
|
|
|
print '<div class="nowrapfordate">'; |
2597
|
|
|
print $form->selectDate($search_date_export_end, 'search_date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); |
2598
|
|
|
print '</div>'; |
2599
|
|
|
print '</td>'; |
2600
|
|
|
} |
2601
|
|
|
// Date validation |
2602
|
|
|
if (!empty($arrayfields['t.date_validated']['checked'])) { |
2603
|
|
|
print '<td class="liste_titre center">'; |
2604
|
|
|
print '<div class="nowrapfordate">'; |
2605
|
|
|
print $form->selectDate($search_date_validation_start, 'search_date_validation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); |
2606
|
|
|
print '</div>'; |
2607
|
|
|
print '<div class="nowrapfordate">'; |
2608
|
|
|
print $form->selectDate($search_date_validation_end, 'search_date_validation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); |
2609
|
|
|
print '</div>'; |
2610
|
|
|
print '</td>'; |
2611
|
|
|
} |
2612
|
|
|
if (!empty($arrayfields['t.import_key']['checked'])) { |
2613
|
|
|
print '<td class="liste_titre center">'; |
2614
|
|
|
print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="' . dol_escape_htmltag($search_import_key) . '">'; |
2615
|
|
|
print '</td>'; |
2616
|
|
|
} |
2617
|
|
|
// Action column |
2618
|
|
|
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
2619
|
|
|
print '<td class="liste_titre center">'; |
2620
|
|
|
$searchpicto = $form->showFilterButtons(); |
2621
|
|
|
print $searchpicto; |
2622
|
|
|
print '</td>'; |
2623
|
|
|
} |
2624
|
|
|
print "</tr>\n"; |
2625
|
|
|
|
2626
|
|
|
print '<tr class="liste_titre">'; |
2627
|
|
|
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
2628
|
|
|
print_liste_field_titre($selectedfields, $_SERVER['PHP_SELF'], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch actioncolumn '); |
2629
|
|
|
} |
2630
|
|
|
if (!empty($arrayfields['t.piece_num']['checked'])) { |
2631
|
|
|
print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, "", $sortfield, $sortorder); |
2632
|
|
|
} |
2633
|
|
|
if (!empty($arrayfields['t.code_journal']['checked'])) { |
2634
|
|
|
print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center '); |
2635
|
|
|
} |
2636
|
|
|
if (!empty($arrayfields['t.doc_date']['checked'])) { |
2637
|
|
|
print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center '); |
2638
|
|
|
} |
2639
|
|
|
if (!empty($arrayfields['t.doc_ref']['checked'])) { |
2640
|
|
|
print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder); |
2641
|
|
|
} |
2642
|
|
|
if (!empty($arrayfields['t.numero_compte']['checked'])) { |
2643
|
|
|
print_liste_field_titre($arrayfields['t.numero_compte']['label'], $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder); |
2644
|
|
|
} |
2645
|
|
|
if (!empty($arrayfields['t.subledger_account']['checked'])) { |
2646
|
|
|
print_liste_field_titre($arrayfields['t.subledger_account']['label'], $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder); |
2647
|
|
|
} |
2648
|
|
|
if (!empty($arrayfields['t.label_operation']['checked'])) { |
2649
|
|
|
print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder); |
2650
|
|
|
} |
2651
|
|
|
if (!empty($arrayfields['t.debit']['checked'])) { |
2652
|
|
|
print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right '); |
2653
|
|
|
} |
2654
|
|
|
if (!empty($arrayfields['t.credit']['checked'])) { |
2655
|
|
|
print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right '); |
2656
|
|
|
} |
2657
|
|
|
if (!empty($arrayfields['t.lettering_code']['checked'])) { |
2658
|
|
|
print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center '); |
2659
|
|
|
} |
2660
|
|
|
// Hook fields |
2661
|
|
|
$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder); |
2662
|
|
|
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook |
2663
|
|
|
print $hookmanager->resPrint; |
2664
|
|
|
if (!empty($arrayfields['t.date_creation']['checked'])) { |
2665
|
|
|
print_liste_field_titre($arrayfields['t.date_creation']['label'], $_SERVER['PHP_SELF'], "t.date_creation", "", $param, '', $sortfield, $sortorder, 'center '); |
2666
|
|
|
} |
2667
|
|
|
if (!empty($arrayfields['t.tms']['checked'])) { |
2668
|
|
|
print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER['PHP_SELF'], "t.tms", "", $param, '', $sortfield, $sortorder, 'center '); |
2669
|
|
|
} |
2670
|
|
|
if (!empty($arrayfields['t.date_export']['checked'])) { |
2671
|
|
|
print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export,t.doc_date", "", $param, '', $sortfield, $sortorder, 'center '); |
2672
|
|
|
} |
2673
|
|
|
if (!empty($arrayfields['t.date_validated']['checked'])) { |
2674
|
|
|
print_liste_field_titre($arrayfields['t.date_validated']['label'], $_SERVER['PHP_SELF'], "t.date_validated,t.doc_date", "", $param, '', $sortfield, $sortorder, 'center '); |
2675
|
|
|
} |
2676
|
|
|
if (!empty($arrayfields['t.import_key']['checked'])) { |
2677
|
|
|
print_liste_field_titre($arrayfields['t.import_key']['label'], $_SERVER['PHP_SELF'], "t.import_key", "", $param, '', $sortfield, $sortorder, 'center '); |
2678
|
|
|
} |
2679
|
|
|
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
2680
|
|
|
print_liste_field_titre($selectedfields, $_SERVER['PHP_SELF'], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); |
2681
|
|
|
} |
2682
|
|
|
print "</tr>\n"; |
2683
|
|
|
|
2684
|
|
|
|
2685
|
|
|
$line = new BookKeepingLine($db); |
2686
|
|
|
|
2687
|
|
|
// Loop on record |
2688
|
|
|
// -------------------------------------------------------------------- |
2689
|
|
|
$i = 0; |
2690
|
|
|
$totalarray = array(); |
2691
|
|
|
$totalarray['nbfield'] = 0; |
2692
|
|
|
$total_debit = 0; |
2693
|
|
|
$total_credit = 0; |
2694
|
|
|
$totalarray['val'] = array(); |
2695
|
|
|
$totalarray['val']['totaldebit'] = 0; |
2696
|
|
|
$totalarray['val']['totalcredit'] = 0; |
2697
|
|
|
|
2698
|
|
|
while ($i < min($num, $limit)) { |
2699
|
|
|
$obj = $db->fetch_object($resql); |
2700
|
|
|
if (empty($obj)) { |
2701
|
|
|
break; // Should not happen |
2702
|
|
|
} |
2703
|
|
|
|
2704
|
|
|
$line->id = $obj->rowid; |
2705
|
|
|
$line->doc_date = $db->jdate($obj->doc_date); |
2706
|
|
|
$line->doc_type = $obj->doc_type; |
2707
|
|
|
$line->doc_ref = $obj->doc_ref; |
2708
|
|
|
$line->fk_doc = $obj->fk_doc; |
2709
|
|
|
$line->fk_docdet = $obj->fk_docdet; |
2710
|
|
|
$line->thirdparty_code = $obj->thirdparty_code; |
2711
|
|
|
$line->subledger_account = $obj->subledger_account; |
2712
|
|
|
$line->subledger_label = $obj->subledger_label; |
2713
|
|
|
$line->numero_compte = $obj->numero_compte; |
2714
|
|
|
$line->label_compte = $obj->label_compte; |
2715
|
|
|
$line->label_operation = $obj->label_operation; |
2716
|
|
|
$line->debit = $obj->debit; |
2717
|
|
|
$line->credit = $obj->credit; |
2718
|
|
|
$line->montant = $obj->amount; // deprecated |
2719
|
|
|
$line->amount = $obj->amount; |
2720
|
|
|
$line->sens = $obj->sens; |
2721
|
|
|
$line->lettering_code = $obj->lettering_code; |
2722
|
|
|
$line->fk_user_author = $obj->fk_user_author; |
2723
|
|
|
$line->import_key = $obj->import_key; |
2724
|
|
|
$line->code_journal = $obj->code_journal; |
2725
|
|
|
$line->journal_label = $obj->journal_label; |
2726
|
|
|
$line->piece_num = $obj->piece_num; |
2727
|
|
|
$line->date_creation = $db->jdate($obj->date_creation); |
2728
|
|
|
$line->date_modification = $db->jdate($obj->date_modification); |
2729
|
|
|
$line->date_export = $db->jdate($obj->date_export); |
2730
|
|
|
$line->date_validation = $db->jdate($obj->date_validation); |
2731
|
|
|
|
2732
|
|
|
$total_debit += $line->debit; |
2733
|
|
|
$total_credit += $line->credit; |
2734
|
|
|
|
2735
|
|
|
print '<tr class="oddeven">'; |
2736
|
|
|
// Action column |
2737
|
|
|
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
2738
|
|
|
print '<td class="nowraponall center">'; |
2739
|
|
|
if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined |
2740
|
|
|
$selected = 0; |
2741
|
|
|
if (in_array($line->id, $arrayofselected)) { |
2742
|
|
|
$selected = 1; |
2743
|
|
|
} |
2744
|
|
|
print '<input id="cb' . $line->id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $line->id . '"' . ($selected ? ' checked="checked"' : '') . ' />'; |
2745
|
|
|
} |
2746
|
|
|
print '</td>'; |
2747
|
|
|
if (!$i) { |
2748
|
|
|
$totalarray['nbfield']++; |
2749
|
|
|
} |
2750
|
|
|
} |
2751
|
|
|
|
2752
|
|
|
// Piece number |
2753
|
|
|
if (!empty($arrayfields['t.piece_num']['checked'])) { |
2754
|
|
|
print '<td>'; |
2755
|
|
|
$object->id = $line->id; |
2756
|
|
|
$object->piece_num = $line->piece_num; |
2757
|
|
|
print $object->getNomUrl(1, '', 0, '', 1); |
2758
|
|
|
print '</td>'; |
2759
|
|
|
if (!$i) { |
2760
|
|
|
$totalarray['nbfield']++; |
2761
|
|
|
} |
2762
|
|
|
} |
2763
|
|
|
|
2764
|
|
|
// Journal code |
2765
|
|
|
if (!empty($arrayfields['t.code_journal']['checked'])) { |
2766
|
|
|
$accountingjournal = new AccountingJournal($db); |
2767
|
|
|
$result = $accountingjournal->fetch('', $line->code_journal); |
2768
|
|
|
$journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal); |
2769
|
|
|
print '<td class="center tdoverflowmax150">' . $journaltoshow . '</td>'; |
2770
|
|
|
if (!$i) { |
2771
|
|
|
$totalarray['nbfield']++; |
2772
|
|
|
} |
2773
|
|
|
} |
2774
|
|
|
|
2775
|
|
|
// Document date |
2776
|
|
|
if (!empty($arrayfields['t.doc_date']['checked'])) { |
2777
|
|
|
print '<td class="center">' . dol_print_date($line->doc_date, 'day') . '</td>'; |
2778
|
|
|
if (!$i) { |
2779
|
|
|
$totalarray['nbfield']++; |
2780
|
|
|
} |
2781
|
|
|
} |
2782
|
|
|
|
2783
|
|
|
// Document ref |
2784
|
|
|
if (!empty($arrayfields['t.doc_ref']['checked'])) { |
2785
|
|
|
if ($line->doc_type == 'customer_invoice') { |
2786
|
|
|
$langs->loadLangs(array('bills')); |
2787
|
|
|
|
2788
|
|
|
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; |
2789
|
|
|
$objectstatic = new Facture($db); |
2790
|
|
|
$objectstatic->fetch($line->fk_doc); |
2791
|
|
|
//$modulepart = 'facture'; |
2792
|
|
|
|
2793
|
|
|
$filename = dol_sanitizeFileName($line->doc_ref); |
2794
|
|
|
$filedir = $conf->facture->dir_output . '/' . dol_sanitizeFileName($line->doc_ref); |
2795
|
|
|
$urlsource = $_SERVER['PHP_SELF'] . '?id=' . $objectstatic->id; |
2796
|
|
|
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); |
2797
|
|
|
} elseif ($line->doc_type == 'supplier_invoice') { |
2798
|
|
|
$langs->loadLangs(array('bills')); |
2799
|
|
|
|
2800
|
|
|
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; |
2801
|
|
|
$objectstatic = new FactureFournisseur($db); |
|
|
|
|
2802
|
|
|
$objectstatic->fetch($line->fk_doc); |
2803
|
|
|
//$modulepart = 'invoice_supplier'; |
2804
|
|
|
|
2805
|
|
|
$filename = dol_sanitizeFileName($line->doc_ref); |
2806
|
|
|
$filedir = $conf->fournisseur->facture->dir_output . '/' . get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart) . dol_sanitizeFileName($line->doc_ref); |
|
|
|
|
2807
|
|
|
$subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart) . dol_sanitizeFileName($line->doc_ref); |
2808
|
|
|
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir); |
2809
|
|
|
} elseif ($line->doc_type == 'expense_report') { |
2810
|
|
|
$langs->loadLangs(array('trips')); |
2811
|
|
|
|
2812
|
|
|
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; |
2813
|
|
|
$objectstatic = new ExpenseReport($db); |
|
|
|
|
2814
|
|
|
$objectstatic->fetch($line->fk_doc); |
2815
|
|
|
//$modulepart = 'expensereport'; |
2816
|
|
|
|
2817
|
|
|
$filename = dol_sanitizeFileName($line->doc_ref); |
2818
|
|
|
$filedir = $conf->expensereport->dir_output . '/' . dol_sanitizeFileName($line->doc_ref); |
2819
|
|
|
$urlsource = $_SERVER['PHP_SELF'] . '?id=' . $objectstatic->id; |
2820
|
|
|
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); |
2821
|
|
|
} elseif ($line->doc_type == 'bank') { |
2822
|
|
|
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; |
2823
|
|
|
$objectstatic = new AccountLine($db); |
|
|
|
|
2824
|
|
|
$objectstatic->fetch($line->fk_doc); |
2825
|
|
|
} else { |
2826
|
|
|
// Other type |
2827
|
|
|
} |
2828
|
|
|
|
2829
|
|
|
$labeltoshow = ''; |
2830
|
|
|
$labeltoshowalt = ''; |
2831
|
|
|
if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') { |
2832
|
|
|
$labeltoshow .= $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); |
2833
|
|
|
$labeltoshow .= $documentlink; |
2834
|
|
|
$labeltoshowalt .= $objectstatic->ref; |
2835
|
|
|
} elseif ($line->doc_type == 'bank') { |
2836
|
|
|
$labeltoshow .= $objectstatic->getNomUrl(1); |
2837
|
|
|
$labeltoshowalt .= $objectstatic->ref; |
2838
|
|
|
$bank_ref = strstr($line->doc_ref, '-'); |
2839
|
|
|
$labeltoshow .= " " . $bank_ref; |
2840
|
|
|
$labeltoshowalt .= " " . $bank_ref; |
2841
|
|
|
} else { |
2842
|
|
|
$labeltoshow .= $line->doc_ref; |
2843
|
|
|
$labeltoshowalt .= $line->doc_ref; |
2844
|
|
|
} |
2845
|
|
|
|
2846
|
|
|
print '<td class="nowraponall tdoverflowmax200" title="' . dol_escape_htmltag($labeltoshowalt) . '">'; |
2847
|
|
|
print $labeltoshow; |
2848
|
|
|
print "</td>\n"; |
2849
|
|
|
if (!$i) { |
2850
|
|
|
$totalarray['nbfield']++; |
2851
|
|
|
} |
2852
|
|
|
} |
2853
|
|
|
|
2854
|
|
|
// Account number |
2855
|
|
|
if (!empty($arrayfields['t.numero_compte']['checked'])) { |
2856
|
|
|
print '<td>' . length_accountg($line->numero_compte) . '</td>'; |
2857
|
|
|
if (!$i) { |
2858
|
|
|
$totalarray['nbfield']++; |
2859
|
|
|
} |
2860
|
|
|
} |
2861
|
|
|
|
2862
|
|
|
// Subledger account |
2863
|
|
|
if (!empty($arrayfields['t.subledger_account']['checked'])) { |
2864
|
|
|
print '<td>' . length_accounta($line->subledger_account) . '</td>'; |
2865
|
|
|
if (!$i) { |
2866
|
|
|
$totalarray['nbfield']++; |
2867
|
|
|
} |
2868
|
|
|
} |
2869
|
|
|
|
2870
|
|
|
// Label operation |
2871
|
|
|
if (!empty($arrayfields['t.label_operation']['checked'])) { |
2872
|
|
|
print '<td class="small tdoverflowmax200" title="' . dol_escape_htmltag($line->label_operation) . '">' . dol_escape_htmltag($line->label_operation) . '</td>'; |
2873
|
|
|
if (!$i) { |
2874
|
|
|
$totalarray['nbfield']++; |
2875
|
|
|
} |
2876
|
|
|
} |
2877
|
|
|
|
2878
|
|
|
// Amount debit |
2879
|
|
|
if (!empty($arrayfields['t.debit']['checked'])) { |
2880
|
|
|
print '<td class="right nowraponall amount">' . ($line->debit != 0 ? price($line->debit) : '') . '</td>'; |
2881
|
|
|
if (!$i) { |
2882
|
|
|
$totalarray['nbfield']++; |
2883
|
|
|
} |
2884
|
|
|
if (!$i) { |
2885
|
|
|
$totalarray['pos'][$totalarray['nbfield']] = 'totaldebit'; |
2886
|
|
|
} |
2887
|
|
|
$totalarray['val']['totaldebit'] += $line->debit; |
2888
|
|
|
} |
2889
|
|
|
|
2890
|
|
|
// Amount credit |
2891
|
|
|
if (!empty($arrayfields['t.credit']['checked'])) { |
2892
|
|
|
print '<td class="right nowraponall amount">' . ($line->credit != 0 ? price($line->credit) : '') . '</td>'; |
2893
|
|
|
if (!$i) { |
2894
|
|
|
$totalarray['nbfield']++; |
2895
|
|
|
} |
2896
|
|
|
if (!$i) { |
2897
|
|
|
$totalarray['pos'][$totalarray['nbfield']] = 'totalcredit'; |
2898
|
|
|
} |
2899
|
|
|
$totalarray['val']['totalcredit'] += $line->credit; |
2900
|
|
|
} |
2901
|
|
|
|
2902
|
|
|
// Lettering code |
2903
|
|
|
if (!empty($arrayfields['t.lettering_code']['checked'])) { |
2904
|
|
|
print '<td class="center">' . $line->lettering_code . '</td>'; |
2905
|
|
|
if (!$i) { |
2906
|
|
|
$totalarray['nbfield']++; |
2907
|
|
|
} |
2908
|
|
|
} |
2909
|
|
|
|
2910
|
|
|
// Fields from hook |
2911
|
|
|
$parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray); |
2912
|
|
|
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook |
2913
|
|
|
print $hookmanager->resPrint; |
2914
|
|
|
|
2915
|
|
|
// Creation operation date |
2916
|
|
|
if (!empty($arrayfields['t.date_creation']['checked'])) { |
2917
|
|
|
print '<td class="center">' . dol_print_date($line->date_creation, 'dayhour', 'tzuserrel') . '</td>'; |
2918
|
|
|
if (!$i) { |
2919
|
|
|
$totalarray['nbfield']++; |
2920
|
|
|
} |
2921
|
|
|
} |
2922
|
|
|
|
2923
|
|
|
// Modification operation date |
2924
|
|
|
if (!empty($arrayfields['t.tms']['checked'])) { |
2925
|
|
|
print '<td class="center">' . dol_print_date($line->date_modification, 'dayhour', 'tzuserrel') . '</td>'; |
2926
|
|
|
if (!$i) { |
2927
|
|
|
$totalarray['nbfield']++; |
2928
|
|
|
} |
2929
|
|
|
} |
2930
|
|
|
|
2931
|
|
|
// Exported operation date |
2932
|
|
|
if (!empty($arrayfields['t.date_export']['checked'])) { |
2933
|
|
|
print '<td class="center nowraponall">' . dol_print_date($line->date_export, 'dayhour', 'tzuserrel') . '</td>'; |
2934
|
|
|
if (!$i) { |
2935
|
|
|
$totalarray['nbfield']++; |
2936
|
|
|
} |
2937
|
|
|
} |
2938
|
|
|
|
2939
|
|
|
// Validated operation date |
2940
|
|
|
if (!empty($arrayfields['t.date_validated']['checked'])) { |
2941
|
|
|
print '<td class="center nowraponall">' . dol_print_date($line->date_validation, 'dayhour', 'tzuserrel') . '</td>'; |
2942
|
|
|
if (!$i) { |
2943
|
|
|
$totalarray['nbfield']++; |
2944
|
|
|
} |
2945
|
|
|
} |
2946
|
|
|
|
2947
|
|
|
if (!empty($arrayfields['t.import_key']['checked'])) { |
2948
|
|
|
print '<td class="tdoverflowmax100">' . $obj->import_key . "</td>\n"; |
2949
|
|
|
if (!$i) { |
2950
|
|
|
$totalarray['nbfield']++; |
2951
|
|
|
} |
2952
|
|
|
} |
2953
|
|
|
|
2954
|
|
|
// Action column |
2955
|
|
|
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
2956
|
|
|
print '<td class="nowraponall center">'; |
2957
|
|
|
if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined |
2958
|
|
|
$selected = 0; |
2959
|
|
|
if (in_array($line->id, $arrayofselected)) { |
2960
|
|
|
$selected = 1; |
2961
|
|
|
} |
2962
|
|
|
print '<input id="cb' . $line->id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $line->id . '"' . ($selected ? ' checked="checked"' : '') . ' />'; |
2963
|
|
|
} |
2964
|
|
|
print '</td>'; |
2965
|
|
|
if (!$i) { |
2966
|
|
|
$totalarray['nbfield']++; |
2967
|
|
|
} |
2968
|
|
|
} |
2969
|
|
|
|
2970
|
|
|
|
2971
|
|
|
print "</tr>\n"; |
2972
|
|
|
|
2973
|
|
|
$i++; |
2974
|
|
|
} |
2975
|
|
|
|
2976
|
|
|
// Show total line |
2977
|
|
|
include DOL_DOCUMENT_ROOT . '/core/tpl/list_print_total.tpl.php'; |
2978
|
|
|
|
2979
|
|
|
// If no record found |
2980
|
|
|
if ($num == 0) { |
2981
|
|
|
$colspan = 1; |
2982
|
|
|
foreach ($arrayfields as $key => $val) { |
2983
|
|
|
if (!empty($val['checked'])) { |
2984
|
|
|
$colspan++; |
2985
|
|
|
} |
2986
|
|
|
} |
2987
|
|
|
print '<tr><td colspan="' . $colspan . '"><span class="opacitymedium">' . $langs->trans("NoRecordFound") . '</span></td></tr>'; |
2988
|
|
|
} |
2989
|
|
|
|
2990
|
|
|
$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql); |
2991
|
|
|
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
2992
|
|
|
print $hookmanager->resPrint; |
2993
|
|
|
|
2994
|
|
|
print "</table>"; |
2995
|
|
|
print '</div>'; |
2996
|
|
|
|
2997
|
|
|
print '</form>'; |
2998
|
|
|
|
2999
|
|
|
// End of page |
3000
|
|
|
llxFooter(); |
3001
|
|
|
|
3002
|
|
|
$db->close(); |
3003
|
|
|
} |
3004
|
|
|
|
3005
|
|
|
/** |
3006
|
|
|
* \file htdocs/accountancy/bookkeeping/list.php |
3007
|
|
|
* \ingroup Accountancy (Double entries) |
3008
|
|
|
* \brief List operation of book keeping |
3009
|
|
|
*/ |
3010
|
|
|
public function list() |
3011
|
|
|
{ |
3012
|
|
|
global $conf; |
3013
|
|
|
global $db; |
3014
|
|
|
global $user; |
3015
|
|
|
global $hookmanager; |
3016
|
|
|
global $user; |
3017
|
|
|
global $menumanager; |
3018
|
|
|
global $langs; |
3019
|
|
|
global $mysoc; |
3020
|
|
|
|
3021
|
|
|
// Load translation files required by the page |
3022
|
|
|
$langs->loadLangs(array("accountancy", "compta")); |
3023
|
|
|
|
3024
|
|
|
// Get Parameters |
3025
|
|
|
$socid = GETPOSTINT('socid'); |
3026
|
|
|
|
3027
|
|
|
// action+display Parameters |
3028
|
|
|
$action = GETPOST('action', 'aZ09'); |
3029
|
|
|
$massaction = GETPOST('massaction', 'alpha'); |
3030
|
|
|
$confirm = GETPOST('confirm', 'alpha'); |
3031
|
|
|
$toselect = GETPOST('toselect', 'array'); |
3032
|
|
|
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'bookkeepinglist'; |
3033
|
|
|
|
3034
|
|
|
// Search Parameters |
3035
|
|
|
$search_mvt_num = GETPOSTINT('search_mvt_num'); |
3036
|
|
|
$search_doc_type = GETPOST("search_doc_type", 'alpha'); |
3037
|
|
|
$search_doc_ref = GETPOST("search_doc_ref", 'alpha'); |
3038
|
|
|
$search_date_startyear = GETPOSTINT('search_date_startyear'); |
3039
|
|
|
$search_date_startmonth = GETPOSTINT('search_date_startmonth'); |
3040
|
|
|
$search_date_startday = GETPOSTINT('search_date_startday'); |
3041
|
|
|
$search_date_endyear = GETPOSTINT('search_date_endyear'); |
3042
|
|
|
$search_date_endmonth = GETPOSTINT('search_date_endmonth'); |
3043
|
|
|
$search_date_endday = GETPOSTINT('search_date_endday'); |
3044
|
|
|
$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); |
3045
|
|
|
$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); |
3046
|
|
|
$search_doc_date = dol_mktime(0, 0, 0, GETPOSTINT('doc_datemonth'), GETPOSTINT('doc_dateday'), GETPOSTINT('doc_dateyear')); |
3047
|
|
|
$search_date_creation_startyear = GETPOSTINT('search_date_creation_startyear'); |
3048
|
|
|
$search_date_creation_startmonth = GETPOSTINT('search_date_creation_startmonth'); |
3049
|
|
|
$search_date_creation_startday = GETPOSTINT('search_date_creation_startday'); |
3050
|
|
|
$search_date_creation_endyear = GETPOSTINT('search_date_creation_endyear'); |
3051
|
|
|
$search_date_creation_endmonth = GETPOSTINT('search_date_creation_endmonth'); |
3052
|
|
|
$search_date_creation_endday = GETPOSTINT('search_date_creation_endday'); |
3053
|
|
|
$search_date_creation_start = dol_mktime(0, 0, 0, $search_date_creation_startmonth, $search_date_creation_startday, $search_date_creation_startyear); |
3054
|
|
|
$search_date_creation_end = dol_mktime(23, 59, 59, $search_date_creation_endmonth, $search_date_creation_endday, $search_date_creation_endyear); |
3055
|
|
|
$search_date_modification_startyear = GETPOSTINT('search_date_modification_startyear'); |
3056
|
|
|
$search_date_modification_startmonth = GETPOSTINT('search_date_modification_startmonth'); |
3057
|
|
|
$search_date_modification_startday = GETPOSTINT('search_date_modification_startday'); |
3058
|
|
|
$search_date_modification_endyear = GETPOSTINT('search_date_modification_endyear'); |
3059
|
|
|
$search_date_modification_endmonth = GETPOSTINT('search_date_modification_endmonth'); |
3060
|
|
|
$search_date_modification_endday = GETPOSTINT('search_date_modification_endday'); |
3061
|
|
|
$search_date_modification_start = dol_mktime(0, 0, 0, $search_date_modification_startmonth, $search_date_modification_startday, $search_date_modification_startyear); |
3062
|
|
|
$search_date_modification_end = dol_mktime(23, 59, 59, $search_date_modification_endmonth, $search_date_modification_endday, $search_date_modification_endyear); |
3063
|
|
|
$search_date_export_startyear = GETPOSTINT('search_date_export_startyear'); |
3064
|
|
|
$search_date_export_startmonth = GETPOSTINT('search_date_export_startmonth'); |
3065
|
|
|
$search_date_export_startday = GETPOSTINT('search_date_export_startday'); |
3066
|
|
|
$search_date_export_endyear = GETPOSTINT('search_date_export_endyear'); |
3067
|
|
|
$search_date_export_endmonth = GETPOSTINT('search_date_export_endmonth'); |
3068
|
|
|
$search_date_export_endday = GETPOSTINT('search_date_export_endday'); |
3069
|
|
|
$search_date_export_start = dol_mktime(0, 0, 0, $search_date_export_startmonth, $search_date_export_startday, $search_date_export_startyear); |
3070
|
|
|
$search_date_export_end = dol_mktime(23, 59, 59, $search_date_export_endmonth, $search_date_export_endday, $search_date_export_endyear); |
3071
|
|
|
$search_date_validation_startyear = GETPOSTINT('search_date_validation_startyear'); |
3072
|
|
|
$search_date_validation_startmonth = GETPOSTINT('search_date_validation_startmonth'); |
3073
|
|
|
$search_date_validation_startday = GETPOSTINT('search_date_validation_startday'); |
3074
|
|
|
$search_date_validation_endyear = GETPOSTINT('search_date_validation_endyear'); |
3075
|
|
|
$search_date_validation_endmonth = GETPOSTINT('search_date_validation_endmonth'); |
3076
|
|
|
$search_date_validation_endday = GETPOSTINT('search_date_validation_endday'); |
3077
|
|
|
$search_date_validation_start = dol_mktime(0, 0, 0, $search_date_validation_startmonth, $search_date_validation_startday, $search_date_validation_startyear); |
3078
|
|
|
$search_date_validation_end = dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear); |
3079
|
|
|
$search_import_key = GETPOST("search_import_key", 'alpha'); |
3080
|
|
|
|
3081
|
|
|
$search_account_category = GETPOSTINT('search_account_category'); |
3082
|
|
|
|
3083
|
|
|
$search_accountancy_code = GETPOST("search_accountancy_code", 'alpha'); |
3084
|
|
|
$search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); |
3085
|
|
|
if ($search_accountancy_code_start == - 1) { |
3086
|
|
|
$search_accountancy_code_start = ''; |
3087
|
|
|
} |
3088
|
|
|
$search_accountancy_code_end = GETPOST('search_accountancy_code_end', 'alpha'); |
3089
|
|
|
if ($search_accountancy_code_end == - 1) { |
3090
|
|
|
$search_accountancy_code_end = ''; |
3091
|
|
|
} |
3092
|
|
|
|
3093
|
|
|
$search_accountancy_aux_code = GETPOST("search_accountancy_aux_code", 'alpha'); |
3094
|
|
|
$search_accountancy_aux_code_start = GETPOST('search_accountancy_aux_code_start', 'alpha'); |
3095
|
|
|
if ($search_accountancy_aux_code_start == - 1) { |
3096
|
|
|
$search_accountancy_aux_code_start = ''; |
3097
|
|
|
} |
3098
|
|
|
$search_accountancy_aux_code_end = GETPOST('search_accountancy_aux_code_end', 'alpha'); |
3099
|
|
|
if ($search_accountancy_aux_code_end == - 1) { |
3100
|
|
|
$search_accountancy_aux_code_end = ''; |
3101
|
|
|
} |
3102
|
|
|
$search_mvt_label = GETPOST('search_mvt_label', 'alpha'); |
3103
|
|
|
$search_direction = GETPOST('search_direction', 'alpha'); |
3104
|
|
|
$search_debit = GETPOST('search_debit', 'alpha'); |
3105
|
|
|
$search_credit = GETPOST('search_credit', 'alpha'); |
3106
|
|
|
$search_ledger_code = GETPOST('search_ledger_code', 'array'); |
3107
|
|
|
$search_lettering_code = GETPOST('search_lettering_code', 'alpha'); |
3108
|
|
|
$search_not_reconciled = GETPOST('search_not_reconciled', 'alpha'); |
3109
|
|
|
|
3110
|
|
|
// Load variable for pagination |
3111
|
|
|
$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION', $conf->liste_limit); |
3112
|
|
|
$sortfield = GETPOST('sortfield', 'aZ09comma'); |
3113
|
|
|
$sortorder = GETPOST('sortorder', 'aZ09comma'); |
3114
|
|
|
$optioncss = GETPOST('optioncss', 'alpha'); |
3115
|
|
|
$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); |
3116
|
|
|
if (empty($page) || $page < 0) { |
3117
|
|
|
$page = 0; |
3118
|
|
|
} |
3119
|
|
|
$offset = $limit * $page; |
3120
|
|
|
$pageprev = $page - 1; |
3121
|
|
|
$pagenext = $page + 1; |
3122
|
|
|
if ($sortorder == "") { |
3123
|
|
|
$sortorder = "ASC"; |
3124
|
|
|
} |
3125
|
|
|
if ($sortfield == "") { |
3126
|
|
|
$sortfield = "t.piece_num,t.rowid"; |
3127
|
|
|
} |
3128
|
|
|
|
3129
|
|
|
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
3130
|
|
|
$object = new BookKeeping($db); |
3131
|
|
|
$hookmanager->initHooks(array('bookkeepinglist')); |
3132
|
|
|
|
3133
|
|
|
$formaccounting = new FormAccounting($db); |
3134
|
|
|
$form = new Form($db); |
3135
|
|
|
|
3136
|
|
|
if (!in_array($action, array('delmouv', 'delmouvconfirm')) && !GETPOSTISSET('begin') && !GETPOSTISSET('formfilteraction') && GETPOSTINT('page') == '' && !GETPOSTINT('noreset') && $user->hasRight('accounting', 'mouvements', 'export')) { |
3137
|
|
|
if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values') && !GETPOST('search_accountancy_code_start')) { |
3138
|
|
|
$query = "SELECT date_start, date_end from " . MAIN_DB_PREFIX . "accounting_fiscalyear "; |
3139
|
|
|
$query .= " where date_start < '" . $db->idate(dol_now()) . "' and date_end > '" . $db->idate(dol_now()) . "' limit 1"; |
3140
|
|
|
$res = $db->query($query); |
3141
|
|
|
|
3142
|
|
|
if ($res->num_rows > 0) { |
3143
|
|
|
$fiscalYear = $db->fetch_object($res); |
3144
|
|
|
$search_date_start = strtotime($fiscalYear->date_start); |
3145
|
|
|
$search_date_end = strtotime($fiscalYear->date_end); |
3146
|
|
|
} else { |
3147
|
|
|
$month_start = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); |
3148
|
|
|
$year_start = dol_print_date(dol_now(), '%Y'); |
3149
|
|
|
if (dol_print_date(dol_now(), '%m') < $month_start) { |
3150
|
|
|
$year_start--; // If current month is lower that starting fiscal month, we start last year |
3151
|
|
|
} |
3152
|
|
|
$year_end = $year_start + 1; |
3153
|
|
|
$month_end = $month_start - 1; |
3154
|
|
|
if ($month_end < 1) { |
3155
|
|
|
$month_end = 12; |
3156
|
|
|
$year_end--; |
3157
|
|
|
} |
3158
|
|
|
$search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start); |
3159
|
|
|
$search_date_end = dol_get_last_day($year_end, $month_end); |
3160
|
|
|
} |
3161
|
|
|
} |
3162
|
|
|
} |
3163
|
|
|
|
3164
|
|
|
|
3165
|
|
|
$arrayfields = array( |
3166
|
|
|
't.piece_num' => array('label' => $langs->trans("TransactionNumShort"), 'checked' => 1), |
3167
|
|
|
't.code_journal' => array('label' => $langs->trans("Codejournal"), 'checked' => 1), |
3168
|
|
|
't.doc_date' => array('label' => $langs->trans("Docdate"), 'checked' => 1), |
3169
|
|
|
't.doc_ref' => array('label' => $langs->trans("Piece"), 'checked' => 1), |
3170
|
|
|
't.numero_compte' => array('label' => $langs->trans("AccountAccountingShort"), 'checked' => 1), |
3171
|
|
|
't.subledger_account' => array('label' => $langs->trans("SubledgerAccount"), 'checked' => 1), |
3172
|
|
|
't.label_operation' => array('label' => $langs->trans("Label"), 'checked' => 1), |
3173
|
|
|
't.debit' => array('label' => $langs->trans("AccountingDebit"), 'checked' => 1), |
3174
|
|
|
't.credit' => array('label' => $langs->trans("AccountingCredit"), 'checked' => 1), |
3175
|
|
|
't.lettering_code' => array('label' => $langs->trans("LetteringCode"), 'checked' => 1), |
3176
|
|
|
't.date_creation' => array('label' => $langs->trans("DateCreation"), 'checked' => 0), |
3177
|
|
|
't.tms' => array('label' => $langs->trans("DateModification"), 'checked' => 0), |
3178
|
|
|
't.date_export' => array('label' => $langs->trans("DateExport"), 'checked' => 0), |
3179
|
|
|
't.date_validated' => array('label' => $langs->trans("DateValidationAndLock"), 'checked' => 0, 'enabled' => !getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")), |
3180
|
|
|
't.import_key' => array('label' => $langs->trans("ImportId"), 'checked' => 0, 'position' => 1100), |
3181
|
|
|
); |
3182
|
|
|
|
3183
|
|
|
if (!getDolGlobalString('ACCOUNTING_ENABLE_LETTERING')) { |
3184
|
|
|
unset($arrayfields['t.lettering_code']); |
3185
|
|
|
} |
3186
|
|
|
|
3187
|
|
|
$error = 0; |
3188
|
|
|
|
3189
|
|
|
if (!isModEnabled('accounting')) { |
3190
|
|
|
accessforbidden(); |
3191
|
|
|
} |
3192
|
|
|
if ($user->socid > 0) { |
3193
|
|
|
accessforbidden(); |
3194
|
|
|
} |
3195
|
|
|
if (!$user->hasRight('accounting', 'mouvements', 'lire')) { |
3196
|
|
|
accessforbidden(); |
3197
|
|
|
} |
3198
|
|
|
|
3199
|
|
|
|
3200
|
|
|
/* |
3201
|
|
|
* Actions |
3202
|
|
|
*/ |
3203
|
|
|
|
3204
|
|
|
$param = ''; |
3205
|
|
|
|
3206
|
|
|
if (GETPOST('cancel', 'alpha')) { |
3207
|
|
|
$action = 'list'; |
3208
|
|
|
$massaction = ''; |
3209
|
|
|
} |
3210
|
|
|
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'preunletteringauto' && $massaction != 'preunletteringmanual' && $massaction != 'predeletebookkeepingwriting') { |
3211
|
|
|
$massaction = ''; |
3212
|
|
|
} |
3213
|
|
|
|
3214
|
|
|
$parameters = array('socid' => $socid); |
3215
|
|
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
3216
|
|
|
if ($reshook < 0) { |
3217
|
|
|
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
3218
|
|
|
} |
3219
|
|
|
|
3220
|
|
|
if (empty($reshook)) { |
3221
|
|
|
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php'; |
3222
|
|
|
|
3223
|
|
|
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers |
3224
|
|
|
$search_mvt_num = ''; |
3225
|
|
|
$search_doc_type = ''; |
3226
|
|
|
$search_doc_ref = ''; |
3227
|
|
|
$search_doc_date = ''; |
3228
|
|
|
$search_account_category = ''; |
3229
|
|
|
$search_accountancy_code = ''; |
3230
|
|
|
$search_accountancy_code_start = ''; |
3231
|
|
|
$search_accountancy_code_end = ''; |
3232
|
|
|
$search_accountancy_aux_code = ''; |
3233
|
|
|
$search_accountancy_aux_code_start = ''; |
3234
|
|
|
$search_accountancy_aux_code_end = ''; |
3235
|
|
|
$search_mvt_label = ''; |
3236
|
|
|
$search_direction = ''; |
3237
|
|
|
$search_ledger_code = array(); |
3238
|
|
|
$search_date_startyear = ''; |
3239
|
|
|
$search_date_startmonth = ''; |
3240
|
|
|
$search_date_startday = ''; |
3241
|
|
|
$search_date_endyear = ''; |
3242
|
|
|
$search_date_endmonth = ''; |
3243
|
|
|
$search_date_endday = ''; |
3244
|
|
|
$search_date_start = ''; |
3245
|
|
|
$search_date_end = ''; |
3246
|
|
|
$search_date_creation_startyear = ''; |
3247
|
|
|
$search_date_creation_startmonth = ''; |
3248
|
|
|
$search_date_creation_startday = ''; |
3249
|
|
|
$search_date_creation_endyear = ''; |
3250
|
|
|
$search_date_creation_endmonth = ''; |
3251
|
|
|
$search_date_creation_endday = ''; |
3252
|
|
|
$search_date_creation_start = ''; |
3253
|
|
|
$search_date_creation_end = ''; |
3254
|
|
|
$search_date_modification_startyear = ''; |
3255
|
|
|
$search_date_modification_startmonth = ''; |
3256
|
|
|
$search_date_modification_startday = ''; |
3257
|
|
|
$search_date_modification_endyear = ''; |
3258
|
|
|
$search_date_modification_endmonth = ''; |
3259
|
|
|
$search_date_modification_endday = ''; |
3260
|
|
|
$search_date_modification_start = ''; |
3261
|
|
|
$search_date_modification_end = ''; |
3262
|
|
|
$search_date_export_startyear = ''; |
3263
|
|
|
$search_date_export_startmonth = ''; |
3264
|
|
|
$search_date_export_startday = ''; |
3265
|
|
|
$search_date_export_endyear = ''; |
3266
|
|
|
$search_date_export_endmonth = ''; |
3267
|
|
|
$search_date_export_endday = ''; |
3268
|
|
|
$search_date_export_start = ''; |
3269
|
|
|
$search_date_export_end = ''; |
3270
|
|
|
$search_date_validation_startyear = ''; |
3271
|
|
|
$search_date_validation_startmonth = ''; |
3272
|
|
|
$search_date_validation_startday = ''; |
3273
|
|
|
$search_date_validation_endyear = ''; |
3274
|
|
|
$search_date_validation_endmonth = ''; |
3275
|
|
|
$search_date_validation_endday = ''; |
3276
|
|
|
$search_date_validation_start = ''; |
3277
|
|
|
$search_date_validation_end = ''; |
3278
|
|
|
$search_debit = ''; |
3279
|
|
|
$search_credit = ''; |
3280
|
|
|
$search_lettering_code = ''; |
3281
|
|
|
$search_not_reconciled = ''; |
3282
|
|
|
$search_import_key = ''; |
3283
|
|
|
$toselect = array(); |
3284
|
|
|
} |
3285
|
|
|
|
3286
|
|
|
// Must be after the remove filter action, before the export. |
3287
|
|
|
$filter = array(); |
3288
|
|
|
if (!empty($search_date_start)) { |
3289
|
|
|
$filter['t.doc_date>='] = $search_date_start; |
3290
|
|
|
$tmp = dol_getdate($search_date_start); |
3291
|
|
|
$param .= '&search_date_startmonth=' . urlencode($tmp['mon']) . '&search_date_startday=' . urlencode($tmp['mday']) . '&search_date_startyear=' . urlencode($tmp['year']); |
3292
|
|
|
} |
3293
|
|
|
if (!empty($search_date_end)) { |
3294
|
|
|
$filter['t.doc_date<='] = $search_date_end; |
3295
|
|
|
$tmp = dol_getdate($search_date_end); |
3296
|
|
|
$param .= '&search_date_endmonth=' . urlencode($tmp['mon']) . '&search_date_endday=' . urlencode($tmp['mday']) . '&search_date_endyear=' . urlencode($tmp['year']); |
3297
|
|
|
} |
3298
|
|
|
if (!empty($search_doc_date)) { |
3299
|
|
|
$filter['t.doc_date'] = $search_doc_date; |
3300
|
|
|
$tmp = dol_getdate($search_doc_date); |
3301
|
|
|
$param .= '&doc_datemonth=' . urlencode($tmp['mon']) . '&doc_dateday=' . urlencode($tmp['mday']) . '&doc_dateyear=' . urlencode($tmp['year']); |
3302
|
|
|
} |
3303
|
|
|
if (!empty($search_doc_type)) { |
3304
|
|
|
$filter['t.doc_type'] = $search_doc_type; |
3305
|
|
|
$param .= '&search_doc_type=' . urlencode($search_doc_type); |
3306
|
|
|
} |
3307
|
|
|
if (!empty($search_doc_ref)) { |
3308
|
|
|
$filter['t.doc_ref'] = $search_doc_ref; |
3309
|
|
|
$param .= '&search_doc_ref=' . urlencode($search_doc_ref); |
3310
|
|
|
} |
3311
|
|
|
if ($search_account_category != '-1' && !empty($search_account_category)) { |
3312
|
|
|
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancycategory.class.php'; |
3313
|
|
|
$accountingcategory = new AccountancyCategory($db); |
3314
|
|
|
|
3315
|
|
|
$listofaccountsforgroup = $accountingcategory->getCptsCat(0, 'fk_accounting_category = ' . ((int) $search_account_category)); |
3316
|
|
|
$listofaccountsforgroup2 = array(); |
3317
|
|
|
if (is_array($listofaccountsforgroup)) { |
3318
|
|
|
foreach ($listofaccountsforgroup as $tmpval) { |
3319
|
|
|
$listofaccountsforgroup2[] = "'" . $db->escape($tmpval['id']) . "'"; |
3320
|
|
|
} |
3321
|
|
|
} |
3322
|
|
|
$filter['t.search_accounting_code_in'] = implode(',', $listofaccountsforgroup2); |
3323
|
|
|
$param .= '&search_account_category=' . urlencode((string) ($search_account_category)); |
3324
|
|
|
} |
3325
|
|
|
if (!empty($search_accountancy_code)) { |
3326
|
|
|
$filter['t.numero_compte'] = $search_accountancy_code; |
3327
|
|
|
$param .= '&search_accountancy_code=' . urlencode($search_accountancy_code); |
3328
|
|
|
} |
3329
|
|
|
if (!empty($search_accountancy_code_start)) { |
3330
|
|
|
$filter['t.numero_compte>='] = $search_accountancy_code_start; |
3331
|
|
|
$param .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start); |
3332
|
|
|
} |
3333
|
|
|
if (!empty($search_accountancy_code_end)) { |
3334
|
|
|
$filter['t.numero_compte<='] = $search_accountancy_code_end; |
3335
|
|
|
$param .= '&search_accountancy_code_end=' . urlencode($search_accountancy_code_end); |
3336
|
|
|
} |
3337
|
|
|
if (!empty($search_accountancy_aux_code)) { |
3338
|
|
|
$filter['t.subledger_account'] = $search_accountancy_aux_code; |
3339
|
|
|
$param .= '&search_accountancy_aux_code=' . urlencode($search_accountancy_aux_code); |
3340
|
|
|
} |
3341
|
|
|
if (!empty($search_accountancy_aux_code_start)) { |
3342
|
|
|
$filter['t.subledger_account>='] = $search_accountancy_aux_code_start; |
3343
|
|
|
$param .= '&search_accountancy_aux_code_start=' . urlencode($search_accountancy_aux_code_start); |
3344
|
|
|
} |
3345
|
|
|
if (!empty($search_accountancy_aux_code_end)) { |
3346
|
|
|
$filter['t.subledger_account<='] = $search_accountancy_aux_code_end; |
3347
|
|
|
$param .= '&search_accountancy_aux_code_end=' . urlencode($search_accountancy_aux_code_end); |
3348
|
|
|
} |
3349
|
|
|
if (!empty($search_mvt_label)) { |
3350
|
|
|
$filter['t.label_operation'] = $search_mvt_label; |
3351
|
|
|
$param .= '&search_mvt_label=' . urlencode($search_mvt_label); |
3352
|
|
|
} |
3353
|
|
|
if (!empty($search_direction)) { |
3354
|
|
|
$filter['t.sens'] = $search_direction; |
3355
|
|
|
$param .= '&search_direction=' . urlencode($search_direction); |
3356
|
|
|
} |
3357
|
|
|
if (!empty($search_ledger_code)) { |
3358
|
|
|
$filter['t.code_journal'] = $search_ledger_code; |
3359
|
|
|
foreach ($search_ledger_code as $code) { |
3360
|
|
|
$param .= '&search_ledger_code[]=' . urlencode($code); |
3361
|
|
|
} |
3362
|
|
|
} |
3363
|
|
|
if (!empty($search_mvt_num)) { |
3364
|
|
|
$filter['t.piece_num'] = $search_mvt_num; |
3365
|
|
|
$param .= '&search_mvt_num=' . urlencode((string) ($search_mvt_num)); |
3366
|
|
|
} |
3367
|
|
|
if (!empty($search_date_creation_start)) { |
3368
|
|
|
$filter['t.date_creation>='] = $search_date_creation_start; |
3369
|
|
|
$tmp = dol_getdate($search_date_creation_start); |
3370
|
|
|
$param .= '&search_date_creation_startmonth=' . urlencode($tmp['mon']) . '&search_date_creation_startday=' . urlencode($tmp['mday']) . '&search_date_creation_startyear=' . urlencode($tmp['year']); |
3371
|
|
|
} |
3372
|
|
|
if (!empty($search_date_creation_end)) { |
3373
|
|
|
$filter['t.date_creation<='] = $search_date_creation_end; |
3374
|
|
|
$tmp = dol_getdate($search_date_creation_end); |
3375
|
|
|
$param .= '&search_date_creation_endmonth=' . urlencode($tmp['mon']) . '&search_date_creation_endday=' . urlencode($tmp['mday']) . '&search_date_creation_endyear=' . urlencode($tmp['year']); |
3376
|
|
|
} |
3377
|
|
|
if (!empty($search_date_modification_start)) { |
3378
|
|
|
$filter['t.tms>='] = $search_date_modification_start; |
3379
|
|
|
$tmp = dol_getdate($search_date_modification_start); |
3380
|
|
|
$param .= '&search_date_modification_startmonth=' . urlencode($tmp['mon']) . '&search_date_modification_startday=' . urlencode($tmp['mday']) . '&search_date_modification_startyear=' . urlencode($tmp['year']); |
3381
|
|
|
} |
3382
|
|
|
if (!empty($search_date_modification_end)) { |
3383
|
|
|
$filter['t.tms<='] = $search_date_modification_end; |
3384
|
|
|
$tmp = dol_getdate($search_date_modification_end); |
3385
|
|
|
$param .= '&search_date_modification_endmonth=' . urlencode($tmp['mon']) . '&search_date_modification_endday=' . urlencode($tmp['mday']) . '&search_date_modification_endyear=' . urlencode($tmp['year']); |
3386
|
|
|
} |
3387
|
|
|
if (!empty($search_date_export_start)) { |
3388
|
|
|
$filter['t.date_export>='] = $search_date_export_start; |
3389
|
|
|
$tmp = dol_getdate($search_date_export_start); |
3390
|
|
|
$param .= '&search_date_export_startmonth=' . urlencode($tmp['mon']) . '&search_date_export_startday=' . urlencode($tmp['mday']) . '&search_date_export_startyear=' . urlencode($tmp['year']); |
3391
|
|
|
} |
3392
|
|
|
if (!empty($search_date_export_end)) { |
3393
|
|
|
$filter['t.date_export<='] = $search_date_export_end; |
3394
|
|
|
$tmp = dol_getdate($search_date_export_end); |
3395
|
|
|
$param .= '&search_date_export_endmonth=' . urlencode($tmp['mon']) . '&search_date_export_endday=' . urlencode($tmp['mday']) . '&search_date_export_endyear=' . urlencode($tmp['year']); |
3396
|
|
|
} |
3397
|
|
|
if (!empty($search_date_validation_start)) { |
3398
|
|
|
$filter['t.date_validated>='] = $search_date_validation_start; |
3399
|
|
|
$tmp = dol_getdate($search_date_validation_start); |
3400
|
|
|
$param .= '&search_date_validation_startmonth=' . urlencode($tmp['mon']) . '&search_date_validation_startday=' . urlencode($tmp['mday']) . '&search_date_validation_startyear=' . urlencode($tmp['year']); |
3401
|
|
|
} |
3402
|
|
|
if (!empty($search_date_validation_end)) { |
3403
|
|
|
$filter['t.date_validated<='] = $search_date_validation_end; |
3404
|
|
|
$tmp = dol_getdate($search_date_validation_end); |
3405
|
|
|
$param .= '&search_date_validation_endmonth=' . urlencode($tmp['mon']) . '&search_date_validation_endday=' . urlencode($tmp['mday']) . '&search_date_validation_endyear=' . urlencode($tmp['year']); |
3406
|
|
|
} |
3407
|
|
|
if (!empty($search_debit)) { |
3408
|
|
|
$filter['t.debit'] = $search_debit; |
3409
|
|
|
$param .= '&search_debit=' . urlencode($search_debit); |
3410
|
|
|
} |
3411
|
|
|
if (!empty($search_credit)) { |
3412
|
|
|
$filter['t.credit'] = $search_credit; |
3413
|
|
|
$param .= '&search_credit=' . urlencode($search_credit); |
3414
|
|
|
} |
3415
|
|
|
if (!empty($search_lettering_code)) { |
3416
|
|
|
$filter['t.lettering_code'] = $search_lettering_code; |
3417
|
|
|
$param .= '&search_lettering_code=' . urlencode($search_lettering_code); |
3418
|
|
|
} |
3419
|
|
|
if (!empty($search_not_reconciled)) { |
3420
|
|
|
$filter['t.reconciled_option'] = $search_not_reconciled; |
3421
|
|
|
$param .= '&search_not_reconciled=' . urlencode($search_not_reconciled); |
3422
|
|
|
} |
3423
|
|
|
if (!empty($search_import_key)) { |
3424
|
|
|
$filter['t.import_key'] = $search_import_key; |
3425
|
|
|
$param .= '&search_import_key=' . urlencode($search_import_key); |
3426
|
|
|
} |
3427
|
|
|
|
3428
|
|
|
// Mass actions |
3429
|
|
|
$objectclass = 'Bookkeeping'; |
3430
|
|
|
$objectlabel = 'Bookkeeping'; |
3431
|
|
|
$permissiontoread = $user->hasRight('societe', 'lire'); |
3432
|
|
|
$permissiontodelete = $user->hasRight('societe', 'supprimer'); |
3433
|
|
|
$permissiontoadd = $user->hasRight('societe', 'creer'); |
3434
|
|
|
$uploaddir = $conf->societe->dir_output; |
3435
|
|
|
include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php'; |
3436
|
|
|
|
3437
|
|
|
if (!$error && $action == 'deletebookkeepingwriting' && $confirm == "yes" && $user->hasRight('accounting', 'mouvements', 'supprimer')) { |
3438
|
|
|
$db->begin(); |
3439
|
|
|
|
3440
|
|
|
if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) { |
3441
|
|
|
$lettering = new Lettering($db); |
3442
|
|
|
$nb_lettering = $lettering->bookkeepingLetteringAll($toselect, true); |
3443
|
|
|
if ($nb_lettering < 0) { |
3444
|
|
|
setEventMessages('', $lettering->errors, 'errors'); |
3445
|
|
|
$error++; |
3446
|
|
|
} |
3447
|
|
|
} |
3448
|
|
|
|
3449
|
|
|
$nbok = 0; |
3450
|
|
|
if (!$error) { |
3451
|
|
|
foreach ($toselect as $toselectid) { |
3452
|
|
|
$result = $object->fetch($toselectid); |
3453
|
|
|
if ($result > 0 && (!isset($object->date_validation) || $object->date_validation === '')) { |
3454
|
|
|
$result = $object->deleteMvtNum($object->piece_num); |
3455
|
|
|
if ($result > 0) { |
3456
|
|
|
$nbok++; |
3457
|
|
|
} else { |
3458
|
|
|
setEventMessages($object->error, $object->errors, 'errors'); |
3459
|
|
|
$error++; |
3460
|
|
|
break; |
3461
|
|
|
} |
3462
|
|
|
} elseif ($result < 0) { |
3463
|
|
|
setEventMessages($object->error, $object->errors, 'errors'); |
3464
|
|
|
$error++; |
3465
|
|
|
break; |
3466
|
|
|
} elseif (isset($object->date_validation) && $object->date_validation != '') { |
3467
|
|
|
setEventMessages($langs->trans("ValidatedRecordWhereFound"), null, 'errors'); |
3468
|
|
|
$error++; |
3469
|
|
|
break; |
3470
|
|
|
} |
3471
|
|
|
} |
3472
|
|
|
} |
3473
|
|
|
|
3474
|
|
|
if (!$error) { |
3475
|
|
|
$db->commit(); |
3476
|
|
|
|
3477
|
|
|
// Message for elements well deleted |
3478
|
|
|
if ($nbok > 1) { |
3479
|
|
|
setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs'); |
3480
|
|
|
} elseif ($nbok > 0) { |
3481
|
|
|
setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs'); |
3482
|
|
|
} else { |
3483
|
|
|
setEventMessages($langs->trans("NoRecordDeleted"), null, 'mesgs'); |
3484
|
|
|
} |
3485
|
|
|
|
3486
|
|
|
header("Location: " . $_SERVER['PHP_SELF'] . "?noreset=1" . ($param ? '&' . $param : '')); |
3487
|
|
|
exit; |
3488
|
|
|
} else { |
3489
|
|
|
$db->rollback(); |
3490
|
|
|
} |
3491
|
|
|
} |
3492
|
|
|
|
3493
|
|
|
// others mass actions |
3494
|
|
|
if (!$error && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->hasRight('accounting', 'mouvements', 'creer')) { |
3495
|
|
|
if ($massaction == 'letteringauto') { |
3496
|
|
|
$lettering = new Lettering($db); |
3497
|
|
|
$nb_lettering = $lettering->bookkeepingLetteringAll($toselect); |
3498
|
|
|
if ($nb_lettering < 0) { |
3499
|
|
|
setEventMessages('', $lettering->errors, 'errors'); |
3500
|
|
|
$error++; |
3501
|
|
|
$nb_lettering = max(0, abs($nb_lettering) - 2); |
3502
|
|
|
} elseif ($nb_lettering == 0) { |
3503
|
|
|
$nb_lettering = 0; |
3504
|
|
|
setEventMessages($langs->trans('AccountancyNoLetteringModified'), array(), 'mesgs'); |
3505
|
|
|
} |
3506
|
|
|
if ($nb_lettering == 1) { |
3507
|
|
|
setEventMessages($langs->trans('AccountancyOneLetteringModifiedSuccessfully'), array(), 'mesgs'); |
3508
|
|
|
} elseif ($nb_lettering > 1) { |
3509
|
|
|
setEventMessages($langs->trans('AccountancyLetteringModifiedSuccessfully', $nb_lettering), array(), 'mesgs'); |
3510
|
|
|
} |
3511
|
|
|
|
3512
|
|
|
if (!$error) { |
3513
|
|
|
header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param); |
3514
|
|
|
exit(); |
3515
|
|
|
} |
3516
|
|
|
} elseif ($massaction == 'letteringmanual') { |
3517
|
|
|
$lettering = new Lettering($db); |
3518
|
|
|
$result = $lettering->updateLettering($toselect); |
3519
|
|
|
if ($result < 0) { |
3520
|
|
|
setEventMessages('', $lettering->errors, 'errors'); |
3521
|
|
|
} else { |
3522
|
|
|
setEventMessages($langs->trans('AccountancyOneLetteringModifiedSuccessfully'), array(), 'mesgs'); |
3523
|
|
|
header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param); |
3524
|
|
|
exit(); |
3525
|
|
|
} |
3526
|
|
|
} elseif ($action == 'unletteringauto' && $confirm == "yes") { |
3527
|
|
|
$lettering = new Lettering($db); |
3528
|
|
|
$nb_lettering = $lettering->bookkeepingLetteringAll($toselect, true); |
3529
|
|
|
if ($nb_lettering < 0) { |
3530
|
|
|
setEventMessages('', $lettering->errors, 'errors'); |
3531
|
|
|
$error++; |
3532
|
|
|
$nb_lettering = max(0, abs($nb_lettering) - 2); |
3533
|
|
|
} elseif ($nb_lettering == 0) { |
3534
|
|
|
$nb_lettering = 0; |
3535
|
|
|
setEventMessages($langs->trans('AccountancyNoUnletteringModified'), array(), 'mesgs'); |
3536
|
|
|
} |
3537
|
|
|
if ($nb_lettering == 1) { |
3538
|
|
|
setEventMessages($langs->trans('AccountancyOneUnletteringModifiedSuccessfully'), array(), 'mesgs'); |
3539
|
|
|
} elseif ($nb_lettering > 1) { |
3540
|
|
|
setEventMessages($langs->trans('AccountancyUnletteringModifiedSuccessfully', $nb_lettering), array(), 'mesgs'); |
3541
|
|
|
} |
3542
|
|
|
|
3543
|
|
|
if (!$error) { |
3544
|
|
|
header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param); |
3545
|
|
|
exit(); |
3546
|
|
|
} |
3547
|
|
|
} elseif ($action == 'unletteringmanual' && $confirm == "yes") { |
3548
|
|
|
$lettering = new Lettering($db); |
3549
|
|
|
$nb_lettering = $lettering->deleteLettering($toselect); |
3550
|
|
|
if ($result < 0) { |
3551
|
|
|
setEventMessages('', $lettering->errors, 'errors'); |
3552
|
|
|
} else { |
3553
|
|
|
setEventMessages($langs->trans('AccountancyOneUnletteringModifiedSuccessfully'), array(), 'mesgs'); |
3554
|
|
|
header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param); |
3555
|
|
|
exit(); |
3556
|
|
|
} |
3557
|
|
|
} |
3558
|
|
|
} |
3559
|
|
|
} |
3560
|
|
|
|
3561
|
|
|
// Build and execute select (used by page and export action) |
3562
|
|
|
// must de set after the action that set $filter |
3563
|
|
|
// -------------------------------------------------------------------- |
3564
|
|
|
|
3565
|
|
|
$sql = 'SELECT'; |
3566
|
|
|
$sql .= ' t.rowid,'; |
3567
|
|
|
$sql .= " t.doc_date,"; |
3568
|
|
|
$sql .= " t.doc_type,"; |
3569
|
|
|
$sql .= " t.doc_ref,"; |
3570
|
|
|
$sql .= " t.fk_doc,"; |
3571
|
|
|
$sql .= " t.fk_docdet,"; |
3572
|
|
|
$sql .= " t.thirdparty_code,"; |
3573
|
|
|
$sql .= " t.subledger_account,"; |
3574
|
|
|
$sql .= " t.subledger_label,"; |
3575
|
|
|
$sql .= " t.numero_compte,"; |
3576
|
|
|
$sql .= " t.label_compte,"; |
3577
|
|
|
$sql .= " t.label_operation,"; |
3578
|
|
|
$sql .= " t.debit,"; |
3579
|
|
|
$sql .= " t.credit,"; |
3580
|
|
|
$sql .= " t.lettering_code,"; |
3581
|
|
|
$sql .= " t.montant as amount,"; |
3582
|
|
|
$sql .= " t.sens,"; |
3583
|
|
|
$sql .= " t.fk_user_author,"; |
3584
|
|
|
$sql .= " t.import_key,"; |
3585
|
|
|
$sql .= " t.code_journal,"; |
3586
|
|
|
$sql .= " t.journal_label,"; |
3587
|
|
|
$sql .= " t.piece_num,"; |
3588
|
|
|
$sql .= " t.date_creation,"; |
3589
|
|
|
$sql .= " t.tms as date_modification,"; |
3590
|
|
|
$sql .= " t.date_export,"; |
3591
|
|
|
$sql .= " t.date_validated as date_validation,"; |
3592
|
|
|
$sql .= " t.import_key"; |
3593
|
|
|
|
3594
|
|
|
$sqlfields = $sql; // $sql fields to remove for count total |
3595
|
|
|
|
3596
|
|
|
$sql .= ' FROM ' . MAIN_DB_PREFIX . $object->table_element . ' as t'; |
3597
|
|
|
// Manage filter |
3598
|
|
|
$sqlwhere = array(); |
3599
|
|
|
if (count($filter) > 0) { |
3600
|
|
|
foreach ($filter as $key => $value) { |
3601
|
|
|
if ($key == 't.doc_date') { |
3602
|
|
|
$sqlwhere[] = $db->sanitize($key) . " = '" . $db->idate($value) . "'"; |
3603
|
|
|
} elseif ($key == 't.doc_date>=') { |
3604
|
|
|
$sqlwhere[] = "t.doc_date >= '" . $db->idate($value) . "'"; |
3605
|
|
|
} elseif ($key == 't.doc_date<=') { |
3606
|
|
|
$sqlwhere[] = "t.doc_date <= '" . $db->idate($value) . "'"; |
3607
|
|
|
} elseif ($key == 't.doc_date>') { |
3608
|
|
|
$sqlwhere[] = "t.doc_date > '" . $db->idate($value) . "'"; |
3609
|
|
|
} elseif ($key == 't.doc_date<') { |
3610
|
|
|
$sqlwhere[] = "t.doc_date < '" . $db->idate($value) . "'"; |
3611
|
|
|
} elseif ($key == 't.numero_compte>=') { |
3612
|
|
|
$sqlwhere[] = "t.numero_compte >= '" . $db->escape($value) . "'"; |
3613
|
|
|
} elseif ($key == 't.numero_compte<=') { |
3614
|
|
|
$sqlwhere[] = "t.numero_compte <= '" . $db->escape($value) . "'"; |
3615
|
|
|
} elseif ($key == 't.subledger_account>=') { |
3616
|
|
|
$sqlwhere[] = "t.subledger_account >= '" . $db->escape($value) . "'"; |
3617
|
|
|
} elseif ($key == 't.subledger_account<=') { |
3618
|
|
|
$sqlwhere[] = "t.subledger_account <= '" . $db->escape($value) . "'"; |
3619
|
|
|
} elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { |
3620
|
|
|
$sqlwhere[] = $db->sanitize($key) . ' = ' . ((int) $value); |
3621
|
|
|
} elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { |
3622
|
|
|
$sqlwhere[] = $db->sanitize($key) . " LIKE '" . $db->escape($db->escapeforlike($value)) . "%'"; |
3623
|
|
|
} elseif ($key == 't.subledger_account') { |
3624
|
|
|
$sqlwhere[] = natural_search($key, $value, 0, 1); |
3625
|
|
|
} elseif ($key == 't.tms>=') { |
3626
|
|
|
$sqlwhere[] = "t.tms >= '" . $db->idate($value) . "'"; |
3627
|
|
|
} elseif ($key == 't.tms<=') { |
3628
|
|
|
$sqlwhere[] = "t.tms <= '" . $db->idate($value) . "'"; |
3629
|
|
|
} elseif ($key == 't.date_creation>=') { |
3630
|
|
|
$sqlwhere[] = "t.date_creation >= '" . $db->idate($value) . "'"; |
3631
|
|
|
} elseif ($key == 't.date_creation<=') { |
3632
|
|
|
$sqlwhere[] = "t.date_creation <= '" . $db->idate($value) . "'"; |
3633
|
|
|
} elseif ($key == 't.date_export>=') { |
3634
|
|
|
$sqlwhere[] = "t.date_export >= '" . $db->idate($value) . "'"; |
3635
|
|
|
} elseif ($key == 't.date_export<=') { |
3636
|
|
|
$sqlwhere[] = "t.date_export <= '" . $db->idate($value) . "'"; |
3637
|
|
|
} elseif ($key == 't.date_validated>=') { |
3638
|
|
|
$sqlwhere[] = "t;date_validate >= '" . $db->idate($value) . "'"; |
3639
|
|
|
} elseif ($key == 't.date_validated<=') { |
3640
|
|
|
$sqlwhere[] = "t;date_validate <= '" . $db->idate($value) . "'"; |
3641
|
|
|
} elseif ($key == 't.credit' || $key == 't.debit') { |
3642
|
|
|
$sqlwhere[] = natural_search($key, $value, 1, 1); |
3643
|
|
|
} elseif ($key == 't.reconciled_option') { |
3644
|
|
|
$sqlwhere[] = 't.lettering_code IS NULL'; |
3645
|
|
|
} elseif ($key == 't.code_journal' && !empty($value)) { |
3646
|
|
|
if (is_array($value)) { |
3647
|
|
|
$sqlwhere[] = natural_search("t.code_journal", implode(',', $value), 3, 1); |
3648
|
|
|
} else { |
3649
|
|
|
$sqlwhere[] = natural_search("t.code_journal", $value, 3, 1); |
3650
|
|
|
} |
3651
|
|
|
} elseif ($key == 't.search_accounting_code_in' && !empty($value)) { |
3652
|
|
|
$sqlwhere[] = 't.numero_compte IN (' . $db->sanitize($value, 1) . ')'; |
3653
|
|
|
} else { |
3654
|
|
|
$sqlwhere[] = natural_search($key, $value, 0, 1); |
3655
|
|
|
} |
3656
|
|
|
} |
3657
|
|
|
} |
3658
|
|
|
$sql .= ' WHERE t.entity IN (' . getEntity('accountancy') . ')'; |
3659
|
|
|
|
3660
|
|
|
if (count($sqlwhere) > 0) { |
3661
|
|
|
$sql .= ' AND ' . implode(' AND ', $sqlwhere); |
3662
|
|
|
} |
3663
|
|
|
//print $sql; |
3664
|
|
|
|
3665
|
|
|
/* |
3666
|
|
|
* View |
3667
|
|
|
*/ |
3668
|
|
|
|
3669
|
|
|
$formother = new FormOther($db); |
3670
|
|
|
$formfile = new FormFile($db); |
3671
|
|
|
|
3672
|
|
|
$title_page = $langs->trans("Operations") . ' - ' . $langs->trans("Journals"); |
3673
|
|
|
|
3674
|
|
|
// Count total nb of records |
3675
|
|
|
$nbtotalofrecords = ''; |
3676
|
|
|
if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { |
3677
|
|
|
/* The fast and low memory method to get and count full list converts the sql into a sql count */ |
3678
|
|
|
$sqlforcount = preg_replace('/^' . preg_quote($sqlfields, '/') . '/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); |
3679
|
|
|
$sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); |
3680
|
|
|
$resql = $db->query($sqlforcount); |
3681
|
|
|
if ($resql) { |
3682
|
|
|
$objforcount = $db->fetch_object($resql); |
3683
|
|
|
$nbtotalofrecords = $objforcount->nbtotalofrecords; |
3684
|
|
|
} else { |
3685
|
|
|
dol_print_error($db); |
3686
|
|
|
} |
3687
|
|
|
|
3688
|
|
|
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 |
3689
|
|
|
$page = 0; |
3690
|
|
|
$offset = 0; |
3691
|
|
|
} |
3692
|
|
|
$db->free($resql); |
3693
|
|
|
} |
3694
|
|
|
|
3695
|
|
|
// Complete request and execute it with limit |
3696
|
|
|
$sql .= $db->order($sortfield, $sortorder); |
3697
|
|
|
if ($limit) { |
3698
|
|
|
$sql .= $db->plimit($limit + 1, $offset); |
3699
|
|
|
} |
3700
|
|
|
|
3701
|
|
|
$resql = $db->query($sql); |
3702
|
|
|
if (!$resql) { |
3703
|
|
|
dol_print_error($db); |
3704
|
|
|
exit; |
|
|
|
|
3705
|
|
|
} |
3706
|
|
|
|
3707
|
|
|
$num = $db->num_rows($resql); |
3708
|
|
|
|
3709
|
|
|
$arrayofselected = is_array($toselect) ? $toselect : array(); |
3710
|
|
|
|
3711
|
|
|
// Output page |
3712
|
|
|
// -------------------------------------------------------------------- |
3713
|
|
|
$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double'; |
3714
|
|
|
llxHeader('', $title_page, $help_url); |
3715
|
|
|
|
3716
|
|
|
$formconfirm = ''; |
3717
|
|
|
|
3718
|
|
|
// Print form confirm |
3719
|
|
|
print $formconfirm; |
3720
|
|
|
|
3721
|
|
|
//$param=''; param started before |
3722
|
|
|
if (!empty($contextpage) && $contextpage != $_SERVER['PHP_SELF']) { |
3723
|
|
|
$param .= '&contextpage=' . urlencode($contextpage); |
3724
|
|
|
} |
3725
|
|
|
if ($limit > 0 && $limit != $conf->liste_limit) { |
3726
|
|
|
$param .= '&limit=' . ((int) $limit); |
3727
|
|
|
} |
3728
|
|
|
|
3729
|
|
|
// List of mass actions available |
3730
|
|
|
$arrayofmassactions = array(); |
3731
|
|
|
if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->hasRight('accounting', 'mouvements', 'creer')) { |
3732
|
|
|
$arrayofmassactions['letteringauto'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('LetteringAuto'); |
3733
|
|
|
$arrayofmassactions['preunletteringauto'] = img_picto('', 'uncheck', 'class="pictofixedwidth"') . $langs->trans('UnletteringAuto'); |
3734
|
|
|
$arrayofmassactions['letteringmanual'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('LetteringManual'); |
3735
|
|
|
$arrayofmassactions['preunletteringmanual'] = img_picto('', 'uncheck', 'class="pictofixedwidth"') . $langs->trans('UnletteringManual'); |
3736
|
|
|
} |
3737
|
|
|
if ($user->hasRight('accounting', 'mouvements', 'supprimer')) { |
3738
|
|
|
$arrayofmassactions['predeletebookkeepingwriting'] = img_picto('', 'delete', 'class="pictofixedwidth"') . $langs->trans("Delete"); |
3739
|
|
|
} |
3740
|
|
|
if (GETPOSTINT('nomassaction') || in_array($massaction, array('preunletteringauto', 'preunletteringmanual', 'predeletebookkeepingwriting'))) { |
3741
|
|
|
$arrayofmassactions = array(); |
3742
|
|
|
} |
3743
|
|
|
$massactionbutton = $form->selectMassAction($massaction, $arrayofmassactions); |
3744
|
|
|
|
3745
|
|
|
print '<form method="POST" id="searchFormList" action="' . $_SERVER['PHP_SELF'] . '">'; |
3746
|
|
|
print '<input type="hidden" name="token" value="' . newToken() . '">'; |
3747
|
|
|
print '<input type="hidden" name="action" value="list">'; |
3748
|
|
|
if ($optioncss != '') { |
3749
|
|
|
print '<input type="hidden" name="optioncss" value="' . urlencode($optioncss) . '">'; |
3750
|
|
|
} |
3751
|
|
|
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
3752
|
|
|
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">'; |
3753
|
|
|
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">'; |
3754
|
|
|
print '<input type="hidden" name="contextpage" value="' . $contextpage . '">'; |
3755
|
|
|
|
3756
|
|
|
if (count($filter)) { |
3757
|
|
|
$buttonLabel = $langs->trans("ExportFilteredList"); |
3758
|
|
|
} else { |
3759
|
|
|
$buttonLabel = $langs->trans("ExportList"); |
3760
|
|
|
} |
3761
|
|
|
|
3762
|
|
|
$parameters = array('param' => $param); |
3763
|
|
|
$reshook = $hookmanager->executeHooks('addMoreActionsButtonsList', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
3764
|
|
|
if ($reshook < 0) { |
3765
|
|
|
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
3766
|
|
|
} |
3767
|
|
|
|
3768
|
|
|
$newcardbutton = empty($hookmanager->resPrint) ? '' : $hookmanager->resPrint; |
3769
|
|
|
|
3770
|
|
|
if (empty($reshook)) { |
3771
|
|
|
$newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/list.php?' . $param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); |
3772
|
|
|
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?' . $param, '', 1, array('morecss' => 'marginleftonly')); |
3773
|
|
|
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?type=sub' . $param, '', 1, array('morecss' => 'marginleftonly')); |
3774
|
|
|
|
3775
|
|
|
$url = './card.php?action=create'; |
3776
|
|
|
if (!empty($socid)) { |
3777
|
|
|
$url .= '&socid=' . $socid; |
3778
|
|
|
} |
3779
|
|
|
$newcardbutton .= dolGetButtonTitleSeparator(); |
3780
|
|
|
$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', $url, '', $user->hasRight('accounting', 'mouvements', 'creer')); |
3781
|
|
|
} |
3782
|
|
|
|
3783
|
|
|
print_barre_liste($title_page, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); |
3784
|
|
|
|
3785
|
|
|
if ($massaction == 'preunletteringauto') { |
3786
|
|
|
print $form->formconfirm($_SERVER['PHP_SELF'], $langs->trans("ConfirmMassUnletteringAuto"), $langs->trans("ConfirmMassUnletteringQuestion", count($toselect)), "unletteringauto", null, '', 0, 200, 500, 1); |
3787
|
|
|
} elseif ($massaction == 'preunletteringmanual') { |
3788
|
|
|
print $form->formconfirm($_SERVER['PHP_SELF'], $langs->trans("ConfirmMassUnletteringManual"), $langs->trans("ConfirmMassUnletteringQuestion", count($toselect)), "unletteringmanual", null, '', 0, 200, 500, 1); |
3789
|
|
|
} elseif ($massaction == 'predeletebookkeepingwriting') { |
3790
|
|
|
print $form->formconfirm($_SERVER['PHP_SELF'], $langs->trans("ConfirmMassDeleteBookkeepingWriting"), $langs->trans("ConfirmMassDeleteBookkeepingWritingQuestion", count($toselect)), "deletebookkeepingwriting", null, '', 0, 200, 500, 1); |
3791
|
|
|
} |
3792
|
|
|
|
3793
|
|
|
//$topicmail = "Information"; |
3794
|
|
|
//$modelmail = "accountingbookkeeping"; |
3795
|
|
|
//$objecttmp = new BookKeeping($db); |
3796
|
|
|
//$trackid = 'bk'.$object->id; |
3797
|
|
|
include DOL_DOCUMENT_ROOT . '/core/tpl/massactions_pre.tpl.php'; |
3798
|
|
|
|
3799
|
|
|
$varpage = empty($contextpage) ? $_SERVER['PHP_SELF'] : $contextpage; |
3800
|
|
|
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields |
3801
|
|
|
if ($massactionbutton && $contextpage != 'poslist') { |
3802
|
|
|
$selectedfields .= $form->showCheckAddButtons('checkforselect', 1); |
3803
|
|
|
} |
3804
|
|
|
|
3805
|
|
|
$moreforfilter = ''; |
3806
|
|
|
$moreforfilter .= '<div class="divsearchfield">'; |
3807
|
|
|
$moreforfilter .= $langs->trans('AccountingCategory') . ': '; |
3808
|
|
|
$moreforfilter .= '<div class="nowrap inline-block">'; |
3809
|
|
|
$moreforfilter .= $formaccounting->select_accounting_category($search_account_category, 'search_account_category', 1, 0, 0, 0); |
3810
|
|
|
$moreforfilter .= '</div>'; |
3811
|
|
|
$moreforfilter .= '</div>'; |
3812
|
|
|
|
3813
|
|
|
$parameters = array(); |
3814
|
|
|
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
3815
|
|
|
if (empty($reshook)) { |
3816
|
|
|
$moreforfilter .= $hookmanager->resPrint; |
3817
|
|
|
} else { |
3818
|
|
|
$moreforfilter = $hookmanager->resPrint; |
3819
|
|
|
} |
3820
|
|
|
|
3821
|
|
|
print '<div class="liste_titre liste_titre_bydiv centpercent">'; |
3822
|
|
|
print $moreforfilter; |
3823
|
|
|
print '</div>'; |
3824
|
|
|
|
3825
|
|
|
print '<div class="div-table-responsive">'; |
3826
|
|
|
print '<table class="tagtable liste' . ($moreforfilter ? " listwithfilterbefore" : "") . '">'; |
3827
|
|
|
|
3828
|
|
|
// Filters lines |
3829
|
|
|
print '<tr class="liste_titre_filter">'; |
3830
|
|
|
// Action column |
3831
|
|
|
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
3832
|
|
|
print '<td class="liste_titre center">'; |
3833
|
|
|
$searchpicto = $form->showFilterButtons('left'); |
3834
|
|
|
print $searchpicto; |
3835
|
|
|
print '</td>'; |
3836
|
|
|
} |
3837
|
|
|
// Movement number |
3838
|
|
|
if (!empty($arrayfields['t.piece_num']['checked'])) { |
3839
|
|
|
print '<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="' . dol_escape_htmltag($search_mvt_num) . '"></td>'; |
3840
|
|
|
} |
3841
|
|
|
// Code journal |
3842
|
|
|
if (!empty($arrayfields['t.code_journal']['checked'])) { |
3843
|
|
|
print '<td class="liste_titre center">'; |
3844
|
|
|
print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1, 'small maxwidth75'); |
3845
|
|
|
print '</td>'; |
3846
|
|
|
} |
3847
|
|
|
// Date document |
3848
|
|
|
if (!empty($arrayfields['t.doc_date']['checked'])) { |
3849
|
|
|
print '<td class="liste_titre center">'; |
3850
|
|
|
print '<div class="nowrapfordate">'; |
3851
|
|
|
print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); |
3852
|
|
|
print '</div>'; |
3853
|
|
|
print '<div class="nowrapfordate">'; |
3854
|
|
|
print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); |
3855
|
|
|
print '</div>'; |
3856
|
|
|
print '</td>'; |
3857
|
|
|
} |
3858
|
|
|
// Ref document |
3859
|
|
|
if (!empty($arrayfields['t.doc_ref']['checked'])) { |
3860
|
|
|
print '<td class="liste_titre"><input type="text" name="search_doc_ref" size="8" value="' . dol_escape_htmltag($search_doc_ref) . '"></td>'; |
3861
|
|
|
} |
3862
|
|
|
// Accountancy account |
3863
|
|
|
if (!empty($arrayfields['t.numero_compte']['checked'])) { |
3864
|
|
|
print '<td class="liste_titre">'; |
3865
|
|
|
print '<div class="nowrap">'; |
3866
|
|
|
print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, 'maxwidth150', 'account'); |
3867
|
|
|
print '</div>'; |
3868
|
|
|
print '<div class="nowrap">'; |
3869
|
|
|
print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, 'maxwidth150', 'account'); |
3870
|
|
|
print '</div>'; |
3871
|
|
|
print '</td>'; |
3872
|
|
|
} |
3873
|
|
|
// Subledger account |
3874
|
|
|
if (!empty($arrayfields['t.subledger_account']['checked'])) { |
3875
|
|
|
print '<td class="liste_titre">'; |
3876
|
|
|
// TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not |
3877
|
|
|
// use setup of keypress to select thirdparty and this hang browser on large database. |
3878
|
|
|
if (getDolGlobalString('ACCOUNTANCY_COMBO_FOR_AUX')) { |
3879
|
|
|
print '<div class="nowrap">'; |
3880
|
|
|
//print $langs->trans('From').' '; |
3881
|
|
|
print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', $langs->trans('From'), 'maxwidth250', 'subledgeraccount'); |
3882
|
|
|
print '</div>'; |
3883
|
|
|
print '<div class="nowrap">'; |
3884
|
|
|
print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', $langs->trans('to'), 'maxwidth250', 'subledgeraccount'); |
3885
|
|
|
print '</div>'; |
3886
|
|
|
} else { |
3887
|
|
|
print '<input type="text" class="maxwidth75" name="search_accountancy_aux_code" value="' . dol_escape_htmltag($search_accountancy_aux_code) . '">'; |
3888
|
|
|
} |
3889
|
|
|
print '</td>'; |
3890
|
|
|
} |
3891
|
|
|
// Label operation |
3892
|
|
|
if (!empty($arrayfields['t.label_operation']['checked'])) { |
3893
|
|
|
print '<td class="liste_titre">'; |
3894
|
|
|
print '<input type="text" size="7" class="flat" name="search_mvt_label" value="' . dol_escape_htmltag($search_mvt_label) . '"/>'; |
3895
|
|
|
print '</td>'; |
3896
|
|
|
} |
3897
|
|
|
// Debit |
3898
|
|
|
if (!empty($arrayfields['t.debit']['checked'])) { |
3899
|
|
|
print '<td class="liste_titre right">'; |
3900
|
|
|
print '<input type="text" class="flat" name="search_debit" size="4" value="' . dol_escape_htmltag($search_debit) . '">'; |
3901
|
|
|
print '</td>'; |
3902
|
|
|
} |
3903
|
|
|
// Credit |
3904
|
|
|
if (!empty($arrayfields['t.credit']['checked'])) { |
3905
|
|
|
print '<td class="liste_titre right">'; |
3906
|
|
|
print '<input type="text" class="flat" name="search_credit" size="4" value="' . dol_escape_htmltag($search_credit) . '">'; |
3907
|
|
|
print '</td>'; |
3908
|
|
|
} |
3909
|
|
|
// Lettering code |
3910
|
|
|
if (!empty($arrayfields['t.lettering_code']['checked'])) { |
3911
|
|
|
print '<td class="liste_titre center">'; |
3912
|
|
|
print '<input type="text" size="3" class="flat" name="search_lettering_code" value="' . dol_escape_htmltag($search_lettering_code) . '"/>'; |
3913
|
|
|
print '<br><span class="nowrap"><input type="checkbox" name="search_not_reconciled" value="notreconciled"' . ($search_not_reconciled == 'notreconciled' ? ' checked' : '') . '>' . $langs->trans("NotReconciled") . '</span>'; |
3914
|
|
|
print '</td>'; |
3915
|
|
|
} |
3916
|
|
|
|
3917
|
|
|
// Fields from hook |
3918
|
|
|
$parameters = array('arrayfields' => $arrayfields); |
3919
|
|
|
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook |
3920
|
|
|
print $hookmanager->resPrint; |
3921
|
|
|
|
3922
|
|
|
// Date creation |
3923
|
|
|
if (!empty($arrayfields['t.date_creation']['checked'])) { |
3924
|
|
|
print '<td class="liste_titre center">'; |
3925
|
|
|
print '<div class="nowrapfordate">'; |
3926
|
|
|
print $form->selectDate($search_date_creation_start, 'search_date_creation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); |
3927
|
|
|
print '</div>'; |
3928
|
|
|
print '<div class="nowrapfordate">'; |
3929
|
|
|
print $form->selectDate($search_date_creation_end, 'search_date_creation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); |
3930
|
|
|
print '</div>'; |
3931
|
|
|
print '</td>'; |
3932
|
|
|
} |
3933
|
|
|
// Date modification |
3934
|
|
|
if (!empty($arrayfields['t.tms']['checked'])) { |
3935
|
|
|
print '<td class="liste_titre center">'; |
3936
|
|
|
print '<div class="nowrapfordate">'; |
3937
|
|
|
print $form->selectDate($search_date_modification_start, 'search_date_modification_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); |
3938
|
|
|
print '</div>'; |
3939
|
|
|
print '<div class="nowrapfordate">'; |
3940
|
|
|
print $form->selectDate($search_date_modification_end, 'search_date_modification_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); |
3941
|
|
|
print '</div>'; |
3942
|
|
|
print '</td>'; |
3943
|
|
|
} |
3944
|
|
|
// Date export |
3945
|
|
|
if (!empty($arrayfields['t.date_export']['checked'])) { |
3946
|
|
|
print '<td class="liste_titre center">'; |
3947
|
|
|
print '<div class="nowrapfordate">'; |
3948
|
|
|
print $form->selectDate($search_date_export_start, 'search_date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); |
3949
|
|
|
print '</div>'; |
3950
|
|
|
print '<div class="nowrapfordate">'; |
3951
|
|
|
print $form->selectDate($search_date_export_end, 'search_date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); |
3952
|
|
|
print '</div>'; |
3953
|
|
|
print '</td>'; |
3954
|
|
|
} |
3955
|
|
|
// Date validation |
3956
|
|
|
if (!empty($arrayfields['t.date_validated']['checked'])) { |
3957
|
|
|
print '<td class="liste_titre center">'; |
3958
|
|
|
print '<div class="nowrapfordate">'; |
3959
|
|
|
print $form->selectDate($search_date_validation_start, 'search_date_validation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); |
3960
|
|
|
print '</div>'; |
3961
|
|
|
print '<div class="nowrapfordate">'; |
3962
|
|
|
print $form->selectDate($search_date_validation_end, 'search_date_validation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); |
3963
|
|
|
print '</div>'; |
3964
|
|
|
print '</td>'; |
3965
|
|
|
} |
3966
|
|
|
if (!empty($arrayfields['t.import_key']['checked'])) { |
3967
|
|
|
print '<td class="liste_titre center">'; |
3968
|
|
|
print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="' . dol_escape_htmltag($search_import_key) . '">'; |
3969
|
|
|
print '</td>'; |
3970
|
|
|
} |
3971
|
|
|
// Action column |
3972
|
|
|
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
3973
|
|
|
print '<td class="liste_titre center">'; |
3974
|
|
|
$searchpicto = $form->showFilterButtons(); |
3975
|
|
|
print $searchpicto; |
3976
|
|
|
print '</td>'; |
3977
|
|
|
} |
3978
|
|
|
print "</tr>\n"; |
3979
|
|
|
|
3980
|
|
|
print '<tr class="liste_titre">'; |
3981
|
|
|
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
3982
|
|
|
print_liste_field_titre($selectedfields, $_SERVER['PHP_SELF'], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch actioncolumn '); |
3983
|
|
|
} |
3984
|
|
|
if (!empty($arrayfields['t.piece_num']['checked'])) { |
3985
|
|
|
print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, "", $sortfield, $sortorder); |
3986
|
|
|
} |
3987
|
|
|
if (!empty($arrayfields['t.code_journal']['checked'])) { |
3988
|
|
|
print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center '); |
3989
|
|
|
} |
3990
|
|
|
if (!empty($arrayfields['t.doc_date']['checked'])) { |
3991
|
|
|
print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center '); |
3992
|
|
|
} |
3993
|
|
|
if (!empty($arrayfields['t.doc_ref']['checked'])) { |
3994
|
|
|
print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder); |
3995
|
|
|
} |
3996
|
|
|
if (!empty($arrayfields['t.numero_compte']['checked'])) { |
3997
|
|
|
print_liste_field_titre($arrayfields['t.numero_compte']['label'], $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder); |
3998
|
|
|
} |
3999
|
|
|
if (!empty($arrayfields['t.subledger_account']['checked'])) { |
4000
|
|
|
print_liste_field_titre($arrayfields['t.subledger_account']['label'], $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder); |
4001
|
|
|
} |
4002
|
|
|
if (!empty($arrayfields['t.label_operation']['checked'])) { |
4003
|
|
|
print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder); |
4004
|
|
|
} |
4005
|
|
|
if (!empty($arrayfields['t.debit']['checked'])) { |
4006
|
|
|
print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right '); |
4007
|
|
|
} |
4008
|
|
|
if (!empty($arrayfields['t.credit']['checked'])) { |
4009
|
|
|
print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right '); |
4010
|
|
|
} |
4011
|
|
|
if (!empty($arrayfields['t.lettering_code']['checked'])) { |
4012
|
|
|
print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center '); |
4013
|
|
|
} |
4014
|
|
|
// Hook fields |
4015
|
|
|
$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder); |
4016
|
|
|
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook |
4017
|
|
|
print $hookmanager->resPrint; |
4018
|
|
|
if (!empty($arrayfields['t.date_creation']['checked'])) { |
4019
|
|
|
print_liste_field_titre($arrayfields['t.date_creation']['label'], $_SERVER['PHP_SELF'], "t.date_creation", "", $param, '', $sortfield, $sortorder, 'center '); |
4020
|
|
|
} |
4021
|
|
|
if (!empty($arrayfields['t.tms']['checked'])) { |
4022
|
|
|
print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER['PHP_SELF'], "t.tms", "", $param, '', $sortfield, $sortorder, 'center '); |
4023
|
|
|
} |
4024
|
|
|
if (!empty($arrayfields['t.date_export']['checked'])) { |
4025
|
|
|
print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export,t.doc_date", "", $param, '', $sortfield, $sortorder, 'center '); |
4026
|
|
|
} |
4027
|
|
|
if (!empty($arrayfields['t.date_validated']['checked'])) { |
4028
|
|
|
print_liste_field_titre($arrayfields['t.date_validated']['label'], $_SERVER['PHP_SELF'], "t.date_validated,t.doc_date", "", $param, '', $sortfield, $sortorder, 'center '); |
4029
|
|
|
} |
4030
|
|
|
if (!empty($arrayfields['t.import_key']['checked'])) { |
4031
|
|
|
print_liste_field_titre($arrayfields['t.import_key']['label'], $_SERVER['PHP_SELF'], "t.import_key", "", $param, '', $sortfield, $sortorder, 'center '); |
4032
|
|
|
} |
4033
|
|
|
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
4034
|
|
|
print_liste_field_titre($selectedfields, $_SERVER['PHP_SELF'], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); |
4035
|
|
|
} |
4036
|
|
|
print "</tr>\n"; |
4037
|
|
|
|
4038
|
|
|
|
4039
|
|
|
$line = new BookKeepingLine($db); |
4040
|
|
|
|
4041
|
|
|
// Loop on record |
4042
|
|
|
// -------------------------------------------------------------------- |
4043
|
|
|
$i = 0; |
4044
|
|
|
$totalarray = array(); |
4045
|
|
|
$totalarray['nbfield'] = 0; |
4046
|
|
|
$total_debit = 0; |
4047
|
|
|
$total_credit = 0; |
4048
|
|
|
$totalarray['val'] = array(); |
4049
|
|
|
$totalarray['val']['totaldebit'] = 0; |
4050
|
|
|
$totalarray['val']['totalcredit'] = 0; |
4051
|
|
|
|
4052
|
|
|
while ($i < min($num, $limit)) { |
4053
|
|
|
$obj = $db->fetch_object($resql); |
4054
|
|
|
if (empty($obj)) { |
4055
|
|
|
break; // Should not happen |
4056
|
|
|
} |
4057
|
|
|
|
4058
|
|
|
$line->id = $obj->rowid; |
4059
|
|
|
$line->doc_date = $db->jdate($obj->doc_date); |
4060
|
|
|
$line->doc_type = $obj->doc_type; |
4061
|
|
|
$line->doc_ref = $obj->doc_ref; |
4062
|
|
|
$line->fk_doc = $obj->fk_doc; |
4063
|
|
|
$line->fk_docdet = $obj->fk_docdet; |
4064
|
|
|
$line->thirdparty_code = $obj->thirdparty_code; |
4065
|
|
|
$line->subledger_account = $obj->subledger_account; |
4066
|
|
|
$line->subledger_label = $obj->subledger_label; |
4067
|
|
|
$line->numero_compte = $obj->numero_compte; |
4068
|
|
|
$line->label_compte = $obj->label_compte; |
4069
|
|
|
$line->label_operation = $obj->label_operation; |
4070
|
|
|
$line->debit = $obj->debit; |
4071
|
|
|
$line->credit = $obj->credit; |
4072
|
|
|
$line->montant = $obj->amount; // deprecated |
4073
|
|
|
$line->amount = $obj->amount; |
4074
|
|
|
$line->sens = $obj->sens; |
4075
|
|
|
$line->lettering_code = $obj->lettering_code; |
4076
|
|
|
$line->fk_user_author = $obj->fk_user_author; |
4077
|
|
|
$line->import_key = $obj->import_key; |
4078
|
|
|
$line->code_journal = $obj->code_journal; |
4079
|
|
|
$line->journal_label = $obj->journal_label; |
4080
|
|
|
$line->piece_num = $obj->piece_num; |
4081
|
|
|
$line->date_creation = $db->jdate($obj->date_creation); |
4082
|
|
|
$line->date_modification = $db->jdate($obj->date_modification); |
4083
|
|
|
$line->date_export = $db->jdate($obj->date_export); |
4084
|
|
|
$line->date_validation = $db->jdate($obj->date_validation); |
4085
|
|
|
|
4086
|
|
|
$total_debit += $line->debit; |
4087
|
|
|
$total_credit += $line->credit; |
4088
|
|
|
|
4089
|
|
|
print '<tr class="oddeven">'; |
4090
|
|
|
// Action column |
4091
|
|
|
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
4092
|
|
|
print '<td class="nowraponall center">'; |
4093
|
|
|
if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined |
4094
|
|
|
$selected = 0; |
4095
|
|
|
if (in_array($line->id, $arrayofselected)) { |
4096
|
|
|
$selected = 1; |
4097
|
|
|
} |
4098
|
|
|
print '<input id="cb' . $line->id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $line->id . '"' . ($selected ? ' checked="checked"' : '') . ' />'; |
4099
|
|
|
} |
4100
|
|
|
print '</td>'; |
4101
|
|
|
if (!$i) { |
4102
|
|
|
$totalarray['nbfield']++; |
4103
|
|
|
} |
4104
|
|
|
} |
4105
|
|
|
|
4106
|
|
|
// Piece number |
4107
|
|
|
if (!empty($arrayfields['t.piece_num']['checked'])) { |
4108
|
|
|
print '<td>'; |
4109
|
|
|
$object->id = $line->id; |
4110
|
|
|
$object->piece_num = $line->piece_num; |
4111
|
|
|
print $object->getNomUrl(1, '', 0, '', 1); |
4112
|
|
|
print '</td>'; |
4113
|
|
|
if (!$i) { |
4114
|
|
|
$totalarray['nbfield']++; |
4115
|
|
|
} |
4116
|
|
|
} |
4117
|
|
|
|
4118
|
|
|
// Journal code |
4119
|
|
|
if (!empty($arrayfields['t.code_journal']['checked'])) { |
4120
|
|
|
$accountingjournal = new AccountingJournal($db); |
4121
|
|
|
$result = $accountingjournal->fetch('', $line->code_journal); |
4122
|
|
|
$journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal); |
4123
|
|
|
print '<td class="center tdoverflowmax150">' . $journaltoshow . '</td>'; |
4124
|
|
|
if (!$i) { |
4125
|
|
|
$totalarray['nbfield']++; |
4126
|
|
|
} |
4127
|
|
|
} |
4128
|
|
|
|
4129
|
|
|
// Document date |
4130
|
|
|
if (!empty($arrayfields['t.doc_date']['checked'])) { |
4131
|
|
|
print '<td class="center">' . dol_print_date($line->doc_date, 'day') . '</td>'; |
4132
|
|
|
if (!$i) { |
4133
|
|
|
$totalarray['nbfield']++; |
4134
|
|
|
} |
4135
|
|
|
} |
4136
|
|
|
|
4137
|
|
|
// Document ref |
4138
|
|
|
if (!empty($arrayfields['t.doc_ref']['checked'])) { |
4139
|
|
|
if ($line->doc_type == 'customer_invoice') { |
4140
|
|
|
$langs->loadLangs(array('bills')); |
4141
|
|
|
|
4142
|
|
|
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; |
4143
|
|
|
$objectstatic = new Facture($db); |
4144
|
|
|
$objectstatic->fetch($line->fk_doc); |
4145
|
|
|
//$modulepart = 'facture'; |
4146
|
|
|
|
4147
|
|
|
$filename = dol_sanitizeFileName($line->doc_ref); |
4148
|
|
|
$filedir = $conf->facture->dir_output . '/' . dol_sanitizeFileName($line->doc_ref); |
4149
|
|
|
$urlsource = $_SERVER['PHP_SELF'] . '?id=' . $objectstatic->id; |
4150
|
|
|
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); |
4151
|
|
|
} elseif ($line->doc_type == 'supplier_invoice') { |
4152
|
|
|
$langs->loadLangs(array('bills')); |
4153
|
|
|
|
4154
|
|
|
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; |
4155
|
|
|
$objectstatic = new FactureFournisseur($db); |
4156
|
|
|
$objectstatic->fetch($line->fk_doc); |
4157
|
|
|
//$modulepart = 'invoice_supplier'; |
4158
|
|
|
|
4159
|
|
|
$filename = dol_sanitizeFileName($line->doc_ref); |
4160
|
|
|
$filedir = $conf->fournisseur->facture->dir_output . '/' . get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart) . dol_sanitizeFileName($line->doc_ref); |
|
|
|
|
4161
|
|
|
$subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart) . dol_sanitizeFileName($line->doc_ref); |
4162
|
|
|
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir); |
4163
|
|
|
} elseif ($line->doc_type == 'expense_report') { |
4164
|
|
|
$langs->loadLangs(array('trips')); |
4165
|
|
|
|
4166
|
|
|
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; |
4167
|
|
|
$objectstatic = new ExpenseReport($db); |
4168
|
|
|
$objectstatic->fetch($line->fk_doc); |
4169
|
|
|
//$modulepart = 'expensereport'; |
4170
|
|
|
|
4171
|
|
|
$filename = dol_sanitizeFileName($line->doc_ref); |
4172
|
|
|
$filedir = $conf->expensereport->dir_output . '/' . dol_sanitizeFileName($line->doc_ref); |
4173
|
|
|
$urlsource = $_SERVER['PHP_SELF'] . '?id=' . $objectstatic->id; |
4174
|
|
|
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); |
4175
|
|
|
} elseif ($line->doc_type == 'bank') { |
4176
|
|
|
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; |
4177
|
|
|
$objectstatic = new AccountLine($db); |
4178
|
|
|
$objectstatic->fetch($line->fk_doc); |
4179
|
|
|
} else { |
4180
|
|
|
// Other type |
4181
|
|
|
} |
4182
|
|
|
|
4183
|
|
|
$labeltoshow = ''; |
4184
|
|
|
$labeltoshowalt = ''; |
4185
|
|
|
if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') { |
4186
|
|
|
$labeltoshow .= $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); |
4187
|
|
|
$labeltoshow .= $documentlink; |
4188
|
|
|
$labeltoshowalt .= $objectstatic->ref; |
4189
|
|
|
} elseif ($line->doc_type == 'bank') { |
4190
|
|
|
$labeltoshow .= $objectstatic->getNomUrl(1); |
4191
|
|
|
$labeltoshowalt .= $objectstatic->ref; |
4192
|
|
|
$bank_ref = strstr($line->doc_ref, '-'); |
4193
|
|
|
$labeltoshow .= " " . $bank_ref; |
4194
|
|
|
$labeltoshowalt .= " " . $bank_ref; |
4195
|
|
|
} else { |
4196
|
|
|
$labeltoshow .= $line->doc_ref; |
4197
|
|
|
$labeltoshowalt .= $line->doc_ref; |
4198
|
|
|
} |
4199
|
|
|
|
4200
|
|
|
print '<td class="nowraponall tdoverflowmax250" title="' . dol_escape_htmltag($labeltoshowalt) . '">'; |
4201
|
|
|
print $labeltoshow; |
4202
|
|
|
print "</td>\n"; |
4203
|
|
|
if (!$i) { |
4204
|
|
|
$totalarray['nbfield']++; |
4205
|
|
|
} |
4206
|
|
|
} |
4207
|
|
|
|
4208
|
|
|
// Account number |
4209
|
|
|
if (!empty($arrayfields['t.numero_compte']['checked'])) { |
4210
|
|
|
print '<td>' . length_accountg($line->numero_compte) . '</td>'; |
4211
|
|
|
if (!$i) { |
4212
|
|
|
$totalarray['nbfield']++; |
4213
|
|
|
} |
4214
|
|
|
} |
4215
|
|
|
|
4216
|
|
|
// Subledger account |
4217
|
|
|
if (!empty($arrayfields['t.subledger_account']['checked'])) { |
4218
|
|
|
print '<td>' . length_accounta($line->subledger_account) . '</td>'; |
4219
|
|
|
if (!$i) { |
4220
|
|
|
$totalarray['nbfield']++; |
4221
|
|
|
} |
4222
|
|
|
} |
4223
|
|
|
|
4224
|
|
|
// Label operation |
4225
|
|
|
if (!empty($arrayfields['t.label_operation']['checked'])) { |
4226
|
|
|
print '<td class="small tdoverflowmax200" title="' . dol_escape_htmltag($line->label_operation) . '">' . dol_escape_htmltag($line->label_operation) . '</td>'; |
4227
|
|
|
if (!$i) { |
4228
|
|
|
$totalarray['nbfield']++; |
4229
|
|
|
} |
4230
|
|
|
} |
4231
|
|
|
|
4232
|
|
|
// Amount debit |
4233
|
|
|
if (!empty($arrayfields['t.debit']['checked'])) { |
4234
|
|
|
print '<td class="right nowraponall amount">' . ($line->debit != 0 ? price($line->debit) : '') . '</td>'; |
4235
|
|
|
if (!$i) { |
4236
|
|
|
$totalarray['nbfield']++; |
4237
|
|
|
} |
4238
|
|
|
if (!$i) { |
4239
|
|
|
$totalarray['pos'][$totalarray['nbfield']] = 'totaldebit'; |
4240
|
|
|
} |
4241
|
|
|
$totalarray['val']['totaldebit'] += $line->debit; |
4242
|
|
|
} |
4243
|
|
|
|
4244
|
|
|
// Amount credit |
4245
|
|
|
if (!empty($arrayfields['t.credit']['checked'])) { |
4246
|
|
|
print '<td class="right nowraponall amount">' . ($line->credit != 0 ? price($line->credit) : '') . '</td>'; |
4247
|
|
|
if (!$i) { |
4248
|
|
|
$totalarray['nbfield']++; |
4249
|
|
|
} |
4250
|
|
|
if (!$i) { |
4251
|
|
|
$totalarray['pos'][$totalarray['nbfield']] = 'totalcredit'; |
4252
|
|
|
} |
4253
|
|
|
$totalarray['val']['totalcredit'] += $line->credit; |
4254
|
|
|
} |
4255
|
|
|
|
4256
|
|
|
// Lettering code |
4257
|
|
|
if (!empty($arrayfields['t.lettering_code']['checked'])) { |
4258
|
|
|
print '<td class="center">' . $line->lettering_code . '</td>'; |
4259
|
|
|
if (!$i) { |
4260
|
|
|
$totalarray['nbfield']++; |
4261
|
|
|
} |
4262
|
|
|
} |
4263
|
|
|
|
4264
|
|
|
// Fields from hook |
4265
|
|
|
$parameters = array('arrayfields' => $arrayfields, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray); |
4266
|
|
|
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook |
4267
|
|
|
print $hookmanager->resPrint; |
4268
|
|
|
|
4269
|
|
|
// Creation operation date |
4270
|
|
|
if (!empty($arrayfields['t.date_creation']['checked'])) { |
4271
|
|
|
print '<td class="center">' . dol_print_date($line->date_creation, 'dayhour', 'tzuserrel') . '</td>'; |
4272
|
|
|
if (!$i) { |
4273
|
|
|
$totalarray['nbfield']++; |
4274
|
|
|
} |
4275
|
|
|
} |
4276
|
|
|
|
4277
|
|
|
// Modification operation date |
4278
|
|
|
if (!empty($arrayfields['t.tms']['checked'])) { |
4279
|
|
|
print '<td class="center">' . dol_print_date($line->date_modification, 'dayhour', 'tzuserrel') . '</td>'; |
4280
|
|
|
if (!$i) { |
4281
|
|
|
$totalarray['nbfield']++; |
4282
|
|
|
} |
4283
|
|
|
} |
4284
|
|
|
|
4285
|
|
|
// Exported operation date |
4286
|
|
|
if (!empty($arrayfields['t.date_export']['checked'])) { |
4287
|
|
|
print '<td class="center nowraponall">' . dol_print_date($line->date_export, 'dayhour', 'tzuserrel') . '</td>'; |
4288
|
|
|
if (!$i) { |
4289
|
|
|
$totalarray['nbfield']++; |
4290
|
|
|
} |
4291
|
|
|
} |
4292
|
|
|
|
4293
|
|
|
// Validated operation date |
4294
|
|
|
if (!empty($arrayfields['t.date_validated']['checked'])) { |
4295
|
|
|
print '<td class="center nowraponall">' . dol_print_date($line->date_validation, 'dayhour', 'tzuserrel') . '</td>'; |
4296
|
|
|
if (!$i) { |
4297
|
|
|
$totalarray['nbfield']++; |
4298
|
|
|
} |
4299
|
|
|
} |
4300
|
|
|
|
4301
|
|
|
if (!empty($arrayfields['t.import_key']['checked'])) { |
4302
|
|
|
print '<td class="tdoverflowmax100">' . $obj->import_key . "</td>\n"; |
4303
|
|
|
if (!$i) { |
4304
|
|
|
$totalarray['nbfield']++; |
4305
|
|
|
} |
4306
|
|
|
} |
4307
|
|
|
|
4308
|
|
|
// Action column |
4309
|
|
|
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
4310
|
|
|
print '<td class="nowraponall center">'; |
4311
|
|
|
if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined |
4312
|
|
|
$selected = 0; |
4313
|
|
|
if (in_array($line->id, $arrayofselected)) { |
4314
|
|
|
$selected = 1; |
4315
|
|
|
} |
4316
|
|
|
print '<input id="cb' . $line->id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $line->id . '"' . ($selected ? ' checked="checked"' : '') . ' />'; |
4317
|
|
|
} |
4318
|
|
|
print '</td>'; |
4319
|
|
|
if (!$i) { |
4320
|
|
|
$totalarray['nbfield']++; |
4321
|
|
|
} |
4322
|
|
|
} |
4323
|
|
|
|
4324
|
|
|
|
4325
|
|
|
print "</tr>\n"; |
4326
|
|
|
|
4327
|
|
|
$i++; |
4328
|
|
|
} |
4329
|
|
|
|
4330
|
|
|
// Show total line |
4331
|
|
|
include DOL_DOCUMENT_ROOT . '/core/tpl/list_print_total.tpl.php'; |
4332
|
|
|
|
4333
|
|
|
// If no record found |
4334
|
|
|
if ($num == 0) { |
4335
|
|
|
$colspan = 1; |
4336
|
|
|
foreach ($arrayfields as $key => $val) { |
4337
|
|
|
if (!empty($val['checked'])) { |
4338
|
|
|
$colspan++; |
4339
|
|
|
} |
4340
|
|
|
} |
4341
|
|
|
print '<tr><td colspan="' . $colspan . '"><span class="opacitymedium">' . $langs->trans("NoRecordFound") . '</span></td></tr>'; |
4342
|
|
|
} |
4343
|
|
|
|
4344
|
|
|
$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql); |
4345
|
|
|
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
4346
|
|
|
print $hookmanager->resPrint; |
4347
|
|
|
|
4348
|
|
|
print "</table>"; |
4349
|
|
|
print '</div>'; |
4350
|
|
|
|
4351
|
|
|
print '</form>'; |
4352
|
|
|
|
4353
|
|
|
// End of page |
4354
|
|
|
llxFooter(); |
4355
|
|
|
|
4356
|
|
|
$db->close(); |
4357
|
|
|
} |
4358
|
|
|
|
4359
|
|
|
/** |
4360
|
|
|
* \file htdocs/accountancy/bookkeeping/listbyaccount.php |
4361
|
|
|
* \ingroup Accountancy (Double entries) |
4362
|
|
|
* \brief List operation of ledger ordered by account number |
4363
|
|
|
*/ |
4364
|
|
|
public function listbyaccount() |
4365
|
|
|
{ |
4366
|
|
|
global $conf; |
4367
|
|
|
global $db; |
4368
|
|
|
global $user; |
4369
|
|
|
global $hookmanager; |
4370
|
|
|
global $user; |
4371
|
|
|
global $menumanager; |
4372
|
|
|
global $langs; |
4373
|
|
|
|
4374
|
|
|
// Load translation files required by the page |
4375
|
|
|
$langs->loadLangs(array("accountancy", "compta")); |
4376
|
|
|
|
4377
|
|
|
$action = GETPOST('action', 'aZ09'); |
4378
|
|
|
$socid = GETPOSTINT('socid'); |
4379
|
|
|
$massaction = GETPOST('massaction', 'alpha'); |
4380
|
|
|
$confirm = GETPOST('confirm', 'alpha'); |
4381
|
|
|
$toselect = GETPOST('toselect', 'array'); |
4382
|
|
|
$type = GETPOST('type', 'alpha'); |
4383
|
|
|
if ($type == 'sub') { |
4384
|
|
|
$context_default = 'bookkeepingbysubaccountlist'; |
4385
|
|
|
} else { |
4386
|
|
|
$context_default = 'bookkeepingbyaccountlist'; |
4387
|
|
|
} |
4388
|
|
|
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : $context_default; |
4389
|
|
|
$search_date_startyear = GETPOSTINT('search_date_startyear'); |
4390
|
|
|
$search_date_startmonth = GETPOSTINT('search_date_startmonth'); |
4391
|
|
|
$search_date_startday = GETPOSTINT('search_date_startday'); |
4392
|
|
|
$search_date_endyear = GETPOSTINT('search_date_endyear'); |
4393
|
|
|
$search_date_endmonth = GETPOSTINT('search_date_endmonth'); |
4394
|
|
|
$search_date_endday = GETPOSTINT('search_date_endday'); |
4395
|
|
|
$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); |
4396
|
|
|
$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); |
4397
|
|
|
$search_doc_date = dol_mktime(0, 0, 0, GETPOSTINT('doc_datemonth'), GETPOSTINT('doc_dateday'), GETPOSTINT('doc_dateyear')); |
4398
|
|
|
$search_date_export_startyear = GETPOSTINT('search_date_export_startyear'); |
4399
|
|
|
$search_date_export_startmonth = GETPOSTINT('search_date_export_startmonth'); |
4400
|
|
|
$search_date_export_startday = GETPOSTINT('search_date_export_startday'); |
4401
|
|
|
$search_date_export_endyear = GETPOSTINT('search_date_export_endyear'); |
4402
|
|
|
$search_date_export_endmonth = GETPOSTINT('search_date_export_endmonth'); |
4403
|
|
|
$search_date_export_endday = GETPOSTINT('search_date_export_endday'); |
4404
|
|
|
$search_date_export_start = dol_mktime(0, 0, 0, $search_date_export_startmonth, $search_date_export_startday, $search_date_export_startyear); |
4405
|
|
|
$search_date_export_end = dol_mktime(23, 59, 59, $search_date_export_endmonth, $search_date_export_endday, $search_date_export_endyear); |
4406
|
|
|
$search_date_validation_startyear = GETPOSTINT('search_date_validation_startyear'); |
4407
|
|
|
$search_date_validation_startmonth = GETPOSTINT('search_date_validation_startmonth'); |
4408
|
|
|
$search_date_validation_startday = GETPOSTINT('search_date_validation_startday'); |
4409
|
|
|
$search_date_validation_endyear = GETPOSTINT('search_date_validation_endyear'); |
4410
|
|
|
$search_date_validation_endmonth = GETPOSTINT('search_date_validation_endmonth'); |
4411
|
|
|
$search_date_validation_endday = GETPOSTINT('search_date_validation_endday'); |
4412
|
|
|
$search_date_validation_start = dol_mktime(0, 0, 0, $search_date_validation_startmonth, $search_date_validation_startday, $search_date_validation_startyear); |
4413
|
|
|
$search_date_validation_end = dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear); |
4414
|
|
|
$search_import_key = GETPOST("search_import_key", 'alpha'); |
4415
|
|
|
|
4416
|
|
|
$search_account_category = GETPOSTINT('search_account_category'); |
4417
|
|
|
|
4418
|
|
|
$search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); |
4419
|
|
|
if ($search_accountancy_code_start == - 1) { |
4420
|
|
|
$search_accountancy_code_start = ''; |
4421
|
|
|
} |
4422
|
|
|
$search_accountancy_code_end = GETPOST('search_accountancy_code_end', 'alpha'); |
4423
|
|
|
if ($search_accountancy_code_end == - 1) { |
4424
|
|
|
$search_accountancy_code_end = ''; |
4425
|
|
|
} |
4426
|
|
|
$search_doc_ref = GETPOST('search_doc_ref', 'alpha'); |
4427
|
|
|
$search_label_operation = GETPOST('search_label_operation', 'alpha'); |
4428
|
|
|
$search_mvt_num = GETPOSTINT('search_mvt_num'); |
4429
|
|
|
$search_direction = GETPOST('search_direction', 'alpha'); |
4430
|
|
|
$search_ledger_code = GETPOST('search_ledger_code', 'array'); |
4431
|
|
|
$search_debit = GETPOST('search_debit', 'alpha'); |
4432
|
|
|
$search_credit = GETPOST('search_credit', 'alpha'); |
4433
|
|
|
$search_lettering_code = GETPOST('search_lettering_code', 'alpha'); |
4434
|
|
|
$search_not_reconciled = GETPOST('search_not_reconciled', 'alpha'); |
4435
|
|
|
|
4436
|
|
|
if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_delmvt")) { |
4437
|
|
|
$action = 'delbookkeepingyear'; |
4438
|
|
|
} |
4439
|
|
|
|
4440
|
|
|
// Load variable for pagination |
4441
|
|
|
$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION', $conf->liste_limit); |
4442
|
|
|
$sortfield = GETPOST('sortfield', 'aZ09comma'); |
4443
|
|
|
$sortorder = GETPOST('sortorder', 'aZ09comma'); |
4444
|
|
|
$optioncss = GETPOST('optioncss', 'alpha'); |
4445
|
|
|
$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); |
4446
|
|
|
if (empty($page) || $page < 0) { |
4447
|
|
|
$page = 0; |
4448
|
|
|
} |
4449
|
|
|
$offset = $limit * $page; |
4450
|
|
|
$pageprev = $page - 1; |
4451
|
|
|
$pagenext = $page + 1; |
4452
|
|
|
if ($sortorder == "") { |
4453
|
|
|
$sortorder = "ASC"; |
4454
|
|
|
} |
4455
|
|
|
if ($sortfield == "") { |
4456
|
|
|
$sortfield = "t.doc_date,t.rowid"; |
4457
|
|
|
} |
4458
|
|
|
|
4459
|
|
|
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
4460
|
|
|
$object = new BookKeeping($db); |
4461
|
|
|
$formfile = new FormFile($db); |
4462
|
|
|
$hookmanager->initHooks(array($context_default)); |
4463
|
|
|
|
4464
|
|
|
$formaccounting = new FormAccounting($db); |
4465
|
|
|
$form = new Form($db); |
4466
|
|
|
|
4467
|
|
|
if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('search_date_startday') && !GETPOSTISSET('search_date_startmonth') && !GETPOSTISSET('search_date_starthour')) { |
4468
|
|
|
$sql = "SELECT date_start, date_end from " . MAIN_DB_PREFIX . "accounting_fiscalyear "; |
4469
|
|
|
$sql .= " where date_start < '" . $db->idate(dol_now()) . "' and date_end > '" . $db->idate(dol_now()) . "'"; |
4470
|
|
|
$sql .= $db->plimit(1); |
4471
|
|
|
$res = $db->query($sql); |
4472
|
|
|
|
4473
|
|
|
if ($res->num_rows > 0) { |
4474
|
|
|
$fiscalYear = $db->fetch_object($res); |
4475
|
|
|
$search_date_start = strtotime($fiscalYear->date_start); |
4476
|
|
|
$search_date_end = strtotime($fiscalYear->date_end); |
4477
|
|
|
} else { |
4478
|
|
|
$month_start = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1); |
4479
|
|
|
$year_start = dol_print_date(dol_now(), '%Y'); |
4480
|
|
|
if (dol_print_date(dol_now(), '%m') < $month_start) { |
4481
|
|
|
$year_start--; // If current month is lower that starting fiscal month, we start last year |
4482
|
|
|
} |
4483
|
|
|
$year_end = $year_start + 1; |
4484
|
|
|
$month_end = $month_start - 1; |
4485
|
|
|
if ($month_end < 1) { |
4486
|
|
|
$month_end = 12; |
4487
|
|
|
$year_end--; |
4488
|
|
|
} |
4489
|
|
|
$search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start); |
4490
|
|
|
$search_date_end = dol_get_last_day($year_end, $month_end); |
4491
|
|
|
} |
4492
|
|
|
} |
4493
|
|
|
|
4494
|
|
|
$arrayfields = array( |
4495
|
|
|
// 't.subledger_account'=>array('label'=>$langs->trans("SubledgerAccount"), 'checked'=>1), |
4496
|
|
|
't.piece_num' => array('label' => $langs->trans("TransactionNumShort"), 'checked' => 1), |
4497
|
|
|
't.code_journal' => array('label' => $langs->trans("Codejournal"), 'checked' => 1), |
4498
|
|
|
't.doc_date' => array('label' => $langs->trans("Docdate"), 'checked' => 1), |
4499
|
|
|
't.doc_ref' => array('label' => $langs->trans("Piece"), 'checked' => 1), |
4500
|
|
|
't.label_operation' => array('label' => $langs->trans("Label"), 'checked' => 1), |
4501
|
|
|
't.lettering_code' => array('label' => $langs->trans("Lettering"), 'checked' => 1), |
4502
|
|
|
't.debit' => array('label' => $langs->trans("AccountingDebit"), 'checked' => 1), |
4503
|
|
|
't.credit' => array('label' => $langs->trans("AccountingCredit"), 'checked' => 1), |
4504
|
|
|
't.balance' => array('label' => $langs->trans("Balance"), 'checked' => 1), |
4505
|
|
|
't.date_export' => array('label' => $langs->trans("DateExport"), 'checked' => -1), |
4506
|
|
|
't.date_validated' => array('label' => $langs->trans("DateValidation"), 'checked' => -1, 'enabled' => !getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")), |
4507
|
|
|
't.import_key' => array('label' => $langs->trans("ImportId"), 'checked' => -1, 'position' => 1100), |
4508
|
|
|
); |
4509
|
|
|
|
4510
|
|
|
if (!getDolGlobalString('ACCOUNTING_ENABLE_LETTERING')) { |
4511
|
|
|
unset($arrayfields['t.lettering_code']); |
4512
|
|
|
} |
4513
|
|
|
|
4514
|
|
|
if ($search_date_start && empty($search_date_startyear)) { |
4515
|
|
|
$tmparray = dol_getdate($search_date_start); |
4516
|
|
|
$search_date_startyear = $tmparray['year']; |
4517
|
|
|
$search_date_startmonth = $tmparray['mon']; |
4518
|
|
|
$search_date_startday = $tmparray['mday']; |
4519
|
|
|
} |
4520
|
|
|
if ($search_date_end && empty($search_date_endyear)) { |
4521
|
|
|
$tmparray = dol_getdate($search_date_end); |
4522
|
|
|
$search_date_endyear = $tmparray['year']; |
4523
|
|
|
$search_date_endmonth = $tmparray['mon']; |
4524
|
|
|
$search_date_endday = $tmparray['mday']; |
4525
|
|
|
} |
4526
|
|
|
|
4527
|
|
|
if (!isModEnabled('accounting')) { |
4528
|
|
|
accessforbidden(); |
4529
|
|
|
} |
4530
|
|
|
if ($user->socid > 0) { |
4531
|
|
|
accessforbidden(); |
4532
|
|
|
} |
4533
|
|
|
if (!$user->hasRight('accounting', 'mouvements', 'lire')) { |
4534
|
|
|
accessforbidden(); |
4535
|
|
|
} |
4536
|
|
|
|
4537
|
|
|
$error = 0; |
4538
|
|
|
|
4539
|
|
|
|
4540
|
|
|
/* |
4541
|
|
|
* Action |
4542
|
|
|
*/ |
4543
|
|
|
|
4544
|
|
|
$param = ''; |
4545
|
|
|
|
4546
|
|
|
if (GETPOST('cancel', 'alpha')) { |
4547
|
|
|
$action = 'list'; |
4548
|
|
|
$massaction = ''; |
4549
|
|
|
} |
4550
|
|
|
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'preunletteringauto' && $massaction != 'preunletteringmanual' && $massaction != 'predeletebookkeepingwriting') { |
4551
|
|
|
$massaction = ''; |
4552
|
|
|
} |
4553
|
|
|
|
4554
|
|
|
$parameters = array('socid' => $socid); |
4555
|
|
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
4556
|
|
|
if ($reshook < 0) { |
4557
|
|
|
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
4558
|
|
|
} |
4559
|
|
|
|
4560
|
|
|
if (empty($reshook)) { |
4561
|
|
|
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php'; |
4562
|
|
|
|
4563
|
|
|
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers |
4564
|
|
|
$search_doc_date = ''; |
4565
|
|
|
$search_account_category = ''; |
4566
|
|
|
$search_accountancy_code_start = ''; |
4567
|
|
|
$search_accountancy_code_end = ''; |
4568
|
|
|
$search_label_account = ''; |
4569
|
|
|
$search_doc_ref = ''; |
4570
|
|
|
$search_label_operation = ''; |
4571
|
|
|
$search_mvt_num = ''; |
4572
|
|
|
$search_direction = ''; |
4573
|
|
|
$search_ledger_code = array(); |
4574
|
|
|
$search_date_start = ''; |
4575
|
|
|
$search_date_end = ''; |
4576
|
|
|
$search_date_startyear = ''; |
4577
|
|
|
$search_date_startmonth = ''; |
4578
|
|
|
$search_date_startday = ''; |
4579
|
|
|
$search_date_endyear = ''; |
4580
|
|
|
$search_date_endmonth = ''; |
4581
|
|
|
$search_date_endday = ''; |
4582
|
|
|
$search_date_export_start = ''; |
4583
|
|
|
$search_date_export_end = ''; |
4584
|
|
|
$search_date_export_startyear = ''; |
4585
|
|
|
$search_date_export_startmonth = ''; |
4586
|
|
|
$search_date_export_startday = ''; |
4587
|
|
|
$search_date_export_endyear = ''; |
4588
|
|
|
$search_date_export_endmonth = ''; |
4589
|
|
|
$search_date_export_endday = ''; |
4590
|
|
|
$search_date_validation_start = ''; |
4591
|
|
|
$search_date_validation_end = ''; |
4592
|
|
|
$search_date_validation_startyear = ''; |
4593
|
|
|
$search_date_validation_startmonth = ''; |
4594
|
|
|
$search_date_validation_startday = ''; |
4595
|
|
|
$search_date_validation_endyear = ''; |
4596
|
|
|
$search_date_validation_endmonth = ''; |
4597
|
|
|
$search_date_validation_endday = ''; |
4598
|
|
|
$search_lettering_code = ''; |
4599
|
|
|
$search_debit = ''; |
4600
|
|
|
$search_credit = ''; |
4601
|
|
|
$search_not_reconciled = ''; |
4602
|
|
|
$search_import_key = ''; |
4603
|
|
|
$toselect = array(); |
4604
|
|
|
} |
4605
|
|
|
|
4606
|
|
|
// Must be after the remove filter action, before the export. |
4607
|
|
|
$filter = array(); |
4608
|
|
|
|
4609
|
|
|
if (!empty($search_date_start)) { |
4610
|
|
|
$filter['t.doc_date>='] = $search_date_start; |
4611
|
|
|
$param .= '&search_date_startmonth=' . $search_date_startmonth . '&search_date_startday=' . $search_date_startday . '&search_date_startyear=' . $search_date_startyear; |
4612
|
|
|
} |
4613
|
|
|
if (!empty($search_date_end)) { |
4614
|
|
|
$filter['t.doc_date<='] = $search_date_end; |
4615
|
|
|
$param .= '&search_date_endmonth=' . $search_date_endmonth . '&search_date_endday=' . $search_date_endday . '&search_date_endyear=' . $search_date_endyear; |
4616
|
|
|
} |
4617
|
|
|
if (!empty($search_doc_date)) { |
4618
|
|
|
$filter['t.doc_date'] = $search_doc_date; |
4619
|
|
|
$param .= '&doc_datemonth=' . GETPOSTINT('doc_datemonth') . '&doc_dateday=' . GETPOSTINT('doc_dateday') . '&doc_dateyear=' . GETPOSTINT('doc_dateyear'); |
4620
|
|
|
} |
4621
|
|
|
if ($search_account_category != '-1' && !empty($search_account_category)) { |
4622
|
|
|
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancycategory.class.php'; |
4623
|
|
|
$accountingcategory = new AccountancyCategory($db); |
4624
|
|
|
|
4625
|
|
|
$listofaccountsforgroup = $accountingcategory->getCptsCat(0, 'fk_accounting_category = ' . ((int) $search_account_category)); |
4626
|
|
|
$listofaccountsforgroup2 = array(); |
4627
|
|
|
if (is_array($listofaccountsforgroup)) { |
4628
|
|
|
foreach ($listofaccountsforgroup as $tmpval) { |
4629
|
|
|
$listofaccountsforgroup2[] = "'" . $db->escape($tmpval['id']) . "'"; |
4630
|
|
|
} |
4631
|
|
|
} |
4632
|
|
|
$filter['t.search_accounting_code_in'] = implode(',', $listofaccountsforgroup2); |
4633
|
|
|
$param .= '&search_account_category=' . urlencode((string) ($search_account_category)); |
4634
|
|
|
} |
4635
|
|
|
if (!empty($search_accountancy_code_start)) { |
4636
|
|
|
if ($type == 'sub') { |
4637
|
|
|
$filter['t.subledger_account>='] = $search_accountancy_code_start; |
4638
|
|
|
} else { |
4639
|
|
|
$filter['t.numero_compte>='] = $search_accountancy_code_start; |
4640
|
|
|
} |
4641
|
|
|
$param .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start); |
4642
|
|
|
} |
4643
|
|
|
if (!empty($search_accountancy_code_end)) { |
4644
|
|
|
if ($type == 'sub') { |
4645
|
|
|
$filter['t.subledger_account<='] = $search_accountancy_code_end; |
4646
|
|
|
} else { |
4647
|
|
|
$filter['t.numero_compte<='] = $search_accountancy_code_end; |
4648
|
|
|
} |
4649
|
|
|
$param .= '&search_accountancy_code_end=' . urlencode($search_accountancy_code_end); |
4650
|
|
|
} |
4651
|
|
|
if (!empty($search_label_account)) { |
4652
|
|
|
$filter['t.label_compte'] = $search_label_account; |
4653
|
|
|
$param .= '&search_label_compte=' . urlencode($search_label_account); |
4654
|
|
|
} |
4655
|
|
|
if (!empty($search_mvt_num)) { |
4656
|
|
|
$filter['t.piece_num'] = $search_mvt_num; |
4657
|
|
|
$param .= '&search_mvt_num=' . urlencode((string) ($search_mvt_num)); |
4658
|
|
|
} |
4659
|
|
|
if (!empty($search_doc_ref)) { |
4660
|
|
|
$filter['t.doc_ref'] = $search_doc_ref; |
4661
|
|
|
$param .= '&search_doc_ref=' . urlencode($search_doc_ref); |
4662
|
|
|
} |
4663
|
|
|
if (!empty($search_label_operation)) { |
4664
|
|
|
$filter['t.label_operation'] = $search_label_operation; |
4665
|
|
|
$param .= '&search_label_operation=' . urlencode($search_label_operation); |
4666
|
|
|
} |
4667
|
|
|
if (!empty($search_direction)) { |
4668
|
|
|
$filter['t.sens'] = $search_direction; |
4669
|
|
|
$param .= '&search_direction=' . urlencode($search_direction); |
4670
|
|
|
} |
4671
|
|
|
if (!empty($search_ledger_code)) { |
4672
|
|
|
$filter['t.code_journal'] = $search_ledger_code; |
4673
|
|
|
foreach ($search_ledger_code as $code) { |
4674
|
|
|
$param .= '&search_ledger_code[]=' . urlencode($code); |
4675
|
|
|
} |
4676
|
|
|
} |
4677
|
|
|
if (!empty($search_lettering_code)) { |
4678
|
|
|
$filter['t.lettering_code'] = $search_lettering_code; |
4679
|
|
|
$param .= '&search_lettering_code=' . urlencode($search_lettering_code); |
4680
|
|
|
} |
4681
|
|
|
if (!empty($search_debit)) { |
4682
|
|
|
$filter['t.debit'] = $search_debit; |
4683
|
|
|
$param .= '&search_debit=' . urlencode($search_debit); |
4684
|
|
|
} |
4685
|
|
|
if (!empty($search_credit)) { |
4686
|
|
|
$filter['t.credit'] = $search_credit; |
4687
|
|
|
$param .= '&search_credit=' . urlencode($search_credit); |
4688
|
|
|
} |
4689
|
|
|
if (!empty($search_not_reconciled)) { |
4690
|
|
|
$filter['t.reconciled_option'] = $search_not_reconciled; |
4691
|
|
|
$param .= '&search_not_reconciled=' . urlencode($search_not_reconciled); |
4692
|
|
|
} |
4693
|
|
|
if (!empty($search_date_export_start)) { |
4694
|
|
|
$filter['t.date_export>='] = $search_date_export_start; |
4695
|
|
|
$param .= '&search_date_export_startmonth=' . $search_date_export_startmonth . '&search_date_export_startday=' . $search_date_export_startday . '&search_date_export_startyear=' . $search_date_export_startyear; |
4696
|
|
|
} |
4697
|
|
|
if (!empty($search_date_export_end)) { |
4698
|
|
|
$filter['t.date_export<='] = $search_date_export_end; |
4699
|
|
|
$param .= '&search_date_export_endmonth=' . $search_date_export_endmonth . '&search_date_export_endday=' . $search_date_export_endday . '&search_date_export_endyear=' . $search_date_export_endyear; |
4700
|
|
|
} |
4701
|
|
|
if (!empty($search_date_validation_start)) { |
4702
|
|
|
$filter['t.date_validated>='] = $search_date_validation_start; |
4703
|
|
|
$param .= '&search_date_validation_startmonth=' . $search_date_validation_startmonth . '&search_date_validation_startday=' . $search_date_validation_startday . '&search_date_validation_startyear=' . $search_date_validation_startyear; |
4704
|
|
|
} |
4705
|
|
|
if (!empty($search_date_validation_end)) { |
4706
|
|
|
$filter['t.date_validated<='] = $search_date_validation_end; |
4707
|
|
|
$param .= '&search_date_validation_endmonth=' . $search_date_validation_endmonth . '&search_date_validation_endday=' . $search_date_validation_endday . '&search_date_validation_endyear=' . $search_date_validation_endyear; |
4708
|
|
|
} |
4709
|
|
|
if (!empty($search_import_key)) { |
4710
|
|
|
$filter['t.import_key'] = $search_import_key; |
4711
|
|
|
$param .= '&search_import_key=' . urlencode($search_import_key); |
4712
|
|
|
} |
4713
|
|
|
// param with type of list |
4714
|
|
|
$url_param = substr($param, 1); // remove first "&" |
4715
|
|
|
if (!empty($type)) { |
4716
|
|
|
$param = '&type=' . $type . $param; |
4717
|
|
|
} |
4718
|
|
|
|
4719
|
|
|
//if ($action == 'delbookkeepingyearconfirm' && $user->hasRight('accounting', 'mouvements', 'supprimer')_tous) { |
4720
|
|
|
// $delmonth = GETPOST('delmonth', 'int'); |
4721
|
|
|
// $delyear = GETPOST('delyear', 'int'); |
4722
|
|
|
// if ($delyear == -1) { |
4723
|
|
|
// $delyear = 0; |
4724
|
|
|
// } |
4725
|
|
|
// $deljournal = GETPOST('deljournal', 'alpha'); |
4726
|
|
|
// if ($deljournal == -1) { |
4727
|
|
|
// $deljournal = 0; |
4728
|
|
|
// } |
4729
|
|
|
// |
4730
|
|
|
// if (!empty($delmonth) || !empty($delyear) || !empty($deljournal)) { |
4731
|
|
|
// $result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0)); |
4732
|
|
|
// if ($result < 0) { |
4733
|
|
|
// setEventMessages($object->error, $object->errors, 'errors'); |
4734
|
|
|
// } else { |
4735
|
|
|
// setEventMessages("RecordDeleted", null, 'mesgs'); |
4736
|
|
|
// } |
4737
|
|
|
// |
4738
|
|
|
// // Make a redirect to avoid to launch the delete later after a back button |
4739
|
|
|
// header("Location: ".$_SERVER['PHP_SELF'].($param ? '?'.$param : '')); |
4740
|
|
|
// exit; |
4741
|
|
|
// } else { |
4742
|
|
|
// setEventMessages("NoRecordDeleted", null, 'warnings'); |
4743
|
|
|
// } |
4744
|
|
|
//} |
4745
|
|
|
|
4746
|
|
|
// Mass actions |
4747
|
|
|
$objectclass = 'Bookkeeping'; |
4748
|
|
|
$objectlabel = 'Bookkeeping'; |
4749
|
|
|
$permissiontoread = $user->hasRight('societe', 'lire'); |
4750
|
|
|
$permissiontodelete = $user->hasRight('societe', 'supprimer'); |
4751
|
|
|
$permissiontoadd = $user->hasRight('societe', 'creer'); |
4752
|
|
|
$uploaddir = $conf->societe->dir_output; |
4753
|
|
|
include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php'; |
4754
|
|
|
|
4755
|
|
|
if (!$error && $action == 'deletebookkeepingwriting' && $confirm == "yes" && $user->hasRight('accounting', 'mouvements', 'supprimer')) { |
4756
|
|
|
$db->begin(); |
4757
|
|
|
|
4758
|
|
|
if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) { |
4759
|
|
|
$lettering = new Lettering($db); |
4760
|
|
|
$nb_lettering = $lettering->bookkeepingLetteringAll($toselect, true); |
4761
|
|
|
if ($nb_lettering < 0) { |
4762
|
|
|
setEventMessages('', $lettering->errors, 'errors'); |
4763
|
|
|
$error++; |
4764
|
|
|
} |
4765
|
|
|
} |
4766
|
|
|
|
4767
|
|
|
$nbok = 0; |
4768
|
|
|
if (!$error) { |
4769
|
|
|
foreach ($toselect as $toselectid) { |
4770
|
|
|
$result = $object->fetch($toselectid); |
4771
|
|
|
if ($result > 0 && (!isset($object->date_validation) || $object->date_validation === '')) { |
4772
|
|
|
$result = $object->deleteMvtNum($object->piece_num); |
4773
|
|
|
if ($result > 0) { |
4774
|
|
|
$nbok++; |
4775
|
|
|
} else { |
4776
|
|
|
setEventMessages($object->error, $object->errors, 'errors'); |
4777
|
|
|
$error++; |
4778
|
|
|
break; |
4779
|
|
|
} |
4780
|
|
|
} elseif ($result < 0) { |
4781
|
|
|
setEventMessages($object->error, $object->errors, 'errors'); |
4782
|
|
|
$error++; |
4783
|
|
|
break; |
4784
|
|
|
} elseif (isset($object->date_validation) && $object->date_validation != '') { |
4785
|
|
|
setEventMessages($langs->trans("ValidatedRecordWhereFound"), null, 'errors'); |
4786
|
|
|
$error++; |
4787
|
|
|
break; |
4788
|
|
|
} |
4789
|
|
|
} |
4790
|
|
|
} |
4791
|
|
|
|
4792
|
|
|
if (!$error) { |
4793
|
|
|
$db->commit(); |
4794
|
|
|
|
4795
|
|
|
// Message for elements well deleted |
4796
|
|
|
if ($nbok > 1) { |
4797
|
|
|
setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs'); |
4798
|
|
|
} elseif ($nbok > 0) { |
4799
|
|
|
setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs'); |
4800
|
|
|
} elseif (!$error) { |
4801
|
|
|
setEventMessages($langs->trans("NoRecordDeleted"), null, 'mesgs'); |
4802
|
|
|
} |
4803
|
|
|
|
4804
|
|
|
header("Location: " . $_SERVER['PHP_SELF'] . "?noreset=1" . ($param ? '&' . $param : '')); |
4805
|
|
|
exit; |
4806
|
|
|
} else { |
4807
|
|
|
$db->rollback(); |
4808
|
|
|
} |
4809
|
|
|
} |
4810
|
|
|
|
4811
|
|
|
// others mass actions |
4812
|
|
|
if (!$error && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->hasRight('accounting', 'mouvements', 'creer')) { |
4813
|
|
|
if ($massaction == 'letteringauto') { |
4814
|
|
|
$lettering = new Lettering($db); |
4815
|
|
|
$nb_lettering = $lettering->bookkeepingLetteringAll($toselect); |
4816
|
|
|
if ($nb_lettering < 0) { |
4817
|
|
|
setEventMessages('', $lettering->errors, 'errors'); |
4818
|
|
|
$error++; |
4819
|
|
|
$nb_lettering = max(0, abs($nb_lettering) - 2); |
4820
|
|
|
} elseif ($nb_lettering == 0) { |
4821
|
|
|
$nb_lettering = 0; |
4822
|
|
|
setEventMessages($langs->trans('AccountancyNoLetteringModified'), array(), 'mesgs'); |
4823
|
|
|
} |
4824
|
|
|
if ($nb_lettering == 1) { |
4825
|
|
|
setEventMessages($langs->trans('AccountancyOneLetteringModifiedSuccessfully'), array(), 'mesgs'); |
4826
|
|
|
} elseif ($nb_lettering > 1) { |
4827
|
|
|
setEventMessages($langs->trans('AccountancyLetteringModifiedSuccessfully', $nb_lettering), array(), 'mesgs'); |
4828
|
|
|
} |
4829
|
|
|
|
4830
|
|
|
if (!$error) { |
4831
|
|
|
header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param); |
4832
|
|
|
exit(); |
4833
|
|
|
} |
4834
|
|
|
} elseif ($massaction == 'letteringmanual') { |
4835
|
|
|
$lettering = new Lettering($db); |
4836
|
|
|
$result = $lettering->updateLettering($toselect); |
4837
|
|
|
if ($result < 0) { |
4838
|
|
|
setEventMessages('', $lettering->errors, 'errors'); |
4839
|
|
|
} else { |
4840
|
|
|
setEventMessages($langs->trans('AccountancyOneLetteringModifiedSuccessfully'), array(), 'mesgs'); |
4841
|
|
|
header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param); |
4842
|
|
|
exit(); |
4843
|
|
|
} |
4844
|
|
|
} elseif ($action == 'unletteringauto' && $confirm == "yes") { |
4845
|
|
|
$lettering = new Lettering($db); |
4846
|
|
|
$nb_lettering = $lettering->bookkeepingLetteringAll($toselect, true); |
4847
|
|
|
if ($nb_lettering < 0) { |
4848
|
|
|
setEventMessages('', $lettering->errors, 'errors'); |
4849
|
|
|
$error++; |
4850
|
|
|
$nb_lettering = max(0, abs($nb_lettering) - 2); |
4851
|
|
|
} elseif ($nb_lettering == 0) { |
4852
|
|
|
$nb_lettering = 0; |
4853
|
|
|
setEventMessages($langs->trans('AccountancyNoUnletteringModified'), array(), 'mesgs'); |
4854
|
|
|
} |
4855
|
|
|
if ($nb_lettering == 1) { |
4856
|
|
|
setEventMessages($langs->trans('AccountancyOneUnletteringModifiedSuccessfully'), array(), 'mesgs'); |
4857
|
|
|
} elseif ($nb_lettering > 1) { |
4858
|
|
|
setEventMessages($langs->trans('AccountancyUnletteringModifiedSuccessfully', $nb_lettering), array(), 'mesgs'); |
4859
|
|
|
} |
4860
|
|
|
|
4861
|
|
|
if (!$error) { |
4862
|
|
|
header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param); |
4863
|
|
|
exit(); |
4864
|
|
|
} |
4865
|
|
|
} elseif ($action == 'unletteringmanual' && $confirm == "yes") { |
4866
|
|
|
$lettering = new Lettering($db); |
4867
|
|
|
$nb_lettering = $lettering->deleteLettering($toselect); |
4868
|
|
|
if ($result < 0) { |
4869
|
|
|
setEventMessages('', $lettering->errors, 'errors'); |
4870
|
|
|
} else { |
4871
|
|
|
setEventMessages($langs->trans('AccountancyOneUnletteringModifiedSuccessfully'), array(), 'mesgs'); |
4872
|
|
|
header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param); |
4873
|
|
|
exit(); |
4874
|
|
|
} |
4875
|
|
|
} |
4876
|
|
|
} |
4877
|
|
|
} |
4878
|
|
|
|
4879
|
|
|
|
4880
|
|
|
/* |
4881
|
|
|
* View |
4882
|
|
|
*/ |
4883
|
|
|
|
4884
|
|
|
$formaccounting = new FormAccounting($db); |
4885
|
|
|
$formfile = new FormFile($db); |
4886
|
|
|
$formother = new FormOther($db); |
4887
|
|
|
$form = new Form($db); |
4888
|
|
|
|
4889
|
|
|
$title_page = $langs->trans("Operations") . ' - ' . $langs->trans("VueByAccountAccounting") . ' ('; |
4890
|
|
|
if ($type == 'sub') { |
4891
|
|
|
$title_page .= $langs->trans("BookkeepingSubAccount"); |
4892
|
|
|
} else { |
4893
|
|
|
$title_page .= $langs->trans("Bookkeeping"); |
4894
|
|
|
} |
4895
|
|
|
$title_page .= ')'; |
4896
|
|
|
$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double'; |
4897
|
|
|
llxHeader('', $title_page, $help_url); |
4898
|
|
|
|
4899
|
|
|
// List |
4900
|
|
|
$nbtotalofrecords = ''; |
4901
|
|
|
if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { |
4902
|
|
|
// TODO Perf Replace this by a count |
4903
|
|
|
if ($type == 'sub') { |
4904
|
|
|
$nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter, 'AND', 1, 1); |
4905
|
|
|
} else { |
4906
|
|
|
$nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter, 'AND', 0, 1); |
4907
|
|
|
} |
4908
|
|
|
|
4909
|
|
|
if ($nbtotalofrecords < 0) { |
4910
|
|
|
setEventMessages($object->error, $object->errors, 'errors'); |
4911
|
|
|
$error++; |
4912
|
|
|
} |
4913
|
|
|
} |
4914
|
|
|
|
4915
|
|
|
if (!$error) { |
4916
|
|
|
if ($type == 'sub') { |
4917
|
|
|
$result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 1); |
4918
|
|
|
} else { |
4919
|
|
|
$result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 0); |
4920
|
|
|
} |
4921
|
|
|
|
4922
|
|
|
if ($result < 0) { |
4923
|
|
|
setEventMessages($object->error, $object->errors, 'errors'); |
4924
|
|
|
} |
4925
|
|
|
} |
4926
|
|
|
|
4927
|
|
|
$arrayofselected = is_array($toselect) ? $toselect : array(); |
4928
|
|
|
|
4929
|
|
|
$num = count($object->lines); |
4930
|
|
|
|
4931
|
|
|
|
4932
|
|
|
///if ($action == 'delbookkeepingyear') { |
4933
|
|
|
// $form_question = array(); |
4934
|
|
|
// $delyear = GETPOST('delyear', 'int'); |
4935
|
|
|
// $deljournal = GETPOST('deljournal', 'alpha'); |
4936
|
|
|
// |
4937
|
|
|
// if (empty($delyear)) { |
4938
|
|
|
// $delyear = dol_print_date(dol_now(), '%Y'); |
4939
|
|
|
// } |
4940
|
|
|
// $month_array = array(); |
4941
|
|
|
// for ($i = 1; $i <= 12; $i++) { |
4942
|
|
|
// $month_array[$i] = $langs->trans("Month".sprintf("%02d", $i)); |
4943
|
|
|
// } |
4944
|
|
|
// $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array'); |
4945
|
|
|
// $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1); |
4946
|
|
|
// |
4947
|
|
|
// $form_question['delmonth'] = array( |
4948
|
|
|
// 'name' => 'delmonth', |
4949
|
|
|
// 'type' => 'select', |
4950
|
|
|
// 'label' => $langs->trans('DelMonth'), |
4951
|
|
|
// 'values' => $month_array, |
4952
|
|
|
// 'default' => '' |
4953
|
|
|
// ); |
4954
|
|
|
// $form_question['delyear'] = array( |
4955
|
|
|
// 'name' => 'delyear', |
4956
|
|
|
// 'type' => 'select', |
4957
|
|
|
// 'label' => $langs->trans('DelYear'), |
4958
|
|
|
// 'values' => $year_array, |
4959
|
|
|
// 'default' => $delyear |
4960
|
|
|
// ); |
4961
|
|
|
// $form_question['deljournal'] = array( |
4962
|
|
|
// 'name' => 'deljournal', |
4963
|
|
|
// 'type' => 'other', // We don't use select here, the journal_array is already a select html component |
4964
|
|
|
// 'label' => $langs->trans('DelJournal'), |
4965
|
|
|
// 'value' => $journal_array, |
4966
|
|
|
// 'default' => $deljournal |
4967
|
|
|
// ); |
4968
|
|
|
// |
4969
|
|
|
// $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'delbookkeepingyearconfirm', $form_question, '', 1, 300); |
4970
|
|
|
//} |
4971
|
|
|
|
4972
|
|
|
// Print form confirm |
4973
|
|
|
$formconfirm = ''; |
4974
|
|
|
print $formconfirm; |
4975
|
|
|
|
4976
|
|
|
// List of mass actions available |
4977
|
|
|
$arrayofmassactions = array(); |
4978
|
|
|
if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->hasRight('accounting', 'mouvements', 'creer')) { |
4979
|
|
|
$arrayofmassactions['letteringauto'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('LetteringAuto'); |
4980
|
|
|
$arrayofmassactions['preunletteringauto'] = img_picto('', 'uncheck', 'class="pictofixedwidth"') . $langs->trans('UnletteringAuto'); |
4981
|
|
|
$arrayofmassactions['letteringmanual'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('LetteringManual'); |
4982
|
|
|
$arrayofmassactions['preunletteringmanual'] = img_picto('', 'uncheck', 'class="pictofixedwidth"') . $langs->trans('UnletteringManual'); |
4983
|
|
|
} |
4984
|
|
|
if ($user->hasRight('accounting', 'mouvements', 'supprimer')) { |
4985
|
|
|
$arrayofmassactions['predeletebookkeepingwriting'] = img_picto('', 'delete', 'class="pictofixedwidth"') . $langs->trans("Delete"); |
4986
|
|
|
} |
4987
|
|
|
if (GETPOSTINT('nomassaction') || in_array($massaction, array('preunletteringauto', 'preunletteringmanual', 'predeletebookkeepingwriting'))) { |
4988
|
|
|
$arrayofmassactions = array(); |
4989
|
|
|
} |
4990
|
|
|
$massactionbutton = $form->selectMassAction($massaction, $arrayofmassactions); |
4991
|
|
|
|
4992
|
|
|
print '<form method="POST" id="searchFormList" action="' . $_SERVER['PHP_SELF'] . '">'; |
4993
|
|
|
print '<input type="hidden" name="token" value="' . newToken() . '">'; |
4994
|
|
|
print '<input type="hidden" name="action" value="list">'; |
4995
|
|
|
if ($optioncss != '') { |
4996
|
|
|
print '<input type="hidden" name="optioncss" value="' . $optioncss . '">'; |
4997
|
|
|
} |
4998
|
|
|
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
4999
|
|
|
print '<input type="hidden" name="type" value="' . $type . '">'; |
5000
|
|
|
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">'; |
5001
|
|
|
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">'; |
5002
|
|
|
print '<input type="hidden" name="contextpage" value="' . $contextpage . '">'; |
5003
|
|
|
|
5004
|
|
|
$parameters = array('param' => $param); |
5005
|
|
|
$reshook = $hookmanager->executeHooks('addMoreActionsButtonsList', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
5006
|
|
|
if ($reshook < 0) { |
5007
|
|
|
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
5008
|
|
|
} |
5009
|
|
|
|
5010
|
|
|
$newcardbutton = empty($hookmanager->resPrint) ? '' : $hookmanager->resPrint; |
5011
|
|
|
|
5012
|
|
|
if (empty($reshook)) { |
5013
|
|
|
$newcardbutton = dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/list.php?' . $param); |
5014
|
|
|
if ($type == 'sub') { |
5015
|
|
|
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?' . $url_param, '', 1, array('morecss' => 'marginleftonly')); |
5016
|
|
|
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?type=sub&' . $url_param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); |
5017
|
|
|
} else { |
5018
|
|
|
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?' . $url_param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); |
5019
|
|
|
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?type=sub&' . $url_param, '', 1, array('morecss' => 'marginleftonly')); |
5020
|
|
|
} |
5021
|
|
|
$newcardbutton .= dolGetButtonTitleSeparator(); |
5022
|
|
|
$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT . '/accountancy/bookkeeping/card.php?action=create'); |
5023
|
|
|
} |
5024
|
|
|
|
5025
|
|
|
if (!empty($contextpage) && $contextpage != $_SERVER['PHP_SELF']) { |
5026
|
|
|
$param .= '&contextpage=' . urlencode($contextpage); |
5027
|
|
|
} |
5028
|
|
|
if ($limit > 0 && $limit != $conf->liste_limit) { |
5029
|
|
|
$param .= '&limit=' . ((int) $limit); |
5030
|
|
|
} |
5031
|
|
|
|
5032
|
|
|
print_barre_liste($title_page, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, $massactionbutton, $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); |
5033
|
|
|
|
5034
|
|
|
if ($massaction == 'preunletteringauto') { |
5035
|
|
|
print $form->formconfirm($_SERVER['PHP_SELF'], $langs->trans("ConfirmMassUnletteringAuto"), $langs->trans("ConfirmMassUnletteringQuestion", count($toselect)), "unletteringauto", null, '', 0, 200, 500, 1); |
5036
|
|
|
} elseif ($massaction == 'preunletteringmanual') { |
5037
|
|
|
print $form->formconfirm($_SERVER['PHP_SELF'], $langs->trans("ConfirmMassUnletteringManual"), $langs->trans("ConfirmMassUnletteringQuestion", count($toselect)), "unletteringmanual", null, '', 0, 200, 500, 1); |
5038
|
|
|
} elseif ($massaction == 'predeletebookkeepingwriting') { |
5039
|
|
|
print $form->formconfirm($_SERVER['PHP_SELF'], $langs->trans("ConfirmMassDeleteBookkeepingWriting"), $langs->trans("ConfirmMassDeleteBookkeepingWritingQuestion", count($toselect)), "deletebookkeepingwriting", null, '', 0, 200, 500, 1); |
5040
|
|
|
} |
5041
|
|
|
//DeleteMvt=Supprimer des lignes d'opérations de la comptabilité |
5042
|
|
|
//DelMonth=Mois à effacer |
5043
|
|
|
//DelYear=Année à supprimer |
5044
|
|
|
//DelJournal=Journal à supprimer |
5045
|
|
|
//ConfirmDeleteMvt=Cette action supprime les lignes des opérations pour l'année/mois et/ou pour le journal sélectionné (au moins un critère est requis). Vous devrez utiliser de nouveau la fonctionnalité '%s' pour retrouver vos écritures dans la comptabilité. |
5046
|
|
|
//ConfirmDeleteMvtPartial=Cette action supprime l'écriture de la comptabilité (toutes les lignes opérations liées à une même écriture seront effacées). |
5047
|
|
|
|
5048
|
|
|
//$topicmail = "Information"; |
5049
|
|
|
//$modelmail = "accountingbookkeeping"; |
5050
|
|
|
//$objecttmp = new BookKeeping($db); |
5051
|
|
|
//$trackid = 'bk'.$object->id; |
5052
|
|
|
include DOL_DOCUMENT_ROOT . '/core/tpl/massactions_pre.tpl.php'; |
5053
|
|
|
|
5054
|
|
|
$varpage = empty($contextpage) ? $_SERVER['PHP_SELF'] : $contextpage; |
5055
|
|
|
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields |
5056
|
|
|
if ($massactionbutton && $contextpage != 'poslist') { |
5057
|
|
|
$selectedfields .= $form->showCheckAddButtons('checkforselect', 1); |
5058
|
|
|
} |
5059
|
|
|
|
5060
|
|
|
// Reverse sort order |
5061
|
|
|
if (preg_match('/^asc/i', $sortorder)) { |
5062
|
|
|
$sortorder = "asc"; |
5063
|
|
|
} else { |
5064
|
|
|
$sortorder = "desc"; |
5065
|
|
|
} |
5066
|
|
|
|
5067
|
|
|
// Warning to explain why list of record is not consistent with the other list view (missing a lot of lines) |
5068
|
|
|
if ($type == 'sub') { |
5069
|
|
|
print info_admin($langs->trans("WarningRecordWithoutSubledgerAreExcluded")); |
5070
|
|
|
} |
5071
|
|
|
|
5072
|
|
|
$moreforfilter = ''; |
5073
|
|
|
|
5074
|
|
|
// Search on accountancy custom groups or account |
5075
|
|
|
$moreforfilter .= '<div class="divsearchfield">'; |
5076
|
|
|
$moreforfilter .= $langs->trans('AccountAccounting') . ': '; |
5077
|
|
|
$moreforfilter .= '<div class="nowrap inline-block">'; |
5078
|
|
|
if ($type == 'sub') { |
5079
|
|
|
$moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), 'maxwidth200'); |
5080
|
|
|
} else { |
5081
|
|
|
$moreforfilter .= $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, 'maxwidth200'); |
5082
|
|
|
} |
5083
|
|
|
$moreforfilter .= ' '; |
5084
|
|
|
if ($type == 'sub') { |
5085
|
|
|
$moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), 'maxwidth200'); |
5086
|
|
|
} else { |
5087
|
|
|
$moreforfilter .= $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, 'maxwidth200'); |
5088
|
|
|
} |
5089
|
|
|
$stringforfirstkey = $langs->trans("KeyboardShortcut"); |
5090
|
|
|
if ($conf->browser->name == 'chrome') { |
5091
|
|
|
$stringforfirstkey .= ' ALT +'; |
5092
|
|
|
} elseif ($conf->browser->name == 'firefox') { |
5093
|
|
|
$stringforfirstkey .= ' ALT + SHIFT +'; |
5094
|
|
|
} else { |
5095
|
|
|
$stringforfirstkey .= ' CTL +'; |
5096
|
|
|
} |
5097
|
|
|
$moreforfilter .= ' <a id="previous_account" accesskey="p" title="' . $stringforfirstkey . ' p" class="classfortooltip" href="#"><i class="fa fa-chevron-left"></i></a>'; |
5098
|
|
|
$moreforfilter .= ' <a id="next_account" accesskey="n" title="' . $stringforfirstkey . ' n" class="classfortooltip" href="#"><i class="fa fa-chevron-right"></i></a>'; |
5099
|
|
|
$moreforfilter .= <<<SCRIPT |
5100
|
|
|
<script type="text/javascript"> |
5101
|
|
|
jQuery(document).ready(function() { |
5102
|
|
|
var searchFormList = $('#searchFormList'); |
5103
|
|
|
var searchAccountancyCodeStart = $('#search_accountancy_code_start'); |
5104
|
|
|
var searchAccountancyCodeEnd = $('#search_accountancy_code_end'); |
5105
|
|
|
jQuery('#previous_account').on('click', function() { |
5106
|
|
|
var previousOption = searchAccountancyCodeStart.find('option:selected').prev('option'); |
5107
|
|
|
if (previousOption.length == 1) searchAccountancyCodeStart.val(previousOption.attr('value')); |
5108
|
|
|
searchAccountancyCodeEnd.val(searchAccountancyCodeStart.val()); |
5109
|
|
|
searchFormList.submit(); |
5110
|
|
|
}); |
5111
|
|
|
jQuery('#next_account').on('click', function() { |
5112
|
|
|
var nextOption = searchAccountancyCodeStart.find('option:selected').next('option'); |
5113
|
|
|
if (nextOption.length == 1) searchAccountancyCodeStart.val(nextOption.attr('value')); |
5114
|
|
|
searchAccountancyCodeEnd.val(searchAccountancyCodeStart.val()); |
5115
|
|
|
searchFormList.submit(); |
5116
|
|
|
}); |
5117
|
|
|
jQuery('input[name="search_mvt_num"]').on("keypress", function(event) { |
5118
|
|
|
console.log(event); |
5119
|
|
|
}); |
5120
|
|
|
}); |
5121
|
|
|
</script> |
5122
|
|
|
SCRIPT; |
5123
|
|
|
$moreforfilter .= '</div>'; |
5124
|
|
|
$moreforfilter .= '</div>'; |
5125
|
|
|
|
5126
|
|
|
$moreforfilter .= '<div class="divsearchfield">'; |
5127
|
|
|
$moreforfilter .= $langs->trans('AccountingCategory') . ': '; |
5128
|
|
|
$moreforfilter .= '<div class="nowrap inline-block">'; |
5129
|
|
|
$moreforfilter .= $formaccounting->select_accounting_category($search_account_category, 'search_account_category', 1, 0, 0, 0); |
5130
|
|
|
$moreforfilter .= '</div>'; |
5131
|
|
|
$moreforfilter .= '</div>'; |
5132
|
|
|
|
5133
|
|
|
$parameters = array(); |
5134
|
|
|
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook |
5135
|
|
|
if (empty($reshook)) { |
5136
|
|
|
$moreforfilter .= $hookmanager->resPrint; |
5137
|
|
|
} else { |
5138
|
|
|
$moreforfilter = $hookmanager->resPrint; |
5139
|
|
|
} |
5140
|
|
|
|
5141
|
|
|
print '<div class="liste_titre liste_titre_bydiv centpercent">'; |
5142
|
|
|
print $moreforfilter; |
5143
|
|
|
print '</div>'; |
5144
|
|
|
|
5145
|
|
|
print '<div class="div-table-responsive">'; |
5146
|
|
|
print '<table class="tagtable liste centpercent">'; |
5147
|
|
|
|
5148
|
|
|
// Filters lines |
5149
|
|
|
print '<tr class="liste_titre_filter">'; |
5150
|
|
|
// Action column |
5151
|
|
|
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
5152
|
|
|
print '<td class="liste_titre center">'; |
5153
|
|
|
$searchpicto = $form->showFilterButtons('left'); |
5154
|
|
|
print $searchpicto; |
5155
|
|
|
print '</td>'; |
5156
|
|
|
} |
5157
|
|
|
// Movement number |
5158
|
|
|
if (!empty($arrayfields['t.piece_num']['checked'])) { |
5159
|
|
|
print '<td class="liste_titre"><input type="text" name="search_mvt_num" class="width50" value="' . dol_escape_htmltag($search_mvt_num) . '"></td>'; |
5160
|
|
|
} |
5161
|
|
|
// Code journal |
5162
|
|
|
if (!empty($arrayfields['t.code_journal']['checked'])) { |
5163
|
|
|
print '<td class="liste_titre center">'; |
5164
|
|
|
print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1, 'maxwidth75'); |
5165
|
|
|
print '</td>'; |
5166
|
|
|
} |
5167
|
|
|
// Date document |
5168
|
|
|
if (!empty($arrayfields['t.doc_date']['checked'])) { |
5169
|
|
|
print '<td class="liste_titre center">'; |
5170
|
|
|
print '<div class="nowrapfordate">'; |
5171
|
|
|
print $form->selectDate($search_date_start, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); |
5172
|
|
|
print '</div>'; |
5173
|
|
|
print '<div class="nowrapfordate">'; |
5174
|
|
|
print $form->selectDate($search_date_end, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); |
5175
|
|
|
print '</div>'; |
5176
|
|
|
print '</td>'; |
5177
|
|
|
} |
5178
|
|
|
// Ref document |
5179
|
|
|
if (!empty($arrayfields['t.doc_ref']['checked'])) { |
5180
|
|
|
print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_doc_ref" value="' . dol_escape_htmltag($search_doc_ref) . '"/></td>'; |
5181
|
|
|
} |
5182
|
|
|
// Label operation |
5183
|
|
|
if (!empty($arrayfields['t.label_operation']['checked'])) { |
5184
|
|
|
print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_label_operation" value="' . dol_escape_htmltag($search_label_operation) . '"/></td>'; |
5185
|
|
|
} |
5186
|
|
|
// Lettering code |
5187
|
|
|
if (!empty($arrayfields['t.lettering_code']['checked'])) { |
5188
|
|
|
print '<td class="liste_titre center">'; |
5189
|
|
|
print '<input type="text" size="3" class="flat" name="search_lettering_code" value="' . $search_lettering_code . '"/>'; |
5190
|
|
|
print '<br><span class="nowrap"><input type="checkbox" name="search_not_reconciled" value="notreconciled"' . ($search_not_reconciled == 'notreconciled' ? ' checked' : '') . '>' . $langs->trans("NotReconciled") . '</span>'; |
5191
|
|
|
print '</td>'; |
5192
|
|
|
} |
5193
|
|
|
// Debit |
5194
|
|
|
if (!empty($arrayfields['t.debit']['checked'])) { |
5195
|
|
|
print '<td class="liste_titre right"><input type="text" class="flat" name="search_debit" size="4" value="' . dol_escape_htmltag($search_debit) . '"></td>'; |
5196
|
|
|
} |
5197
|
|
|
// Credit |
5198
|
|
|
if (!empty($arrayfields['t.credit']['checked'])) { |
5199
|
|
|
print '<td class="liste_titre right"><input type="text" class="flat" name="search_credit" size="4" value="' . dol_escape_htmltag($search_credit) . '"></td>'; |
5200
|
|
|
} |
5201
|
|
|
// Balance |
5202
|
|
|
if (!empty($arrayfields['t.balance']['checked'])) { |
5203
|
|
|
print '<td></td>'; |
5204
|
|
|
} |
5205
|
|
|
// Date export |
5206
|
|
|
if (!empty($arrayfields['t.date_export']['checked'])) { |
5207
|
|
|
print '<td class="liste_titre center">'; |
5208
|
|
|
print '<div class="nowrapfordate">'; |
5209
|
|
|
print $form->selectDate($search_date_export_start, 'search_date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); |
5210
|
|
|
print '</div>'; |
5211
|
|
|
print '<div class="nowrapfordate">'; |
5212
|
|
|
print $form->selectDate($search_date_export_end, 'search_date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); |
5213
|
|
|
print '</div>'; |
5214
|
|
|
print '</td>'; |
5215
|
|
|
} |
5216
|
|
|
// Date validation |
5217
|
|
|
if (!empty($arrayfields['t.date_validated']['checked'])) { |
5218
|
|
|
print '<td class="liste_titre center">'; |
5219
|
|
|
print '<div class="nowrapfordate">'; |
5220
|
|
|
print $form->selectDate($search_date_validation_start, 'search_date_validation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); |
5221
|
|
|
print '</div>'; |
5222
|
|
|
print '<div class="nowrapfordate">'; |
5223
|
|
|
print $form->selectDate($search_date_validation_end, 'search_date_validation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); |
5224
|
|
|
print '</div>'; |
5225
|
|
|
print '</td>'; |
5226
|
|
|
} |
5227
|
|
|
if (!empty($arrayfields['t.import_key']['checked'])) { |
5228
|
|
|
print '<td class="liste_titre center">'; |
5229
|
|
|
print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="' . dol_escape_htmltag($search_import_key) . '">'; |
5230
|
|
|
print '</td>'; |
5231
|
|
|
} |
5232
|
|
|
|
5233
|
|
|
// Fields from hook |
5234
|
|
|
$parameters = array('arrayfields' => $arrayfields); |
5235
|
|
|
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook |
5236
|
|
|
print $hookmanager->resPrint; |
5237
|
|
|
|
5238
|
|
|
// Action column |
5239
|
|
|
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
5240
|
|
|
print '<td class="liste_titre center">'; |
5241
|
|
|
$searchpicto = $form->showFilterButtons(); |
5242
|
|
|
print $searchpicto; |
5243
|
|
|
print '</td>'; |
5244
|
|
|
} |
5245
|
|
|
print "</tr>\n"; |
5246
|
|
|
|
5247
|
|
|
print '<tr class="liste_titre">'; |
5248
|
|
|
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
5249
|
|
|
print_liste_field_titre($selectedfields, $_SERVER['PHP_SELF'], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); |
5250
|
|
|
} |
5251
|
|
|
if (!empty($arrayfields['t.piece_num']['checked'])) { |
5252
|
|
|
print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, '', $sortfield, $sortorder, 'tdoverflowmax80imp '); |
5253
|
|
|
} |
5254
|
|
|
if (!empty($arrayfields['t.code_journal']['checked'])) { |
5255
|
|
|
print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center '); |
5256
|
|
|
} |
5257
|
|
|
if (!empty($arrayfields['t.doc_date']['checked'])) { |
5258
|
|
|
print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center '); |
5259
|
|
|
} |
5260
|
|
|
if (!empty($arrayfields['t.doc_ref']['checked'])) { |
5261
|
|
|
print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder); |
5262
|
|
|
} |
5263
|
|
|
if (!empty($arrayfields['t.label_operation']['checked'])) { |
5264
|
|
|
print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder); |
5265
|
|
|
} |
5266
|
|
|
if (!empty($arrayfields['t.lettering_code']['checked'])) { |
5267
|
|
|
print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center '); |
5268
|
|
|
} |
5269
|
|
|
if (!empty($arrayfields['t.debit']['checked'])) { |
5270
|
|
|
print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right '); |
5271
|
|
|
} |
5272
|
|
|
if (!empty($arrayfields['t.credit']['checked'])) { |
5273
|
|
|
print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right '); |
5274
|
|
|
} |
5275
|
|
|
if (!empty($arrayfields['t.balance']['checked'])) { |
5276
|
|
|
print_liste_field_titre($arrayfields['t.balance']['label'], "", "", "", $param, '', $sortfield, $sortorder, 'right '); |
5277
|
|
|
} |
5278
|
|
|
if (!empty($arrayfields['t.date_export']['checked'])) { |
5279
|
|
|
print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center '); |
5280
|
|
|
} |
5281
|
|
|
if (!empty($arrayfields['t.date_validated']['checked'])) { |
5282
|
|
|
print_liste_field_titre($arrayfields['t.date_validated']['label'], $_SERVER['PHP_SELF'], "t.date_validated", "", $param, '', $sortfield, $sortorder, 'center '); |
5283
|
|
|
} |
5284
|
|
|
if (!empty($arrayfields['t.import_key']['checked'])) { |
5285
|
|
|
print_liste_field_titre($arrayfields['t.import_key']['label'], $_SERVER['PHP_SELF'], "t.import_key", "", $param, '', $sortfield, $sortorder, 'center '); |
5286
|
|
|
} |
5287
|
|
|
// Hook fields |
5288
|
|
|
$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder); |
5289
|
|
|
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook |
5290
|
|
|
print $hookmanager->resPrint; |
5291
|
|
|
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
5292
|
|
|
print_liste_field_titre($selectedfields, $_SERVER['PHP_SELF'], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); |
5293
|
|
|
} |
5294
|
|
|
print "</tr>\n"; |
5295
|
|
|
|
5296
|
|
|
$displayed_account_number = null; // Start with undefined to be able to distinguish with empty |
5297
|
|
|
|
5298
|
|
|
// Loop on record |
5299
|
|
|
// -------------------------------------------------------------------- |
5300
|
|
|
$i = 0; |
5301
|
|
|
|
5302
|
|
|
$totalarray = array(); |
5303
|
|
|
$totalarray['val'] = array(); |
5304
|
|
|
$totalarray['nbfield'] = 0; |
5305
|
|
|
$total_debit = 0; |
5306
|
|
|
$total_credit = 0; |
5307
|
|
|
$sous_total_debit = 0; |
5308
|
|
|
$sous_total_credit = 0; |
5309
|
|
|
$totalarray['val']['totaldebit'] = 0; |
5310
|
|
|
$totalarray['val']['totalcredit'] = 0; |
5311
|
|
|
|
5312
|
|
|
while ($i < min($num, $limit)) { |
5313
|
|
|
$line = $object->lines[$i]; |
5314
|
|
|
|
5315
|
|
|
$total_debit += $line->debit; |
5316
|
|
|
$total_credit += $line->credit; |
5317
|
|
|
|
5318
|
|
|
if ($type == 'sub') { |
5319
|
|
|
$accountg = length_accounta($line->subledger_account); |
5320
|
|
|
} else { |
5321
|
|
|
$accountg = length_accountg($line->numero_compte); |
5322
|
|
|
} |
5323
|
|
|
//if (empty($accountg)) $accountg = '-'; |
5324
|
|
|
|
5325
|
|
|
$colspan = 0; // colspan before field 'label of operation' |
5326
|
|
|
$colspanend = 0; // colspan after debit/credit |
5327
|
|
|
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
5328
|
|
|
$colspan++; |
5329
|
|
|
} |
5330
|
|
|
if (!empty($arrayfields['t.piece_num']['checked'])) { |
5331
|
|
|
$colspan++; |
5332
|
|
|
} |
5333
|
|
|
if (!empty($arrayfields['t.code_journal']['checked'])) { |
5334
|
|
|
$colspan++; |
5335
|
|
|
} |
5336
|
|
|
if (!empty($arrayfields['t.doc_date']['checked'])) { |
5337
|
|
|
$colspan++; |
5338
|
|
|
} |
5339
|
|
|
if (!empty($arrayfields['t.doc_ref']['checked'])) { |
5340
|
|
|
$colspan++; |
5341
|
|
|
} |
5342
|
|
|
if (!empty($arrayfields['t.label_operation']['checked'])) { |
5343
|
|
|
$colspan++; |
5344
|
|
|
} |
5345
|
|
|
if (!empty($arrayfields['t.lettering_code']['checked'])) { |
5346
|
|
|
$colspan++; |
5347
|
|
|
} |
5348
|
|
|
|
5349
|
|
|
if (!empty($arrayfields['t.balance']['checked'])) { |
5350
|
|
|
$colspanend++; |
5351
|
|
|
} |
5352
|
|
|
if (!empty($arrayfields['t.date_export']['checked'])) { |
5353
|
|
|
$colspanend++; |
5354
|
|
|
} |
5355
|
|
|
if (!empty($arrayfields['t.date_validated']['checked'])) { |
5356
|
|
|
$colspanend++; |
5357
|
|
|
} |
5358
|
|
|
if (!empty($arrayfields['t.lettering_code']['checked'])) { |
5359
|
|
|
$colspanend++; |
5360
|
|
|
} |
5361
|
|
|
if (!empty($arrayfields['t.import_key']['checked'])) { |
5362
|
|
|
$colspanend++; |
5363
|
|
|
} |
5364
|
|
|
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
5365
|
|
|
$colspan++; |
5366
|
|
|
$colspanend--; |
5367
|
|
|
} |
5368
|
|
|
|
5369
|
|
|
// Is it a break ? |
5370
|
|
|
if ($accountg != $displayed_account_number || !isset($displayed_account_number)) { |
5371
|
|
|
// Show a subtotal by accounting account |
5372
|
|
|
if (isset($displayed_account_number)) { |
5373
|
|
|
print '<tr class="liste_total">'; |
5374
|
|
|
if ($type == 'sub') { |
5375
|
|
|
print '<td class="right" colspan="' . $colspan . '">' . $langs->trans("TotalForAccount") . ' ' . length_accounta($displayed_account_number) . ':</td>'; |
5376
|
|
|
} else { |
5377
|
|
|
print '<td class="right" colspan="' . $colspan . '">' . $langs->trans("TotalForAccount") . ' ' . length_accountg($displayed_account_number) . ':</td>'; |
5378
|
|
|
} |
5379
|
|
|
print '<td class="nowrap right">' . price(price2num($sous_total_debit, 'MT')) . '</td>'; |
5380
|
|
|
print '<td class="nowrap right">' . price(price2num($sous_total_credit, 'MT')) . '</td>'; |
5381
|
|
|
if ($colspanend > 0) { |
5382
|
|
|
print '<td colspan="' . $colspanend . '"></td>'; |
5383
|
|
|
} |
5384
|
|
|
print '</tr>'; |
5385
|
|
|
// Show balance of last shown account |
5386
|
|
|
$balance = $sous_total_debit - $sous_total_credit; |
5387
|
|
|
print '<tr class="liste_total">'; |
5388
|
|
|
print '<td class="right" colspan="' . $colspan . '">' . $langs->trans("Balance") . ':</td>'; |
5389
|
|
|
if ($balance > 0) { |
5390
|
|
|
print '<td class="nowraponall right">'; |
5391
|
|
|
print price(price2num($sous_total_debit - $sous_total_credit, 'MT')); |
5392
|
|
|
print '</td>'; |
5393
|
|
|
print '<td></td>'; |
5394
|
|
|
} else { |
5395
|
|
|
print '<td></td>'; |
5396
|
|
|
print '<td class="nowraponall right">'; |
5397
|
|
|
print price(price2num($sous_total_credit - $sous_total_debit, 'MT')); |
5398
|
|
|
print '</td>'; |
5399
|
|
|
} |
5400
|
|
|
if ($colspanend > 0) { |
5401
|
|
|
print '<td colspan="' . $colspanend . '"></td>'; |
5402
|
|
|
} |
5403
|
|
|
print '</tr>'; |
5404
|
|
|
} |
5405
|
|
|
|
5406
|
|
|
// Show the break account |
5407
|
|
|
print '<tr class="trforbreak">'; |
5408
|
|
|
print '<td colspan="' . ($totalarray['nbfield'] ? $totalarray['nbfield'] : count($arrayfields) + 1) . '" class="tdforbreak">'; |
5409
|
|
|
if ($type == 'sub') { |
5410
|
|
|
if ($line->subledger_account != "" && $line->subledger_account != '-1') { |
5411
|
|
|
print empty($line->subledger_label) ? '<span class="error">' . $langs->trans("Unknown") . '</span>' : $line->subledger_label; |
5412
|
|
|
print ' : '; |
5413
|
|
|
print length_accounta($line->subledger_account); |
5414
|
|
|
} else { |
5415
|
|
|
// Should not happen: subledger account must be null or a non empty value |
5416
|
|
|
print '<span class="error">' . $langs->trans("Unknown"); |
5417
|
|
|
if ($line->subledger_label) { |
5418
|
|
|
print ' (' . $line->subledger_label . ')'; |
5419
|
|
|
$htmltext = 'EmptyStringForSubledgerAccountButSubledgerLabelDefined'; |
5420
|
|
|
} else { |
5421
|
|
|
$htmltext = 'EmptyStringForSubledgerAccountAndSubledgerLabel'; |
5422
|
|
|
} |
5423
|
|
|
print $form->textwithpicto('', $htmltext); |
5424
|
|
|
print '</span>'; |
5425
|
|
|
} |
5426
|
|
|
} else { |
5427
|
|
|
if ($line->numero_compte != "" && $line->numero_compte != '-1') { |
5428
|
|
|
print length_accountg($line->numero_compte) . ' : ' . $object->get_compte_desc($line->numero_compte); |
5429
|
|
|
} else { |
5430
|
|
|
print '<span class="error">' . $langs->trans("Unknown") . '</span>'; |
5431
|
|
|
} |
5432
|
|
|
} |
5433
|
|
|
print '</td>'; |
5434
|
|
|
print '</tr>'; |
5435
|
|
|
|
5436
|
|
|
$displayed_account_number = $accountg; |
5437
|
|
|
//if (empty($displayed_account_number)) $displayed_account_number='-'; |
5438
|
|
|
$sous_total_debit = 0; |
5439
|
|
|
$sous_total_credit = 0; |
5440
|
|
|
|
5441
|
|
|
$colspan = 0; |
5442
|
|
|
} |
5443
|
|
|
|
5444
|
|
|
print '<tr class="oddeven">'; |
5445
|
|
|
// Action column |
5446
|
|
|
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
5447
|
|
|
print '<td class="nowraponall center">'; |
5448
|
|
|
if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined |
5449
|
|
|
$selected = 0; |
5450
|
|
|
if (in_array($line->id, $arrayofselected)) { |
5451
|
|
|
$selected = 1; |
5452
|
|
|
} |
5453
|
|
|
print '<input id="cb' . $line->id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $line->id . '"' . ($selected ? ' checked="checked"' : '') . ' />'; |
5454
|
|
|
} |
5455
|
|
|
print '</td>'; |
5456
|
|
|
if (!$i) { |
5457
|
|
|
$totalarray['nbfield']++; |
5458
|
|
|
} |
5459
|
|
|
} |
5460
|
|
|
// Piece number |
5461
|
|
|
if (!empty($arrayfields['t.piece_num']['checked'])) { |
5462
|
|
|
print '<td>'; |
5463
|
|
|
$object->id = $line->id; |
5464
|
|
|
$object->piece_num = $line->piece_num; |
5465
|
|
|
print $object->getNomUrl(1, '', 0, '', 1); |
5466
|
|
|
print '</td>'; |
5467
|
|
|
if (!$i) { |
5468
|
|
|
$totalarray['nbfield']++; |
5469
|
|
|
} |
5470
|
|
|
} |
5471
|
|
|
|
5472
|
|
|
// Journal code |
5473
|
|
|
if (!empty($arrayfields['t.code_journal']['checked'])) { |
5474
|
|
|
$accountingjournal = new AccountingJournal($db); |
5475
|
|
|
$result = $accountingjournal->fetch('', $line->code_journal); |
5476
|
|
|
$journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal); |
5477
|
|
|
print '<td class="center tdoverflowmax80">' . $journaltoshow . '</td>'; |
5478
|
|
|
if (!$i) { |
5479
|
|
|
$totalarray['nbfield']++; |
5480
|
|
|
} |
5481
|
|
|
} |
5482
|
|
|
|
5483
|
|
|
// Document date |
5484
|
|
|
if (!empty($arrayfields['t.doc_date']['checked'])) { |
5485
|
|
|
print '<td class="center">' . dol_print_date($line->doc_date, 'day') . '</td>'; |
5486
|
|
|
if (!$i) { |
5487
|
|
|
$totalarray['nbfield']++; |
5488
|
|
|
} |
5489
|
|
|
} |
5490
|
|
|
|
5491
|
|
|
// Document ref |
5492
|
|
|
if (!empty($arrayfields['t.doc_ref']['checked'])) { |
5493
|
|
|
if ($line->doc_type == 'customer_invoice') { |
5494
|
|
|
$langs->loadLangs(array('bills')); |
5495
|
|
|
|
5496
|
|
|
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; |
5497
|
|
|
$objectstatic = new Facture($db); |
5498
|
|
|
$objectstatic->fetch($line->fk_doc); |
5499
|
|
|
//$modulepart = 'facture'; |
5500
|
|
|
|
5501
|
|
|
$filename = dol_sanitizeFileName($line->doc_ref); |
5502
|
|
|
$filedir = $conf->facture->dir_output . '/' . dol_sanitizeFileName($line->doc_ref); |
5503
|
|
|
$urlsource = $_SERVER['PHP_SELF'] . '?id=' . $objectstatic->id; |
5504
|
|
|
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); |
5505
|
|
|
} elseif ($line->doc_type == 'supplier_invoice') { |
5506
|
|
|
$langs->loadLangs(array('bills')); |
5507
|
|
|
|
5508
|
|
|
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; |
5509
|
|
|
$objectstatic = new FactureFournisseur($db); |
5510
|
|
|
$objectstatic->fetch($line->fk_doc); |
5511
|
|
|
//$modulepart = 'invoice_supplier'; |
5512
|
|
|
|
5513
|
|
|
$filename = dol_sanitizeFileName($line->doc_ref); |
5514
|
|
|
$filedir = $conf->fournisseur->facture->dir_output . '/' . get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart) . dol_sanitizeFileName($line->doc_ref); |
5515
|
|
|
$subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart) . dol_sanitizeFileName($line->doc_ref); |
5516
|
|
|
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir); |
5517
|
|
|
} elseif ($line->doc_type == 'expense_report') { |
5518
|
|
|
$langs->loadLangs(array('trips')); |
5519
|
|
|
|
5520
|
|
|
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; |
5521
|
|
|
$objectstatic = new ExpenseReport($db); |
5522
|
|
|
$objectstatic->fetch($line->fk_doc); |
5523
|
|
|
//$modulepart = 'expensereport'; |
5524
|
|
|
|
5525
|
|
|
$filename = dol_sanitizeFileName($line->doc_ref); |
5526
|
|
|
$filedir = $conf->expensereport->dir_output . '/' . dol_sanitizeFileName($line->doc_ref); |
5527
|
|
|
$urlsource = $_SERVER['PHP_SELF'] . '?id=' . $objectstatic->id; |
5528
|
|
|
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); |
5529
|
|
|
} elseif ($line->doc_type == 'bank') { |
5530
|
|
|
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; |
5531
|
|
|
$objectstatic = new AccountLine($db); |
5532
|
|
|
$objectstatic->fetch($line->fk_doc); |
5533
|
|
|
} else { |
5534
|
|
|
// Other type |
5535
|
|
|
} |
5536
|
|
|
|
5537
|
|
|
print '<td class="tdoverflowmax250">'; |
5538
|
|
|
|
5539
|
|
|
// Picto + Ref |
5540
|
|
|
if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') { |
5541
|
|
|
print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); |
5542
|
|
|
print $documentlink; |
5543
|
|
|
} elseif ($line->doc_type == 'bank') { |
5544
|
|
|
print $objectstatic->getNomUrl(1); |
5545
|
|
|
$bank_ref = strstr($line->doc_ref, '-'); |
5546
|
|
|
print " " . $bank_ref; |
5547
|
|
|
} else { |
5548
|
|
|
print $line->doc_ref; |
5549
|
|
|
} |
5550
|
|
|
|
5551
|
|
|
print "</td>\n"; |
5552
|
|
|
if (!$i) { |
5553
|
|
|
$totalarray['nbfield']++; |
5554
|
|
|
} |
5555
|
|
|
} |
5556
|
|
|
|
5557
|
|
|
// Label operation |
5558
|
|
|
if (!empty($arrayfields['t.label_operation']['checked'])) { |
5559
|
|
|
// Affiche un lien vers la facture client/fournisseur |
5560
|
|
|
$doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref); |
5561
|
|
|
if (strlen(length_accounta($line->subledger_account)) == 0) { |
5562
|
|
|
print '<td class="small tdoverflowmax350 classfortooltip" title="' . dol_escape_htmltag($line->label_operation) . '">' . dol_escape_htmltag($line->label_operation) . '</td>'; |
5563
|
|
|
} else { |
5564
|
|
|
print '<td class="small tdoverflowmax350 classfortooltip" title="' . dol_escape_htmltag($line->label_operation . ($line->label_operation ? '<br>' : '') . '<span style="font-size:0.8em">(' . length_accounta($line->subledger_account) . ')') . '">' . dol_escape_htmltag($line->label_operation) . ($line->label_operation ? '<br>' : '') . '<span style="font-size:0.8em">(' . dol_escape_htmltag(length_accounta($line->subledger_account)) . ')</span></td>'; |
5565
|
|
|
} |
5566
|
|
|
if (!$i) { |
5567
|
|
|
$totalarray['nbfield']++; |
5568
|
|
|
} |
5569
|
|
|
} |
5570
|
|
|
|
5571
|
|
|
// Lettering code |
5572
|
|
|
if (!empty($arrayfields['t.lettering_code']['checked'])) { |
5573
|
|
|
print '<td class="center">' . dol_escape_htmltag($line->lettering_code) . '</td>'; |
5574
|
|
|
if (!$i) { |
5575
|
|
|
$totalarray['nbfield']++; |
5576
|
|
|
} |
5577
|
|
|
} |
5578
|
|
|
|
5579
|
|
|
// Amount debit |
5580
|
|
|
if (!empty($arrayfields['t.debit']['checked'])) { |
5581
|
|
|
print '<td class="right nowraponall amount">' . ($line->debit != 0 ? price($line->debit) : '') . '</td>'; |
5582
|
|
|
if (!$i) { |
5583
|
|
|
$totalarray['nbfield']++; |
5584
|
|
|
} |
5585
|
|
|
if (!$i) { |
5586
|
|
|
$totalarray['pos'][$totalarray['nbfield']] = 'totaldebit'; |
5587
|
|
|
} |
5588
|
|
|
$totalarray['val']['totaldebit'] += $line->debit; |
5589
|
|
|
} |
5590
|
|
|
|
5591
|
|
|
// Amount credit |
5592
|
|
|
if (!empty($arrayfields['t.credit']['checked'])) { |
5593
|
|
|
print '<td class="right nowraponall amount">' . ($line->credit != 0 ? price($line->credit) : '') . '</td>'; |
5594
|
|
|
if (!$i) { |
5595
|
|
|
$totalarray['nbfield']++; |
5596
|
|
|
} |
5597
|
|
|
if (!$i) { |
5598
|
|
|
$totalarray['pos'][$totalarray['nbfield']] = 'totalcredit'; |
5599
|
|
|
} |
5600
|
|
|
$totalarray['val']['totalcredit'] += $line->credit; |
5601
|
|
|
} |
5602
|
|
|
|
5603
|
|
|
// Amount balance |
5604
|
|
|
if (!empty($arrayfields['t.balance']['checked'])) { |
5605
|
|
|
print '<td class="right nowraponall amount">' . price(price2num($sous_total_debit + $line->debit - $sous_total_credit - $line->credit, 'MT')) . '</td>'; |
5606
|
|
|
if (!$i) { |
5607
|
|
|
$totalarray['nbfield']++; |
5608
|
|
|
} |
5609
|
|
|
if (!$i) { |
5610
|
|
|
$totalarray['pos'][$totalarray['nbfield']] = 'totalbalance'; |
5611
|
|
|
}; |
5612
|
|
|
$totalarray['val']['totalbalance'] += $line->debit - $line->credit; |
5613
|
|
|
} |
5614
|
|
|
|
5615
|
|
|
// Exported operation date |
5616
|
|
|
if (!empty($arrayfields['t.date_export']['checked'])) { |
5617
|
|
|
print '<td class="center">' . dol_print_date($line->date_export, 'dayhour') . '</td>'; |
5618
|
|
|
if (!$i) { |
5619
|
|
|
$totalarray['nbfield']++; |
5620
|
|
|
} |
5621
|
|
|
} |
5622
|
|
|
|
5623
|
|
|
// Validated operation date |
5624
|
|
|
if (!empty($arrayfields['t.date_validated']['checked'])) { |
5625
|
|
|
print '<td class="center">' . dol_print_date($line->date_validation, 'dayhour') . '</td>'; |
5626
|
|
|
if (!$i) { |
5627
|
|
|
$totalarray['nbfield']++; |
5628
|
|
|
} |
5629
|
|
|
} |
5630
|
|
|
|
5631
|
|
|
if (!empty($arrayfields['t.import_key']['checked'])) { |
5632
|
|
|
print '<td class="tdoverflowmax100">' . dol_escape_htmltag($line->import_key) . "</td>\n"; |
5633
|
|
|
if (!$i) { |
5634
|
|
|
$totalarray['nbfield']++; |
5635
|
|
|
} |
5636
|
|
|
} |
5637
|
|
|
|
5638
|
|
|
// Fields from hook |
5639
|
|
|
$parameters = array('arrayfields' => $arrayfields, 'obj' => $line); |
5640
|
|
|
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook |
5641
|
|
|
print $hookmanager->resPrint; |
5642
|
|
|
|
5643
|
|
|
// Action column |
5644
|
|
|
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { |
5645
|
|
|
print '<td class="nowraponall center">'; |
5646
|
|
|
if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined |
5647
|
|
|
$selected = 0; |
5648
|
|
|
if (in_array($line->id, $arrayofselected)) { |
5649
|
|
|
$selected = 1; |
5650
|
|
|
} |
5651
|
|
|
print '<input id="cb' . $line->id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $line->id . '"' . ($selected ? ' checked="checked"' : '') . ' />'; |
5652
|
|
|
} |
5653
|
|
|
print '</td>'; |
5654
|
|
|
if (!$i) { |
5655
|
|
|
$totalarray['nbfield']++; |
5656
|
|
|
} |
5657
|
|
|
} |
5658
|
|
|
|
5659
|
|
|
// Comptabilise le sous-total |
5660
|
|
|
$sous_total_debit += $line->debit; |
5661
|
|
|
$sous_total_credit += $line->credit; |
5662
|
|
|
|
5663
|
|
|
print "</tr>\n"; |
5664
|
|
|
|
5665
|
|
|
$i++; |
5666
|
|
|
} |
5667
|
|
|
|
5668
|
|
|
if ($num > 0 && $colspan > 0) { |
5669
|
|
|
print '<tr class="liste_total">'; |
5670
|
|
|
print '<td class="right" colspan="' . $colspan . '">' . $langs->trans("TotalForAccount") . ' ' . $accountg . ':</td>'; |
5671
|
|
|
print '<td class="nowrap right">' . price(price2num($sous_total_debit, 'MT')) . '</td>'; |
5672
|
|
|
print '<td class="nowrap right">' . price(price2num($sous_total_credit, 'MT')) . '</td>'; |
5673
|
|
|
if ($colspanend > 0) { |
5674
|
|
|
print '<td colspan="' . $colspanend . '"></td>'; |
5675
|
|
|
} |
5676
|
|
|
print '</tr>'; |
5677
|
|
|
// Show balance of last shown account |
5678
|
|
|
$balance = $sous_total_debit - $sous_total_credit; |
5679
|
|
|
print '<tr class="liste_total">'; |
5680
|
|
|
print '<td class="right" colspan="' . $colspan . '">' . $langs->trans("Balance") . ':</td>'; |
5681
|
|
|
if ($balance > 0) { |
5682
|
|
|
print '<td class="nowraponall right">'; |
5683
|
|
|
print price(price2num($sous_total_debit - $sous_total_credit, 'MT')); |
5684
|
|
|
print '</td>'; |
5685
|
|
|
print '<td></td>'; |
5686
|
|
|
} else { |
5687
|
|
|
print '<td></td>'; |
5688
|
|
|
print '<td class="nowraponall right">'; |
5689
|
|
|
print price(price2num($sous_total_credit - $sous_total_debit, 'MT')); |
5690
|
|
|
print '</td>'; |
5691
|
|
|
} |
5692
|
|
|
if ($colspanend > 0) { |
5693
|
|
|
print '<td colspan="' . $colspanend . '"></td>'; |
5694
|
|
|
} |
5695
|
|
|
print '</tr>'; |
5696
|
|
|
} |
5697
|
|
|
|
5698
|
|
|
|
5699
|
|
|
// Clean total values to round them |
5700
|
|
|
if (!empty($totalarray['val']['totaldebit'])) { |
5701
|
|
|
$totalarray['val']['totaldebit'] = price2num($totalarray['val']['totaldebit'], 'MT'); |
5702
|
|
|
} |
5703
|
|
|
if (!empty($totalarray['val']['totalcredit'])) { |
5704
|
|
|
$totalarray['val']['totalcredit'] = price2num($totalarray['val']['totalcredit'], 'MT'); |
5705
|
|
|
} |
5706
|
|
|
if (!empty($totalarray['val']['totalbalance'])) { |
5707
|
|
|
$totalarray['val']['totalbalance'] = price2num($totalarray['val']['totaldebit'] - $totalarray['val']['totalcredit'], 'MT'); |
5708
|
|
|
} |
5709
|
|
|
|
5710
|
|
|
// Show total line |
5711
|
|
|
include DOL_DOCUMENT_ROOT . '/core/tpl/list_print_total.tpl.php'; |
5712
|
|
|
|
5713
|
|
|
// If no record found |
5714
|
|
|
if ($num == 0) { |
5715
|
|
|
$colspan = 1; |
5716
|
|
|
foreach ($arrayfields as $key => $val) { |
5717
|
|
|
if (!empty($val['checked'])) { |
5718
|
|
|
$colspan++; |
5719
|
|
|
} |
5720
|
|
|
} |
5721
|
|
|
print '<tr><td colspan="' . $colspan . '"><span class="opacitymedium">' . $langs->trans("NoRecordFound") . '</span></td></tr>'; |
5722
|
|
|
} |
5723
|
|
|
|
5724
|
|
|
$parameters = array('arrayfields' => $arrayfields); |
5725
|
|
|
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
5726
|
|
|
print $hookmanager->resPrint; |
5727
|
|
|
|
5728
|
|
|
print "</table>"; |
5729
|
|
|
print '</div>'; |
5730
|
|
|
|
5731
|
|
|
// TODO Replace this with mass delete action |
5732
|
|
|
//if ($user->hasRight('accounting', 'mouvements, 'supprimer_tous')) { |
5733
|
|
|
// print '<div class="tabsAction tabsActionNoBottom">'."\n"; |
5734
|
|
|
// print '<a class="butActionDelete" name="button_delmvt" href="'.$_SERVER['PHP_SELF'].'?action=delbookkeepingyear&token='.newToken().($param ? '&'.$param : '').'">'.$langs->trans("DeleteMvt").'</a>'; |
5735
|
|
|
// print '</div>'; |
5736
|
|
|
//} |
5737
|
|
|
|
5738
|
|
|
print '</form>'; |
5739
|
|
|
|
5740
|
|
|
// End of page |
5741
|
|
|
llxFooter(); |
5742
|
|
|
$db->close(); |
5743
|
|
|
} |
5744
|
|
|
} |
5745
|
|
|
|