* Copyright (C) 2007-2016 Laurent Destailleur * Copyright (C) 2009-2012 Regis Houssin * Copyright (C) 2014 Alexandre Spangaro * Copyright (C) 2016 Juanjo Menent * * 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/compta/paiement/cheque/list.php * \ingroup compta * \brief Page list of cheque deposits */ require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; // Load translation files required by the page $langs->loadLangs(array('banks', 'categories', 'bills')); // Security check if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'banque', '', ''); $search_ref = GETPOST('search_ref', 'alpha'); $search_account = GETPOST('search_account', 'int'); $search_amount = GETPOST('search_amount', 'alpha'); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="dp"; $year=GETPOST("year"); $month=GETPOST("month"); $form=new Form($db); $formother = new FormOther($db); $checkdepositstatic=new RemiseCheque($db); $accountstatic=new Account($db); /* * Actions */ // If click on purge search criteria ? 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 { $search_ref=''; $search_amount=''; $search_account=''; $year=''; $month=''; } /* * View */ llxHeader('', $langs->trans("ChequesReceipts")); $sql = "SELECT bc.rowid, bc.ref as ref, bc.date_bordereau as dp,"; $sql.= " bc.nbcheque, bc.amount, bc.statut,"; $sql.= " ba.rowid as bid, ba.label"; $sql.= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc,"; $sql.= " ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " WHERE bc.fk_bank_account = ba.rowid"; $sql.= " AND bc.entity = ".$conf->entity; // Search criteria if ($search_ref) $sql.=natural_search("bc.ref", $search_ref); if ($search_account > 0) $sql.=" AND bc.fk_bank_account=".$search_account; if ($search_amount) $sql.=natural_search("bc.amount", price2num($search_amount)); if ($month > 0) { if ($year > 0 && empty($day)) $sql.= " AND bc.date_bordereau BETWEEN '".$db->idate(dol_get_first_day($year, $month, false))."' AND '".$db->idate(dol_get_last_day($year, $month, false))."'"; elseif ($year > 0 && ! empty($day)) $sql.= " AND bc.date_bordereau BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'"; else $sql.= " AND date_format(bc.date_bordereau, '%m') = '".$month."'"; } elseif ($year > 0) { $sql.= " AND bc.date_bordereau BETWEEN '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; } $sql.= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 { $page = 0; $offset = 0; } } $sql.= $db->plimit($limit+1, $offset); //print "$sql"; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; $newcardbutton=''; if ($user->rights->banque->cheque) { $newcardbutton.= dolGetButtonTitle($langs->trans('NewCheckDeposit'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/paiement/cheque/card.php?action=new'); } print '
'; if ($optioncss != '') print ''; print ''; print ''; print ''; print ''; print ''; print ''; print_barre_liste($langs->trans("MenuChequeDeposits"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_bank.png', 0, $newcardbutton, '', $limit); $moreforfilter=''; print '
'; print ''."\n"; // Fields title search print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "bc.ref", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "dp", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("NbOfCheques", $_SERVER["PHP_SELF"], "bc.nbcheque", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "bc.amount", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "bc.statut", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre(''); print "\n"; if ($num > 0) { while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); print ''; // Num ref cheque print ''; // Date print ''; // TODO Use date hour // Bank print ''; // Number of cheques print ''; // Amount print ''; // Statut print ''; print ''; print "\n"; $i++; } } else { print ''; print '"; print ''; } print "
'; print ''; print ''; if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; $formother->select_year($year?$year:-1, 'year', 1, 20, 5); print ''; $form->select_comptes($search_account, 'search_account', 0, '', 1); print ' '; print ''; print ''; $searchpicto=$form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
'; $checkdepositstatic->id=$objp->rowid; $checkdepositstatic->ref=($objp->ref?$objp->ref:$objp->rowid); $checkdepositstatic->statut=$objp->statut; print $checkdepositstatic->getNomUrl(1); print ''.dol_print_date($db->jdate($objp->dp), 'day').''; if ($objp->bid) print ''.img_object($langs->trans("ShowAccount"), 'account').' '.$objp->label.''; else print ' '; print ''.$objp->nbcheque.''.price($objp->amount).''; print $checkdepositstatic->LibStatut($objp->statut, 5); print '
'.$langs->trans("None")."
"; print "
"; print "
\n"; } else { dol_print_error($db); } // End of page llxFooter(); $db->close();