2004-10-19 22:35:36 +02:00
< ? php
2020-01-23 19:28:56 +01:00
/* Copyright ( C ) 2004 - 2020 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2013 Regis Houssin < regis . houssin @ inodbox . com >
2018-09-09 09:36:12 +02:00
* Copyright ( C ) 2016 - 2018 Frédéric France < frederic . france @ netlogic . fr >
2019-01-28 21:39:22 +01:00
* Copyright ( C ) 2017 Alexandre Spangaro < aspangaro @ open - dsi . fr >
2004-05-02 18:01:35 +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
2004-05-02 18:01:35 +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
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2004-05-02 18:01:35 +02:00
*/
2004-10-03 20:31:14 +02:00
2006-08-20 23:09:23 +02:00
/**
2016-08-22 13:43:49 +02:00
* \file htdocs / compta / sociales / card . php
2009-10-25 21:48:44 +01:00
* \ingroup tax
2015-07-15 19:54:51 +02:00
* \brief Social contribution card page
2009-10-25 21:48:44 +01:00
*/
2004-10-03 20:31:14 +02:00
2012-08-22 23:24:21 +02:00
require '../../main.inc.php' ;
2017-10-07 21:03:46 +02:00
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/compta/sociales/class/chargesociales.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formsocialcontrib.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/tax.lib.php' ;
2018-07-17 22:33:20 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php' ;
2020-01-30 01:48:28 +01:00
if ( ! empty ( $conf -> projet -> enabled ))
2017-03-12 14:32:49 +01:00
{
2018-07-26 11:57:25 +02:00
include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php' ;
2017-03-12 14:32:49 +01:00
}
2020-01-30 01:48:28 +01:00
if ( ! empty ( $conf -> accounting -> enabled )) {
include_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php' ;
2017-10-07 21:03:46 +02:00
}
2004-05-02 18:01:35 +02:00
2018-05-27 09:27:09 +02:00
// Load translation files required by the page
2018-08-31 16:57:50 +02:00
$langs -> loadLangs ( array ( 'compta' , 'bills' , 'banks' ));
2004-10-03 20:31:14 +02:00
2020-01-30 01:48:28 +01:00
$id = GETPOST ( 'id' , 'int' );
$action = GETPOST ( 'action' , 'aZ09' );
$confirm = GETPOST ( 'confirm' );
2017-03-12 14:32:49 +01:00
$projectid = ( GETPOST ( 'projectid' ) ? GETPOST ( 'projectid' , 'int' ) : 0 );
2004-05-02 18:01:35 +02:00
2020-02-11 14:13:08 +01:00
$dateech = dol_mktime ( GETPOST ( 'echhour' ), GETPOST ( 'echmin' ), GETPOST ( 'echsec' ), GETPOST ( 'echmonth' ), GETPOST ( 'echday' ), GETPOST ( 'echyear' ));
$dateperiod = dol_mktime ( GETPOST ( 'periodhour' ), GETPOST ( 'periodmin' ), GETPOST ( 'periodsec' ), GETPOST ( 'periodmonth' ), GETPOST ( 'periodday' ), GETPOST ( 'periodyear' ));
2020-02-11 14:15:23 +01:00
$label = GETPOST ( 'label' , 'alpha' );
2020-02-11 14:13:08 +01:00
$actioncode = GETPOST ( 'actioncode' );
2008-10-13 16:22:10 +02:00
// Security check
2019-01-27 11:55:16 +01:00
$socid = GETPOST ( 'socid' , 'int' );
2020-01-30 01:48:28 +01:00
if ( $user -> socid ) $socid = $user -> socid ;
2019-01-27 11:55:16 +01:00
$result = restrictedArea ( $user , 'tax' , $id , 'chargesociales' , 'charges' );
2008-10-13 16:22:10 +02:00
2016-04-22 17:11:12 +02:00
$object = new ChargeSociales ( $db );
2004-05-02 18:01:35 +02:00
2004-06-08 17:09:49 +02:00
/* *************************************************************************** */
/* */
2007-01-30 20:58:19 +01:00
/* Actions */
2004-06-08 17:09:49 +02:00
/* */
/* *************************************************************************** */
2007-01-30 20:58:19 +01:00
2014-03-26 15:41:09 +01:00
// Classify paid
2016-04-22 17:11:12 +02:00
if ( $action == 'confirm_paid' && $user -> rights -> tax -> charges -> creer && $confirm == 'yes' )
2004-06-08 17:09:49 +02:00
{
2016-04-22 17:11:12 +02:00
$object -> fetch ( $id );
$result = $object -> set_paid ( $user );
}
if ( $action == 'reopen' && $user -> rights -> tax -> charges -> creer ) {
2017-10-07 13:09:31 +02:00
$result = $object -> fetch ( $id );
if ( $object -> paye )
{
$result = $object -> set_unpaid ( $user );
if ( $result > 0 )
{
2019-11-08 15:51:54 +01:00
header ( 'Location: ' . $_SERVER [ " PHP_SELF " ] . '?id=' . $id );
2017-10-07 13:09:31 +02:00
exit ();
} else {
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
}
2004-06-08 17:09:49 +02:00
}
2006-08-20 23:09:23 +02:00
2017-05-21 02:43:51 +02:00
// Link to a project
if ( $action == 'classin' && $user -> rights -> tax -> charges -> creer )
{
2017-10-07 13:09:31 +02:00
$object -> fetch ( $id );
$object -> setProject ( GETPOST ( 'projectid' ));
2017-05-21 02:43:51 +02:00
}
2016-11-28 23:58:36 +01:00
if ( $action == 'setlib' && $user -> rights -> tax -> charges -> creer )
{
2017-10-07 13:09:31 +02:00
$object -> fetch ( $id );
$result = $object -> setValueFrom ( 'libelle' , GETPOST ( 'lib' ), '' , '' , 'text' , '' , $user , 'TAX_MODIFY' );
if ( $result < 0 )
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2016-11-28 23:58:36 +01:00
}
2016-06-19 18:53:19 +02:00
// payment mode
if ( $action == 'setmode' && $user -> rights -> tax -> charges -> creer ) {
2017-10-07 13:09:31 +02:00
$object -> fetch ( $id );
$result = $object -> setPaymentMethods ( GETPOST ( 'mode_reglement_id' , 'int' ));
if ( $result < 0 )
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2016-06-19 18:53:19 +02:00
}
// bank account
if ( $action == 'setbankaccount' && $user -> rights -> tax -> charges -> creer ) {
2017-10-07 13:09:31 +02:00
$object -> fetch ( $id );
2019-11-08 15:51:54 +01:00
$result = $object -> setBankAccount ( GETPOST ( 'fk_account' , 'int' ));
2017-10-07 13:09:31 +02:00
if ( $result < 0 ) {
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
2016-06-19 18:53:19 +02:00
}
2014-03-26 15:41:09 +01:00
// Delete social contribution
if ( $action == 'confirm_delete' && $confirm == 'yes' )
2007-01-30 01:30:48 +01:00
{
2016-04-22 17:11:12 +02:00
$object -> fetch ( $id );
2019-11-08 15:51:54 +01:00
$result = $object -> delete ( $user );
2009-05-09 21:45:18 +02:00
if ( $result > 0 )
2007-01-30 01:30:48 +01:00
{
2019-04-08 09:05:51 +02:00
header ( " Location: list.php " );
2009-05-09 21:45:18 +02:00
exit ;
2020-05-21 15:05:19 +02:00
} else {
2016-04-22 17:11:12 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2007-01-30 01:30:48 +01:00
}
}
2004-06-08 17:09:49 +02:00
2009-03-03 00:43:17 +01:00
2014-03-26 15:41:09 +01:00
// Add social contribution
2011-12-21 21:14:10 +01:00
if ( $action == 'add' && $user -> rights -> tax -> charges -> creer )
2007-06-25 02:02:37 +02:00
{
2019-11-08 15:51:54 +01:00
$amount = price2num ( GETPOST ( 'amount' ));
2017-03-12 14:32:49 +01:00
2019-11-08 15:51:54 +01:00
if ( ! $dateech )
2007-06-25 02:02:37 +02:00
{
2020-01-23 19:37:34 +01:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Date " )), null , 'errors' );
2011-12-21 21:14:10 +01:00
$action = 'create' ;
2020-05-21 15:05:19 +02:00
} elseif ( ! $dateperiod )
2007-06-25 02:02:37 +02:00
{
2015-10-17 16:18:33 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Period " )), null , 'errors' );
2011-12-21 21:14:10 +01:00
$action = 'create' ;
2020-05-21 15:05:19 +02:00
} elseif ( ! $actioncode > 0 )
2009-10-25 21:48:44 +01:00
{
2015-10-17 16:18:33 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Type " )), null , 'errors' );
2011-12-21 21:14:10 +01:00
$action = 'create' ;
2020-05-21 15:05:19 +02:00
} elseif ( empty ( $amount ))
2007-06-25 02:02:37 +02:00
{
2015-10-17 16:18:33 +02:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Amount " )), null , 'errors' );
2011-12-21 21:14:10 +01:00
$action = 'create' ;
2020-05-21 15:05:19 +02:00
} elseif ( ! is_numeric ( $amount ))
2015-04-19 23:15:24 +02:00
{
2019-01-27 11:55:16 +01:00
setEventMessages ( $langs -> trans ( " ErrorFieldMustBeANumeric " , $langs -> transnoentities ( " Amount " )), null , 'errors' );
2015-04-19 23:15:24 +02:00
$action = 'create' ;
2020-05-21 15:05:19 +02:00
} else {
2020-01-30 01:48:28 +01:00
$object -> type = $actioncode ;
$object -> label = GETPOST ( 'label' , 'alpha' );
$object -> date_ech = $dateech ;
2017-03-12 14:32:49 +01:00
$object -> periode = $dateperiod ;
$object -> amount = $amount ;
2020-01-30 01:48:28 +01:00
$object -> mode_reglement_id = GETPOST ( 'mode_reglement_id' );
2017-10-07 13:09:31 +02:00
$object -> fk_account = GETPOST ( 'fk_account' , 'int' );
2017-03-12 14:32:49 +01:00
$object -> fk_project = GETPOST ( 'fk_project' );
2009-03-03 00:43:17 +01:00
2020-01-30 01:48:28 +01:00
$id = $object -> create ( $user );
2014-07-20 00:10:40 +02:00
if ( $id <= 0 )
2007-06-25 02:02:37 +02:00
{
2016-04-22 17:11:12 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2020-01-30 01:48:28 +01:00
$action = 'create' ;
2007-06-25 02:02:37 +02:00
}
}
}
2004-06-08 17:09:49 +02:00
2007-01-30 01:30:48 +01:00
2020-01-30 01:48:28 +01:00
if ( $action == 'update' && ! $_POST [ " cancel " ] && $user -> rights -> tax -> charges -> creer )
2007-06-25 02:02:37 +02:00
{
2020-01-30 01:48:28 +01:00
$amount = price2num ( GETPOST ( 'amount' ));
2017-10-07 13:09:31 +02:00
2020-01-30 01:48:28 +01:00
if ( ! $dateech )
2017-10-07 13:09:31 +02:00
{
2020-01-23 19:37:34 +01:00
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Date " )), null , 'errors' );
2017-10-07 13:09:31 +02:00
$action = 'edit' ;
2020-05-21 15:05:19 +02:00
} elseif ( ! $dateperiod )
2017-10-07 13:09:31 +02:00
{
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Period " )), null , 'errors' );
$action = 'edit' ;
2020-05-21 15:05:19 +02:00
} elseif ( empty ( $amount ))
2017-10-07 13:09:31 +02:00
{
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Amount " )), null , 'errors' );
$action = 'edit' ;
2020-05-21 15:05:19 +02:00
} elseif ( ! is_numeric ( $amount ))
2015-10-18 21:17:19 +02:00
{
2019-01-27 11:55:16 +01:00
setEventMessages ( $langs -> trans ( " ErrorFieldMustBeANumeric " , $langs -> transnoentities ( " Amount " )), null , 'errors' );
2015-10-18 21:17:19 +02:00
$action = 'create' ;
2020-05-21 15:05:19 +02:00
} else {
2019-11-08 15:51:54 +01:00
$result = $object -> fetch ( $id );
2015-03-10 14:43:13 +01:00
2019-11-08 15:51:54 +01:00
$object -> date_ech = $dateech ;
2017-10-07 13:09:31 +02:00
$object -> periode = $dateperiod ;
$object -> amount = price2num ( $amount );
2015-03-10 14:43:13 +01:00
2019-11-08 15:51:54 +01:00
$result = $object -> update ( $user );
2017-10-07 13:09:31 +02:00
if ( $result <= 0 )
{
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
2007-06-25 02:02:37 +02:00
}
}
2009-03-03 00:43:17 +01:00
2015-04-19 23:15:24 +02:00
// Action clone object
2019-11-08 15:51:54 +01:00
if ( $action == 'confirm_clone' && $confirm != 'yes' ) { $action = '' ; }
2015-04-19 23:15:24 +02:00
2014-09-23 16:52:15 +02:00
if ( $action == 'confirm_clone' && $confirm == 'yes' && ( $user -> rights -> tax -> charges -> creer ))
{
2014-10-04 17:20:17 +02:00
$db -> begin ();
$originalId = $id ;
$object -> fetch ( $id );
if ( $object -> id > 0 )
{
$object -> paye = 0 ;
$object -> id = $object -> ref = null ;
2019-10-31 14:06:26 +01:00
if ( GETPOST ( 'clone_label' , 'alphanohtml' )) {
$object -> label = GETPOST ( 'clone_label' , 'alphanohtml' );
2020-05-21 15:05:19 +02:00
} else {
2019-10-31 14:06:26 +01:00
$object -> label = $langs -> trans ( " CopyOf " ) . ' ' . $object -> label ;
}
if ( GETPOST ( 'clone_for_next_month' , 'int' )) {
2018-07-17 22:31:28 +02:00
$object -> periode = dol_time_plus_duree ( $object -> periode , 1 , 'm' );
2019-10-31 14:06:26 +01:00
$object -> date_ech = dol_time_plus_duree ( $object -> date_ech , 1 , 'm' );
2020-05-21 15:05:19 +02:00
} else {
2019-10-31 14:06:26 +01:00
$newdateperiod = dol_mktime ( 0 , 0 , 0 , GETPOST ( 'clone_periodmonth' , 'int' ), GETPOST ( 'clone_periodday' , 'int' ), GETPOST ( 'clone_periodyear' , 'int' ));
$newdateech = dol_mktime ( 0 , 0 , 0 , GETPOST ( 'clone_date_echmonth' , 'int' ), GETPOST ( 'clone_date_echday' , 'int' ), GETPOST ( 'clone_date_echyear' , 'int' ));
if ( $newdateperiod ) $object -> periode = $newdateperiod ;
if ( $newdateech ) $object -> date_ech = $newdateech ;
2014-10-04 17:20:17 +02:00
}
if ( $object -> check ())
{
$id = $object -> create ( $user );
if ( $id > 0 )
{
$db -> commit ();
$db -> close ();
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . " ?id= " . $id );
exit ;
2020-05-21 15:05:19 +02:00
} else {
2019-11-08 15:51:54 +01:00
$id = $originalId ;
2014-10-04 17:20:17 +02:00
$db -> rollback ();
2019-01-27 11:55:16 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2014-10-04 17:20:17 +02:00
}
}
2020-05-21 15:05:19 +02:00
} else {
2014-10-04 17:20:17 +02:00
$db -> rollback ();
2019-01-27 11:55:16 +01:00
dol_print_error ( $db , $object -> error );
2014-10-04 17:20:17 +02:00
}
2014-09-23 16:52:15 +02:00
}
2009-05-09 21:45:18 +02:00
/*
* View
*/
2012-02-20 10:09:28 +01:00
$form = new Form ( $db );
$formsocialcontrib = new FormSocialContrib ( $db );
2017-10-07 21:03:46 +02:00
$bankaccountstatic = new Account ( $db );
2019-11-08 15:51:54 +01:00
if ( ! empty ( $conf -> projet -> enabled )) { $formproject = new FormProjets ( $db ); }
2012-02-20 10:09:28 +01:00
2019-11-08 15:51:54 +01:00
$title = $langs -> trans ( " SocialContribution " ) . ' - ' . $langs -> trans ( " Card " );
$help_url = 'EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:Módulo Impuestos y cargas sociales (IVA, impuestos)' ;
2019-01-27 11:55:16 +01:00
llxHeader ( " " , $title , $help_url );
2007-01-30 01:30:48 +01:00
2007-07-31 02:23:30 +02:00
2011-08-05 23:05:19 +02:00
// Mode creation
2011-12-21 21:14:10 +01:00
if ( $action == 'create' )
2007-06-25 02:02:37 +02:00
{
2015-09-24 18:33:48 +02:00
print load_fiche_titre ( $langs -> trans ( " NewSocialContribution " ));
2009-03-03 00:43:17 +01:00
2017-10-07 13:09:31 +02:00
print '<form name="charge" method="post" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2017-10-07 13:09:31 +02:00
print '<input type="hidden" name="action" value="add">' ;
2007-06-25 02:02:37 +02:00
2017-10-07 13:09:31 +02:00
dol_fiche_head ();
2007-06-25 02:02:37 +02:00
2019-11-05 21:24:41 +01:00
print '<table class="border centpercent">' ;
2016-11-28 21:27:02 +01:00
2017-10-07 13:09:31 +02:00
// Label
print " <tr> " ;
print '<td class="titlefieldcreate fieldrequired">' ;
print $langs -> trans ( " Label " );
print '</td>' ;
2019-01-27 11:55:16 +01:00
print '<td><input type="text" size="34" name="label" class="flat" value="' . dol_escape_htmltag ( GETPOST ( 'label' , 'alpha' )) . '" autofocus></td>' ;
2017-10-07 13:09:31 +02:00
print '</tr>' ;
print '<tr>' ;
// Type
print '<td class="fieldrequired">' ;
print $langs -> trans ( " Type " );
print '</td>' ;
print '<td>' ;
2019-11-08 15:51:54 +01:00
$formsocialcontrib -> select_type_socialcontrib ( GETPOST ( " actioncode " , 'alpha' ) ? GETPOST ( " actioncode " , 'alpha' ) : '' , 'actioncode' , 1 );
2017-10-07 13:09:31 +02:00
print '</td>' ;
print '</tr>' ;
2016-11-28 21:27:02 +01:00
2020-01-23 19:28:56 +01:00
// Date
2017-10-07 13:09:31 +02:00
print '<tr>' ;
print '<td class="fieldrequired">' ;
2020-01-23 19:28:56 +01:00
print $langs -> trans ( " Date " );
2017-10-07 13:09:31 +02:00
print '</td>' ;
2020-01-23 19:28:56 +01:00
print '<td>' ;
print $form -> selectDate ( ! empty ( $dateech ) ? $dateech : '-1' , 'ech' , 0 , 0 , 0 , 'charge' , 1 );
2009-05-09 21:45:18 +02:00
print '</td>' ;
2020-01-23 19:28:56 +01:00
print " </tr> \n " ;
2016-11-28 21:27:02 +01:00
2020-01-23 19:28:56 +01:00
// Date end period
2018-04-28 17:18:38 +02:00
print '<tr>' ;
print '<td class="fieldrequired">' ;
2020-01-23 19:28:56 +01:00
print $form -> textwithpicto ( $langs -> trans ( " PeriodEndDate " ), $langs -> trans ( " LastDayTaxIsRelatedTo " ));
2018-04-28 17:18:38 +02:00
print '</td>' ;
print '<td>' ;
2020-01-23 19:28:56 +01:00
print $form -> selectDate ( ! empty ( $dateperiod ) ? $dateperiod : '-1' , 'period' , 0 , 0 , 0 , 'charge' , 1 );
2018-04-28 17:18:38 +02:00
print '</td>' ;
2020-01-23 19:28:56 +01:00
print '</tr>' ;
2018-04-28 17:18:38 +02:00
2017-10-07 13:09:31 +02:00
// Amount
print '<tr>' ;
print '<td class="fieldrequired">' ;
print $langs -> trans ( " Amount " );
print '</td>' ;
2019-01-27 11:55:16 +01:00
print '<td><input type="text" size="6" name="amount" class="flat" value="' . dol_escape_htmltag ( GETPOST ( 'amount' , 'alpha' )) . '"></td>' ;
2017-10-07 13:09:31 +02:00
print '</tr>' ;
2016-11-28 21:27:02 +01:00
2017-03-12 14:32:49 +01:00
// Project
2019-11-08 15:51:54 +01:00
if ( ! empty ( $conf -> projet -> enabled ))
2017-03-12 14:32:49 +01:00
{
2019-11-08 15:51:54 +01:00
$formproject = new FormProjets ( $db );
2017-03-12 14:32:49 +01:00
// Associated project
$langs -> load ( " projects " );
print '<tr><td>' . $langs -> trans ( " Project " ) . '</td><td>' ;
2019-11-08 15:51:54 +01:00
$numproject = $formproject -> select_projects ( - 1 , $projectid , 'fk_project' , 0 , 0 , 1 , 1 );
2017-06-09 09:25:15 +02:00
2017-03-12 14:32:49 +01:00
print '</td></tr>' ;
}
2017-10-07 13:09:31 +02:00
// Payment Mode
2019-11-08 15:51:54 +01:00
print '<tr><td>' . $langs -> trans ( 'PaymentMode' ) . '</td><td colspan="2">' ;
2017-10-07 13:09:31 +02:00
$form -> select_types_paiements ( $mode_reglement_id , 'mode_reglement_id' );
print '</td></tr>' ;
// Bank Account
2019-11-08 15:51:54 +01:00
if ( ! empty ( $conf -> banque -> enabled ))
2017-10-07 13:09:31 +02:00
{
2019-11-08 15:51:54 +01:00
print '<tr><td>' . $langs -> trans ( 'BankAccount' ) . '</td><td colspan="2">' ;
2017-10-07 13:09:31 +02:00
$form -> select_comptes ( $fk_account , 'fk_account' , 0 , '' , 1 );
print '</td></tr>' ;
}
print '</table>' ;
2007-06-25 02:02:37 +02:00
2015-04-19 23:15:24 +02:00
dol_fiche_end ();
print '<div class="center">' ;
print '<input type="submit" class="button" value="' . $langs -> trans ( " Add " ) . '">' ;
2016-11-28 21:27:02 +01:00
print ' ' ;
2019-11-08 15:51:54 +01:00
print '<input type="button" class="button" value="' . $langs -> trans ( " Cancel " ) . '" onClick="javascript:history.go(-1)">' ;
2016-11-28 21:27:02 +01:00
print '</div>' ;
2015-04-19 23:15:24 +02:00
2017-10-07 13:09:31 +02:00
print '</form>' ;
2007-06-25 02:02:37 +02:00
}
2004-05-02 18:01:35 +02:00
/* *************************************************************************** */
/* */
2016-06-19 18:53:19 +02:00
/* Card Mode */
2004-05-02 18:01:35 +02:00
/* */
/* *************************************************************************** */
2012-02-11 20:30:16 +01:00
if ( $id > 0 )
2006-08-20 23:09:23 +02:00
{
2012-02-11 20:30:16 +01:00
$object = new ChargeSociales ( $db );
2019-11-08 15:51:54 +01:00
$result = $object -> fetch ( $id );
2006-08-20 23:09:23 +02:00
2010-09-12 13:49:02 +02:00
if ( $result > 0 )
2006-08-20 23:09:23 +02:00
{
2019-11-08 15:51:54 +01:00
$head = tax_prepare_head ( $object );
2006-08-20 23:09:23 +02:00
2016-11-28 23:58:36 +01:00
$totalpaye = $object -> getSommePaiement ();
2017-06-09 09:25:15 +02:00
2014-09-23 16:52:15 +02:00
// Clone confirmation
if ( $action === 'clone' )
{
2019-11-08 15:51:54 +01:00
$formquestion = array (
2019-10-31 14:06:26 +01:00
array ( 'type' => 'text' , 'name' => 'clone_label' , 'label' => $langs -> trans ( " Label " ), 'value' => $langs -> trans ( " CopyOf " ) . ' ' . $object -> label ),
2014-09-23 16:52:15 +02:00
);
2019-11-08 15:51:54 +01:00
if ( ! empty ( $conf -> global -> TAX_ADD_CLON_FOR_NEXT_MONTH_CHECKBOX ))
2019-10-31 14:06:26 +01:00
{
2019-11-08 15:51:54 +01:00
$formquestion [] = array ( 'type' => 'checkbox' , 'name' => 'clone_for_next_month' , 'label' => $langs -> trans ( " CloneTaxForNextMonth " ), 'value' => 1 );
2020-05-21 15:05:19 +02:00
} else {
2020-01-23 19:28:56 +01:00
$formquestion [] = array ( 'type' => 'date' , 'name' => 'clone_date_ech' , 'label' => $langs -> trans ( " Date " ), 'value' => - 1 );
2019-11-08 15:51:54 +01:00
$formquestion [] = array ( 'type' => 'date' , 'name' => 'clone_period' , 'label' => $langs -> trans ( " PeriodEndDate " ), 'value' => - 1 );
2019-10-31 14:06:26 +01:00
}
2014-10-04 17:20:17 +02:00
2020-01-23 19:28:56 +01:00
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id , $langs -> trans ( 'ToClone' ), $langs -> trans ( 'ConfirmCloneTax' , $object -> ref ), 'confirm_clone' , $formquestion , 'yes' , 1 , 240 );
2014-09-23 16:52:15 +02:00
}
2014-10-04 17:20:17 +02:00
2019-11-04 15:09:43 +01:00
2011-12-21 21:14:10 +01:00
if ( $action == 'paid' )
2006-08-20 23:09:23 +02:00
{
2020-01-30 01:48:28 +01:00
$text = $langs -> trans ( 'ConfirmPaySocialContribution' );
2019-01-27 11:55:16 +01:00
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id , $langs -> trans ( 'PaySocialContribution' ), $text , " confirm_paid " , '' , '' , 2 );
2006-08-20 23:09:23 +02:00
}
2019-11-04 15:09:43 +01:00
2019-11-04 15:08:43 +01:00
// Confirmation of the removal of the Social Contribution
2011-12-21 21:14:10 +01:00
if ( $action == 'delete' )
2007-01-30 20:58:19 +01:00
{
2020-01-30 01:48:28 +01:00
$text = $langs -> trans ( 'ConfirmDeleteSocialContribution' );
2019-01-27 11:55:16 +01:00
print $form -> formconfirm ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , $langs -> trans ( 'DeleteSocialContribution' ), $text , 'confirm_delete' , '' , '' , 2 );
2007-01-30 20:58:19 +01:00
}
2011-12-21 21:14:10 +01:00
if ( $action == 'edit' )
2009-05-16 14:52:53 +02:00
{
2016-08-22 13:43:49 +02:00
print " <form name= \" charge \" action= \" " . $_SERVER [ " PHP_SELF " ] . " ?id= $object->id &action=update \" method= \" post \" > " ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2009-05-16 14:52:53 +02:00
}
2006-08-20 23:09:23 +02:00
2017-05-21 02:43:51 +02:00
dol_fiche_head ( $head , 'card' , $langs -> trans ( " SocialContribution " ), - 1 , 'bill' );
2006-08-20 23:09:23 +02:00
2020-01-30 01:48:28 +01:00
$morehtmlref = '<div class="refidno">' ;
2016-11-28 23:58:36 +01:00
// Ref customer
2020-01-30 01:48:28 +01:00
$morehtmlref .= $form -> editfieldkey ( " Label " , 'lib' , $object -> label , $object , $user -> rights -> tax -> charges -> creer , 'string' , '' , 0 , 1 );
$morehtmlref .= $form -> editfieldval ( " Label " , 'lib' , $object -> label , $object , $user -> rights -> tax -> charges -> creer , 'string' , '' , null , null , '' , 1 );
2017-05-21 02:43:51 +02:00
// Project
2020-01-30 01:48:28 +01:00
if ( ! empty ( $conf -> projet -> enabled ))
2017-05-21 02:43:51 +02:00
{
2017-10-07 13:09:31 +02:00
$langs -> load ( " projects " );
2020-01-30 01:48:28 +01:00
$morehtmlref .= '<br>' . $langs -> trans ( 'Project' ) . ' ' ;
2017-10-07 13:09:31 +02:00
if ( $user -> rights -> tax -> charges -> creer )
{
2019-10-26 18:13:20 +02:00
if ( $action != 'classify' ) {
2020-01-30 01:48:28 +01:00
$morehtmlref .= '<a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=classify&id=' . $object -> id . '">' . img_edit ( $langs -> transnoentitiesnoconv ( 'SetProject' )) . '</a> : ' ;
2019-10-26 18:13:20 +02:00
}
if ( $action == 'classify' ) {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
2020-01-30 01:48:28 +01:00
$morehtmlref .= '<form method="post" action="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '">' ;
$morehtmlref .= '<input type="hidden" name="action" value="classin">' ;
$morehtmlref .= '<input type="hidden" name="token" value="' . newToken () . '">' ;
$morehtmlref .= $formproject -> select_projects ( 0 , $object -> fk_project , 'projectid' , $maxlength , 0 , 1 , 0 , 1 , 0 , 0 , '' , 1 );
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="' . $langs -> trans ( " Modify " ) . '">' ;
$morehtmlref .= '</form>' ;
2019-10-26 18:13:20 +02:00
} else {
2020-01-30 01:48:28 +01:00
$morehtmlref .= $form -> form_project ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , $object -> socid , $object -> fk_project , 'none' , 0 , 0 , 0 , 1 );
2019-10-26 18:13:20 +02:00
}
2017-10-07 13:09:31 +02:00
} else {
2020-01-30 01:48:28 +01:00
if ( ! empty ( $object -> fk_project )) {
2017-10-07 13:09:31 +02:00
$proj = new Project ( $db );
$proj -> fetch ( $object -> fk_project );
2020-01-30 01:48:28 +01:00
$morehtmlref .= '<a href="' . DOL_URL_ROOT . '/projet/card.php?id=' . $object -> fk_project . '" title="' . $langs -> trans ( 'ShowProject' ) . '">' ;
$morehtmlref .= $proj -> ref ;
$morehtmlref .= '</a>' ;
2017-10-07 13:09:31 +02:00
} else {
2020-01-30 01:48:28 +01:00
$morehtmlref .= '' ;
2017-10-07 13:09:31 +02:00
}
}
2017-06-09 09:25:15 +02:00
}
2020-01-30 01:48:28 +01:00
$morehtmlref .= '</div>' ;
2017-06-09 09:25:15 +02:00
2020-07-09 23:18:19 +02:00
$morehtmlright = '' ;
2020-01-30 01:48:28 +01:00
$linkback = '<a href="' . DOL_URL_ROOT . '/compta/sociales/list.php?restore_lastsearch_values=1">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2017-06-09 09:25:15 +02:00
2020-01-30 01:48:28 +01:00
$object -> totalpaye = $totalpaye ; // To give a chance to dol_banner_tab to use already paid amount to show correct status
2017-06-09 09:25:15 +02:00
2016-11-28 23:58:36 +01:00
dol_banner_tab ( $object , 'id' , $linkback , 1 , 'rowid' , 'ref' , $morehtmlref , '' , 0 , '' , $morehtmlright );
2017-06-09 09:25:15 +02:00
2016-11-29 06:34:20 +01:00
print '<div class="fichecenter">' ;
print '<div class="fichehalfleft">' ;
print '<div class="underbanner clearboth"></div>' ;
2017-06-09 09:25:15 +02:00
2019-11-05 21:24:41 +01:00
print '<table class="border centpercent">' ;
2017-06-09 09:25:15 +02:00
2009-05-09 21:45:18 +02:00
// Type
2020-01-23 19:28:56 +01:00
print '<tr><td class="titlefield">' ;
print $langs -> trans ( " Type " ) . " </td><td> " . $object -> type_label . " </td> " ;
2006-08-20 23:09:23 +02:00
print " </tr> " ;
2009-03-03 00:43:17 +01:00
2020-01-23 19:28:56 +01:00
// Date
if ( $action == 'edit' )
{
2020-01-23 19:37:34 +01:00
print '<tr><td>' . $langs -> trans ( " Date " ) . " </td><td> " ;
2020-01-23 19:28:56 +01:00
print $form -> selectDate ( $object -> date_ech , 'ech' , 0 , 0 , 0 , 'charge' , 1 );
print " </td></tr> " ;
} else {
2020-01-23 19:37:34 +01:00
print " <tr><td> " . $langs -> trans ( " Date " ) . " </td><td> " . dol_print_date ( $object -> date_ech , 'day' ) . " </td></tr> " ;
2020-01-23 19:28:56 +01:00
}
2017-10-07 13:09:31 +02:00
// Period end date
2018-04-28 17:18:38 +02:00
print " <tr><td> " . $form -> textwithpicto ( $langs -> trans ( " PeriodEndDate " ), $langs -> trans ( " LastDayTaxIsRelatedTo " )) . " </td> " ;
2013-11-03 15:07:26 +01:00
print " <td> " ;
if ( $action == 'edit' )
{
2018-09-09 09:36:12 +02:00
print $form -> selectDate ( $object -> periode , 'period' , 0 , 0 , 0 , 'charge' , 1 );
2020-05-21 15:05:19 +02:00
} else {
2019-01-27 11:55:16 +01:00
print dol_print_date ( $object -> periode , " day " );
2013-11-03 15:07:26 +01:00
}
print " </td></tr> " ;
2014-05-06 22:54:33 +02:00
2010-07-27 01:00:39 +02:00
// Amount
2017-10-07 13:09:31 +02:00
if ( $action == 'edit' )
{
print '<tr><td>' . $langs -> trans ( " AmountTTC " ) . " </td><td> " ;
print '<input type="text" name="amount" size="12" class="flat" value="' . $object -> amount . '">' ;
print " </td></tr> " ;
2020-05-21 15:05:19 +02:00
} else {
2019-01-27 11:55:16 +01:00
print '<tr><td>' . $langs -> trans ( " AmountTTC " ) . '</td><td>' . price ( $object -> amount , 0 , $outputlangs , 1 , - 1 , - 1 , $conf -> currency ) . '</td></tr>' ;
2017-10-07 13:09:31 +02:00
}
// Mode of payment
print '<tr><td>' ;
print '<table class="nobordernopadding" width="100%"><tr><td>' ;
print $langs -> trans ( 'PaymentMode' );
print '</td>' ;
if ( $action != 'editmode' )
2019-11-08 15:51:54 +01:00
print '<td class="right"><a class="editfielda" href="' . $_SERVER [ " PHP_SELF " ] . '?action=editmode&id=' . $object -> id . '">' . img_edit ( $langs -> trans ( 'SetMode' ), 1 ) . '</a></td>' ;
2017-10-07 13:09:31 +02:00
print '</tr></table>' ;
print '</td><td>' ;
if ( $action == 'editmode' ) {
2019-11-08 15:51:54 +01:00
$form -> form_modes_reglement ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , $object -> mode_reglement_id , 'mode_reglement_id' );
2017-10-07 13:09:31 +02:00
} else {
2019-11-08 15:51:54 +01:00
$form -> form_modes_reglement ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , $object -> mode_reglement_id , 'none' );
2017-10-07 13:09:31 +02:00
}
print '</td></tr>' ;
// Bank Account
2019-11-08 15:51:54 +01:00
if ( ! empty ( $conf -> banque -> enabled ))
2017-10-07 13:09:31 +02:00
{
print '<tr><td class="nowrap">' ;
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">' ;
print $langs -> trans ( 'BankAccount' );
print '<td>' ;
if ( $action != 'editbankaccount' && $user -> rights -> tax -> charges -> creer )
2019-10-06 15:34:22 +02:00
print '<td class="right"><a class="editfielda" href="' . $_SERVER [ " PHP_SELF " ] . '?action=editbankaccount&id=' . $object -> id . '">' . img_edit ( $langs -> trans ( 'SetBankAccount' ), 1 ) . '</a></td>' ;
2017-10-07 13:09:31 +02:00
print '</tr></table>' ;
print '</td><td>' ;
if ( $action == 'editbankaccount' ) {
$form -> formSelectAccount ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , $object -> fk_account , 'fk_account' , 1 );
} else {
$form -> formSelectAccount ( $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id , $object -> fk_account , 'none' );
}
print '</td>' ;
print '</tr>' ;
}
2016-06-19 18:53:19 +02:00
2011-12-21 21:14:10 +01:00
print '</table>' ;
2016-11-29 06:34:20 +01:00
print '</div>' ;
print '<div class="fichehalfright">' ;
print '<div class="ficheaddleft">' ;
2017-10-07 21:03:46 +02:00
$nbcols = 3 ;
2019-11-08 15:51:54 +01:00
if ( ! empty ( $conf -> banque -> enabled )) {
$nbcols ++ ;
2017-10-07 21:03:46 +02:00
}
2016-11-29 06:34:20 +01:00
/*
* Payments
*/
2020-03-16 19:23:18 +01:00
$sql = " SELECT p.rowid, p.num_paiement as num_payment, datep as dp, p.amount, " ;
2019-11-08 15:51:54 +01:00
$sql .= " c.code as type_code,c.libelle as paiement_type, " ;
2020-01-17 14:32:22 +01:00
$sql .= ' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.currency_code as bacurrency_code, ba.fk_accountancy_journal' ;
2019-11-08 15:51:54 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " paiementcharge as p " ;
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid' ;
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid' ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " c_paiement as c ON p.fk_typepaiement = c.id " ;
$sql .= " , " . MAIN_DB_PREFIX . " chargesociales as cs " ;
$sql .= " WHERE p.fk_charge = " . $id ;
$sql .= " AND p.fk_charge = cs.rowid " ;
$sql .= " AND cs.entity IN ( " . getEntity ( 'tax' ) . " ) " ;
$sql .= " ORDER BY dp DESC " ;
2016-11-29 06:34:20 +01:00
//print $sql;
$resql = $db -> query ( $sql );
if ( $resql )
{
2017-10-07 13:09:31 +02:00
$totalpaye = 0 ;
$num = $db -> num_rows ( $resql );
$i = 0 ; $total = 0 ;
2019-05-29 12:56:11 +02:00
2019-11-08 15:51:54 +01:00
print '<div class="div-table-responsive-no-min">' ; // You can use div-table-responsive-no-min if you dont need reserved height for your table
2017-10-07 13:09:31 +02:00
print '<table class="noborder paymenttable">' ;
print '<tr class="liste_titre">' ;
print '<td>' . $langs -> trans ( " RefPayment " ) . '</td>' ;
print '<td>' . $langs -> trans ( " Date " ) . '</td>' ;
print '<td>' . $langs -> trans ( " Type " ) . '</td>' ;
2019-11-08 15:51:54 +01:00
if ( ! empty ( $conf -> banque -> enabled )) {
print '<td class="liste_titre right">' . $langs -> trans ( 'BankAccount' ) . '</td>' ;
2017-10-07 21:03:46 +02:00
}
2019-02-12 14:53:35 +01:00
print '<td class="right">' . $langs -> trans ( " Amount " ) . '</td>' ;
2017-10-07 13:09:31 +02:00
print '</tr>' ;
if ( $num > 0 )
{
while ( $i < $num )
{
$objp = $db -> fetch_object ( $resql );
2017-10-07 21:03:46 +02:00
print '<tr class="oddeven"><td>' ;
2019-01-27 11:55:16 +01:00
print '<a href="' . DOL_URL_ROOT . '/compta/payment_sc/card.php?id=' . $objp -> rowid . '">' . img_object ( $langs -> trans ( " Payment " ), " payment " ) . ' ' . $objp -> rowid . '</a></td>' ;
print '<td>' . dol_print_date ( $db -> jdate ( $objp -> dp ), 'day' ) . " </td> \n " ;
2019-11-08 15:51:54 +01:00
$labeltype = $langs -> trans ( " PaymentType " . $objp -> type_code ) != ( " PaymentType " . $objp -> type_code ) ? $langs -> trans ( " PaymentType " . $objp -> type_code ) : $objp -> paiement_type ;
2020-03-16 19:23:18 +01:00
print " <td> " . $labeltype . ' ' . $objp -> num_payment . " </td> \n " ;
2019-11-08 15:51:54 +01:00
if ( ! empty ( $conf -> banque -> enabled ))
2017-10-07 21:03:46 +02:00
{
$bankaccountstatic -> id = $objp -> baid ;
$bankaccountstatic -> ref = $objp -> baref ;
$bankaccountstatic -> label = $objp -> baref ;
$bankaccountstatic -> number = $objp -> banumber ;
2020-01-17 14:32:22 +01:00
$bankaccountstatic -> currency_code = $objp -> bacurrency_code ;
2017-10-07 21:03:46 +02:00
2019-11-08 15:51:54 +01:00
if ( ! empty ( $conf -> accounting -> enabled )) {
2017-10-07 21:03:46 +02:00
$bankaccountstatic -> account_number = $objp -> account_number ;
$accountingjournal = new AccountingJournal ( $db );
$accountingjournal -> fetch ( $objp -> fk_accountancy_journal );
2019-01-27 11:55:16 +01:00
$bankaccountstatic -> accountancy_journal = $accountingjournal -> getNomUrl ( 0 , 1 , 1 , '' , 1 );
2017-10-07 21:03:46 +02:00
}
2019-02-12 14:53:35 +01:00
print '<td class="right">' ;
2017-10-07 21:03:46 +02:00
if ( $bankaccountstatic -> id )
print $bankaccountstatic -> getNomUrl ( 1 , 'transactions' );
print '</td>' ;
}
2019-02-12 14:53:35 +01:00
print '<td class="right">' . price ( $objp -> amount ) . " </td> \n " ;
2017-10-07 13:09:31 +02:00
print " </tr> " ;
$totalpaye += $objp -> amount ;
$i ++ ;
}
2020-05-21 15:05:19 +02:00
} else {
2019-07-21 20:55:12 +02:00
print '<tr class="oddeven"><td><span class="opacitymedium">' . $langs -> trans ( " None " ) . '</span></td>' ;
2017-10-16 20:53:23 +02:00
print '<td></td><td></td><td></td><td></td>' ;
print '</tr>' ;
2017-10-07 13:09:31 +02:00
}
2019-02-12 14:53:35 +01:00
print '<tr><td colspan="' . $nbcols . '" class="right">' . $langs -> trans ( " AlreadyPaid " ) . " :</td><td class= \" right \" > " . price ( $totalpaye ) . " </td></tr> \n " ;
print '<tr><td colspan="' . $nbcols . '" class="right">' . $langs -> trans ( " AmountExpected " ) . " :</td><td class= \" right \" > " . price ( $object -> amount ) . " </td></tr> \n " ;
2017-10-07 21:03:46 +02:00
$resteapayer = $object -> amount - $totalpaye ;
$cssforamountpaymentcomplete = 'amountpaymentcomplete' ;
2017-10-07 13:09:31 +02:00
2019-02-12 14:53:35 +01:00
print '<tr><td colspan="' . $nbcols . '" class="right">' . $langs -> trans ( " RemainderToPay " ) . " :</td> " ;
2019-11-08 15:51:54 +01:00
print '<td class="right' . ( $resteapayer ? ' amountremaintopay' : ( ' ' . $cssforamountpaymentcomplete )) . '">' . price ( $resteapayer ) . " </td></tr> \n " ;
2017-10-07 13:09:31 +02:00
print " </table> " ;
2019-05-29 12:56:11 +02:00
print '</div>' ;
2017-10-07 13:09:31 +02:00
$db -> free ( $resql );
2020-05-21 15:05:19 +02:00
} else {
2017-10-07 13:09:31 +02:00
dol_print_error ( $db );
2017-06-09 09:25:15 +02:00
}
2016-11-29 06:34:20 +01:00
print '</div>' ;
print '</div>' ;
print '</div>' ;
2017-06-09 09:25:15 +02:00
2016-11-29 06:34:20 +01:00
print '<div class="clearboth"></div>' ;
2016-11-29 06:43:16 +01:00
2016-06-02 21:11:14 +02:00
dol_fiche_end ();
2016-11-29 06:34:20 +01:00
2011-12-21 21:14:10 +01:00
if ( $action == 'edit' )
2007-06-25 02:02:37 +02:00
{
2016-06-02 21:11:14 +02:00
print '<div align="center">' ;
2007-06-25 02:02:37 +02:00
print '<input type="submit" class="button" name="save" value="' . $langs -> trans ( " Save " ) . '">' ;
print ' ' ;
print '<input type="submit" class="button" name="cancel" value="' . $langs -> trans ( " Cancel " ) . '">' ;
2016-06-19 18:53:19 +02:00
print '</div>' ;
2007-06-25 02:02:37 +02:00
}
2009-03-03 00:43:17 +01:00
2011-12-21 21:14:10 +01:00
if ( $action == 'edit' ) print " </form> \n " ;
2006-08-20 23:09:23 +02:00
2007-06-25 02:02:37 +02:00
/*
2015-07-15 19:54:51 +02:00
* Actions buttons
2007-06-25 02:02:37 +02:00
*/
2011-12-21 21:14:10 +01:00
if ( $action != 'edit' )
2007-06-25 02:02:37 +02:00
{
2006-08-20 23:09:23 +02:00
print " <div class= \" tabsAction \" > \n " ;
2016-04-22 17:11:12 +02:00
// Reopen
if ( $object -> paye && $user -> rights -> tax -> charges -> creer )
{
2019-11-08 15:51:54 +01:00
print " <div class= \" inline-block divButAction \" ><a class= \" butAction \" href= \" " . dol_buildpath ( " /compta/sociales/card.php " , 1 ) . " ?id= $object->id &action=reopen \" > " . $langs -> trans ( " ReOpen " ) . " </a></div> " ;
2016-04-22 17:11:12 +02:00
}
2016-11-28 21:27:02 +01:00
2009-05-09 21:45:18 +02:00
// Edit
2015-03-10 14:49:36 +01:00
if ( $object -> paye == 0 && $user -> rights -> tax -> charges -> creer )
2007-01-30 22:20:05 +01:00
{
2019-08-26 15:35:20 +02:00
print " <div class= \" inline-block divButAction \" ><a class= \" butAction \" href= \" " . DOL_URL_ROOT . " /compta/sociales/card.php?id= $object->id &action=edit \" > " . $langs -> trans ( " Modify " ) . " </a></div> " ;
2007-01-30 22:20:05 +01:00
}
2015-07-15 19:54:51 +02:00
// Emit payment
2015-05-22 09:05:38 +02:00
if ( $object -> paye == 0 && (( price2num ( $object -> amount ) < 0 && price2num ( $resteapayer , 'MT' ) < 0 ) || ( price2num ( $object -> amount ) > 0 && price2num ( $resteapayer , 'MT' ) > 0 )) && $user -> rights -> tax -> charges -> creer )
2006-08-20 23:09:23 +02:00
{
2019-08-26 15:35:20 +02:00
print " <div class= \" inline-block divButAction \" ><a class= \" butAction \" href= \" " . DOL_URL_ROOT . " /compta/paiement_charge.php?id= $object->id &action=create \" > " . $langs -> trans ( " DoPayment " ) . " </a></div> " ;
2006-08-20 23:09:23 +02:00
}
2009-08-19 19:16:47 +02:00
// Classify 'paid'
2019-11-08 15:51:54 +01:00
if ( $object -> paye == 0 && round ( $resteapayer ) <= 0 && $user -> rights -> tax -> charges -> creer )
2006-08-20 23:09:23 +02:00
{
2019-08-26 15:35:20 +02:00
print " <div class= \" inline-block divButAction \" ><a class= \" butAction \" href= \" " . DOL_URL_ROOT . " /compta/sociales/card.php?id= $object->id &action=paid \" > " . $langs -> trans ( " ClassifyPaid " ) . " </a></div> " ;
2006-08-20 23:09:23 +02:00
}
2014-10-04 17:20:17 +02:00
2014-09-23 16:52:15 +02:00
// Clone
if ( $user -> rights -> tax -> charges -> creer )
{
2019-11-08 15:51:54 +01:00
print " <div class= \" inline-block divButAction \" ><a class= \" butAction \" href= \" " . dol_buildpath ( " /compta/sociales/card.php " , 1 ) . " ?id= $object->id &action=clone \" > " . $langs -> trans ( " ToClone " ) . " </a></div> " ;
2014-09-23 16:52:15 +02:00
}
2006-08-20 23:09:23 +02:00
2009-05-09 21:45:18 +02:00
// Delete
2011-08-05 23:05:19 +02:00
if ( $user -> rights -> tax -> charges -> supprimer )
2007-01-30 20:58:19 +01:00
{
2019-08-26 15:35:20 +02:00
print " <div class= \" inline-block divButAction \" ><a class= \" butActionDelete \" href= \" " . DOL_URL_ROOT . " /compta/sociales/card.php?id= $object->id &action=delete \" > " . $langs -> trans ( " Delete " ) . " </a></div> " ;
2007-01-30 20:58:19 +01:00
}
2006-08-20 23:09:23 +02:00
print " </div> " ;
}
2020-05-21 15:05:19 +02:00
} else {
2015-03-10 14:49:36 +01:00
/* Social contribution not found */
2019-01-27 11:55:16 +01:00
dol_print_error ( '' , $object -> error );
2006-08-20 23:09:23 +02:00
}
2004-05-02 18:01:35 +02:00
}
2018-08-08 12:29:36 +02:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2012-02-11 20:30:16 +01:00
$db -> close ();