25 require
'../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
27 require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/paymentsocialcontribution.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
31 $langs->load(
"bills");
34 $action =
GETPOST(
'action',
'aZ09');
41 $socid = $user->socid;
51 if ($action ==
'add_payment' || ($action ==
'confirm_paiement' && $confirm ==
'yes'))
57 $loc = DOL_URL_ROOT.
'/compta/sociales/card.php?id='.$chid;
58 header(
"Location: ".$loc);
62 $datepaye =
dol_mktime(12, 0, 0, $_POST[
"remonth"], $_POST[
"reday"], $_POST[
"reyear"]);
64 if (!$_POST[
"paiementtype"] > 0)
66 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"PaymentMode")), null,
'errors');
72 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Date")), null,
'errors');
76 if (!empty($conf->banque->enabled) && !($_POST[
"accountid"] > 0))
78 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"AccountToCredit")), null,
'errors');
88 foreach ($_POST as $key => $value)
90 if (substr($key, 0, 7) ==
'amount_')
92 $other_chid = substr($key, 7);
93 $amounts[$other_chid] =
price2num($_POST[$key]);
97 if (count($amounts) <= 0)
110 $paiement->chid = $chid;
111 $paiement->datepaye = $datepaye;
112 $paiement->amounts = $amounts;
113 $paiement->paiementtype =
GETPOST(
"paiementtype",
'alphanohtml');
114 $paiement->num_payment =
GETPOST(
"num_payment",
'alphanohtml');
115 $paiement->note =
GETPOST(
"note",
'restricthtml');
116 $paiement->note_private =
GETPOST(
"note",
'restricthtml');
120 $paymentid = $paiement->create($user, (
GETPOST(
'closepaidcontrib') ==
'on' ? 1 : 0));
131 $result = $paiement->addPaymentToBank($user,
'payment_sc',
'(SocialContributionPayment)',
GETPOST(
'accountid',
'int'),
'',
'');
143 $loc = DOL_URL_ROOT.
'/compta/sociales/card.php?id='.$chid;
144 header(
'Location: '.$loc);
160 $form =
new Form($db);
164 if ($action ==
'create')
166 $charge->fetch($chid);
167 $charge->accountid = $charge->fk_account ? $charge->fk_account : $charge->accountid;
168 $charge->paiementtype = $charge->mode_reglement_id ? $charge->mode_reglement_id : $charge->paiementtype;
170 $total = $charge->amount;
171 if (!empty($conf->use_javascript_ajax))
173 print "\n".
'<script type="text/javascript" language="javascript">';
176 print ' $(document).ready(function () {';
177 print ' $(".AutoFillAmount").on(\'click touchstart\', function(){
178 var amount = $(this).data("value");
179 document.getElementById($(this).data(\'rowid\')).value = amount ;
183 print ' </script>'.
"\n";
191 print
"<div class=\"error\">$mesg</div>";
194 print
'<form name="add_payment" action="'.$_SERVER[
'PHP_SELF'].
'" method="post">';
195 print
'<input type="hidden" name="token" value="'.newToken().
'">';
196 print
'<input type="hidden" name="id" value="'.$chid.
'">';
197 print
'<input type="hidden" name="chid" value="'.$chid.
'">';
198 print
'<input type="hidden" name="action" value="add_payment">';
202 print
'<table class="border centpercent">';
204 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>';
205 print
'<tr><td>'.$langs->trans(
"Type").
"</td><td>".$charge->type_label.
"</td></tr>\n";
206 print
'<tr><td>'.$langs->trans(
"Period").
"</td><td>".
dol_print_date($charge->periode,
'day').
"</td></tr>\n";
207 print
'<tr><td>'.$langs->trans(
"Label").
'</td><td>'.$charge->label.
"</td></tr>\n";
211 $sql =
"SELECT sum(p.amount) as total";
212 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiementcharge as p";
213 $sql .=
" WHERE p.fk_charge = ".$chid;
214 $resql = $db->query($sql);
217 $obj = $db->fetch_object(
$resql);
218 $sumpaid = $obj->total;
224 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Date").
'</td><td>';
226 $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ? (
GETPOSTISSET(
"remonth") ? $datepaye : -1) :
'';
227 print $form->selectDate($datepayment,
'',
'',
'', 0,
"add_payment", 1, 1, 0,
'',
'', $charge->date_ech,
'', 1, $langs->trans(
"DateOfSocialContribution"));
231 print
'<tr><td class="fieldrequired">'.$langs->trans(
"PaymentMode").
'</td><td>';
232 $form->select_types_paiements(
GETPOSTISSET(
"paiementtype") ?
GETPOST(
"paiementtype") : $charge->paiementtype,
"paiementtype");
237 print
'<td class="fieldrequired">'.$langs->trans(
'AccountToDebit').
'</td>';
239 $form->select_comptes(
GETPOSTISSET(
"accountid") ?
GETPOST(
"accountid",
'int') : $charge->accountid,
"accountid", 0,
'', 2);
243 print
'<tr><td>'.$langs->trans(
'Numero');
244 print
' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
246 print
'<td><input name="num_payment" type="text" value="'.GETPOST(
'num_payment',
'alphanohtml').
'"></td></tr>'.
"\n";
249 print
'<td class="tdtop">'.$langs->trans(
"Comments").
'</td>';
250 print
'<td class="tdtop"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_3.
'"></textarea></td>';
263 print
'<table class="noborder centpercent">';
264 print
'<tr class="liste_titre">';
266 print
'<td class="left">'.$langs->trans(
"DateDue").
'</td>';
267 print
'<td class="right">'.$langs->trans(
"Amount").
'</td>';
268 print
'<td class="right">'.$langs->trans(
"AlreadyPaid").
'</td>';
269 print
'<td class="right">'.$langs->trans(
"RemainderToPay").
'</td>';
270 print
'<td class="center">'.$langs->trans(
"Amount").
'</td>';
280 print
'<tr class="oddeven">';
282 if ($objp->date_ech > 0)
284 print
'<td class="left">'.dol_print_date($objp->date_ech,
'day').
'</td>'.
"\n";
286 print
"<td align=\"center\"><b>!!!</b></td>\n";
289 print
'<td class="right">'.price($objp->amount).
"</td>";
291 print
'<td class="right">'.price($sumpaid).
"</td>";
293 print
'<td class="right">'.price($objp->amount - $sumpaid).
"</td>";
295 print
'<td class="center">';
296 if ($sumpaid < $objp->amount)
298 $namef =
"amount_".$objp->id;
299 $nameRemain =
"remain_".$objp->id;
300 if (!empty($conf->use_javascript_ajax))
301 print
img_picto(
"Auto fill",
'rightarrow',
"class='AutoFillAmount' data-rowid='".$namef.
"' data-value='".($objp->amount - $sumpaid).
"'");
302 $remaintopay = $objp->amount - $sumpaid;
303 print
'<input type=hidden class="sum_remain" name="'.$nameRemain.
'" value="'.$remaintopay.
'">';
304 print
'<input type="text" size="8" name="'.$namef.
'" id="'.$namef.
'">';
311 $total += $objp->total;
312 $total_ttc += $objp->total_ttc;
313 $totalrecu += $objp->am;
319 print
'<tr class="oddeven">';
320 print
'<td colspan="2" class="left">'.$langs->trans(
"Total").
':</td>';
321 print
'<td class="right"><b>'.price($total_ttc).
'</b></td>';
322 print
'<td class="right"><b>'.price($totalrecu).
'</b></td>';
323 print
'<td class="right"><b>'.price($total_ttc - $totalrecu).
'</b></td>';
324 print
'<td align="center"> </td>';
331 print
'<br><div class="center"><input type="checkbox" checked name="closepaidcontrib"> '.$langs->trans(
"ClosePaidContributionsAutomatically");
332 print
'<br><input type="submit" class="button" name="save" value="'.$langs->trans(
'ToMakePayment').
'">';
333 print
' ';
334 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Class to manage payments of social contributions.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Classe permettant la gestion des paiements des charges La tva collectee n'est calculee que sur les fa...