28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/paymentsocialcontribution.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
42$langs->loadLangs(array(
"banks",
"bills",
"compta"));
44$action =
GETPOST(
'action',
'aZ09');
45$confirm =
GETPOST(
'confirm',
'alpha');
53if ($user->socid > 0) {
54 $socid = $user->socid;
64if (($action ==
'add_payment' || ($action ==
'confirm_paiement' && $confirm ==
'yes')) && $user->hasRight(
'tax',
'charges',
'creer')) {
68 $loc = DOL_URL_ROOT.
'/compta/sociales/card.php?id='.$chid;
69 header(
"Location: ".$loc);
75 if (!(
GETPOST(
"paiementtype") > 0)) {
76 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"PaymentMode")),
null,
'errors');
80 if ($datepaye ==
'') {
81 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Date")),
null,
'errors');
85 if (isModEnabled(
"bank") && !(
GETPOST(
"accountid") > 0)) {
86 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"AccountToCredit")),
null,
'errors');
95 foreach ($_POST as $key => $value) {
96 if (substr($key, 0, 7) ==
'amount_') {
97 $other_chid = substr($key, 7);
102 if (count($amounts) <= 0) {
113 $paiement->chid = $chid;
114 $paiement->datepaye = $datepaye;
115 $paiement->amounts = $amounts;
116 $paiement->paiementtype =
GETPOST(
"paiementtype",
'alphanohtml');
117 $paiement->num_payment =
GETPOST(
"num_payment",
'alphanohtml');
118 $paiement->note =
GETPOST(
"note",
'restricthtml');
119 $paiement->note_private =
GETPOST(
"note",
'restricthtml');
122 $paymentid = $paiement->create($user, (
GETPOST(
'closepaidcontrib') ==
'on' ? 1 : 0));
123 if ($paymentid < 0) {
131 $result = $paiement->addPaymentToBank($user,
'payment_sc',
'(SocialContributionPayment)',
GETPOSTINT(
'accountid'),
'',
'');
132 if (!($result > 0)) {
141 $loc = DOL_URL_ROOT.
'/compta/sociales/card.php?id='.$chid;
142 header(
'Location: '.$loc);
158$form =
new Form($db);
162if ($action ==
'create') {
163 $charge->fetch($chid);
164 $charge->accountid = $charge->fk_account ? $charge->fk_account : $charge->accountid;
165 $charge->paiementtype = $charge->mode_reglement_id ? $charge->mode_reglement_id : $charge->paiementtype;
167 $total = $charge->amount;
168 if (!empty(
$conf->use_javascript_ajax)) {
169 print
"\n".
'<script type="text/javascript">';
172 print
' $(document).ready(function () {';
173 print
' $(".AutoFillAmount").on(\'click touchstart\', function() {
174 console.log("Click on .AutoFillAmount");
175 var amount = $(this).data("value");
176 document.getElementById($(this).data(\'rowid\')).value = amount ;
180 print
' </script>'.
"\n";
185 print
'<form name="add_payment" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
186 print
'<input type="hidden" name="token" value="'.newToken().
'">';
187 print
'<input type="hidden" name="id" value="'.$chid.
'">';
188 print
'<input type="hidden" name="chid" value="'.$chid.
'">';
189 print
'<input type="hidden" name="action" value="add_payment">';
193 print
'<table class="border centpercent">';
195 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td><a href="'.DOL_URL_ROOT.
'/compta/sociales/card.php?id='.$chid.
'">'.$chid.
'</a></td></tr>';
196 print
'<tr><td>'.$langs->trans(
"Label").
'</td><td>'.$charge->label.
"</td></tr>\n";
197 print
'<tr><td>'.$langs->trans(
"Type").
"</td><td>".$charge->type_label.
"</td></tr>\n";
198 print
'<tr><td>'.$langs->trans(
"Period").
"</td><td>".
dol_print_date($charge->periode,
'day').
"</td></tr>\n";
202 $sql =
"SELECT sum(p.amount) as total";
203 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiementcharge as p";
204 $sql .=
" WHERE p.fk_charge = ".((int) $chid);
206 $resql = $db->query($sql);
208 $obj = $db->fetch_object($resql);
209 $sumpaid = $obj->total;
215 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Date").
'</td><td>';
217 $datepayment = !
getDolGlobalString(
'MAIN_AUTOFILL_DATE') ? (GETPOSTISSET(
"remonth") ? $datepaye : -1) :
'';
218 print $form->selectDate($datepayment,
'', 0, 0, 0,
"add_payment", 1, 1, 0,
'',
'', $charge->date_ech,
'', 1, $langs->trans(
"DateOfSocialContribution"));
222 print
'<tr><td class="fieldrequired">'.$langs->trans(
"PaymentMode").
'</td><td>';
223 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
224 print $form->select_types_paiements(GETPOSTISSET(
"paiementtype") ?
GETPOST(
"paiementtype") : $charge->paiementtype,
"paiementtype",
'', 0, 1, 0, 0, 1,
'maxwidth500 widthcentpercentminusxx', 1);
229 print
'<td class="fieldrequired">'.$langs->trans(
'AccountToDebit').
'</td>';
231 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
232 print $form->select_comptes(GETPOSTISSET(
"accountid") ?
GETPOSTINT(
"accountid") : $charge->accountid,
"accountid", 0,
'', 2,
'', 0,
'maxwidth500 widthcentpercentminusx', 1);
236 print
'<tr><td>'.$langs->trans(
'Numero');
237 if (empty(
$conf->dol_optimize_smallscreen)) {
238 print
' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
241 print
'<td><input name="num_payment" class="width100" type="text" value="'.GETPOST(
'num_payment',
'alphanohtml').
'"></td></tr>'.
"\n";
244 print
'<td class="tdtop">'.$langs->trans(
"Comments").
'</td>';
245 print
'<td class="tdtop"><textarea class="quatrevingtpercent" name="note" wrap="soft" rows="'.ROWS_3.
'">'.
GETPOST(
'note',
'alphanohtml').
'</textarea></td>';
258 print
'<div class="div-table-responsive-no-min">';
259 print
'<table class="noborder centpercent">';
260 print
'<tr class="liste_titre">';
262 print
'<td class="left">'.$langs->trans(
"DateDue").
'</td>';
263 print
'<td class="right">'.$langs->trans(
"Amount").
'</td>';
264 print
'<td class="right">'.$langs->trans(
"AlreadyPaid").
'</td>';
265 print
'<td class="right">'.$langs->trans(
"RemainderToPay").
'</td>';
266 print
'<td class="center">'.$langs->trans(
"Amount").
'</td>';
276 print
'<tr class="oddeven">';
278 if ($objp->date_ech > 0) {
279 print
'<td class="left">'.dol_print_date($objp->date_ech,
'day').
'</td>'.
"\n";
281 print
"<td align=\"center\"><b>!!!</b></td>\n";
284 print
'<td class="right nowraponall"><span class="amount">'.price($objp->amount).
"</span></td>";
286 print
'<td class="right nowraponall"><span class="amount">'.price($sumpaid).
"</span></td>";
288 print
'<td class="right nowraponall"><span class="amount">'.price($objp->amount - $sumpaid).
"</span></td>";
290 print
'<td class="center nowraponall">';
291 if ($sumpaid < $objp->amount) {
292 $namef =
"amount_".$objp->id;
293 $nameRemain =
"remain_".$objp->id;
294 if (!empty(
$conf->use_javascript_ajax)) {
295 print
img_picto(
"Auto fill",
'rightarrow',
"class='AutoFillAmount' data-rowid='".$namef.
"' data-value='".($objp->amount - $sumpaid).
"'");
297 $remaintopay = $objp->amount - $sumpaid;
298 print
'<input type=hidden class="sum_remain" name="'.$nameRemain.
'" value="'.$remaintopay.
'">';
299 print
'<input type="text" size="8" name="'.$namef.
'" id="'.$namef.
'" value="'.
GETPOST(
'amount_'.$objp->id,
'alpha').
'">';
306 $total += $objp->total;
307 $total_ttc += $objp->total_ttc;
308 $totalrecu += $objp->amount;
313 print
'<tr class="oddeven">';
314 print
'<td colspan="2" class="left">'.$langs->trans(
"Total").
':</td>';
315 print
'<td class="right"><b>'.price($total_ttc).
'</b></td>';
316 print
'<td class="right"><b>'.price($totalrecu).
'</b></td>';
317 print
'<td class="right"><b>'.price($total_ttc - $totalrecu).
'</b></td>';
318 print
'<td align="center"> </td>';
326 print
'<br><div class="center"><input type="checkbox" checked name="closepaidcontrib"> '.$langs->trans(
"ClosePaidContributionsAutomatically");
327 print
'<br><input type="submit" class="button" name="save" value="'.$langs->trans(
'ToMakePayment').
'">';
328 print
' ';
329 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class for managing the social charges.
Class to manage payments of social contributions.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...