* Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2013-2015 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ /** * \file htdocs/accountancy/bookkeeping/list.php * \ingroup Accounting Expert * \brief List operation of book keeping */ require '../../main.inc.php'; // Class require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; // Langs $langs->load("accountancy"); $page = GETPOST("page"); $sortorder = GETPOST("sortorder"); $sortfield = GETPOST("sortfield"); $action = GETPOST('action', 'alpha'); $search_doc_type = GETPOST("search_doc_type"); $search_doc_ref = GETPOST("search_doc_ref"); $search_account = GETPOST("search_account"); $search_thirdparty = GETPOST("search_thirdparty"); $search_journal = GETPOST("search_journal"); if ($sortorder == "") $sortorder = "ASC"; if ($sortfield == "") $sortfield = "bk.rowid"; $offset = $conf->liste_limit * $page; $formventilation = new FormVentilation($db); if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_doc_type=""; $search_doc_ref=""; $search_account=""; $search_thirdparty=""; $search_journal=""; } /* * Action */ if ($action == 'delbookkeeping') { $import_key = GETPOST('importkey', 'alpha'); if (! empty($import_key)) { $object = new BookKeeping($db); $result = $object->delete_by_importkey($import_key); Header("Location: list.php"); if ($result < 0) { setEventMessage($object->errors, 'errors'); } } } // Export else if ($action == 'export_csv') { header('Content-Type: text/csv'); header('Content-Disposition: attachment;filename=export_csv.csv'); $object = new BookKeeping($db); $result = $object->export_bookkeping('ebp'); if ($result < 0) { setEventMessage($object->errors, 'errors'); } foreach ( $object->linesexport as $line ) { print $line->id . ','; print '"' . dol_print_date($line->doc_date, '%d%m%Y') . '",'; print '"' . $line->code_journal . '",'; print '"' . $line->numero_compte . '",'; print '"' . substr($line->code_journal, 0, 2) . '",'; print '"' . substr($line->doc_ref, 0, 40) . '",'; print '"' . $line->num_piece . '",'; print '"' . $line->montant . '",'; print '"' . $line->sens . '",'; print '"' . dol_print_date($line->doc_date, '%d%m%Y') . '",'; print '"' . $conf->currency . '",'; print "\n"; } } else { llxHeader('', $langs->trans("Bookkeeping")); /* * List */ $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num "; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk"; if (dol_strlen(trim($search_doc_type))) { $sql .= " WHERE bk.doc_type LIKE '%" . $search_doc_type . "%'"; if (dol_strlen(trim($search_doc_ref))) { $sql .= " AND bk.doc_ref LIKE '%" . $search_doc_ref . "%'"; } } if (dol_strlen(trim($search_doc_ref))) { $sql .= " WHERE bk.doc_ref LIKE '%" . $search_doc_ref . "%'"; } if (dol_strlen(trim($search_account))) { $sql .= " WHERE bk.numero_compte LIKE '%" . $search_account . "%'"; } if (dol_strlen(trim($search_thirdparty))) { $sql .= " WHERE bk.code_tiers LIKE '%" . $search_thirdparty . "%'"; } if (dol_strlen(trim($search_journal))) { $sql .= " WHERE bk.code_journal LIKE '%" . $search_journal . "%'"; } $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit + 1, $offset); dol_syslog('accountancy/bookkeeping/list.php:: $sql=' . $sql); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; print_barre_liste($langs->trans("Bookkeeping"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num); print '
'; print ''; print ''; print $formventilation->select_bookkeeping_importkey('importkey', GETPOST('importkey')); print '
'; print '
'; print '
'; print ''; print ''; print ''; print '
'; print ''; print ''; print_liste_field_titre($langs->trans("Doctype"), $_SERVER['PHP_SELF'], "bk.doc_type", "", "", "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Docdate"), $_SERVER['PHP_SELF'], "bk.doc_date", "", "", "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "bk.doc_ref", "", "", "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Numerocompte"), $_SERVER['PHP_SELF'], "bk.numero_compte", "", "", "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Code_tiers"), $_SERVER['PHP_SELF'], "bk.code_tiers", "", "", "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "bk_label_compte", "", "", "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "bk.debit", "", "", 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "bk.credit", "", "", 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "bk.montant", "", "", 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Sens"), $_SERVER['PHP_SELF'], "bk.sens", "", "", 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "bk.code_journal", "", "", "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"",$param,"",'width="60" align="center"',$sortfield,$sortorder); print "\n"; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; $var = True; while ( $i < min($num, $conf->liste_limit) ) { $obj = $db->fetch_object($resql); $var = ! $var; print ""; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; $i ++; } print "
      '; print ''; print ' '; print ''; print '
' . $obj->doc_type . '' . dol_print_date($db->jdate($obj->doc_date), 'day') . '' . $obj->doc_ref . '' . length_accountg($obj->numero_compte) . '' . length_accounta($obj->code_tiers) . '' . $obj->label_compte . '' . price($obj->debit) . '' . price($obj->credit) . '' . price($obj->montant) . '' . $obj->sens . '' . $obj->code_journal . '' . img_edit() . '
"; print ''; $db->free($resql); } else { dol_print_error($db); } } llxFooter(); $db->close();