27require
'../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/salaries/class/paymentsalary.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
33$langs->loadLangs(array(
"banks",
"bills"));
35$action =
GETPOST(
'action',
'alpha');
36$cancel =
GETPOST(
'cancel',
'alpha');
37$confirm =
GETPOST(
'confirm',
'alpha');
44if ($id > 0 || !empty($ref)) {
45 $object->fetch($id, $ref);
49$socid =
GETPOST(
"socid",
"int");
50if ($user->socid > 0) {
51 $socid = $user->socid;
60if (($action ==
'add_payment' || ($action ==
'confirm_paiement' && $confirm ==
'yes')) && $user->hasRight(
'salaries',
'write')) {
64 $loc = DOL_URL_ROOT.
'/salaries/card.php?id='.$id;
65 header(
"Location: ".$loc);
69 $datepaye =
dol_mktime(
GETPOST(
"rehour",
'int'),
GETPOST(
"remin",
'int'),
GETPOST(
"resec",
'int'),
GETPOST(
"remonth",
'int'),
GETPOST(
"reday",
'int'),
GETPOST(
"reyear",
'int'),
'tzuserrel');
71 if (!(
GETPOST(
"paiementtype",
'int') > 0)) {
72 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"PaymentMode")),
null,
'errors');
76 if ($datepaye ==
'') {
77 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Date")),
null,
'errors');
81 if (isModEnabled(
"banque") && !(
GETPOST(
"accountid",
'int') > 0)) {
82 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"AccountToDebit")),
null,
'errors');
88 foreach ($_POST as $key => $value) {
89 if (substr($key, 0, 7) ==
'amount_') {
90 $other_chid = substr($key, 7);
95 if ($amounts[key($amounts)] <= 0) {
97 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Amount")),
null,
'errors');
109 $paiement->fk_salary = $id;
110 $paiement->chid = $id;
111 $paiement->datep = $datepaye;
112 $paiement->amounts = $amounts;
113 $paiement->fk_typepayment =
GETPOST(
"paiementtype",
'alphanohtml');
114 $paiement->num_payment =
GETPOST(
"num_payment",
'alphanohtml');
115 $paiement->note =
GETPOST(
"note",
'restricthtml');
116 $paiement->note_private =
GETPOST(
"note",
'restricthtml');
119 $paymentid = $paiement->create($user, (
GETPOST(
'closepaidsalary') ==
'on' ? 1 : 0));
120 if ($paymentid < 0) {
128 $result = $paiement->addPaymentToBank($user,
'payment_salary',
'(SalaryPayment)',
GETPOST(
'accountid',
'int'),
'',
'');
130 if (!($result > 0)) {
139 $loc = DOL_URL_ROOT.
'/salaries/card.php?id='.$id;
140 header(
'Location: '.$loc);
154$form =
new Form($db);
163if ($action ==
'create') {
164 $salary->accountid = $salary->fk_account ? $salary->fk_account : $salary->accountid;
165 $salary->paiementtype = $salary->mode_reglement_id ? $salary->mode_reglement_id : $salary->paiementtype;
167 $total = $salary->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 var amount = $(this).data("value");
175 document.getElementById($(this).data(\'rowid\')).value = amount ;
179 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="'.$id.
'">';
188 print
'<input type="hidden" name="chid" value="'.$id.
'">';
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.
'/salaries/card.php?id='.$id.
'">'.$id.
'</a></td></tr>';
196 print
'<tr><td>'.$langs->trans(
"DateStart").
"</td><td>".
dol_print_date($salary->datesp,
'day').
"</td></tr>\n";
197 print
'<tr><td>'.$langs->trans(
"DateEnd").
"</td><td>".
dol_print_date($salary->dateep,
'day').
"</td></tr>\n";
198 print
'<tr><td>'.$langs->trans(
"Label").
'</td><td>'.$salary->label.
"</td></tr>\n";
202 $sql =
"SELECT sum(p.amount) as total";
203 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_salary as p";
204 $sql .=
" WHERE p.fk_salary = ".((int) $id);
205 $resql = $db->query($sql);
207 $obj = $db->fetch_object($resql);
208 $sumpaid = $obj->total;
214 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Date").
'</td><td>';
215 $datepaye =
dol_mktime(
GETPOST(
"rehour",
'int'),
GETPOST(
"remin",
'int'),
GETPOST(
"resec",
'int'),
GETPOST(
"remonth",
'int'),
GETPOST(
"reday",
'int'),
GETPOST(
"reyear",
'int'));
217 print $form->selectDate($datepayment,
'', 1, 1, 0,
"add_payment", 1, 1, 0,
'',
'', $salary->dateep,
'', 1, $langs->trans(
"DateEnd"));
221 print
'<tr><td class="fieldrequired">'.$langs->trans(
"PaymentMode").
'</td><td>';
222 $form->select_types_paiements(GETPOSTISSET(
"paiementtype") ?
GETPOST(
"paiementtype") : $salary->type_payment,
"paiementtype");
227 print
'<td class="fieldrequired">'.$langs->trans(
'AccountToDebit').
'</td>';
229 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
230 $form->select_comptes(GETPOSTISSET(
"accountid") ?
GETPOST(
"accountid",
'int') : $salary->accountid,
"accountid", 0,
'', 1);
234 print
'<tr><td>'.$langs->trans(
'Numero');
235 print
' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
237 print
'<td><input name="num_payment" type="text" value="'.GETPOST(
'num_payment',
'alphanohtml').
'"></td></tr>'.
"\n";
240 print
'<td class="tdtop">'.$langs->trans(
"Comments").
'</td>';
241 print
'<td class="tdtop"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_3.
'">';
243 print
'</textarea></td>';
256 print
'<table class="noborder centpercent">';
257 print
'<tr class="liste_titre">';
259 print
'<td class="left">'.$langs->trans(
"DateEnd").
'</td>';
260 print
'<td class="right">'.$langs->trans(
"Amount").
'</td>';
261 print
'<td class="right">'.$langs->trans(
"AlreadyPaid").
'</td>';
262 print
'<td class="right">'.$langs->trans(
"RemainderToPay").
'</td>';
263 print
'<td class="center">'.$langs->trans(
"Amount").
'</td>';
272 print
'<tr class="oddeven">';
274 if ($objp->dateep > 0) {
275 print
'<td class="left">'.dol_print_date($objp->dateep,
'day').
'</td>'.
"\n";
277 print
'<td align="center"><b>!!!</b></td>'.
"\n";
280 print
'<td class="right">'.price($objp->amount).
"</td>";
282 print
'<td class="right">'.price($sumpaid).
"</td>";
284 print
'<td class="right">'.price($objp->amount - $sumpaid).
"</td>";
286 print
'<td class="center">';
287 if ($sumpaid < $objp->amount) {
288 $namef =
"amount_".$objp->id;
289 $nameRemain =
"remain_".$objp->id;
294 $valuetoshow = GETPOSTISSET($namef) ?
GETPOST($namef) : ($objp->amount - $sumpaid);
296 print
'<input type=hidden class="sum_remain" name="'.$nameRemain.
'" value="'.$valuetoshow.
'">';
297 print
'<input type="text" class="right width75" name="'.$namef.
'" id="'.$namef.
'" value="'.$valuetoshow.
'">';
304 $total += $objp->total;
305 $total_ttc += $objp->total_ttc;
306 $totalrecu += $objp->am;
311 print
'<tr class="oddeven">';
312 print
'<td colspan="2" class="left">'.$langs->trans(
"Total").
':</td>';
313 print
'<td class="right"><b>'.price($total_ttc).
'</b></td>';
314 print
'<td class="right"><b>'.price($totalrecu).
'</b></td>';
315 print
'<td class="right"><b>'.price($total_ttc - $totalrecu).
'</b></td>';
316 print
'<td align="center"> </td>';
325 print
'<div class="center">';
326 print
'<div class="paddingbottom"><input type="checkbox" checked name="closepaidsalary" id="closepaidsalary"><label for="closepaidsalary">'.$langs->trans(
"ClosePaidSalaryAutomatically").
'</label></div>';
327 print $form->buttonsSaveCancel(
"ToMakePayment",
"Cancel",
'',
true);
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage payments of salaries.
Class to manage salary payments.
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...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOSTINT($paramname, $method=0)
Return value of a param into GET or POST supervariable.
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='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.