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;
70 $childids = $user->getAllChildIds(1);
72 if ($user->hasRight(
'salaries',
'readall')) {
75 if ($user->hasRight(
'salaries',
'read') &&
$object->fk_user > 0 && in_array(
$object->fk_user, $childids)) {
88if (($action ==
'add_payment' || ($action ==
'confirm_paiement' && $confirm ==
'yes')) && $user->hasRight(
'salaries',
'write')) {
92 $loc = DOL_URL_ROOT.
'/salaries/card.php?id='.
$id;
93 header(
"Location: ".$loc);
100 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"PaymentMode")),
null,
'errors');
104 if ($datepaye ==
'') {
105 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Date")),
null,
'errors');
110 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"AccountToDebit")),
null,
'errors');
116 foreach ($_POST as $key => $value) {
117 if (substr($key, 0, 7) ==
'amount_') {
118 $other_chid = substr($key, 7);
123 if ($amounts[key($amounts)] <= 0) {
125 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Amount")),
null,
'errors');
135 $paiement->fk_salary =
$id;
136 $paiement->chid =
$id;
137 $paiement->datep = $datepaye;
138 $paiement->amounts = $amounts;
139 $paiement->fk_typepayment =
GETPOSTINT(
"paiementtype");
140 $paiement->num_payment =
GETPOST(
"num_payment",
'alphanohtml');
141 $paiement->note =
GETPOST(
"note",
'restricthtml');
142 $paiement->note_private =
GETPOST(
"note",
'restricthtml');
144 $paymentid = $paiement->create($user, (
GETPOST(
'closepaidsalary') ==
'on' ? 1 : 0));
145 if ($paymentid < 0) {
152 $result = $paiement->addPaymentToBank($user,
'payment_salary',
'(SalaryPayment)',
GETPOSTINT(
'accountid'),
'',
'');
154 if (!($result > 0)) {
163 $loc = DOL_URL_ROOT.
'/salaries/card.php?id='.
$id;
164 header(
'Location: '.$loc);
187if ($action ==
'create') {
188 $salary->accountid = $salary->fk_account ? $salary->fk_account : $salary->accountid;
189 $salary->fk_typepayment = $salary->mode_reglement_id ? $salary->mode_reglement_id : $salary->paiementtype;
191 if (!empty(
$conf->use_javascript_ajax)) {
192 print
"\n".
'<script type="text/javascript">';
195 print
' $(document).ready(function () {';
196 print
' $(".AutoFillAmount").on(\'click touchstart\', function(){
197 var amount = $(this).data("value");
198 document.getElementById($(this).data(\'rowid\')).value = amount ;
202 print
' </script>'.
"\n";
207 print
'<form name="add_payment" action="'.$_SERVER[
'PHP_SELF'].
'" method="post">';
208 print
'<input type="hidden" name="token" value="'.newToken().
'">';
209 print
'<input type="hidden" name="id" value="'.$id.
'">';
210 print
'<input type="hidden" name="chid" value="'.$id.
'">';
211 print
'<input type="hidden" name="action" value="add_payment">';
215 print
'<table class="border centpercent">';
217 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td><a href="'.DOL_URL_ROOT.
'/salaries/card.php?id='.
$id.
'">'.
$id.
'</a></td></tr>';
218 print
'<tr><td>'.$langs->trans(
"Label").
'</td><td>'.$salary->label.
"</td></tr>\n";
219 print
'<tr><td>'.$langs->trans(
"DateStart").
"</td><td>".
dol_print_date($salary->datesp,
'day').
"</td></tr>\n";
220 print
'<tr><td>'.$langs->trans(
"DateEnd").
"</td><td>".
dol_print_date($salary->dateep,
'day').
"</td></tr>\n";
224 $sql =
"SELECT sum(p.amount) as total";
225 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_salary as p";
226 $sql .=
" WHERE p.fk_salary = ".((int) $id);
227 $resql =
$db->query($sql);
229 $obj =
$db->fetch_object($resql);
230 $sumpaid = (float) $obj->total;
236 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Date").
'</td><td>';
239 print $form->selectDate($datepayment,
'', 1, 1, 0,
"add_payment", 1, 1, 0,
'',
'', $salary->dateep,
'', 1, $langs->trans(
"DateEnd"));
243 print
'<tr><td class="fieldrequired">'.$langs->trans(
"PaymentMode").
'</td><td>';
244 $form->select_types_paiements(
GETPOSTISSET(
"paiementtype") ?
GETPOST(
"paiementtype") : $salary->type_payment,
"paiementtype");
249 print
'<td class="fieldrequired">'.$langs->trans(
'AccountToDebit').
'</td>';
251 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
252 $form->select_comptes(
GETPOSTISSET(
"accountid") ?
GETPOSTINT(
"accountid") : $salary->accountid,
"accountid", 0,
'', 1);
256 print
'<tr><td>'.$langs->trans(
'Numero');
257 print
' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
259 print
'<td><input name="num_payment" type="text" value="'.GETPOST(
'num_payment',
'alphanohtml').
'"></td></tr>'.
"\n";
262 print
'<td class="tdtop">'.$langs->trans(
"Comments").
'</td>';
263 print
'<td class="tdtop"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_2.
'">';
265 print
'</textarea></td>';
280 print
'<table class="noborder centpercent">';
281 print
'<tr class="liste_titre">';
283 print
'<td class="left">'.$langs->trans(
"DateEnd").
'</td>';
284 print
'<td class="right">'.$langs->trans(
"Amount").
'</td>';
285 print
'<td class="right">'.$langs->trans(
"AlreadyPaid").
'</td>';
286 print
'<td class="right">'.$langs->trans(
"RemainderToPay").
'</td>';
287 print
'<td class="center">'.$langs->trans(
"Amount").
'</td>';
296 print
'<tr class="oddeven">';
298 if ($objp->dateep > 0) {
299 print
'<td class="left">'.dol_print_date($objp->dateep,
'day').
'</td>'.
"\n";
301 print
'<td align="center"><b>!!!</b></td>'.
"\n";
304 print
'<td class="right">'.price($objp->amount).
"</td>";
306 print
'<td class="right">'.price($sumpaid).
"</td>";
308 print
'<td class="right">'.price((
float) $objp->amount - $sumpaid).
"</td>";
310 print
'<td class="center">';
311 if ($sumpaid < $objp->
amount) {
312 $namef =
"amount_".$objp->id;
313 $nameRemain =
"remain_".$objp->id;
320 print
'<input type=hidden class="sum_remain" name="'.$nameRemain.
'" value="'.$valuetoshow.
'">';
321 print
'<input type="text" class="right width75" name="'.$namef.
'" id="'.$namef.
'" value="'.$valuetoshow.
'">';
328 $total_ttc += $objp->total_ttc;
329 $totalrecu += $objp->amount;
351 print
'<div class="center">';
352 print
'<div class="paddingbottom"><input type="checkbox" checked name="closepaidsalary" id="closepaidsalary" class="marginrightonly"><label for="closepaidsalary" class="opacitymedium">'.$langs->trans(
"ClosePaidSalaryAutomatically").
'</label></div>';
353 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)
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, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
print $langs trans('Date')." left Ref 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 Paid 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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.