dolibarr  7.0.0-beta
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
3  * Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
4  * Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
5  * Copyright (C) 2016-2017 Laurent Destailleur <eldy@users.sourceforge.net>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
26 require '../../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancyexport.class.php';
28 require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
29 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
30 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
31 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
32 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
33 require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
34 
35 // Langs
36 $langs->load("accountancy");
37 
38 $page = GETPOST("page");
39 $sortorder = GETPOST("sortorder");
40 $sortfield = GETPOST("sortfield");
41 $action = GETPOST('action', 'alpha');
42 $search_mvt_num = GETPOST('search_mvt_num', 'int');
43 $search_doc_type = GETPOST("search_doc_type");
44 $search_doc_ref = GETPOST("search_doc_ref");
45 $search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int'));
46 $search_date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int'));
47 $search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int'));
48 $search_date_creation_start = dol_mktime(0, 0, 0, GETPOST('date_creation_startmonth', 'int'), GETPOST('date_creation_startday', 'int'), GETPOST('date_creation_startyear', 'int'));
49 $search_date_creation_end = dol_mktime(0, 0, 0, GETPOST('date_creation_endmonth', 'int'), GETPOST('date_creation_endday', 'int'), GETPOST('date_creation_endyear', 'int'));
50 $search_date_modification_start = dol_mktime(0, 0, 0, GETPOST('date_modification_startmonth', 'int'), GETPOST('date_modification_startday', 'int'), GETPOST('date_modification_startyear', 'int'));
51 $search_date_modification_end = dol_mktime(0, 0, 0, GETPOST('date_modification_endmonth', 'int'), GETPOST('date_modification_endday', 'int'), GETPOST('date_modification_endyear', 'int'));
52 
53 if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_delmvt")) {
54  $action = 'delbookkeepingyear';
55 }
56 if (GETPOST("button_export_file_x") || GETPOST("button_export_file.x") || GETPOST("button_export_file")) {
57  $action = 'export_file';
58 }
59 
60 $search_accountancy_code = GETPOST("search_accountancy_code");
61 $search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha');
62 if ($search_accountancy_code_start == - 1) {
63  $search_accountancy_code_start = '';
64 }
65 $search_accountancy_code_end = GETPOST('search_accountancy_code_end', 'alpha');
66 if ($search_accountancy_code_end == - 1) {
67  $search_accountancy_code_end = '';
68 }
69 
70 $search_accountancy_aux_code = GETPOST("search_accountancy_aux_code");
71 $search_accountancy_aux_code_start = GETPOST('search_accountancy_aux_code_start', 'alpha');
72 if ($search_accountancy_aux_code_start == - 1) {
73  $search_accountancy_aux_code_start = '';
74 }
75 $search_accountancy_aux_code_end = GETPOST('search_accountancy_aux_code_end', 'alpha');
76 if ($search_accountancy_aux_code_end == - 1) {
77  $search_accountancy_aux_code_end = '';
78 }
79 $search_mvt_label = GETPOST('search_mvt_label', 'alpha');
80 $search_direction = GETPOST('search_direction', 'alpha');
81 $search_ledger_code = GETPOST('search_ledger_code', 'alpha');
82 
83 // Load variable for pagination
84 $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
85 $sortfield = GETPOST('sortfield', 'alpha');
86 $sortorder = GETPOST('sortorder', 'alpha');
87 $page = GETPOST('page','int');
88 if (empty($page) || $page < 0) { $page = 0; }
89 $offset = $limit * $page;
90 $pageprev = $page - 1;
91 $pagenext = $page + 1;
92 if ($sortorder == "") $sortorder = "ASC";
93 if ($sortfield == "") $sortfield = "t.rowid";
94 
95 
96 $object = new BookKeeping($db);
97 
98 $formaccounting = new FormAccounting($db);
99 $formother = new FormOther($db);
100 $form = new Form($db);
101 
102 if (! in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && ! isset($_POST['begin']) && ! isset($_GET['begin']) && ! isset($_POST['formfilteraction']) && empty($page) && ! GETPOST('noreset','int'))
103 {
104  $query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
105  $query .= " where date_start < now() and date_end > now() limit 1";
106  $res = $db->query($query);
107  if ($res->num_rows > 0) {
108  $fiscalYear = $db->fetch_object($res);
109  $search_date_start = strtotime($fiscalYear->date_start);
110  $search_date_end = strtotime($fiscalYear->date_end);
111  } else {
112  $month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
113  $year_start = dol_print_date(dol_now(), '%Y');
114  $year_end = $year_start + 1;
115  $month_end = $month_start - 1;
116  if ($month_end < 1)
117  {
118  $month_end = 12;
119  $year_end--;
120  }
121  $search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start);
122  $search_date_end = dol_get_last_day($year_end, $month_end);
123  }
124 }
125 
126 
127 $arrayfields=array(
128  't.piece_num'=>array('label'=>$langs->trans("TransactionNumShort"), 'checked'=>1),
129  't.doc_date'=>array('label'=>$langs->trans("Docdate"), 'checked'=>1),
130  't.doc_ref'=>array('label'=>$langs->trans("Docref"), 'checked'=>1),
131  't.numero_compte'=>array('label'=>$langs->trans("AccountAccountingShort"), 'checked'=>1),
132  't.subledger_account'=>array('label'=>$langs->trans("SubledgerAccount"), 'checked'=>1),
133  't.label_operation'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
134  't.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1),
135  't.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1),
136  't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1),
137  't.date_creation'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0),
138  't.tms'=>array('label'=>$langs->trans("DateModification"), 'checked'=>0),
139 );
140 
141 
142 /*
143  * Actions
144  */
145 
146 if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
147 if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
148 
149 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
150 
151 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
152 {
153  $search_mvt_num = '';
154  $search_doc_type = '';
155  $search_doc_ref = '';
156  $search_doc_date = '';
157  $search_accountancy_code = '';
158  $search_accountancy_code_start = '';
159  $search_accountancy_code_end = '';
160  $search_accountancy_aux_code = '';
161  $search_accountancy_aux_code_start = '';
162  $search_accountancy_aux_code_end = '';
163  $search_mvt_label = '';
164  $search_direction = '';
165  $search_ledger_code = '';
166  $search_date_start = '';
167  $search_date_end = '';
168  $search_date_creation_start = '';
169  $search_date_creation_end = '';
170  $search_date_modification_start = '';
171  $search_date_modification_end = '';
172  $search_debit = '';
173  $search_credit = '';
174 }
175 
176 // Must be after the remove filter action, before the export.
177 $param = '';
178 $filter = array ();
179 if (! empty($search_date_start)) {
180  $filter['t.doc_date>='] = $search_date_start;
181  $tmp=dol_getdate($search_date_start);
182  $param .= '&date_startmonth=' . $tmp['mon'] . '&date_startday=' . $tmp['mday'] . '&date_startyear=' . $tmp['year'];
183 }
184 if (! empty($search_date_end)) {
185  $filter['t.doc_date<='] = $search_date_end;
186  $tmp=dol_getdate($search_date_end);
187  $param .= '&date_endmonth=' . $tmp['mon'] . '&date_endday=' . $tmp['mday'] . '&date_endyear=' . $tmp['year'];
188 }
189 if (! empty($search_doc_date)) {
190  $filter['t.doc_date'] = $search_doc_date;
191  $tmp=dol_getdate($search_doc_date);
192  $param .= '&doc_datemonth=' . $tmp['mon'] . '&doc_dateday=' . $tmp['mday'] . '&doc_dateyear=' . $tmp['year'];
193 }
194 if (! empty($search_doc_type)) {
195  $filter['t.doc_type'] = $search_doc_type;
196  $param .= '&search_doc_type=' . $search_doc_type;
197 }
198 if (! empty($search_doc_ref)) {
199  $filter['t.doc_ref'] = $search_doc_ref;
200  $param .= '&search_doc_ref=' . $search_doc_ref;
201 }
202 if (! empty($search_accountancy_code)) {
203  $filter['t.numero_compte'] = $search_accountancy_code;
204  $param .= '&search_accountancy_code=' . $search_accountancy_code;
205 }
206 if (! empty($search_accountancy_code_start)) {
207  $filter['t.numero_compte>='] = $search_accountancy_code_start;
208  $param .= '&search_accountancy_code_start=' . $search_accountancy_code_start;
209 }
210 if (! empty($search_accountancy_code_end)) {
211  $filter['t.numero_compte<='] = $search_accountancy_code_end;
212  $param .= '&search_accountancy_code_end=' . $search_accountancy_code_end;
213 }
214 if (! empty($search_accountancy_aux_code)) {
215  $filter['t.subledger_account'] = $search_accountancy_aux_code;
216  $param .= '&search_accountancy_aux_code=' . $search_accountancy_aux_code;
217 }
218 if (! empty($search_accountancy_aux_code_start)) {
219  $filter['t.subledger_account>='] = $search_accountancy_aux_code_start;
220  $param .= '&search_accountancy_aux_code_start=' . $search_accountancy_aux_code_start;
221 }
222 if (! empty($search_accountancy_aux_code_end)) {
223  $filter['t.subledger_account<='] = $search_accountancy_aux_code_end;
224  $param .= '&search_accountancy_aux_code_end=' . $search_accountancy_aux_code_end;
225 }
226 if (! empty($search_mvt_label)) {
227  $filter['t.label_operation'] = $search_mvt_label;
228  $param .= '&search_mvt_label=' . $search_mvt_label;
229 }
230 if (! empty($search_direction)) {
231  $filter['t.sens'] = $search_direction;
232  $param .= '&search_direction=' . $search_direction;
233 }
234 if (! empty($search_ledger_code)) {
235  $filter['t.code_journal'] = $search_ledger_code;
236  $param .= '&search_ledger_code=' . $search_ledger_code;
237 }
238 if (! empty($search_mvt_num)) {
239  $filter['t.piece_num'] = $search_mvt_num;
240  $param .= '&search_mvt_num=' . $search_mvt_num;
241 }
242 if (! empty($search_date_creation_start)) {
243  $filter['t.date_creation>='] = $search_date_creation_start;
244  $tmp=dol_getdate($search_date_creation_start);
245  $param .= '&date_creation_startmonth=' . $tmp['mon'] . '&date_creation_startday=' . $tmp['mday'] . '&date_creation_startyear=' . $tmp['year'];
246 }
247 if (! empty($search_date_creation_end)) {
248  $filter['t.date_creation<='] = $search_date_creation_end;
249  $tmp=dol_getdate($search_date_creation_end);
250  $param .= '&date_creation_endmonth=' . $tmp['mon'] . '&date_creation_endday=' . $tmp['mday'] . '&date_creation_endyear=' . $tmp['year'];
251 }
252 if (! empty($search_date_modification_start)) {
253  $filter['t.tms>='] = $search_date_modification_start;
254  $tmp=dol_getdate($search_date_modification_start);
255  $param .= '&date_modification_startmonth=' . $tmp['mon'] . '&date_modification_startday=' . $tmp['mday'] . '&date_modification_startyear=' . $tmp['year'];
256 }
257 if (! empty($search_date_modification_end)) {
258  $filter['t.tms<='] = $search_date_modification_end;
259  $tmp=dol_getdate($search_date_modification_end);
260  $param .= '&date_modification_endmonth=' . $tmp['mon'] . '&date_modification_endday=' . $tmp['mday'] . '&date_modification_endyear=' . $tmp['year'];
261 }
262 if (! empty($search_debit)) {
263  $filter['t.debit'] = $search_debit;
264  $param .= '&search_debit=' . $search_debit;
265 }
266 if (! empty($search_credit)) {
267  $filter['t.credit'] = $search_credit;
268  $param .= '&search_credit=' . $search_credit;
269 }
270 
271 if ($action == 'delbookkeeping') {
272 
273  $import_key = GETPOST('importkey', 'alpha');
274 
275  if (! empty($import_key)) {
276  $result = $object->deleteByImportkey($import_key);
277  if ($result < 0) {
278  setEventMessages($object->error, $object->errors, 'errors');
279  }
280  Header("Location: list.php");
281  exit();
282  }
283 }
284 if ($action == 'delbookkeepingyearconfirm') {
285 
286  $delyear = GETPOST('delyear', 'int');
287  if ($delyear==-1) {
288  $delyear=0;
289  }
290  $deljournal = GETPOST('deljournal','alpha');
291  if ($deljournal==-1) {
292  $deljournal=0;
293  }
294 
295  if (! empty($delyear) || ! empty($deljournal))
296  {
297  $result = $object->deleteByYearAndJournal($delyear,$deljournal);
298  if ($result < 0) {
299  setEventMessages($object->error, $object->errors, 'errors');
300  }
301  else
302  {
303  setEventMessages("RecordDeleted", null, 'mesgs');
304  }
305  Header("Location: list.php");
306  exit;
307  }
308  else
309  {
310  setEventMessages("NoRecordDeleted", null, 'warnings');
311  Header("Location: list.php");
312  exit;
313  }
314 }
315 if ($action == 'delmouvconfirm') {
316 
317  $mvt_num = GETPOST('mvt_num', 'int');
318 
319  if (! empty($mvt_num)) {
320  $result = $object->deleteMvtNum($mvt_num);
321  if ($result < 0) {
322  setEventMessages($object->error, $object->errors, 'errors');
323  }
324  else
325  {
326  setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
327  }
328 
329  Header("Location: list.php?noreset=1".($param?'&'.$param:''));
330  exit;
331  }
332 }
333 
334 // Export into a file with format defined into setup
335 if ($action == 'export_file') {
336 
337  $result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter);
338 
339  if ($result < 0)
340  {
341  setEventMessages($object->error, $object->errors, 'errors');
342  }
343  else
344  {
345  $accountancyexport = new AccountancyExport($db);
346  $accountancyexport->export($object->lines);
347  if (!empty($accountancyexport->errors)) {
348  setEventMessages('', $accountancyexport->errors, 'errors');
349  }
350  exit;
351  }
352 }
353 
354 
355 /*
356  * View
357  */
358 
359 $title_page = $langs->trans("Bookkeeping");
360 
361 llxHeader('', $title_page);
362 
363 // List
364 $nbtotalofrecords = '';
365 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
366  $nbtotalofrecords = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter);
367  if ($nbtotalofrecords < 0) {
368  setEventMessages($object->error, $object->errors, 'errors');
369  }
370 }
371 
372 // TODO Do not use this
373 $result = $object->fetchAll($sortorder, $sortfield, $limit, $offset, $filter);
374 if ($result < 0) {
375  setEventMessages($object->error, $object->errors, 'errors');
376 }
377 
378 $num=count($object->lines);
379 
380 if ($action == 'delmouv') {
381  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?mvt_num='.GETPOST('mvt_num').$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1);
382  print $formconfirm;
383 }
384 if ($action == 'delbookkeepingyear') {
385 
386  $form_question = array ();
387  $delyear = GETPOST('delyear');
388  $deljournal = GETPOST('deljournal');
389 
390  if (empty($delyear)) {
391  $delyear = dol_print_date(dol_now(), '%Y');
392  }
393  $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
394  $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1);
395 
396  $form_question['delyear'] = array (
397  'name' => 'delyear',
398  'type' => 'select',
399  'label' => $langs->trans('DelYear'),
400  'values' => $year_array,
401  'default' => $delyear
402  );
403  $form_question['deljournal'] = array (
404  'name' => 'deljournal',
405  'type' => 'other', // We don't use select here, the journal_array is already a select html component
406  'label' => $langs->trans('DelJournal'),
407  'value' => $journal_array,
408  'default' => $deljournal
409  );
410 
411  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, 0, 1, 250);
412  print $formconfirm;
413 }
414 
415 //$param=''; param started before
416 if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
417 if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
418 
419 print '<form method="POST" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">';
420 print '<input type="hidden" name="action" value="list">';
421 if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
422 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
423 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
424 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
425 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
426 print '<input type="hidden" name="page" value="'.$page.'">';
427 
428 $listofformat=AccountancyExport::getType();
429 $button = '<a class="butAction" name="button_export_file" href="'.$_SERVER["PHP_SELF"].'?action=export_file'.($param?'&'.$param:'').'">';
430 if (count($filter)) $button.= $langs->trans("ExportFilteredList");
431 else $button.= $langs->trans("ExportList");
432 //$button.=' ('.$listofformat[$conf->global->ACCOUNTING_EXPORT_MODELCSV].')';
433 $button.= '</a>';
434 
435 
436 $groupby = ' <a class="nohover" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php"">' . $langs->trans("GroupByAccountAccounting") . '</a>';
437 $addbutton = '<a class="butAction" href="./card.php?action=create">' . $langs->trans("NewAccountingMvt") . '</a>';
438 
439 print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $button, $result, $nbtotalofrecords, 'title_accountancy', 0, $groupby.$addbutton, '', $limit);
440 
441 $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
442 $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
443 if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
444 
445 print '<div class="div-table-responsive">';
446 print '<table class="tagtable liste" width="100%">';
447 
448 // Filters lines
449 print '<tr class="liste_titre_filter">';
450 // Movement number
451 if (! empty($arrayfields['t.piece_num']['checked']))
452 {
453  print '<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="' . dol_escape_htmltag($search_mvt_num) . '"></td>';
454 }
455 // Date document
456 if (! empty($arrayfields['t.doc_date']['checked']))
457 {
458  print '<td class="liste_titre center">';
459  print '<div class="nowrap">';
460  print $langs->trans('From') . ' ';
461  print $form->select_date($search_date_start?$search_date_start:-1, 'date_start', 0, 0, 1);
462  print '</div>';
463  print '<div class="nowrap">';
464  print $langs->trans('to') . ' ';
465  print $form->select_date($search_date_end?$search_date_end:-1, 'date_end', 0, 0, 1);
466  print '</div>';
467  print '</td>';
468 }
469 // Ref document
470 if (! empty($arrayfields['t.doc_ref']['checked']))
471 {
472  print '<td class="liste_titre"><input type="text" name="search_doc_ref" size="8" value="' . dol_escape_htmltag($search_doc_ref) . '"></td>';
473 }
474 // Accountancy account
475 if (! empty($arrayfields['t.numero_compte']['checked']))
476 {
477  print '<td class="liste_titre">';
478  print '<div class="nowrap">';
479  print $langs->trans('From').' ';
480  print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, 'maxwidth200');
481  print '</div>';
482  print '<div class="nowrap">';
483  print $langs->trans('to').' ';
484  print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, 'maxwidth200');
485  print '</div>';
486  print '</td>';
487 }
488 // Subledger account
489 if (! empty($arrayfields['t.subledger_account']['checked']))
490 {
491  print '<td class="liste_titre">';
492  print '<div class="nowrap">';
493  print $langs->trans('From').' ';
494  // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not
495  // use setup of keypress to select thirdparty and this hang browser on large database.
496  if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
497  {
498  print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1);
499  }
500  else
501  {
502  print '<input type="text" name="search_accountancy_aux_code_start" value="'.$search_accountancy_aux_code_start.'">';
503  }
504  print '</div>';
505  print '<div class="nowrap">';
506  print $langs->trans('to').' ';
507  // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not
508  // use setup of keypress to select thirdparty and this hang browser on large database.
509  if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
510  {
511  print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1);
512  }
513  else
514  {
515  print '<input type="text" name="search_accountancy_aux_code_end" value="'.$search_accountancy_aux_code_end.'">';
516  }
517  print '</div>';
518  print '</td>';
519 }
520 // Label operation
521 if (! empty($arrayfields['t.label_operation']['checked']))
522 {
523  print '<td class="liste_titre">';
524  print '<input type="text" size="7" class="flat" name="search_mvt_label" value="' . $search_mvt_label . '"/>';
525  print '</td>';
526 }
527 // Debit
528 if (! empty($arrayfields['t.debit']['checked']))
529 {
530  print '<td class="liste_titre" align="right">';
531  print '<input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).'">';
532  print '</td>';
533 }
534 // Credit
535 if (! empty($arrayfields['t.credit']['checked']))
536 {
537  print '<td class="liste_titre" align="right">';
538  print '<input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).'">';
539  print '</td>';
540 }
541 // Code journal
542 if (! empty($arrayfields['t.code_journal']['checked']))
543 {
544  print '<td class="liste_titre center"><input type="text" name="search_ledger_code" size="3" value="' . $search_ledger_code . '"></td>';
545 }
546 // Date creation
547 if (! empty($arrayfields['t.date_creation']['checked']))
548 {
549  print '<td class="liste_titre center">';
550  print '<div class="nowrap">';
551  print $langs->trans('From') . ' ';
552  print $form->select_date($search_date_creation_start, 'date_creation_start', 0, 0, 1);
553  print '</div>';
554  print '<div class="nowrap">';
555  print $langs->trans('to') . ' ';
556  print $form->select_date($search_date_creation_end, 'date_creation_end', 0, 0, 1);
557  print '</div>';
558  print '</td>';
559 }
560 // Date modification
561 if (! empty($arrayfields['t.tms']['checked']))
562 {
563  print '<td class="liste_titre center">';
564  print '<div class="nowrap">';
565  print $langs->trans('From') . ' ';
566  print $form->select_date($search_date_modification_start, 'date_modification_start', 0, 0, 1);
567  print '</div>';
568  print '<div class="nowrap">';
569  print $langs->trans('to') . ' ';
570  print $form->select_date($search_date_modification_end, 'date_modification_end', 0, 0, 1);
571  print '</div>';
572  print '</td>';
573 }
574 // Action column
575 print '<td class="liste_titre center">';
576 $searchpicto=$form->showFilterButtons();
577 print $searchpicto;
578 print '</td>';
579 print "</tr>\n";
580 
581 print '<tr class="liste_titre">';
582 if (! empty($arrayfields['t.piece_num']['checked'])) print_liste_field_titre("TransactionNumShort", $_SERVER['PHP_SELF'], "t.piece_num", "", $param, "", $sortfield, $sortorder);
583 if (! empty($arrayfields['t.doc_date']['checked'])) print_liste_field_titre("Docdate", $_SERVER['PHP_SELF'], "t.doc_date", "", $param, 'align="center"', $sortfield, $sortorder);
584 if (! empty($arrayfields['t.doc_ref']['checked'])) print_liste_field_titre("Docref", $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder);
585 if (! empty($arrayfields['t.numero_compte']['checked'])) print_liste_field_titre("AccountAccountingShort", $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
586 if (! empty($arrayfields['t.subledger_account']['checked'])) print_liste_field_titre("SubledgerAccount", $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder);
587 if (! empty($arrayfields['t.label_operation']['checked'])) print_liste_field_titre("Label", $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
588 if (! empty($arrayfields['t.debit']['checked'])) print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $param, 'align="right"', $sortfield, $sortorder);
589 if (! empty($arrayfields['t.credit']['checked'])) print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $param, 'align="right"', $sortfield, $sortorder);
590 if (! empty($arrayfields['t.code_journal']['checked'])) print_liste_field_titre("Codejournal", $_SERVER['PHP_SELF'], "t.code_journal", "", $param, 'align="center"', $sortfield, $sortorder);
591 if (! empty($arrayfields['t.date_creation']['checked'])) print_liste_field_titre("DateCreation", $_SERVER['PHP_SELF'], "t.date_creation", "", $param, 'align="center"', $sortfield, $sortorder);
592 if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre("DateModification", $_SERVER['PHP_SELF'], "t.tms", "", $param, 'align="center"', $sortfield, $sortorder);
593 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
594 print "</tr>\n";
595 
596 
597 if ($num > 0)
598 {
599  $i=0;
600  $totalarray=array();
601  while ($i < min($num, $limit))
602  {
603  $line = $object->lines[$i];
604 
605  $total_debit += $line->debit;
606  $total_credit += $line->credit;
607 
608  print '<tr class="oddeven">';
609 
610  // Piece number
611  if (! empty($arrayfields['t.piece_num']['checked']))
612  {
613  print '<td><a href="./card.php?piece_num=' . $line->piece_num . '">' . $line->piece_num . '</a></td>';
614  if (! $i) $totalarray['nbfield']++;
615  }
616 
617  // Document date
618  if (! empty($arrayfields['t.doc_date']['checked']))
619  {
620  print '<td align="center">' . dol_print_date($line->doc_date, 'day') . '</td>';
621  if (! $i) $totalarray['nbfield']++;
622  }
623 
624  // Document ref
625  if (! empty($arrayfields['t.doc_ref']['checked']))
626  {
627  print '<td class="nowrap">' . $line->doc_ref . '</td>';
628  if (! $i) $totalarray['nbfield']++;
629  }
630 
631  // Account number
632  if (! empty($arrayfields['t.numero_compte']['checked']))
633  {
634  print '<td>' . length_accountg($line->numero_compte) . '</td>';
635  if (! $i) $totalarray['nbfield']++;
636  }
637 
638  // Subledger account
639  if (! empty($arrayfields['t.subledger_account']['checked']))
640  {
641  print '<td>' . length_accounta($line->subledger_account) . '</td>';
642  if (! $i) $totalarray['nbfield']++;
643  }
644 
645  // Label operation
646  if (! empty($arrayfields['t.label_operation']['checked']))
647  {
648  print '<td>' . $line->label_operation . '</td>';
649  if (! $i) $totalarray['nbfield']++;
650  }
651 
652  // Amount debit
653  if (! empty($arrayfields['t.debit']['checked']))
654  {
655  print '<td align="right">' . ($line->debit ? price($line->debit) : ''). '</td>';
656  if (! $i) $totalarray['nbfield']++;
657  if (! $i) $totalarray['totaldebitfield']=$totalarray['nbfield'];
658  $totalarray['totaldebit'] += $line->debit;
659  }
660 
661  // Amount credit
662  if (! empty($arrayfields['t.credit']['checked']))
663  {
664  print '<td align="right">' . ($line->credit ? price($line->credit) : '') . '</td>';
665  if (! $i) $totalarray['nbfield']++;
666  if (! $i) $totalarray['totalcreditfield']=$totalarray['nbfield'];
667  $totalarray['totalcredit'] += $line->credit;
668  }
669 
670  // Journal code
671  if (! empty($arrayfields['t.code_journal']['checked']))
672  {
673  $accountingjournal = new AccountingJournal($db);
674  $result = $accountingjournal->fetch('',$line->code_journal);
675  $journaltoshow = (($result > 0)?$accountingjournal->getNomUrl(0,0,0,'',0) : $line->code_journal);
676  print '<td align="center">' . $journaltoshow . '</td>';
677  if (! $i) $totalarray['nbfield']++;
678  }
679 
680  // Creation operation date
681  if (! empty($arrayfields['t.date_creation']['checked']))
682  {
683  print '<td align="center">' . dol_print_date($line->date_creation, 'day') . '</td>';
684  if (! $i) $totalarray['nbfield']++;
685  }
686 
687  // Modification operation date
688  if (! empty($arrayfields['t.tms']['checked']))
689  {
690  print '<td align="center">' . dol_print_date($line->date_modification, 'day') . '</td>';
691  if (! $i) $totalarray['nbfield']++;
692  }
693 
694  // Action column
695  print '<td align="center">';
696  print '<a href="./card.php?piece_num=' . $line->piece_num . '">' . img_edit() . '</a>&nbsp;';
697  print '<a href="' . $_SERVER['PHP_SELF'] . '?action=delmouv&mvt_num=' . $line->piece_num . $param . '&page=' . $page . '">' . img_delete() . '</a>';
698  print '</td>';
699  if (! $i) $totalarray['nbfield']++;
700 
701  print "</tr>\n";
702 
703  $i++;
704  }
705 
706  // Show total line
707  if (isset($totalarray['totaldebitfield']) || isset($totalarray['totalcreditfield']))
708  {
709  $i=0;
710  while ($i < $totalarray['nbfield'])
711  {
712  $i++;
713  if ($i == 1)
714  {
715  if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>';
716  else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
717  }
718  elseif ($totalarray['totaldebitfield'] == $i) print '<td align="right">'.price($totalarray['totaldebit']).'</td>';
719  elseif ($totalarray['totalcreditfield'] == $i) print '<td align="right">'.price($totalarray['totalcredit']).'</td>';
720  else print '<td></td>';
721  }
722  print '</tr>';
723 
724  }
725 }
726 
727 print "</table>";
728 print '</div>';
729 
730 // TODO Replace this with mass action
731 print '<div class="tabsAction tabsActionNoBottom">' . "\n";
732 print '<a class="butActionDelete" name="button_delmvt" href="'.$_SERVER["PHP_SELF"].'?action=delbookkeepingyear'.($param?'&'.$param:'').'">' . $langs->trans("DelBookKeeping") . '</a>';
733 print '</div>';
734 
735 
736 print '</form>';
737 
738 llxFooter();
739 
740 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
if(!GETPOST('transkey')&&!GETPOST('transphrase')) else
View.
Definition: notice.php:43
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm=false, $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
if(GETPOST('cancel','alpha')) if(!GETPOST('confirmmassaction','alpha')&&$massaction!= 'presend'&&$massaction!= 'confirm_presend')
Draft customers invoices.
Definition: list.php:147
if(empty($reshook)) $form
View.
Definition: perms.php:103
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage Ledger (General Ledger and Subledger)
Class to manage generation of HTML components Only common components must be here.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='title_generic.png', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0)
Print a title with navigation controls for pagination.
static getType()
Array with all export type available (key + label)
Classe permettant la generation de composants html autre Only common components are here...
llxHeader()
Empty header.
Definition: wrapper.php:46
length_accounta($accounta)
Return Auxiliary accounting account of thirdparties with defined length.
dol_now($mode='gmt')
Return date for now.
img_delete($titlealt= 'default', $other= 'class="pictodelete"')
Show delete logo.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:104
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition: date.lib.php:459
print
Draft customers invoices.
Definition: index.php:91
Class to manage generation of HTML components for accounting management.
Class AccountancyExport.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="")
Show title line of an array.
Class to manage accounting accounts.
dol_getdate($timestamp, $fast=false)
Return an array with locale date info.
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous) ...
img_edit($titlealt= 'default', $float=0, $other= 'class="pictoedit"')
Show logo editer/modifier fiche.