* Copyright (C) 2005 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2010-2012 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/prelevement/fiche-rejet.php * \ingroup prelevement * \brief Debit order or credit transfer reject */ // Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/rejetprelevement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->loadLangs(array("banks", "categories", 'withdrawals', 'bills')); // Security check if ($user->socid > 0) { accessforbidden(); } // Get supervariables $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $type = GETPOST('type', 'aZ09'); // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : 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; $object = new BonPrelevement($db); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals // Security check if ($user->socid > 0) { accessforbidden(); } $type = $object->type; if ($type == 'bank-transfer') { $result = restrictedArea($user, 'paymentbybanktransfer', '', '', ''); } else { $result = restrictedArea($user, 'prelevement', '', '', 'bons'); } /* * View */ llxHeader('', $langs->trans("WithdrawalsReceipts")); if ($id > 0 || $ref) { if ($object->fetch($id, $ref) >= 0) { $head = prelevement_prepare_head($object); print dol_get_fiche_head($head, 'rejects', $langs->trans("WithdrawalsReceipts"), -1, 'payment'); $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref'); print '
'; print '
'; print ''."\n"; //print ''; print ''; print ''; if (!empty($object->date_trans)) { $muser = new User($db); $muser->fetch($object->user_trans); print ''; print ''; } if (!empty($object->date_credit)) { print ''; } print '
'.$langs->trans("Ref").''.$object->getNomUrl(1).'
'.$langs->trans("Date").''.dol_print_date($object->datec, 'day').'
'.$langs->trans("Amount").''.price($object->amount).'
'.$langs->trans("TransData").''; print dol_print_date($object->date_trans, 'day'); print '   '.$langs->trans("By").' '.$muser->getNomUrl(-1).'
'.$langs->trans("TransMetod").''; print $object->methodes_trans[$object->method_trans]; print '
'.$langs->trans('CreditDate').''; print dol_print_date($object->date_credit, 'day'); print '
'; print '
'; print '
'; print ''; $acc = new Account($db); $result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); print ''; print ''; print ''; print '
'; $labelofbankfield = "BankToReceiveWithdraw"; if ($object->type == 'bank-transfer') { $labelofbankfield = 'BankToPayCreditTransfer'; } print $langs->trans($labelofbankfield); print ''; if ($acc->id > 0) { print $acc->getNomUrl(1); } print '
'; $labelfororderfield = 'WithdrawalFile'; if ($object->type == 'bank-transfer') { $labelfororderfield = 'CreditTransferFile'; } print $langs->trans($labelfororderfield).''; $relativepath = 'receipts/'.$object->ref.'.xml'; $modulepart = 'prelevement'; if ($object->type == 'bank-transfer') { $modulepart = 'paymentbybanktransfer'; } print ''.$relativepath; print img_picto('', 'download', 'class="paddingleft"'); print ''; print '
'; print '
'; print dol_get_fiche_end(); } else { dol_print_error($db); } } $rej = new RejetPrelevement($db, $user, $type); /* * List errors */ $sql = "SELECT pl.rowid, pl.amount, pl.statut"; $sql .= " , s.rowid as socid, s.nom as name"; $sql .= " , pr.motif, pr.afacturer, pr.fk_facture"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; $sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl"; $sql .= " , ".MAIN_DB_PREFIX."societe as s"; $sql .= " , ".MAIN_DB_PREFIX."prelevement_rejet as pr"; $sql .= " WHERE p.rowid=".((int) $object->id); $sql .= " AND pl.fk_prelevement_bons = p.rowid"; $sql .= " AND p.entity = ".$conf->entity; $sql .= " AND pl.fk_soc = s.rowid"; $sql .= " AND pl.statut = 3 "; $sql .= " AND pr.fk_prelevement_lignes = pl.rowid"; /*if ($socid) { $sql .= " AND s.rowid = ".((int) $socid); }*/ $sql .= " ORDER BY pl.amount DESC"; // Count total nb of records $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); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); print_barre_liste($langs->trans("Rejects"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); print"\n\n"; print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; print ''; print ''; $total = 0; if ($num > 0) { $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); print ''; print '\n"; print '\n"; print ''; print ''; print ''; print "\n"; $total += $obj->amount; $i++; } } else { print ''; } if ($num > 0) { print ''; print ''; print '\n"; print ''; print "\n"; } print "
'.$langs->trans("Line").''.$langs->trans("ThirdParty").''.$langs->trans("Amount").''.$langs->trans("Reason").''.$langs->trans("ToBill").''.$langs->trans("Invoice").'
'; print ''; print img_picto('', 'statut'.$obj->statut).' '; print substr('000000'.$obj->rowid, -6); print ''.$obj->name."'.price($obj->amount)."'.$rej->motifs[$obj->motif].''.yn($obj->afacturer).''.$obj->fk_facture.'
'.$langs->trans("None").'
 '.$langs->trans("Total").''.price($total)." 
\n"; print '
'; $db->free($resql); } else { dol_print_error($db); } // End of page llxFooter(); $db->close();