* Copyright (C) 2005-2010 Laurent Destailleur * 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.php * \ingroup prelevement * \brief Fiche prelevement */ 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/bank/class/account.class.php'; $langs->load("banks"); $langs->load("categories"); if (!$user->rights->prelevement->bons->lire) accessforbidden(); $langs->load("bills"); $langs->load("withdrawals"); // Security check if ($user->societe_id > 0) accessforbidden(); // Get supervariables $action = GETPOST('action','alpha'); $id = GETPOST('id','int'); /* * Actions */ if ( $action == 'confirm_delete' ) { $bon = new BonPrelevement($db,""); $bon->fetch($id); $res=$bon->delete(); if ($res > 0) { header("Location: index.php"); exit; } } if ( $action == 'confirm_credite' && GETPOST('confirm','alpha') == 'yes') { $bon = new BonPrelevement($db,""); $bon->fetch($id); $bon->set_credite(); header("Location: fiche.php?id=".$id); exit; } if ($action == 'infotrans' && $user->rights->prelevement->bons->send) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $bon = new BonPrelevement($db,""); $bon->fetch($id); $dt = dol_mktime(12,0,0,GETPOST('remonth','int'),GETPOST('reday','int'),GETPOST('reyear','int')); /* if ($_FILES['userfile']['name'] && basename($_FILES['userfile']['name'],".ps") == $bon->ref) { $dir = $conf->prelevement->dir_output.'/receipts'; if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $dir . "/" . dol_unescapefile($_FILES['userfile']['name']),1) > 0) { $bon->set_infotrans($user, $dt, GETPOST('methode','alpha')); } header("Location: fiche.php?id=".$id); exit; } else { dol_syslog("Fichier invalide",LOG_WARNING); $mesg='BadFile'; }*/ $error = $bon->set_infotrans($user, $dt, GETPOST('methode','alpha')); if ($error) { header("Location: fiche.php?id=".$id."&error=$error"); exit; } } if ($action == 'infocredit' && $user->rights->prelevement->bons->credit) { $bon = new BonPrelevement($db,""); $bon->fetch($id); $dt = dol_mktime(12,0,0,GETPOST('remonth','int'),GETPOST('reday','int'),GETPOST('reyear','int')); $error = $bon->set_infocredit($user, $dt); if ($error) { header("Location: fiche.php?id=".$id."&error=$error"); exit; } } /* * View */ $bon = new BonPrelevement($db,""); $form = new Form($db); llxHeader('',$langs->trans("WithdrawalsReceipts")); if ($id > 0) { $bon->fetch($id); $head = prelevement_prepare_head($bon); dol_fiche_head($head, 'prelevement', $langs->trans("WithdrawalsReceipts"), '', 'payment'); if (GETPOST('error','alpha')!='') { print '
'.$bon->ReadError(GETPOST('error','alpha')).'
'; } /*if ($action == 'credite') { print $form->formconfirm("fiche.php?id=".$bon->id,$langs->trans("ClassCredited"),$langs->trans("ClassCreditedConfirm"),"confirm_credite",'',1,1); }*/ print ''; print ''; print ''; print ''; // Status print ''; print ''; print ''; if($bon->date_trans <> 0) { $muser = new User($db); $muser->fetch($bon->user_trans); print ''; print ''; } if($bon->date_credit <> 0) { print ''; } print '
'.$langs->trans("Ref").''.$bon->getNomUrl(1).'
'.$langs->trans("Date").''.dol_print_date($bon->datec,'day').'
'.$langs->trans("Amount").''.price($bon->amount).'
'.$langs->trans('Status').''.$bon->getLibStatut(1).'
'.$langs->trans("TransData").''; print dol_print_date($bon->date_trans,'day'); print ' '.$langs->trans("By").' '.$muser->getFullName($langs).'
'.$langs->trans("TransMetod").''; print $bon->methodes_trans[$bon->method_trans]; print '
'.$langs->trans('CreditDate').''; print dol_print_date($bon->date_credit,'day'); print '
'; print '
'; print '
'; print $langs->trans("WithdrawalFile").''; $relativepath = 'receipts/'.$bon->ref; print ''.$relativepath.''; print '
'; dol_fiche_end(); if (empty($bon->date_trans) && $user->rights->prelevement->bons->send && $action=='settransmitted') { print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; /* print '';*/ print '
'.$langs->trans("NotifyTransmision").'
'.$langs->trans("TransData").''; print $form->select_date('','','','','',"userfile",1,1); print '
'.$langs->trans("TransMetod").''; print $form->selectarray("methode",$bon->methodes_trans); print '
'.$langs->trans("File").''; print ''; print '
'; print '

'; print '
'; print ''; } if (! empty($bon->date_trans) && $bon->date_credit == 0 && $user->rights->prelevement->bons->credit && $action=='setcredited') { print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print '
'.$langs->trans("NotifyCredit").'
'.$langs->trans('CreditDate').''; print $form->select_date('','','','','',"infocredit",1,1); print '
'; print '
'.$langs->trans("ThisWillAlsoAddPaymentOnInvoice"); print '
'; print ''; } // Actions if ($action != 'settransmitted' && $action != 'setcredited') { print "\n
\n"; if (empty($bon->date_trans) && $user->rights->prelevement->bons->send) { print "id."\">".$langs->trans("SetToStatusSent").""; } if (! empty($bon->date_trans) && $bon->date_credit == 0) { print "id."\">".$langs->trans("ClassCredited").""; } print "id."\">".$langs->trans("Delete").""; print "
"; } } llxFooter(); $db->close();