29 require
'../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/salaries/class/paymentsalary.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/salaries.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
44 $langs->loadLangs(array(
"compta",
"banks",
"bills",
"users",
"salaries",
"hrm",
"trips"));
46 $langs->load(
"projects");
51 $action =
GETPOST(
'action',
'aZ09');
52 $cancel =
GETPOST(
'cancel',
'aZ09');
53 $backtopage =
GETPOST(
'backtopage',
'alpha');
54 $backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
57 $label =
GETPOST(
'label',
'alphanohtml');
58 $projectid = (
GETPOST(
'projectid',
'int') ?
GETPOST(
'projectid',
'int') :
GETPOST(
'fk_project',
'int'));
59 $accountid =
GETPOST(
'accountid',
'int') > 0 ?
GETPOST(
'accountid',
'int') : 0;
60 if (
GETPOSTISSET(
'auto_create_paiement') || $action ===
'add') {
61 $auto_create_paiement =
GETPOST(
"auto_create_paiement",
"int");
63 $auto_create_paiement = empty($conf->global->CREATE_NEW_SALARY_WITHOUT_AUTO_PAYMENT);
75 $childids = $user->getAllChildIds(1);
78 $extrafields->fetch_name_optionals_label($object->table_element);
81 $hookmanager->initHooks(array(
'salarycard',
'globalcard'));
83 if ($id > 0 || !empty($ref)) {
84 $object->fetch($id, $ref);
88 if (!empty($user->rights->salaries->readall)) {
91 if (!empty($user->rights->salaries->read) && $object->fk_user > 0 && in_array($object->fk_user, $childids)) {
102 $socid = $user->socid;
107 $permissiontoread = $user->rights->salaries->read;
108 $permissiontoadd = $user->rights->salaries->write;
109 $permissiontodelete = $user->rights->salaries->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
116 $parameters = array();
117 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
122 if (empty($reshook)) {
127 if (empty($backtopage) || ($cancel && empty($id))) {
128 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
129 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
130 $backtopage = $backurlforlist;
132 $backtopage =
dol_buildpath(
'/salaries/card.php', 1).
'?id='.($id > 0 ? $id :
'__ID__');
140 if (!empty($backtopageforcancel)) {
141 header(
"Location: ".$backtopageforcancel);
143 } elseif (!empty($backtopage)) {
144 header(
"Location: ".$backtopage);
152 if ($action ==
'classin' && $user->rights->banque->modifier) {
154 $object->setProject($projectid);
158 if ($action ==
'setlabel' && $user->rights->salaries->write) {
160 $object->label = $label;
161 $object->update($user);
165 if ($action ==
'confirm_paid' && $user->rights->salaries->write && $confirm ==
'yes') {
167 $result = $object->set_paid($user);
170 if ($action ==
'setfk_user' && $user->rights->salaries->write) {
171 $result = $object->fetch($id);
173 $object->fk_user = $fk_user;
174 $object->update($user);
181 if ($action ==
'reopen' && $user->rights->salaries->write) {
182 $result = $object->fetch($id);
184 $result = $object->set_unpaid($user);
186 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
195 if ($action ==
'setmode' && $user->rights->salaries->write) {
197 $result = $object->setPaymentMethods(
GETPOST(
'mode_reglement_id',
'int'));
203 if ($action ==
'setbankaccount' && $user->rights->salaries->write) {
205 $result = $object->setBankAccount(
GETPOST(
'fk_account',
'int'));
211 if ($action ==
'add' && empty($cancel)) {
214 if (empty($datev)) $datev = $datep;
216 $type_payment =
GETPOST(
"paymenttype",
'alpha');
219 $object->accountid =
GETPOST(
"accountid",
'int') > 0 ?
GETPOST(
"accountid",
"int") : 0;
220 $object->fk_user =
GETPOST(
"fk_user",
'int') > 0 ?
GETPOST(
"fk_user",
"int") : 0;
221 $object->datev = $datev;
222 $object->datep = $datep;
223 $object->amount = $amount;
224 $object->label =
GETPOST(
"label",
'alphanohtml');
225 $object->datesp = $datesp;
226 $object->dateep = $dateep;
227 $object->note =
GETPOST(
"note",
'restricthtml');
228 $object->type_payment = ($type_payment > 0 ? $type_payment : 0);
229 $object->fk_user_author = $user->id;
230 $object->fk_project = $projectid;
233 $fuser =
new User($db);
234 $fuser->fetch(
GETPOST(
"fk_user",
"int"));
235 $object->salary = $fuser->salary;
238 $ret = $extrafields->setOptionalsFromPost(null, $object);
243 if (!empty($auto_create_paiement) && empty($datep)) {
244 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DATE_PAIEMENT")), null,
'errors');
247 if (empty($datesp) || empty($dateep)) {
248 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")), null,
'errors');
251 if (empty($object->fk_user) || $object->fk_user < 0) {
252 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Employee")), null,
'errors');
255 if (!empty($auto_create_paiement) && (empty($type_payment) || $type_payment < 0)) {
256 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PaymentMode")), null,
'errors');
259 if (empty($object->amount)) {
260 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount")), null,
'errors');
263 if (
isModEnabled(
'banque') && !empty($auto_create_paiement) && !$object->accountid > 0) {
264 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankAccount")), null,
'errors');
271 $ret = $object->create($user);
276 if (!empty($auto_create_paiement) && !$error) {
279 $paiement->chid = $object->id;
280 $paiement->datepaye = $datep;
281 $paiement->datev = $datev;
282 $paiement->amounts = array($object->id=>$amount);
283 $paiement->paiementtype = $type_payment;
284 $paiement->num_payment =
GETPOST(
"num_payment",
'alphanohtml');
285 $paiement->note =
GETPOST(
"note",
'restricthtml');
288 $paymentid = $paiement->create($user, (
int)
GETPOST(
'closepaidsalary'));
289 if ($paymentid < 0) {
297 $result = $paiement->addPaymentToBank($user,
'payment_salary',
'(SalaryPayment)',
GETPOST(
'accountid',
'int'),
'',
'');
298 if (!($result > 0)) {
308 if (
GETPOST(
'saveandnew',
'alpha')) {
310 header(
"Location: card.php?action=create&fk_project=" . urlencode($projectid) .
"&accountid=" . urlencode($accountid) .
'&paymenttype=' . urlencode(
GETPOST(
'paymenttype',
'az09')) .
'&datepday=' .
GETPOST(
"datepday",
'int') .
'&datepmonth=' .
GETPOST(
"datepmonth",
'int') .
'&datepyear=' .
GETPOST(
"datepyear",
'int'));
313 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id);
324 if ($action ==
'confirm_delete') {
325 $result = $object->fetch($id);
326 $totalpaid = $object->getSommePaiement();
328 if (empty($totalpaid)) {
331 $ret = $object->delete($user);
334 header(
"Location: ".DOL_URL_ROOT.
'/salaries/list.php');
346 if ($action ==
'update' && !
GETPOST(
"cancel") && $user->rights->salaries->write) {
349 if (empty($amount)) {
350 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Amount")), null,
'errors');
352 } elseif (!is_numeric($amount)) {
353 setEventMessages($langs->trans(
"ErrorFieldMustBeANumeric", $langs->transnoentities(
"Amount")), null,
'errors');
356 $result = $object->fetch($id);
362 $result = $object->update($user);
369 if ($action ==
'confirm_clone' && $confirm !=
'yes') { $action =
''; }
371 if ($action ==
'confirm_clone' && $confirm ==
'yes' && ($user->rights->salaries->write)) {
378 if ($object->id > 0) {
380 $object->id = $object->ref = null;
382 if (
GETPOST(
'clone_label',
'alphanohtml')) {
383 $object->label =
GETPOST(
'clone_label',
'alphanohtml');
385 $object->label = $langs->trans(
"CopyOf").
' '.$object->label;
388 $newdatestart =
dol_mktime(0, 0, 0,
GETPOST(
'clone_date_startmonth',
'int'),
GETPOST(
'clone_date_startday',
'int'),
GETPOST(
'clone_date_startyear',
'int'));
391 if ($newdatestart) $object->datesp = $newdatestart;
392 if ($newdateend) $object->dateep = $newdateend;
394 $id = $object->create($user);
399 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
414 if ($action ==
"update_extras" && !empty($user->rights->salaries->read)) {
415 $object->fetch(
GETPOST(
'id',
'int'));
417 $attributekey =
GETPOST(
'attribute',
'alpha');
418 $attributekeylong =
'options_'.$attributekey;
422 $object->array_options[
'options_'.$attributekey] =
dol_mktime(
GETPOST($attributekeylong.
'hour',
'int'),
GETPOST($attributekeylong.
'min',
'int'),
GETPOST($attributekeylong.
'sec',
'int'),
GETPOST($attributekeylong.
'month',
'int'),
GETPOST($attributekeylong.
'day',
'int'),
GETPOST($attributekeylong.
'year',
'int'));
425 $object->array_options[
'options_'.$attributekey] =
GETPOST($attributekeylong,
'alpha');
428 $result = $object->insertExtraFields(empty($triggermodname) ?
'' : $triggermodname, $user);
434 $action =
'edit_extras';
446 $title = $langs->trans(
'Salary').
" - ".$langs->trans(
'Card');
452 $result = $object->fetch($id);
460 if ($action ==
'create') {
461 $year_current = strftime(
"%Y",
dol_now());
462 $pastmonth = strftime(
"%m",
dol_now()) - 1;
463 $pastmonthyear = $year_current;
464 if ($pastmonth == 0) {
469 $datespmonth =
GETPOST(
'datespmonth',
'int');
470 $datespday =
GETPOST(
'datespday',
'int');
471 $datespyear =
GETPOST(
'datespyear',
'int');
472 $dateepmonth =
GETPOST(
'dateepmonth',
'int');
473 $dateepday =
GETPOST(
'dateepday',
'int');
474 $dateepyear =
GETPOST(
'dateepyear',
'int');
475 $datesp =
dol_mktime(0, 0, 0, $datespmonth, $datespday, $datespyear);
476 $dateep =
dol_mktime(23, 59, 59, $dateepmonth, $dateepday, $dateepyear);
478 if (empty($datesp) || empty($dateep)) {
482 print
'<form name="salary" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
483 print
'<input type="hidden" name="token" value="'.newToken().
'">';
484 print
'<input type="hidden" name="action" value="add">';
486 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
488 if ($backtopageforcancel) {
489 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
494 if (!empty($conf->use_javascript_ajax)) {
495 print
"\n".
'<script type="text/javascript">';
497 $(document).ready(function () {
498 let onAutoCreatePaiementChange = function () {
499 if($("#auto_create_paiement").is(":checked")) {
500 $("#label_fk_account").find("span").addClass("fieldrequired");
501 $("#label_type_payment").find("span").addClass("fieldrequired");
502 $(".hide_if_no_auto_create_payment").show();
504 $("#label_fk_account").find("span").removeClass("fieldrequired");
505 $("#label_type_payment").find("span").removeClass("fieldrequired");
506 $(".hide_if_no_auto_create_payment").hide();
509 $("#radiopayment").click(function() {
510 $("#label").val($(this).data("label"));
512 $("#radiorefund").click(function() {
513 $("#label").val($(this).data("label"));
515 $("#auto_create_paiement").click(function () {
516 onAutoCreatePaiementChange();
518 onAutoCreatePaiementChange();
521 print
'</script>'.
"\n";
526 print
'<table class="border centpercent">';
529 print
'<tr><td class="titlefieldcreate">';
530 print
$form->editfieldkey(
'Employee',
'fk_user',
'', $object, 0,
'string',
'', 1).
'</td><td>';
532 print
img_picto(
'',
'user',
'class="paddingrighonly"').$form->select_dolusers(
GETPOST(
'fk_user',
'int'),
'fk_user', 1,
'', 0,
'',
'', 0, 0, 0,
'AND employee=1', 0,
'',
'maxwidth300', $noactive);
537 print
$form->editfieldkey(
'Label',
'label',
'', $object, 0,
'string',
'', 1).
'</td><td>';
538 print
'<input name="label" id="label" class="minwidth300" value="'.(GETPOST(
"label") ?
GETPOST(
"label") : $langs->trans(
"Salary")).
'">';
543 print
$form->editfieldkey(
'DateStartPeriod',
'datesp',
'', $object, 0,
'string',
'', 1).
'</td><td>';
544 print
$form->selectDate($datesp,
"datesp",
'',
'',
'',
'add');
549 print
$form->editfieldkey(
'DateEndPeriod',
'dateep',
'', $object, 0,
'string',
'', 1).
'</td><td>';
550 print
$form->selectDate($dateep,
"dateep",
'',
'',
'',
'add');
555 print
$form->editfieldkey(
'Amount',
'amount',
'', $object, 0,
'string',
'', 1).
'</td><td>';
556 print
'<input name="amount" id="amount" class="minwidth75 maxwidth100" value="'.GETPOST(
"amount").
'"> ';
557 print
'<button class="dpInvisibleButtons datenow" id="updateAmountWithLastSalary" name="_useless" type="button">'.$langs->trans(
'UpdateAmountWithLastSalary').
'</a>';
565 print
'<tr><td>'.$langs->trans(
"Project").
'</td><td>';
566 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
567 print $formproject->select_projects(-1, $projectid,
'fk_project', 0, 0, 1, 1, 0, 0, 0,
'', 1);
573 print
'<td class="tdtop">'.$langs->trans(
"Comments").
'</td>';
574 print
'<td class="tdtop"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_3.
'">'.
GETPOST(
'note',
'restricthtml').
'</textarea></td>';
578 print
'<tr><td colspan="2"><hr></td></tr>';
582 print
'<tr><td><label for="auto_create_paiement">'.$langs->trans(
'AutomaticCreationPayment').
'</label></td>';
583 print
'<td><input id="auto_create_paiement" name="auto_create_paiement" type="checkbox" ' . (empty($auto_create_paiement) ?
'' :
'checked="checked"') .
' value="1"></td></tr>'.
"\n";
587 print
'<tr><td id="label_fk_account">';
588 print
$form->editfieldkey(
'BankAccount',
'selectaccountid',
'', $object, 0,
'string',
'', 1).
'</td><td>';
589 print
img_picto(
'',
'bank_account',
'class="paddingrighonly"');
590 $form->select_comptes($accountid,
"accountid", 0,
'', 1);
595 print
'<tr><td id="label_type_payment">';
596 print
$form->editfieldkey(
'PaymentMode',
'selectpaymenttype',
'', $object, 0,
'string',
'', 1).
'</td><td>';
597 $form->select_types_paiements(
GETPOST(
"paymenttype",
'aZ09'),
"paymenttype",
'');
601 print
'<tr class="hide_if_no_auto_create_payment"><td>';
602 print
$form->editfieldkey(
'DatePayment',
'datep',
'', $object, 0,
'string',
'', 1).
'</td><td>';
603 print
$form->selectDate((empty($datep) ?
'' : $datep),
"datep", 0, 0, 0,
'add', 1, 1);
607 print
'<tr class="hide_if_no_auto_create_payment"><td>';
608 print
$form->editfieldkey(
'DateValue',
'datev',
'', $object, 0).
'</td><td>';
609 print
$form->selectDate((empty($datev) ?-1 : $datev),
"datev",
'',
'',
'',
'add', 1, 1);
615 print
'<tr class="hide_if_no_auto_create_payment"><td><label for="num_payment">'.$langs->trans(
'Numero');
616 print
' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
617 print
'</label></td>';
618 print
'<td><input name="num_payment" id="num_payment" type="text" value="'.GETPOST(
"num_payment").
'"></td></tr>'.
"\n";
629 $parameters = array();
630 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
631 print $hookmanager->resPrint;
632 if (empty($reshook)) {
633 print $object->showOptionals($extrafields,
'create');
640 print
'<div class="center">';
642 print
'<div class="hide_if_no_auto_create_payment paddingbottom">';
643 print
'<input type="checkbox" checked value="1" name="closepaidsalary">'.$langs->trans(
"ClosePaidSalaryAutomatically");
648 $addition_button = array(
649 'name' =>
'saveandnew',
650 'label_key' =>
'SaveAndNew',
652 print
$form->buttonsSaveCancel(
"Save",
"Cancel", $addition_button);
656 print
'$( document ).ready(function() {';
657 print
'$("#updateAmountWithLastSalary").on("click", function updateAmountWithLastSalary() {
658 console.log("We click on link to autofill salary amount");
659 var fk_user = $("#fk_user").val()
660 var url = "'.DOL_URL_ROOT.
'/salaries/ajax/ajaxsalaries.php?fk_user="+fk_user;
666 console.log("Data returned: "+data);
667 item = JSON.parse(data);
668 if(item[0].key == "Amount") {
669 value = item[0].value;
671 $("#amount").val(item[0].value);
673 console.error("Error: Ajax url "+url+" has returned a null value.");
676 console.error("Error: Ajax url "+url+" has returned the wrong key.");
679 console.error("Error: Ajax url "+url+" has returned an empty page.");
701 $head = salaries_prepare_head($object);
704 if ($action ===
'clone') {
705 $formquestion = array(
706 array(
'type' =>
'text',
'name' =>
'clone_label',
'label' => $langs->trans(
"Label"),
'value' => $langs->trans(
"CopyOf").
' '.$object->label),
710 $formquestion[] = array(
'type' =>
'date',
'name' =>
'clone_date_start',
'label' => $langs->trans(
"DateStart"),
'value' => -1);
711 $formquestion[] = array(
'type' =>
'date',
'name' =>
'clone_date_end',
'label' => $langs->trans(
"DateEnd"),
'value' => -1);
713 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneSalary', $object->ref),
'confirm_clone', $formquestion,
'yes', 1, 240);
716 if ($action ==
'paid') {
717 $text = $langs->trans(
'ConfirmPaySalary');
718 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
'PaySalary'), $text,
"confirm_paid",
'',
'', 2);
721 if ($action ==
'delete') {
722 $text = $langs->trans(
'ConfirmDeleteSalary');
723 $formconfirm =
$form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $langs->trans(
'DeleteSalary'), $text,
'confirm_delete',
'',
'', 2);
726 if ($action ==
'edit') {
727 print
"<form name=\"charge\" action=\"".$_SERVER[
"PHP_SELF"].
"?id=$object->id&action=update\" method=\"post\">";
728 print
'<input type="hidden" name="token" value="'.newToken().
'">';
732 $parameters = array(
'formConfirm' => $formconfirm);
733 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
734 if (empty($reshook)) {
735 $formconfirm .= $hookmanager->resPrint;
736 } elseif ($reshook > 0) {
737 $formconfirm = $hookmanager->resPrint;
744 print
dol_get_fiche_head($head,
'card', $langs->trans(
"SalaryPayment"), -1,
'salary');
746 $linkback =
'<a href="'.DOL_URL_ROOT.
'/salaries/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
748 $morehtmlref =
'<div class="refidno">';
751 if ($action !=
'editlabel') {
752 $morehtmlref .=
$form->editfieldkey(
"Label",
'label', $object->label, $object, $user->rights->salaries->write,
'string',
'', 0, 1);
753 $morehtmlref .= $object->label;
755 $morehtmlref .= $langs->trans(
'Label').
' : ';
756 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
757 $morehtmlref .=
'<input type="hidden" name="action" value="setlabel">';
758 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
759 $morehtmlref .=
'<input type="text" name="label" value="'.$object->label.
'"/>';
760 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
761 $morehtmlref .=
'</form>';
765 if ($action !=
'editfk_user') {
766 if ($object->getSommePaiement() > 0 && !empty($object->fk_user)) {
767 $userstatic =
new User($db);
768 $result = $userstatic->fetch($object->fk_user);
770 $morehtmlref .=
'<br>' .$langs->trans(
'Employee').
' : '.$userstatic->getNomUrl(-1);
773 $morehtmlref .=
'<br>' .
$form->editfieldkey(
"Employee",
'fk_user', $object->label, $object, $user->rights->salaries->write,
'string',
'', 0, 1);
775 if (!empty($object->fk_user)) {
776 $userstatic =
new User($db);
777 $result = $userstatic->fetch($object->fk_user);
779 $morehtmlref .= $userstatic->getNomUrl(-1);
787 $morehtmlref .=
'<br>'.$langs->trans(
'Employee').
' : ';
788 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
789 $morehtmlref .=
'<input type="hidden" name="action" value="setfk_user">';
790 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
791 $morehtmlref .=
$form->select_dolusers($object->fk_user,
'userid', 1);
792 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
793 $morehtmlref .=
'</form>';
798 $morehtmlref .=
'<br>'.$langs->trans(
'Project').
' ';
799 if ($user->rights->salaries->write) {
800 if ($action !=
'classify') {
801 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> : ';
803 if ($action ==
'classify') {
805 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
806 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
807 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
808 $morehtmlref .= $formproject->select_projects(-1, $object->fk_project,
'projectid', 0, 0, 1, 0, 1, 0, 0,
'', 1, 0,
'maxwidth500');
809 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
810 $morehtmlref .=
'</form>';
812 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project,
'none', 0, 0, 0, 1);
815 if (!empty($object->fk_project)) {
817 $proj->fetch($object->fk_project);
818 $morehtmlref .=
' : '.$proj->getNomUrl(1);
820 $morehtmlref .=
' - '.$proj->title;
828 $morehtmlref .=
'</div>';
830 $totalpaid = $object->getSommePaiement();
831 $object->totalpaid = $totalpaid;
833 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref,
'', 0,
'',
'');
835 print
'<div class="fichecenter">';
836 print
'<div class="fichehalfleft">';
837 print
'<div class="underbanner clearboth"></div>';
839 print
'<table class="border centpercent tableforfield">';
841 if ($action ==
'edit') {
842 print
'<tr><td class="titlefield">'.$langs->trans(
"DateStartPeriod").
"</td><td>";
843 print
$form->selectDate($object->datesp,
'datesp', 0, 0, 0,
'datesp', 1);
847 print
'<td class="titlefield">' . $langs->trans(
"DateStartPeriod") .
'</td><td>';
852 if ($action ==
'edit') {
853 print
'<tr><td>'.$langs->trans(
"DateEndPeriod").
"</td><td>";
854 print
$form->selectDate($object->dateep,
'dateep', 0, 0, 0,
'dateep', 1);
858 print
'<td>' . $langs->trans(
"DateEndPeriod") .
'</td><td>';
872 if ($action ==
'edit') {
873 print
'<tr><td class="fieldrequired">' . $langs->trans(
"Amount") .
'</td><td><input name="amount" size="10" value="' .
price($object->amount) .
'"></td></tr>';
875 print
'<tr><td>' . $langs->trans(
"Amount") .
'</td><td><span class="amount">' .
price($object->amount, 0, $langs, 1, -1, -1, $conf->currency) .
'</span></td></tr>';
880 print
'<table class="nobordernopadding" width="100%"><tr><td>';
881 print $langs->trans(
'DefaultPaymentMode');
883 if ($action !=
'editmode')
884 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmode&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->trans(
'SetMode'), 1).
'</a></td>';
885 print
'</tr></table>';
888 if ($action ==
'editmode') {
889 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->type_payment,
'mode_reglement_id');
891 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->type_payment,
'none');
897 print
'<tr><td class="nowrap">';
898 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
899 print $langs->trans(
'DefaultBankAccount');
901 if ($action !=
'editbankaccount' && $user->rights->salaries->write) {
902 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editbankaccount&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->trans(
'SetBankAccount'), 1).
'</a></td>';
904 print
'</tr></table>';
906 if ($action ==
'editbankaccount') {
907 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'fk_account', 1);
909 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'none');
916 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
922 print
'<div class="fichehalfright">';
932 $sql =
"SELECT p.rowid, p.num_payment as num_payment, p.datep as dp, p.amount,";
933 $sql .=
" c.code as type_code,c.libelle as paiement_type,";
934 $sql .=
' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.currency_code as bacurrency_code, ba.fk_accountancy_journal';
935 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_salary as p";
936 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
937 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
938 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as c ON p.fk_typepayment = c.id";
939 $sql .=
", ".MAIN_DB_PREFIX.
"salary as salaire";
940 $sql .=
" WHERE p.fk_salary = ".((int) $id);
941 $sql .=
" AND p.fk_salary = salaire.rowid";
942 $sql .=
" AND salaire.entity IN (".getEntity(
'tax').
")";
943 $sql .=
" ORDER BY dp DESC";
946 $resql = $db->query($sql);
950 $num = $db->num_rows(
$resql);
953 print
'<div class="div-table-responsive-no-min">';
954 print
'<table class="noborder paymenttable">';
955 print
'<tr class="liste_titre">';
956 print
'<td>'.$langs->trans(
"RefPayment").
'</td>';
957 print
'<td>'.$langs->trans(
"Date").
'</td>';
958 print
'<td>'.$langs->trans(
"Type").
'</td>';
960 print
'<td class="liste_titre right">'.$langs->trans(
'BankAccount').
'</td>';
962 print
'<td class="right">'.$langs->trans(
"Amount").
'</td>';
966 $bankaccountstatic =
new Account($db);
968 $objp = $db->fetch_object(
$resql);
970 print
'<tr class="oddeven"><td>';
971 print
'<a href="'.DOL_URL_ROOT.
'/salaries/payment_salary/card.php?id='.$objp->rowid.
'">'.
img_object($langs->trans(
"Payment"),
"payment").
' '.$objp->rowid.
'</a></td>';
972 print
'<td>'.dol_print_date($db->jdate($objp->dp),
'day').
"</td>\n";
973 $labeltype = $langs->trans(
"PaymentType".$objp->type_code) != (
"PaymentType".$objp->type_code) ? $langs->trans(
"PaymentType".$objp->type_code) : $objp->paiement_type;
974 print
"<td>".$labeltype.
' '.$objp->num_payment.
"</td>\n";
976 $bankaccountstatic->id = $objp->baid;
977 $bankaccountstatic->ref = $objp->baref;
978 $bankaccountstatic->label = $objp->baref;
979 $bankaccountstatic->number = $objp->banumber;
980 $bankaccountstatic->currency_code = $objp->bacurrency_code;
983 $bankaccountstatic->account_number = $objp->account_number;
986 $accountingjournal->fetch($objp->fk_accountancy_journal);
987 $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
990 print
'<td class="right">';
991 if ($bankaccountstatic->id)
992 print $bankaccountstatic->getNomUrl(1,
'transactions');
995 print
'<td class="right nowrap amountcard">'.price($objp->amount).
"</td>\n";
997 $totalpaid += $objp->amount;
1001 print
'<tr class="oddeven"><td><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td>';
1002 print
'<td></td><td></td><td></td><td></td>';
1006 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AlreadyPaid").
" :</td><td class=\"right nowrap amountcard\">".
price($totalpaid).
"</td></tr>\n";
1007 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AmountExpected").
" :</td><td class=\"right nowrap amountcard\">".
price($object->amount).
"</td></tr>\n";
1009 $resteapayer = $object->amount - $totalpaid;
1010 $cssforamountpaymentcomplete =
'amountpaymentcomplete';
1012 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"RemainderToPay").
" :</td>";
1013 print
'<td class="right nowrap'.($resteapayer ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($resteapayer).
"</td></tr>\n";
1026 print
'<div class="clearboth"></div>';
1030 if ($action ==
'edit') {
1031 print
$form->buttonsSaveCancel();
1035 $resteapayer =
price2num($resteapayer,
'MT');
1042 print
'<div class="tabsAction">'.
"\n";
1043 if ($action !=
'edit') {
1045 if ($object->paye && $user->rights->salaries->write) {
1046 print
dolGetButtonAction(
'', $langs->trans(
'ReOpen'),
'default', $_SERVER[
"PHP_SELF"].
'?action=reopen&token='.
newToken().
'&id='.$object->id,
'');
1050 if ($object->paye == 0 && $user->rights->salaries->write) {
1051 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'&id='.$object->id,
'');
1055 if ($object->paye == 0 && ((
price2num($object->amount) < 0 && $resteapayer < 0) || (
price2num($object->amount) > 0 && $resteapayer > 0)) && $user->rights->salaries->write) {
1056 print
dolGetButtonAction(
'', $langs->trans(
'DoPayment'),
'default', DOL_URL_ROOT.
'/salaries/paiement_salary.php?action=create&token='.
newToken().
'&id='. $object->id,
'');
1061 if ($object->paye == 0 && (($resteapayer <= 0 && $object->amount > 0) || ($object->amount <= 0)) && $user->rights->salaries->write) {
1062 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyPaid'),
'default', $_SERVER[
"PHP_SELF"].
'?action=paid&token='.
newToken().
'&id='.$object->id,
'');
1066 if ($user->rights->salaries->write) {
1067 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
"PHP_SELF"].
'?action=clone&token='.
newToken().
'&id='.$object->id,
'');
1070 if (!empty($user->rights->salaries->delete) && empty($totalpaid)) {
1071 print
dolGetButtonAction(
'', $langs->trans(
'Delete'),
'delete', $_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&id='.$object->id,
'');
1073 print
dolGetButtonAction($langs->trans(
'DisabledBecausePayments'), $langs->trans(
'Delete'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1081 if (
GETPOST(
'modelselected')) {
1082 $action =
'presend';
1085 if ($action !=
'presend') {
1086 print
'<div class="fichecenter"><div class="fichehalfleft">';
1087 print
'<a name="builddoc"></a>';
1089 $includedocgeneration = 1;
1092 if ($includedocgeneration) {
1094 $relativepath = $objref.
'/'.$objref.
'.pdf';
1095 $filedir = $conf->salaries->dir_output.
'/'.$objref;
1096 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
1099 $delallowed = $permissiontoadd;
1100 print $formfile->showdocuments(
'salaries', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
1109 print
'</div><div class="fichehalfright">';
1113 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode',
dol_buildpath(
'/mymodule/myobject_agenda.php', 1).
'?id='.$object->id);
1116 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1120 print
'</div></div>';
1124 if (
GETPOST(
'modelselected')) {
1125 $action =
'presend';
1129 $modelmail =
'salary';
1130 $defaulttopic =
'InformationMessage';
1131 $diroutput = $conf->salaries->dir_output;
1132 $trackid =
'salary'.$object->id;
1134 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action== 'set') elseif($action== 'specimen') elseif($action== 'setmodel') elseif($action== 'del') elseif($action== 'setdoc') $formactions
View.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
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...
Class to manage payments of salaries.
dolGetButtonTitle($label, $helpText= '', $iconClass= 'fa fa-file', $url= '', $id= '', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dolGetButtonAction($label, $html= '', $actionType= 'default', $url= '', $id= '', $userRight=1, $params=array())
Function dolGetButtonAction.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save"&&empty($cancel)) $help_url
View.
Class to manage bank accounts.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form...
Class to manage projects.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return value of a param into GET or POST supervariable.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
restrictedArea($user, $features, $objectid=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.
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->supplier_invoice->lire)) if(isModEnabled('don')&&!empty($user->rights->don->lire)) if(isModEnabled('tax')&&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture')&&isModEnabled('commande')&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Class to manage salary payments.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
isModEnabled($module)
Is Dolibarr module enabled.
Class to manage accounting accounts.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
$formconfirm
if ($action == 'delbookkeepingyear') {