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';
42$langs->loadLangs(array(
"banks",
"bills"));
44$action =
GETPOST(
'action',
'alpha');
45$cancel =
GETPOST(
'cancel',
'alpha');
46$confirm =
GETPOST(
'confirm',
'alpha');
59if ($user->socid > 0) {
60 $socid = $user->socid;
69if (($action ==
'add_payment' || ($action ==
'confirm_paiement' && $confirm ==
'yes')) && $user->hasRight(
'salaries',
'write')) {
73 $loc = DOL_URL_ROOT.
'/salaries/card.php?id='.
$id;
74 header(
"Location: ".$loc);
81 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"PaymentMode")),
null,
'errors');
85 if ($datepaye ==
'') {
86 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Date")),
null,
'errors');
91 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"AccountToDebit")),
null,
'errors');
97 foreach ($_POST as $key => $value) {
98 if (substr($key, 0, 7) ==
'amount_') {
99 $other_chid = substr($key, 7);
104 if ($amounts[key($amounts)] <= 0) {
106 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Amount")),
null,
'errors');
116 $paiement->fk_salary =
$id;
117 $paiement->chid =
$id;
118 $paiement->datep = $datepaye;
119 $paiement->amounts = $amounts;
120 $paiement->fk_typepayment =
GETPOSTINT(
"paiementtype");
121 $paiement->num_payment =
GETPOST(
"num_payment",
'alphanohtml');
122 $paiement->note =
GETPOST(
"note",
'restricthtml');
123 $paiement->note_private =
GETPOST(
"note",
'restricthtml');
125 $paymentid = $paiement->create($user, (
GETPOST(
'closepaidsalary') ==
'on' ? 1 : 0));
126 if ($paymentid < 0) {
133 $result = $paiement->addPaymentToBank($user,
'payment_salary',
'(SalaryPayment)',
GETPOSTINT(
'accountid'),
'',
'');
135 if (!($result > 0)) {
144 $loc = DOL_URL_ROOT.
'/salaries/card.php?id='.
$id;
145 header(
'Location: '.$loc);
158$form =
new Form($db);
168if ($action ==
'create') {
169 $salary->accountid = $salary->fk_account ? $salary->fk_account : $salary->accountid;
170 $salary->fk_typepayment = $salary->mode_reglement_id ? $salary->mode_reglement_id : $salary->paiementtype;
172 if (!empty($conf->use_javascript_ajax)) {
173 print
"\n".
'<script type="text/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";
188 print
'<form name="add_payment" action="'.$_SERVER[
'PHP_SELF'].
'" method="post">';
189 print
'<input type="hidden" name="token" value="'.newToken().
'">';
190 print
'<input type="hidden" name="id" value="'.$id.
'">';
191 print
'<input type="hidden" name="chid" value="'.$id.
'">';
192 print
'<input type="hidden" name="action" value="add_payment">';
196 print
'<table class="border centpercent">';
198 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td><a href="'.DOL_URL_ROOT.
'/salaries/card.php?id='.
$id.
'">'.
$id.
'</a></td></tr>';
199 print
'<tr><td>'.$langs->trans(
"Label").
'</td><td>'.$salary->label.
"</td></tr>\n";
200 print
'<tr><td>'.$langs->trans(
"DateStart").
"</td><td>".
dol_print_date($salary->datesp,
'day').
"</td></tr>\n";
201 print
'<tr><td>'.$langs->trans(
"DateEnd").
"</td><td>".
dol_print_date($salary->dateep,
'day').
"</td></tr>\n";
205 $sql =
"SELECT sum(p.amount) as total";
206 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_salary as p";
207 $sql .=
" WHERE p.fk_salary = ".((int) $id);
208 $resql = $db->query($sql);
210 $obj = $db->fetch_object($resql);
211 $sumpaid = (float) $obj->total;
217 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Date").
'</td><td>';
220 print $form->selectDate($datepayment,
'', 1, 1, 0,
"add_payment", 1, 1, 0,
'',
'', $salary->dateep,
'', 1, $langs->trans(
"DateEnd"));
224 print
'<tr><td class="fieldrequired">'.$langs->trans(
"PaymentMode").
'</td><td>';
225 $form->select_types_paiements(GETPOSTISSET(
"paiementtype") ?
GETPOST(
"paiementtype") : $salary->type_payment,
"paiementtype");
230 print
'<td class="fieldrequired">'.$langs->trans(
'AccountToDebit').
'</td>';
232 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
233 $form->select_comptes(GETPOSTISSET(
"accountid") ?
GETPOSTINT(
"accountid") : $salary->accountid,
"accountid", 0,
'', 1);
237 print
'<tr><td>'.$langs->trans(
'Numero');
238 print
' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
240 print
'<td><input name="num_payment" type="text" value="'.GETPOST(
'num_payment',
'alphanohtml').
'"></td></tr>'.
"\n";
243 print
'<td class="tdtop">'.$langs->trans(
"Comments").
'</td>';
244 print
'<td class="tdtop"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_2.
'">';
246 print
'</textarea></td>';
261 print
'<table class="noborder centpercent">';
262 print
'<tr class="liste_titre">';
264 print
'<td class="left">'.$langs->trans(
"DateEnd").
'</td>';
265 print
'<td class="right">'.$langs->trans(
"Amount").
'</td>';
266 print
'<td class="right">'.$langs->trans(
"AlreadyPaid").
'</td>';
267 print
'<td class="right">'.$langs->trans(
"RemainderToPay").
'</td>';
268 print
'<td class="center">'.$langs->trans(
"Amount").
'</td>';
277 print
'<tr class="oddeven">';
279 if ($objp->dateep > 0) {
280 print
'<td class="left">'.dol_print_date($objp->dateep,
'day').
'</td>'.
"\n";
282 print
'<td align="center"><b>!!!</b></td>'.
"\n";
285 print
'<td class="right">'.price($objp->amount).
"</td>";
287 print
'<td class="right">'.price($sumpaid).
"</td>";
289 print
'<td class="right">'.price((
float) $objp->amount - $sumpaid).
"</td>";
291 print
'<td class="center">';
292 if ($sumpaid < $objp->
amount) {
293 $namef =
"amount_".$objp->id;
294 $nameRemain =
"remain_".$objp->id;
299 $valuetoshow = GETPOSTISSET($namef) ?
GETPOST($namef) : ((float) $objp->
amount - $sumpaid);
301 print
'<input type=hidden class="sum_remain" name="'.$nameRemain.
'" value="'.$valuetoshow.
'">';
302 print
'<input type="text" class="right width75" name="'.$namef.
'" id="'.$namef.
'" value="'.$valuetoshow.
'">';
309 $total_ttc += $objp->total_ttc;
310 $totalrecu += $objp->amount;
332 print
'<div class="center">';
333 print
'<div class="paddingbottom"><input type="checkbox" checked name="closepaidsalary" id="closepaidsalary" class="marginrightonly"><label for="closepaidsalary" class="opacitymedium">'.$langs->trans(
"ClosePaidSalaryAutomatically").
'</label></div>';
334 print $form->buttonsSaveCancel(
"ToMakePayment",
"Cancel", array(),
true);
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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...
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, $allowothertags=array())
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, $morecssdiv='')
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
if(getDolGlobalString( 'TAKEPOS_SHOW_CUSTOMER')) print $langs trans('Date')." left Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right PaymentTypeShortLIQ right SELECT p pos_change as p datep as p p num_paiement as f pf amount as amount
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.