dolibarr/htdocs/compta/prelevement/card.php

268 lines
8.1 KiB
PHP
Raw Normal View History

2012-08-22 23:27:53 +02:00
<?php
2008-12-15 23:13:55 +01:00
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
2012-02-29 18:56:54 +01:00
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
2005-01-07 16:26:30 +01:00
*
* 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
2005-01-07 16:26:30 +01:00
* (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
2011-08-01 00:21:57 +02:00
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2005-01-07 16:26:30 +01:00
*/
2009-03-28 20:59:12 +01:00
2005-01-21 23:59:48 +01:00
/**
* \file htdocs/compta/prelevement/card.php
2009-03-28 20:59:12 +01:00
* \ingroup prelevement
* \brief Fiche prelevement
*/
2005-01-21 23:59:48 +01:00
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';
2013-06-05 16:24:32 +02:00
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$langs->load("banks");
$langs->load("categories");
2005-01-07 16:26:30 +01:00
2005-08-03 18:05:00 +02:00
if (!$user->rights->prelevement->bons->lire)
2009-03-28 20:59:12 +01:00
accessforbidden();
2005-08-03 18:05:00 +02:00
2005-01-21 23:59:48 +01:00
$langs->load("bills");
2008-11-05 23:34:14 +01:00
$langs->load("withdrawals");
2005-01-21 23:59:48 +01:00
2009-03-28 20:59:12 +01:00
// Security check
if ($user->societe_id > 0) accessforbidden();
2011-05-06 15:49:34 +02:00
// Get supervariables
2012-02-29 18:56:54 +01:00
$action = GETPOST('action','alpha');
2012-02-27 22:26:22 +01:00
$id = GETPOST('id','int');
2008-11-05 23:34:14 +01:00
2008-11-05 23:34:14 +01:00
/*
* Actions
*/
if ( $action == 'confirm_delete' )
{
$bon = new BonPrelevement($db,"");
$bon->fetch($id);
$res=$bon->delete();
if ($res > 0)
{
header("Location: index.php");
exit;
}
}
2008-11-05 23:34:14 +01:00
2012-02-29 18:56:54 +01:00
if ( $action == 'confirm_credite' && GETPOST('confirm','alpha') == 'yes')
2005-01-07 16:26:30 +01:00
{
2009-03-28 20:59:12 +01:00
$bon = new BonPrelevement($db,"");
$bon->fetch($id);
2009-03-28 20:59:12 +01:00
$bon->set_credite();
header("Location: card.php?id=".$id);
2009-03-28 20:59:12 +01:00
exit;
2005-01-07 16:26:30 +01:00
}
2011-05-06 15:49:34 +02:00
if ($action == 'infotrans' && $user->rights->prelevement->bons->send)
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
2009-03-28 20:59:12 +01:00
$bon = new BonPrelevement($db,"");
2011-05-06 15:49:34 +02:00
$bon->fetch($id);
2009-03-28 20:59:12 +01:00
$dt = dol_mktime(12,0,0,GETPOST('remonth','int'),GETPOST('reday','int'),GETPOST('reyear','int'));
/*
2009-03-28 20:59:12 +01:00
if ($_FILES['userfile']['name'] && basename($_FILES['userfile']['name'],".ps") == $bon->ref)
{
$dir = $conf->prelevement->dir_output.'/receipts';
2005-04-05 16:23:45 +02:00
if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $dir . "/" . dol_unescapefile($_FILES['userfile']['name']),1) > 0)
2009-03-28 20:59:12 +01:00
{
2012-02-29 18:56:54 +01:00
$bon->set_infotrans($user, $dt, GETPOST('methode','alpha'));
2009-03-28 20:59:12 +01:00
}
header("Location: card.php?id=".$id);
exit;
2009-03-28 20:59:12 +01:00
}
else
2005-04-05 16:23:45 +02:00
{
2009-03-28 20:59:12 +01:00
dol_syslog("Fichier invalide",LOG_WARNING);
$mesg='BadFile';
}*/
$error = $bon->set_infotrans($user, $dt, GETPOST('methode','alpha'));
if ($error)
{
header("Location: card.php?id=".$id."&error=$error");
exit;
2005-04-05 16:23:45 +02:00
}
}
2011-05-06 15:49:34 +02:00
if ($action == 'infocredit' && $user->rights->prelevement->bons->credit)
{
2009-03-28 20:59:12 +01:00
$bon = new BonPrelevement($db,"");
2011-05-06 15:49:34 +02:00
$bon->fetch($id);
2012-02-29 18:56:54 +01:00
$dt = dol_mktime(12,0,0,GETPOST('remonth','int'),GETPOST('reday','int'),GETPOST('reyear','int'));
2009-03-28 20:59:12 +01:00
$error = $bon->set_infocredit($user, $dt);
if ($error)
2009-03-28 20:59:12 +01:00
{
header("Location: card.php?id=".$id."&error=$error");
exit;
2009-03-28 20:59:12 +01:00
}
}
2009-03-28 20:59:12 +01:00
/*
* View
*/
$bon = new BonPrelevement($db,"");
$form = new Form($db);
llxHeader('',$langs->trans("WithdrawalsReceipts"));
if ($id > 0)
2005-01-11 15:40:08 +01:00
{
$bon->fetch($id);
$head = prelevement_prepare_head($bon);
2014-05-16 15:50:38 +02:00
dol_fiche_head($head, 'prelevement', $langs->trans("WithdrawalsReceipts"), '', 'payment');
if (GETPOST('error','alpha')!='')
2005-08-03 17:17:53 +02:00
{
print '<div class="error">'.$bon->ReadError(GETPOST('error','alpha')).'</div>';
}
2009-03-28 20:59:12 +01:00
/*if ($action == 'credite')
{
print $form->formconfirm("card.php?id=".$bon->id,$langs->trans("ClassCredited"),$langs->trans("ClassCreditedConfirm"),"confirm_credite",'',1,1);
}*/
2009-03-28 20:59:12 +01:00
print '<table class="border" width="100%">';
2009-03-28 20:59:12 +01:00
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td>'.$bon->getNomUrl(1).'</td></tr>';
print '<tr><td width="20%">'.$langs->trans("Date").'</td><td>'.dol_print_date($bon->datec,'day').'</td></tr>';
print '<tr><td width="20%">'.$langs->trans("Amount").'</td><td>'.price($bon->amount).'</td></tr>';
// Status
print '<tr><td width="20%">'.$langs->trans('Status').'</td>';
print '<td>'.$bon->getLibStatut(1).'</td>';
print '</tr>';
if($bon->date_trans <> 0)
{
$muser = new User($db);
$muser->fetch($bon->user_trans);
print '<tr><td width="20%">'.$langs->trans("TransData").'</td><td>';
print dol_print_date($bon->date_trans,'day');
print ' '.$langs->trans("By").' '.$muser->getFullName($langs).'</td></tr>';
print '<tr><td width="20%">'.$langs->trans("TransMetod").'</td><td>';
print $bon->methodes_trans[$bon->method_trans];
print '</td></tr>';
}
if($bon->date_credit <> 0)
{
print '<tr><td width="20%">'.$langs->trans('CreditDate').'</td><td>';
print dol_print_date($bon->date_credit,'day');
print '</td></tr>';
}
2009-03-28 20:59:12 +01:00
print '</table>';
2009-03-28 20:59:12 +01:00
print '<br>';
2009-03-28 20:59:12 +01:00
print '<table class="border" width="100%"><tr><td width="20%">';
print $langs->trans("WithdrawalFile").'</td><td>';
2015-04-19 01:55:35 +02:00
$relativepath = 'receipts/'.$bon->ref.'.xml';
2013-04-20 20:30:18 +02:00
print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart=prelevement&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
print '</td></tr></table>';
dol_fiche_end();
2009-03-28 20:59:12 +01:00
2009-03-28 20:59:12 +01:00
if (empty($bon->date_trans) && $user->rights->prelevement->bons->send && $action=='settransmitted')
{
print '<form method="post" name="userfile" action="card.php?id='.$bon->id.'" enctype="multipart/form-data">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="infotrans">';
print '<table class="border" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("NotifyTransmision").'</td></tr>';
print '<tr><td width="20%">'.$langs->trans("TransData").'</td><td>';
print $form->select_date('','','','','',"userfile",1,1);
print '</td></tr>';
print '<tr><td width="20%">'.$langs->trans("TransMetod").'</td><td>';
print $form->selectarray("methode",$bon->methodes_trans);
print '</td></tr>';
/* print '<tr><td width="20%">'.$langs->trans("File").'</td><td>';
print '<input type="hidden" name="max_file_size" value="'.$conf->maxfilesize.'">';
print '<input class="flat" type="file" name="userfile"><br>';
print '</td></tr>';*/
print '</table><br>';
2014-11-25 20:13:43 +01:00
print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("SetToStatusSent")).'"></div>';
print '</form>';
}
if (! empty($bon->date_trans) && $bon->date_credit == 0 && $user->rights->prelevement->bons->credit && $action=='setcredited')
{
print '<form name="infocredit" method="post" action="card.php?id='.$bon->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="infocredit">';
print '<table class="border" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("NotifyCredit").'</td></tr>';
print '<tr><td width="20%">'.$langs->trans('CreditDate').'</td><td>';
print $form->select_date('','','','','',"infocredit",1,1);
print '</td></tr>';
print '</table>';
print '<br>'.$langs->trans("ThisWillAlsoAddPaymentOnInvoice");
2014-11-25 20:13:43 +01:00
print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("ClassCredited")).'"></div>';
print '</form>';
}
2009-03-28 20:59:12 +01:00
// Actions
if ($action != 'settransmitted' && $action != 'setcredited')
{
print "\n<div class=\"tabsAction\">\n";
if (empty($bon->date_trans) && $user->rights->prelevement->bons->send)
2009-03-28 20:59:12 +01:00
{
print "<a class=\"butAction\" href=\"card.php?action=settransmitted&id=".$bon->id."\">".$langs->trans("SetToStatusSent")."</a>";
2009-03-28 20:59:12 +01:00
}
if (! empty($bon->date_trans) && $bon->date_credit == 0)
2009-03-28 20:59:12 +01:00
{
print "<a class=\"butAction\" href=\"card.php?action=setcredited&id=".$bon->id."\">".$langs->trans("ClassCredited")."</a>";
2009-03-28 20:59:12 +01:00
}
2005-01-11 15:40:08 +01:00
print "<a class=\"butActionDelete\" href=\"card.php?action=confirm_delete&id=".$bon->id."\">".$langs->trans("Delete")."</a>";
2005-01-11 15:40:08 +01:00
print "</div>";
}
}
2005-01-07 16:26:30 +01:00
llxFooter();
$db->close();