2004-10-19 22:35:36 +02:00
< ? php
2005-01-23 03:03:08 +01:00
/* Copyright ( C ) 2003 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2013-12-09 22:39:41 +01:00
* Copyright ( C ) 2004 - 2013 Laurent Destailleur < eldy @ users . sourceforge . net >
2013-04-15 21:27:01 +02:00
* Copyright ( C ) 2005 - 2013 Regis Houssin < regis . houssin @ capnetworks . com >
2003-08-04 21:00:07 +02: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
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2003-08-04 21:00:07 +02: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-03 02:45:22 +02:00
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2003-08-04 21:00:07 +02:00
*/
2005-01-23 03:03:08 +01:00
2005-05-08 21:32:01 +02:00
/**
2008-11-16 23:26:47 +01:00
* \file htdocs / compta / tva / fiche . php
* \ingroup tax
2010-02-14 13:42:00 +01:00
* \brief Page of VAT payments
2008-11-16 23:26:47 +01:00
*/
2005-01-23 03:03:08 +01:00
2012-08-22 23:24:21 +02:00
require '../../main.inc.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/compta/tva/class/tva.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php' ;
2003-08-04 21:00:07 +02:00
2005-05-08 21:32:01 +02:00
$langs -> load ( " compta " );
2008-04-03 22:43:12 +02:00
$langs -> load ( " banks " );
2010-02-21 13:12:14 +01:00
$langs -> load ( " bills " );
2005-05-08 21:32:01 +02:00
2013-12-09 22:39:41 +01:00
$id = GETPOST ( " id " , 'int' );
2013-05-14 23:39:17 +02:00
$action = GETPOST ( 'action' );
2007-10-29 22:11:44 +01:00
2008-10-13 16:22:10 +02:00
// Security check
$socid = isset ( $_GET [ " socid " ]) ? $_GET [ " socid " ] : '' ;
if ( $user -> societe_id ) $socid = $user -> societe_id ;
$result = restrictedArea ( $user , 'tax' , '' , '' , 'charges' );
2013-06-05 16:24:32 +02:00
$tva = new Tva ( $db );
2013-05-14 23:39:17 +02:00
Add: hooks and triggers for a lot of core modules (action/calendrier, deplacement, dons, tva, contact/tiers, contrat, product lines, expedition, fournisseur commandes et factures, fiche intervention, projet et taches)
Signed-off-by: Stephen L. <lrq3000@gmail.com>
2012-08-14 15:50:45 +02:00
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager -> initHooks ( array ( 'taxvatcard' ));
2005-05-08 21:32:01 +02:00
2013-05-14 23:39:17 +02:00
2005-05-08 21:32:01 +02:00
/**
2013-05-14 23:39:17 +02:00
* Actions
2005-05-08 21:32:01 +02:00
*/
2013-05-14 23:39:17 +02:00
if ( $_POST [ " cancel " ] == $langs -> trans ( " Cancel " ))
2003-08-04 21:00:07 +02:00
{
2013-06-05 16:24:32 +02:00
header ( " Location: reglement.php " );
2013-05-14 23:39:17 +02:00
exit ;
}
2010-02-14 13:42:00 +01:00
2013-05-14 23:39:17 +02:00
if ( $action == 'add' && $_POST [ " cancel " ] <> $langs -> trans ( " Cancel " ))
{
2005-05-08 21:32:01 +02:00
$db -> begin ();
2010-02-14 13:42:00 +01:00
2009-02-20 23:53:15 +01:00
$datev = dol_mktime ( 12 , 0 , 0 , $_POST [ " datevmonth " ], $_POST [ " datevday " ], $_POST [ " datevyear " ]);
$datep = dol_mktime ( 12 , 0 , 0 , $_POST [ " datepmonth " ], $_POST [ " datepday " ], $_POST [ " datepyear " ]);
2010-02-14 13:42:00 +01:00
2005-05-08 21:32:01 +02:00
$tva -> accountid = $_POST [ " accountid " ];
$tva -> paymenttype = $_POST [ " paiementtype " ];
2008-11-16 23:26:47 +01:00
$tva -> datev = $datev ;
$tva -> datep = $datep ;
2005-05-08 21:32:01 +02:00
$tva -> amount = $_POST [ " amount " ];
2007-10-29 22:11:44 +01:00
$tva -> label = $_POST [ " label " ];
2005-05-08 21:32:01 +02:00
2007-10-29 22:11:44 +01:00
$ret = $tva -> addPayment ( $user );
2005-05-08 21:32:01 +02:00
if ( $ret > 0 )
{
$db -> commit ();
2012-08-31 05:58:38 +02:00
header ( " Location: reglement.php " );
2005-11-20 20:43:49 +01:00
exit ;
2005-05-08 21:32:01 +02:00
}
else
{
$db -> rollback ();
2013-10-25 19:26:30 +02:00
setEventMessage ( $tva -> error , 'errors' );
2013-05-14 23:39:17 +02:00
$action = " create " ;
2005-05-08 21:32:01 +02:00
}
2003-08-04 21:00:07 +02:00
}
2013-05-14 23:39:17 +02:00
if ( $action == 'delete' )
2008-04-03 22:43:12 +02:00
{
2013-12-09 22:39:41 +01:00
$result = $tva -> fetch ( $id );
2010-02-14 13:42:00 +01:00
2008-04-03 22:43:12 +02:00
if ( $tva -> rappro == 0 )
{
$db -> begin ();
2010-02-14 13:42:00 +01:00
2008-04-03 22:43:12 +02:00
$ret = $tva -> delete ( $user );
if ( $ret > 0 )
{
if ( $tva -> fk_bank )
{
$accountline = new AccountLine ( $db );
2009-11-05 19:31:54 +01:00
$result = $accountline -> fetch ( $tva -> fk_bank );
2013-12-09 22:39:41 +01:00
if ( $result > 0 ) $result = $accountline -> delete ( $user ); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing)
2008-04-03 22:43:12 +02:00
}
2010-02-14 13:42:00 +01:00
2013-12-09 22:39:41 +01:00
if ( $result >= 0 )
2008-04-03 22:43:12 +02:00
{
$db -> commit ();
header ( " Location: " . DOL_URL_ROOT . '/compta/tva/reglement.php' );
exit ;
}
else
{
$tva -> error = $accountline -> error ;
$db -> rollback ();
2013-10-25 19:26:30 +02:00
setEventMessage ( $tva -> error , 'errors' );
2008-04-03 22:43:12 +02:00
}
}
else
{
$db -> rollback ();
2013-10-25 19:26:30 +02:00
setEventMessage ( $tva -> error , 'errors' );
2008-04-03 22:43:12 +02:00
}
}
else
{
2013-10-25 19:26:30 +02:00
setEventMessage ( 'Error try do delete a line linked to a conciliated bank transaction' , 'errors' );
2008-04-03 22:43:12 +02:00
}
}
2005-05-08 21:32:01 +02:00
2008-04-03 22:43:12 +02:00
/*
* View
*/
2003-08-04 21:00:07 +02:00
llxHeader ();
2011-11-08 10:18:45 +01:00
$form = new Form ( $db );
2005-05-08 21:32:01 +02:00
2008-04-03 21:35:46 +02:00
if ( $id )
{
$vatpayment = new Tva ( $db );
$result = $vatpayment -> fetch ( $id );
if ( $result <= 0 )
{
2009-02-20 23:53:15 +01:00
dol_print_error ( $db );
2008-04-03 21:35:46 +02:00
exit ;
}
}
2005-05-08 21:32:01 +02:00
// Formulaire saisie tva
2013-05-14 23:39:17 +02:00
if ( $action == 'create' )
2003-08-04 21:00:07 +02:00
{
2006-03-01 17:59:18 +01:00
print " <form name='add' action= \" fiche.php \" method= \" post \" > \n " ;
2009-05-17 10:01:54 +02:00
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
2005-05-08 21:32:01 +02:00
print '<input type="hidden" name="action" value="add">' ;
2010-02-14 13:42:00 +01:00
2005-07-02 14:16:33 +02:00
print_fiche_titre ( $langs -> trans ( " NewVATPayment " ));
2010-02-14 13:42:00 +01:00
2005-05-08 21:32:01 +02:00
print '<table class="border" width="100%">' ;
2010-02-14 13:42:00 +01:00
2005-05-08 21:32:01 +02:00
print " <tr> " ;
2010-02-21 13:12:14 +01:00
print '<td class="fieldrequired">' . $langs -> trans ( " DatePayment " ) . '</td><td>' ;
2011-11-08 10:18:45 +01:00
print $form -> select_date ( $datep , " datep " , '' , '' , '' , 'add' );
2005-05-08 21:32:01 +02:00
print '</td></tr>' ;
2010-02-21 13:12:14 +01:00
print '<tr><td class="fieldrequired">' . $langs -> trans ( " DateValue " ) . '</td><td>' ;
2011-11-08 10:18:45 +01:00
print $form -> select_date ( $datev , " datev " , '' , '' , '' , 'add' );
2005-05-08 21:32:01 +02:00
print '</td></tr>' ;
2007-10-29 22:11:44 +01:00
// Label
2010-02-21 13:12:14 +01:00
print '<tr><td class="fieldrequired">' . $langs -> trans ( " Label " ) . '</td><td><input name="label" size="40" value="' . ( $_POST [ " label " ] ? $_POST [ " label " ] : $langs -> trans ( " VATPayment " )) . '"></td></tr>' ;
2007-10-29 22:11:44 +01:00
// Amount
2010-02-21 13:12:14 +01:00
print '<tr><td class="fieldrequired">' . $langs -> trans ( " Amount " ) . '</td><td><input name="amount" size="10" value="' . $_POST [ " amount " ] . '"></td></tr>' ;
2007-10-29 22:11:44 +01:00
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> banque -> enabled ))
2005-11-20 20:43:49 +01:00
{
2010-02-21 13:12:14 +01:00
print '<tr><td class="fieldrequired">' . $langs -> trans ( " Account " ) . '</td><td>' ;
2011-11-08 10:18:45 +01:00
$form -> select_comptes ( $_POST [ " accountid " ], " accountid " , 0 , " courant=1 " , 1 ); // Affiche liste des comptes courant
2005-11-20 20:43:49 +01:00
print '</td></tr>' ;
2007-10-29 22:11:44 +01:00
2010-02-21 13:12:14 +01:00
print '<tr><td class="fieldrequired">' . $langs -> trans ( " PaymentMode " ) . '</td><td>' ;
2011-11-08 10:18:45 +01:00
$form -> select_types_paiements ( $_POST [ " paiementtype " ], " paiementtype " );
2007-10-29 22:11:44 +01:00
print " </td> \n " ;
2010-03-17 20:26:54 +01:00
print " </tr> " ;
2007-10-29 22:11:44 +01:00
}
Add: hooks and triggers for a lot of core modules (action/calendrier, deplacement, dons, tva, contact/tiers, contrat, product lines, expedition, fournisseur commandes et factures, fiche intervention, projet et taches)
Signed-off-by: Stephen L. <lrq3000@gmail.com>
2012-08-14 15:50:45 +02:00
// Other attributes
$parameters = array ( 'colspan' => ' colspan="1"' );
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2005-05-08 21:32:01 +02:00
print '</table>' ;
2010-03-17 20:26:54 +01:00
print " <br> " ;
print '<center><input type="submit" class="button" value="' . $langs -> trans ( " Save " ) . '"> ' ;
print '<input type="submit" class="button" name="cancel" value="' . $langs -> trans ( " Cancel " ) . '"></center>' ;
2010-02-14 13:42:00 +01:00
print '</form>' ;
2003-08-04 21:00:07 +02:00
}
/* ************************************************************************** */
2010-02-14 13:42:00 +01:00
/* */
/* Barre d'action */
/* */
2003-08-04 21:00:07 +02:00
/* ************************************************************************** */
2007-10-29 22:11:44 +01:00
if ( $id )
{
2008-04-03 22:43:12 +02:00
$h = 0 ;
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/compta/tva/fiche.php?id=' . $vatpayment -> id ;
$head [ $h ][ 1 ] = $langs -> trans ( 'Card' );
$head [ $h ][ 2 ] = 'card' ;
$h ++ ;
2007-10-29 22:11:44 +01:00
2010-02-14 13:42:00 +01:00
dol_fiche_head ( $head , 'card' , $langs -> trans ( " VATPayment " ), 0 , 'payment' );
2007-10-29 22:11:44 +01:00
2008-04-03 22:43:12 +02:00
print '<table class="border" width="100%">' ;
2010-02-14 13:42:00 +01:00
2008-04-03 22:43:12 +02:00
print " <tr> " ;
print '<td width="25%">' . $langs -> trans ( " Ref " ) . '</td><td colspan="3">' ;
print $vatpayment -> ref ;
print '</td></tr>' ;
2007-10-29 22:11:44 +01:00
2013-06-05 16:24:32 +02:00
// Label
print '<tr><td>' . $langs -> trans ( " Label " ) . '</td><td>' . $vatpayment -> label . '</td></tr>' ;
2008-04-03 22:43:12 +02:00
print " <tr> " ;
print '<td>' . $langs -> trans ( " DatePayment " ) . '</td><td colspan="3">' ;
2009-02-20 23:53:15 +01:00
print dol_print_date ( $vatpayment -> datep , 'day' );
2008-04-03 22:43:12 +02:00
print '</td></tr>' ;
2007-10-29 22:11:44 +01:00
2008-04-03 22:43:12 +02:00
print '<tr><td>' . $langs -> trans ( " DateValue " ) . '</td><td colspan="3">' ;
2009-02-20 23:53:15 +01:00
print dol_print_date ( $vatpayment -> datev , 'day' );
2008-04-03 22:43:12 +02:00
print '</td></tr>' ;
2008-04-03 21:35:46 +02:00
2008-11-16 23:26:47 +01:00
print '<tr><td>' . $langs -> trans ( " Amount " ) . '</td><td colspan="3">' . price ( $vatpayment -> amount ) . '</td></tr>' ;
2010-02-14 13:42:00 +01:00
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> banque -> enabled ))
2008-04-03 21:35:46 +02:00
{
2008-04-03 22:43:12 +02:00
if ( $vatpayment -> fk_account > 0 )
{
2008-11-16 23:26:47 +01:00
$bankline = new AccountLine ( $db );
$bankline -> fetch ( $vatpayment -> fk_bank );
print '<tr>' ;
print '<td>' . $langs -> trans ( 'BankTransactionLine' ) . '</td>' ;
print '<td colspan="3">' ;
2010-02-14 13:42:00 +01:00
print $bankline -> getNomUrl ( 1 , 0 , 'showall' );
2008-11-16 23:26:47 +01:00
print '</td>' ;
print '</tr>' ;
2008-04-03 22:43:12 +02:00
}
}
2008-04-03 21:35:46 +02:00
Add: hooks and triggers for a lot of core modules (action/calendrier, deplacement, dons, tva, contact/tiers, contrat, product lines, expedition, fournisseur commandes et factures, fiche intervention, projet et taches)
Signed-off-by: Stephen L. <lrq3000@gmail.com>
2012-08-14 15:50:45 +02:00
// Other attributes
$parameters = array ( 'colspan' => ' colspan="3"' );
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $vatpayment , $action ); // Note that $action and $object may have been modified by hook
2008-04-03 22:43:12 +02:00
print '</table>' ;
2010-02-14 13:42:00 +01:00
2008-04-03 22:43:12 +02:00
print '</div>' ;
2010-02-14 13:42:00 +01:00
2008-04-03 22:43:12 +02:00
/*
* Boutons d ' actions
*/
print " <div class= \" tabsAction \" > \n " ;
if ( $vatpayment -> rappro == 0 )
2013-10-25 19:26:30 +02:00
{
if ( ! empty ( $user -> rights -> tax -> charges -> supprimer ))
{
print '<a class="butActionDelete" href="fiche.php?id=' . $vatpayment -> id . '&action=delete">' . $langs -> trans ( " Delete " ) . '</a>' ;
}
else
{
print '<a class="butActionRefused" href="#" title="' . ( dol_escape_htmltag ( $langs -> trans ( " NotAllowed " ))) . '">' . $langs -> trans ( " Delete " ) . '</a>' ;
}
}
2008-04-03 22:43:12 +02:00
else
2013-10-25 19:26:30 +02:00
{
2008-04-03 22:43:12 +02:00
print '<a class="butActionRefused" href="#" title="' . $langs -> trans ( " LinkedToAConcialitedTransaction " ) . '">' . $langs -> trans ( " Delete " ) . '</a>' ;
2013-10-25 19:26:30 +02:00
}
2008-04-03 22:43:12 +02:00
print " </div> " ;
2007-10-29 22:11:44 +01:00
}
2003-08-04 21:00:07 +02:00
$db -> close ();
2011-08-27 16:24:16 +02:00
llxFooter ();
2013-12-10 21:48:22 +01:00
?>