*
* 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/localtax/card.php
* \ingroup tax
* \brief Page of IRPF payments
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$langs->load("compta");
$langs->load("banks");
$langs->load("bills");
$id=$_REQUEST["id"];
$lttype=GETPOST('localTaxType', 'int');
$mesg = '';
// Security check
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'tax', '', '', 'charges');
/*
* Actions
*/
//add payment of localtax
if($_POST["cancel"] == $langs->trans("Cancel")){
header("Location: reglement.php?localTaxType=".$lttype);
exit;
}
if ($_POST["action"] == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
{
$localtax = new Localtax($db);
$db->begin();
$datev=dol_mktime(12,0,0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]);
$datep=dol_mktime(12,0,0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]);
$localtax->accountid=$_POST["accountid"];
$localtax->paymenttype=$_POST["paiementtype"];
$localtax->datev=$datev;
$localtax->datep=$datep;
$localtax->amount=$_POST["amount"];
$localtax->label=$_POST["label"];
$localtax->ltt=$lttype;
$ret=$localtax->addPayment($user);
if ($ret > 0)
{
$db->commit();
header("Location: reglement.php?localTaxType=".$lttype);
exit;
}
else
{
$db->rollback();
$mesg='
'.$localtax->error.'
';
$_GET["action"]="create";
}
}
//delete payment of localtax
if ($_GET["action"] == 'delete')
{
$localtax = new Localtax($db);
$result=$localtax->fetch($_GET['id']);
if ($localtax->rappro == 0)
{
$db->begin();
$ret=$localtax->delete($user);
if ($ret > 0)
{
if ($localtax->fk_bank)
{
$accountline=new AccountLine($db);
$result=$accountline->fetch($localtax->fk_bank);
$result=$accountline->delete($user);
}
if ($result > 0)
{
$db->commit();
header("Location: ".DOL_URL_ROOT.'/compta/localtax/reglement.php');
exit;
}
else
{
$localtax->error=$accountline->error;
$db->rollback();
$mesg=''.$localtax->error.'
';
}
}
else
{
$db->rollback();
$mesg=''.$localtax->error.'
';
}
}
else
{
$mesg='Error try do delete a line linked to a conciliated bank transaction
';
}
}
/*
* View
*/
llxHeader();
$form = new Form($db);
if ($id)
{
$vatpayment = new Localtax($db);
$result = $vatpayment->fetch($id);
if ($result <= 0)
{
dol_print_error($db);
exit;
}
}
if ($_GET["action"] == 'create')
{
print "';
}
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
if ($id)
{
if ($mesg) print $mesg;
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/compta/localtax/card.php?id='.$vatpayment->id;
$head[$h][1] = $langs->trans('Card');
$head[$h][2] = 'card';
$h++;
dol_fiche_head($head, 'card', $langs->trans("VATPayment"), 0, 'payment');
print '';
print "";
print ''.$langs->trans("Ref").' | ';
print $vatpayment->ref;
print ' |
';
print "";
print ''.$langs->trans("DatePayment").' | ';
print dol_print_date($vatpayment->datep,'day');
print ' |
';
print ''.$langs->trans("DateValue").' | ';
print dol_print_date($vatpayment->datev,'day');
print ' |
';
print ''.$langs->trans("Amount").' | '.price($vatpayment->amount).' |
';
if (! empty($conf->banque->enabled))
{
if ($vatpayment->fk_account > 0)
{
$bankline=new AccountLine($db);
$bankline->fetch($vatpayment->fk_bank);
print '';
print ''.$langs->trans('BankTransactionLine').' | ';
print '';
print $bankline->getNomUrl(1,0,'showall');
print ' | ';
print '
';
}
}
print '
';
print '';
/*
* Boutons d'actions
*/
print "";
}
$db->close();
llxFooter();