28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/salaries/class/paymentsalary.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
34$langs->loadLangs(array(
"banks",
"bills"));
36$action =
GETPOST(
'action',
'alpha');
37$cancel =
GETPOST(
'cancel',
'alpha');
38$confirm =
GETPOST(
'confirm',
'alpha');
45if ($id > 0 || !empty($ref)) {
51if ($user->socid > 0) {
52 $socid = $user->socid;
61if (($action ==
'add_payment' || ($action ==
'confirm_paiement' && $confirm ==
'yes')) && $user->hasRight(
'salaries',
'write')) {
65 $loc = DOL_URL_ROOT.
'/salaries/card.php?id='.
$id;
66 header(
"Location: ".$loc);
73 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"PaymentMode")),
null,
'errors');
77 if ($datepaye ==
'') {
78 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Date")),
null,
'errors');
82 if (isModEnabled(
"bank") && !(
GETPOSTINT(
"accountid") > 0)) {
83 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"AccountToDebit")),
null,
'errors');
89 foreach ($_POST as $key => $value) {
90 if (substr($key, 0, 7) ==
'amount_') {
91 $other_chid = substr($key, 7);
96 if ($amounts[key($amounts)] <= 0) {
98 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Amount")),
null,
'errors');
110 $paiement->fk_salary =
$id;
111 $paiement->chid =
$id;
112 $paiement->datep = $datepaye;
113 $paiement->amounts = $amounts;
114 $paiement->fk_typepayment =
GETPOSTINT(
"paiementtype");
115 $paiement->num_payment =
GETPOST(
"num_payment",
'alphanohtml');
116 $paiement->note =
GETPOST(
"note",
'restricthtml');
117 $paiement->note_private =
GETPOST(
"note",
'restricthtml');
120 $paymentid = $paiement->create($user, (
GETPOST(
'closepaidsalary') ==
'on' ? 1 : 0));
121 if ($paymentid < 0) {
129 $result = $paiement->addPaymentToBank($user,
'payment_salary',
'(SalaryPayment)',
GETPOSTINT(
'accountid'),
'',
'');
131 if (!($result > 0)) {
140 $loc = DOL_URL_ROOT.
'/salaries/card.php?id='.
$id;
141 header(
'Location: '.$loc);
155$form =
new Form($db);
164if ($action ==
'create') {
165 $salary->accountid = $salary->fk_account ? $salary->fk_account : $salary->accountid;
166 $salary->paiementtype = $salary->mode_reglement_id ? $salary->mode_reglement_id : $salary->paiementtype;
168 $total = $salary->amount;
169 if (!empty($conf->use_javascript_ajax)) {
170 print
"\n".
'<script type="text/javascript">';
173 print
' $(document).ready(function () {';
174 print
' $(".AutoFillAmount").on(\'click touchstart\', function(){
175 var amount = $(this).data("value");
176 document.getElementById($(this).data(\'rowid\')).value = amount ;
180 print
' </script>'.
"\n";
186 print
'<form name="add_payment" action="'.$_SERVER[
'PHP_SELF'].
'" method="post">';
187 print
'<input type="hidden" name="token" value="'.newToken().
'">';
188 print
'<input type="hidden" name="id" value="'.$id.
'">';
189 print
'<input type="hidden" name="chid" value="'.$id.
'">';
190 print
'<input type="hidden" name="action" value="add_payment">';
194 print
'<table class="border centpercent">';
196 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td><a href="'.DOL_URL_ROOT.
'/salaries/card.php?id='.
$id.
'">'.
$id.
'</a></td></tr>';
197 print
'<tr><td>'.$langs->trans(
"DateStart").
"</td><td>".
dol_print_date($salary->datesp,
'day').
"</td></tr>\n";
198 print
'<tr><td>'.$langs->trans(
"DateEnd").
"</td><td>".
dol_print_date($salary->dateep,
'day').
"</td></tr>\n";
199 print
'<tr><td>'.$langs->trans(
"Label").
'</td><td>'.$salary->label.
"</td></tr>\n";
203 $sql =
"SELECT sum(p.amount) as total";
204 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_salary as p";
205 $sql .=
" WHERE p.fk_salary = ".((int) $id);
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>';
218 print $form->selectDate($datepayment,
'', 1, 1, 0,
"add_payment", 1, 1, 0,
'',
'', $salary->dateep,
'', 1, $langs->trans(
"DateEnd"));
222 print
'<tr><td class="fieldrequired">'.$langs->trans(
"PaymentMode").
'</td><td>';
223 $form->select_types_paiements(GETPOSTISSET(
"paiementtype") ?
GETPOST(
"paiementtype") : $salary->type_payment,
"paiementtype");
228 print
'<td class="fieldrequired">'.$langs->trans(
'AccountToDebit').
'</td>';
230 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
231 $form->select_comptes(GETPOSTISSET(
"accountid") ?
GETPOSTINT(
"accountid") : $salary->accountid,
"accountid", 0,
'', 1);
235 print
'<tr><td>'.$langs->trans(
'Numero');
236 print
' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
238 print
'<td><input name="num_payment" type="text" value="'.GETPOST(
'num_payment',
'alphanohtml').
'"></td></tr>'.
"\n";
241 print
'<td class="tdtop">'.$langs->trans(
"Comments").
'</td>';
242 print
'<td class="tdtop"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_3.
'">';
244 print
'</textarea></td>';
257 print
'<table class="noborder centpercent">';
258 print
'<tr class="liste_titre">';
260 print
'<td class="left">'.$langs->trans(
"DateEnd").
'</td>';
261 print
'<td class="right">'.$langs->trans(
"Amount").
'</td>';
262 print
'<td class="right">'.$langs->trans(
"AlreadyPaid").
'</td>';
263 print
'<td class="right">'.$langs->trans(
"RemainderToPay").
'</td>';
264 print
'<td class="center">'.$langs->trans(
"Amount").
'</td>';
274 print
'<tr class="oddeven">';
276 if ($objp->dateep > 0) {
277 print
'<td class="left">'.dol_print_date($objp->dateep,
'day').
'</td>'.
"\n";
279 print
'<td align="center"><b>!!!</b></td>'.
"\n";
282 print
'<td class="right">'.price($objp->amount).
"</td>";
284 print
'<td class="right">'.price($sumpaid).
"</td>";
286 print
'<td class="right">'.price((
float) $objp->amount - $sumpaid).
"</td>";
288 print
'<td class="center">';
289 if ($sumpaid < $objp->amount) {
290 $namef =
"amount_".$objp->id;
291 $nameRemain =
"remain_".$objp->id;
296 $valuetoshow = GETPOSTISSET($namef) ?
GETPOST($namef) : ((float) $objp->amount - $sumpaid);
298 print
'<input type=hidden class="sum_remain" name="'.$nameRemain.
'" value="'.$valuetoshow.
'">';
299 print
'<input type="text" class="right width75" name="'.$namef.
'" id="'.$namef.
'" value="'.$valuetoshow.
'">';
306 $total += $objp->total;
307 $total_ttc += $objp->total_ttc;
308 $totalrecu += $objp->am;
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>';
327 print
'<div class="center">';
328 print
'<div class="paddingbottom"><input type="checkbox" checked name="closepaidsalary" id="closepaidsalary"><label for="closepaidsalary">'.$langs->trans(
"ClosePaidSalaryAutomatically").
'</label></div>';
329 print $form->buttonsSaveCancel(
"ToMakePayment",
"Cancel",
'',
true);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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 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 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.
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.