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->chid = $id;
110 $paiement->datepaye = $datepaye;
111 $paiement->amounts = $amounts;
112 $paiement->paiementtype =
GETPOST(
"paiementtype",
'alphanohtml');
113 $paiement->num_payment =
GETPOST(
"num_payment",
'alphanohtml');
114 $paiement->note =
GETPOST(
"note",
'restricthtml');
115 $paiement->note_private =
GETPOST(
"note",
'restricthtml');
118 $paymentid = $paiement->create($user, (
GETPOST(
'closepaidsalary') ==
'on' ? 1 : 0));
119 if ($paymentid < 0) {
127 $result = $paiement->addPaymentToBank($user,
'payment_salary',
'(SalaryPayment)',
GETPOST(
'accountid',
'int'),
'',
'');
128 if (!($result > 0)) {
137 $loc = DOL_URL_ROOT.
'/salaries/card.php?id='.$id;
138 header(
'Location: '.$loc);
152$form =
new Form($db);
161if ($action ==
'create') {
162 $salary->accountid = $salary->fk_account ? $salary->fk_account : $salary->accountid;
163 $salary->paiementtype = $salary->mode_reglement_id ? $salary->mode_reglement_id : $salary->paiementtype;
165 $total = $salary->amount;
166 if (!empty($conf->use_javascript_ajax)) {
167 print
"\n".
'<script type="text/javascript">';
170 print
' $(document).ready(function () {';
171 print
' $(".AutoFillAmount").on(\'click touchstart\', function(){
172 var amount = $(this).data("value");
173 document.getElementById($(this).data(\'rowid\')).value = amount ;
177 print
' </script>'.
"\n";
183 print
'<form name="add_payment" action="'.$_SERVER[
'PHP_SELF'].
'" method="post">';
184 print
'<input type="hidden" name="token" value="'.newToken().
'">';
185 print
'<input type="hidden" name="id" value="'.$id.
'">';
186 print
'<input type="hidden" name="chid" value="'.$id.
'">';
187 print
'<input type="hidden" name="action" value="add_payment">';
191 print
'<table class="border centpercent">';
193 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td><a href="'.DOL_URL_ROOT.
'/salaries/card.php?id='.$id.
'">'.$id.
'</a></td></tr>';
194 print
'<tr><td>'.$langs->trans(
"DateStart").
"</td><td>".
dol_print_date($salary->datesp,
'day').
"</td></tr>\n";
195 print
'<tr><td>'.$langs->trans(
"DateEnd").
"</td><td>".
dol_print_date($salary->dateep,
'day').
"</td></tr>\n";
196 print
'<tr><td>'.$langs->trans(
"Label").
'</td><td>'.$salary->label.
"</td></tr>\n";
200 $sql =
"SELECT sum(p.amount) as total";
201 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_salary as p";
202 $sql .=
" WHERE p.fk_salary = ".((int) $id);
203 $resql = $db->query($sql);
205 $obj = $db->fetch_object($resql);
206 $sumpaid = $obj->total;
212 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Date").
'</td><td>';
213 $datepaye =
dol_mktime(
GETPOST(
"rehour",
'int'),
GETPOST(
"remin",
'int'),
GETPOST(
"resec",
'int'),
GETPOST(
"remonth",
'int'),
GETPOST(
"reday",
'int'),
GETPOST(
"reyear",
'int'));
214 $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ? (
GETPOST(
"remonth") ? $datepaye : -1) :
'';
215 print $form->selectDate($datepayment,
'', 1, 1, 0,
"add_payment", 1, 1, 0,
'',
'', $salary->dateep,
'', 1, $langs->trans(
"DateEnd"));
219 print
'<tr><td class="fieldrequired">'.$langs->trans(
"PaymentMode").
'</td><td>';
220 $form->select_types_paiements(GETPOSTISSET(
"paiementtype") ?
GETPOST(
"paiementtype") : $salary->type_payment,
"paiementtype");
225 print
'<td class="fieldrequired">'.$langs->trans(
'AccountToDebit').
'</td>';
227 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
228 $form->select_comptes(GETPOSTISSET(
"accountid") ?
GETPOST(
"accountid",
'int') : $salary->accountid,
"accountid", 0,
'', 1);
232 print
'<tr><td>'.$langs->trans(
'Numero');
233 print
' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
235 print
'<td><input name="num_payment" type="text" value="'.GETPOST(
'num_payment',
'alphanohtml').
'"></td></tr>'.
"\n";
238 print
'<td class="tdtop">'.$langs->trans(
"Comments").
'</td>';
239 print
'<td class="tdtop"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_3.
'"></textarea></td>';
252 print
'<table class="noborder centpercent">';
253 print
'<tr class="liste_titre">';
255 print
'<td class="left">'.$langs->trans(
"DateEnd").
'</td>';
256 print
'<td class="right">'.$langs->trans(
"Amount").
'</td>';
257 print
'<td class="right">'.$langs->trans(
"AlreadyPaid").
'</td>';
258 print
'<td class="right">'.$langs->trans(
"RemainderToPay").
'</td>';
259 print
'<td class="center">'.$langs->trans(
"Amount").
'</td>';
268 print
'<tr class="oddeven">';
270 if ($objp->dateep > 0) {
271 print
'<td class="left">'.dol_print_date($objp->dateep,
'day').
'</td>'.
"\n";
273 print
'<td align="center"><b>!!!</b></td>'.
"\n";
276 print
'<td class="right">'.price($objp->amount).
"</td>";
278 print
'<td class="right">'.price($sumpaid).
"</td>";
280 print
'<td class="right">'.price($objp->amount - $sumpaid).
"</td>";
282 print
'<td class="center">';
283 if ($sumpaid < $objp->amount) {
284 $namef =
"amount_".$objp->id;
285 $nameRemain =
"remain_".$objp->id;
290 $valuetoshow = GETPOSTISSET($namef) ?
GETPOST($namef) : ($objp->amount - $sumpaid);
292 print
'<input type=hidden class="sum_remain" name="'.$nameRemain.
'" value="'.$valuetoshow.
'">';
293 print
'<input type="text" class="right width75" name="'.$namef.
'" id="'.$namef.
'" value="'.$valuetoshow.
'">';
300 $total += $objp->total;
301 $total_ttc += $objp->total_ttc;
302 $totalrecu += $objp->am;
307 print
'<tr class="oddeven">';
308 print
'<td colspan="2" class="left">'.$langs->trans(
"Total").
':</td>';
309 print
'<td class="right"><b>'.price($total_ttc).
'</b></td>';
310 print
'<td class="right"><b>'.price($totalrecu).
'</b></td>';
311 print
'<td class="right"><b>'.price($total_ttc - $totalrecu).
'</b></td>';
312 print
'<td align="center"> </td>';
321 print
'<div class="center">';
322 print
'<div class="paddingbottom"><input type="checkbox" checked name="closepaidsalary" id="closepaidsalary"><label for="closepaidsalary">'.$langs->trans(
"ClosePaidSalaryAutomatically").
'</label></div>';
323 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.
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.