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