* Copyright (C) 2005-2012 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2010-2013 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/ligne.php * \ingroup prelevement * \brief card of withdraw line */ require('../../main.inc.php'); require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.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'; $langs->load("banks"); $langs->load("categories"); // Security check if ($user->societe_id > 0) accessforbidden(); $langs->load("bills"); $langs->load("withdrawals"); // Get supervariables $action = GETPOST('action','alpha'); $id = GETPOST('id','int'); $socid = GETPOST('socid','int'); $page = GETPOST('page','int'); $sortorder = GETPOST('sortorder','alpha'); $sortfield = GETPOST('sortfield','alpha'); if ($action == 'confirm_rejet') { if ( GETPOST("confirm") == 'yes') { if (GETPOST('remonth','int')) { $daterej = mktime(2, 0, 0, GETPOST('remonth','int'), GETPOST('reday','int'), GETPOST('reyear','int')); } if (empty($daterej)) { $error++; setEventMessage($langs->trans("ErrorFieldRequired",$langs->trans("Date")),'errors'); } elseif ($daterej > dol_now()) { $error++; $langs->load("error"); setEventMessage($langs->transnoentities("ErrorDateMustBeBeforeToday"),'errors'); } if (GETPOST('motif','alpha') == 0) { $error++; setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("RefusedReason")),'errors'); } if ( ! $error ) { $lipre = new LignePrelevement($db, $user); if ($lipre->fetch($id) == 0) { $rej = new RejetPrelevement($db, $user); $rej->create($user, $id, GETPOST('motif','alpha'), $daterej, $lipre->bon_rowid, GETPOST('facturer','int')); header("Location: ligne.php?id=".$id); exit; } } else { $action="rejet"; } } else { header("Location: ligne.php?id=".$id); exit; } } /* * View */ $invoicestatic=new Facture($db); llxHeader('',$langs->trans("StandingOrder")); $h = 0; $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/ligne.php?id='.$id; $head[$h][1] = $langs->trans("Card"); $hselected = $h; $h++; if ($id) { $lipre = new LignePrelevement($db, $user); if ($lipre->fetch($id) == 0) { $bon = new BonPrelevement($db); $bon->fetch($lipre->bon_rowid); dol_fiche_head($head, $hselected, $langs->trans("StandingOrder")); print ''; print ''; print ''; print ''; print ''; if ($lipre->statut == 3) { $rej = new RejetPrelevement($db, $user); $resf = $rej->fetch($lipre->id); if ($resf == 0) { print ''; print ''; print ''; } else { print ''; } } print '
'.$langs->trans("WithdrawalsReceipts").''; print $bon->getNomUrl(1).'
'.$langs->trans("Date").''.dol_print_date($bon->datec,'day').'
'.$langs->trans("Amount").''.price($lipre->amount).'
'.$langs->trans("Status").''.$lipre->LibStatut($lipre->statut,1).'
'.$langs->trans("RefusedReason").''.$rej->motif.'
'.$langs->trans("RefusedData").''; if ($rej->date_rejet == 0) { /* Historique pour certaines install */ print $langs->trans("Unknown"); } else { print dol_print_date($rej->date_rejet,'day'); } print '
'.$langs->trans("RefusedInvoicing").''.$rej->invoicing.'
'.$resf.'
'; dol_fiche_end(); } else { dol_print_error($db); } if ($action == 'rejet' && $user->rights->prelevement->bons->credit) { $form = new Form($db); $soc = new Societe($db); $soc->fetch($lipre->socid); $rej = new RejetPrelevement($db, $user); print '
'; print ''; print ''; print ''; print ''; print ''; //Select yes/no print ''; print ''; //Date print ''; print ''; //Reason print ''; print ''; //Facturer print ''; print ''; print '
'.$langs->trans("WithdrawalRefused").'
'.$langs->trans("WithdrawalRefusedConfirm").' '.$soc->name.' ?'; print $form->selectyesno("confirm",1,0); print '
'.$langs->trans("RefusedData").''; print $form->select_date('','','','','',"confirm_rejet"); print '
'.$langs->trans("RefusedReason").''; print $form->selectarray("motif", $rej->motifs); print '
'.$langs->trans("RefusedInvoicing").''; print $form->selectarray("facturer", $rej->facturer); print '

'; //Confirm Button print '
'; print '
'; } /* ************************************************************************** */ /* */ /* Barre d'action */ /* */ /* ************************************************************************** */ print "
"; if ($action == '') { if ($bon->statut == 2 && $lipre->statut == 2) { if ($user->rights->prelevement->bons->credit) { print "id\">".$langs->trans("StandingOrderReject").""; } else { print "trans("NotAllowed")."\">".$langs->trans("StandingOrderReject").""; } } else { print "trans("NotPossibleForThisStatusOfWithdrawReceiptORLine")."\">".$langs->trans("StandingOrderReject").""; } } print "
"; if ($page == -1) { $page = 0 ; } $offset = $conf->liste_limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; if ($sortorder == "") $sortorder="DESC"; if ($sortfield == "") $sortfield="pl.fk_soc"; /* * Liste des factures */ $sql = "SELECT pf.rowid"; $sql.= " ,f.rowid as facid, f.facnumber as ref, f.total_ttc, f.paye, f.fk_statut"; $sql.= " , s.rowid as socid, s.nom as name"; $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; $sql.= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl"; $sql.= " , ".MAIN_DB_PREFIX."prelevement_facture as pf"; $sql.= " , ".MAIN_DB_PREFIX."facture as f"; $sql.= " , ".MAIN_DB_PREFIX."societe as s"; $sql.= " WHERE pf.fk_prelevement_lignes = pl.rowid"; $sql.= " AND pl.fk_prelevement_bons = p.rowid"; $sql.= " AND f.fk_soc = s.rowid"; $sql.= " AND pf.fk_facture = f.rowid"; $sql.= " AND f.entity = ".$conf->entity; $sql.= " AND pl.rowid=".$id; if ($socid) $sql.= " AND s.rowid = ".$socid; $sql.= " ORDER BY $sortfield $sortorder "; $sql.= $db->plimit($conf->liste_limit+1, $offset); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; $urladd = "&id=".$id; print_barre_liste($langs->trans("Bills"), $page, "factures.php", $urladd, $sortfield, $sortorder, '', $num, 0, ''); print"\n\n"; print ''; print ''; print ''; print ''; $var=True; $total = 0; $var=false; while ($i < min($num,$conf->liste_limit)) { $obj = $db->fetch_object($result); print "\n"; print '\n"; print '\n"; print '\n"; print "\n"; $i++; } print "
'.$langs->trans("Invoice").''.$langs->trans("ThirdParty").''.$langs->trans("Amount").''.$langs->trans("Status").'
"; print ''; print img_object($langs->trans("ShowBill"),"bill"); print ' '; print ''.$obj->ref."'; print img_object($langs->trans("ShowCompany"),"company"). ' '.$obj->name."'.price($obj->total_ttc)."'; $invoicestatic->fetch($obj->facid); print $invoicestatic->getLibStatut(5); print "
"; $db->free($result); } else { dol_print_error($db); } } llxFooter(); $db->close();