33require
'../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/salaries/class/paymentsalary.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/salaries.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
43if (isModEnabled(
'project')) {
44 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
57$langs->loadLangs(array(
"compta",
"banks",
"bills",
"users",
"salaries",
"hrm",
"trips"));
58if (isModEnabled(
'project')) {
59 $langs->load(
"projects");
64$action =
GETPOST(
'action',
'aZ09');
65$cancel =
GETPOST(
'cancel',
'alpha');
66$backtopage =
GETPOST(
'backtopage',
'alpha');
67$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
70$label =
GETPOST(
'label',
'alphanohtml');
73if (GETPOSTISSET(
'auto_create_paiement') || $action ===
'add') {
74 $auto_create_paiement =
GETPOSTINT(
"auto_create_paiement");
88$childids = $user->getAllChildIds(1);
91$extrafields->fetch_name_optionals_label(
$object->table_element);
94$hookmanager->initHooks(array(
'salarycard',
'globalcard'));
96if ($id > 0 || !empty($ref)) {
101 if ($user->hasRight(
'salaries',
'readall')) {
104 if ($user->hasRight(
'salaries',
'read') &&
$object->fk_user > 0 && in_array(
$object->fk_user, $childids)) {
115 $socid = $user->socid;
120$permissiontoread = $user->hasRight(
'salaries',
'read');
121$permissiontoadd = $user->hasRight(
'salaries',
'write');
122$permissiontodelete = $user->hasRight(
'salaries',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_UNPAID);
124$upload_dir =
$conf->salaries->multidir_output[
$conf->entity];
131$parameters = array();
133$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
138if (empty($reshook)) {
141 $backurlforlist = DOL_URL_ROOT.
'/salaries/list.php';
143 if (empty($backtopage) || ($cancel && empty($id))) {
144 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
145 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
146 $backtopage = $backurlforlist;
148 $backtopage = DOL_URL_ROOT.
'/salaries/card.php?id='.(
$id > 0 ?
$id :
'__ID__');
156 if (!empty($backtopageforcancel)) {
157 header(
"Location: ".$backtopageforcancel);
159 } elseif (!empty($backtopage)) {
160 header(
"Location: ".$backtopage);
167 $triggersendname =
'COMPANY_SENTBYMAIL';
169 $mode =
'emailfromthirdparty';
170 $trackid =
'sal'.$object->id;
171 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
175 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
179if ($action ==
'classin' && $permissiontoadd) {
181 $object->setProject($projectid);
185if ($action ==
'setlabel' && $permissiontoadd) {
192if ($action ==
'confirm_paid' && $permissiontoadd && $confirm ==
'yes') {
194 $result =
$object->setPaid($user);
197if ($action ==
'setfk_user' && $permissiontoadd) {
208if ($action ==
'reopen' && $permissiontoadd) {
211 $result =
$object->set_unpaid($user);
213 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
222if ($action ==
'setmode' && $permissiontoadd) {
231if ($action ==
'setbankaccount' && $permissiontoadd) {
239if ($action ==
'add' && empty($cancel) && $permissiontoadd) {
258 $object->type_payment = ($type_payment > 0 ? $type_payment : 0);
259 $object->fk_user_author = $user->id;
260 $object->fk_project = $projectid;
263 $fuser =
new User($db);
265 $object->salary = $fuser->salary;
268 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
273 if (!empty($auto_create_paiement) && empty($datep)) {
274 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DATE_PAIEMENT")),
null,
'errors');
277 if (empty($datesp) || empty($dateep)) {
278 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
282 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Employee")),
null,
'errors');
285 if (!empty($auto_create_paiement) && (empty($type_payment) || $type_payment < 0)) {
286 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PaymentMode")),
null,
'errors');
290 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount")),
null,
'errors');
293 if (isModEnabled(
"bank") && !empty($auto_create_paiement) && !
$object->accountid > 0) {
294 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankAccount")),
null,
'errors');
306 if (!empty($auto_create_paiement) && !$error) {
309 $paiement->fk_salary =
$object->id;
311 $paiement->datep = $datep;
312 $paiement->datev = $datev;
313 $paiement->amounts = array(
$object->id => $amount);
314 $paiement->fk_typepayment = $type_payment;
315 $paiement->num_payment =
GETPOST(
"num_payment",
'alphanohtml');
316 $paiement->note_private =
GETPOST(
"note",
'restricthtml');
319 $paymentid = $paiement->create($user, (
int)
GETPOST(
'closepaidsalary'));
320 if ($paymentid < 0) {
328 $result = $paiement->addPaymentToBank($user,
'payment_salary',
'(SalaryPayment)',
GETPOSTINT(
'accountid'),
'',
'');
329 if (!($result > 0)) {
339 if (
GETPOST(
'saveandnew',
'alpha')) {
341 header(
"Location: card.php?action=create&fk_project=" . urlencode((
string) ($projectid)) .
"&accountid=" . urlencode((
string) ($accountid)) .
'&paymenttype=' . urlencode((
string) (
GETPOSTINT(
'paymenttype'))) .
'&datepday=' .
GETPOSTINT(
"datepday") .
'&datepmonth=' .
GETPOSTINT(
"datepmonth") .
'&datepyear=' .
GETPOSTINT(
"datepyear"));
344 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id);
355if ($action ==
'confirm_delete' && $permissiontodelete) {
357 $totalpaid =
$object->getSommePaiement();
359 if (empty($totalpaid)) {
365 header(
"Location: ".DOL_URL_ROOT.
'/salaries/list.php');
377if ($action ==
'update' && !
GETPOST(
"cancel") && $permissiontoadd) {
380 if (empty($amount)) {
381 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Amount")),
null,
'errors');
383 } elseif (!is_numeric($amount)) {
384 setEventMessages($langs->trans(
"ErrorFieldMustBeANumeric", $langs->transnoentities(
"Amount")),
null,
'errors');
393 $result =
$object->update($user);
400if ($action ==
'confirm_clone' && $confirm !=
'yes') {
404if ($action ==
'confirm_clone' && $confirm ==
'yes' && $permissiontoadd) {
416 if (
GETPOST(
'amount',
'alphanohtml')) {
420 if (
GETPOST(
'clone_label',
'alphanohtml')) {
430 $object->datesp = $newdatestart;
441 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
456if ($action ==
"update_extras" && $permissiontoadd) {
459 $attributekey =
GETPOST(
'attribute',
'alpha');
460 $attributekeylong =
'options_'.$attributekey;
462 if (GETPOSTISSET($attributekeylong.
'day') && GETPOSTISSET($attributekeylong.
'month') && GETPOSTISSET($attributekeylong.
'year')) {
467 $object->array_options[
'options_'.$attributekey] =
GETPOST($attributekeylong,
'alpha');
470 $triggermodname =
'SALARY_MODIFY';
472 $result =
$object->insertExtraFields(empty($triggermodname) ?
'' : $triggermodname, $user);
478 $action =
'edit_extras';
487$form =
new Form($db);
489if (isModEnabled(
'project')) {
493$title = $langs->trans(
'Salary').
" - ".
$object->ref;
494if ($action ==
'create') {
495 $title = $langs->trans(
"NewSalary");
510if ($action ==
'create' && $permissiontoadd) {
513 $pastmonthyear = $year_current;
514 if ($pastmonth == 0) {
525 $datesp =
dol_mktime(0, 0, 0, $datespmonth, $datespday, $datespyear);
526 $dateep =
dol_mktime(23, 59, 59, $dateepmonth, $dateepday, $dateepyear);
528 if (empty($datesp) || empty($dateep)) {
533 print
'<form name="salary" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
534 print
'<input type="hidden" name="token" value="'.newToken().
'">';
535 print
'<input type="hidden" name="action" value="add">';
537 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
539 if ($backtopageforcancel) {
540 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
545 if (!empty(
$conf->use_javascript_ajax)) {
546 print
"\n".
'<script type="text/javascript">';
548 $(document).ready(function () {
549 let onAutoCreatePaiementChange = function () {
550 if($("#auto_create_paiement").is(":checked")) {
551 $("#label_fk_account").find("span").addClass("fieldrequired");
552 $("#label_type_payment").find("span").addClass("fieldrequired");
553 $(".hide_if_no_auto_create_payment").show();
555 $("#label_fk_account").find("span").removeClass("fieldrequired");
556 $("#label_type_payment").find("span").removeClass("fieldrequired");
557 $(".hide_if_no_auto_create_payment").hide();
560 $("#radiopayment").click(function() {
561 $("#label").val($(this).data("label"));
563 $("#radiorefund").click(function() {
564 $("#label").val($(this).data("label"));
566 $("#auto_create_paiement").click(function () {
567 onAutoCreatePaiementChange();
569 onAutoCreatePaiementChange();
572 print
'</script>'.
"\n";
577 print
'<table class="border centpercent">';
580 print
'<tr><td class="titlefieldcreate">';
581 print $form->editfieldkey(
'Employee',
'fk_user',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
583 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->select_dolusers(
GETPOSTINT(
'fk_user'),
'fk_user', 1,
'', 0,
'',
'', 0, 0, 0,
'employee:=:1', 0,
'',
'maxwidth300', $noactive);
588 print $form->editfieldkey(
'Label',
'label',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
589 print
'<input name="label" id="label" class="minwidth300" value="'.(GETPOST(
"label") ?
GETPOST(
"label") : $langs->trans(
"Salary")).
'">';
594 print $form->editfieldkey(
'DateStartPeriod',
'datesp',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
595 print $form->selectDate($datesp,
"datesp", 0, 0, 0,
'add');
600 print $form->editfieldkey(
'DateEndPeriod',
'dateep',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
601 print $form->selectDate($dateep,
"dateep", 0, 0, 0,
'add');
606 print $form->editfieldkey(
'Amount',
'amount',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
607 print
'<input name="amount" id="amount" class="minwidth75 maxwidth100" value="'.GETPOST(
"amount").
'"> ';
608 print
' <button class="dpInvisibleButtons datenowlink" id="updateAmountWithLastSalary" name="_useless" type="button">'.$langs->trans(
'UpdateAmountWithLastSalary').
'</a>';
613 if (isModEnabled(
'project')) {
616 print
'<tr><td>'.$langs->trans(
"Project").
'</td><td>';
617 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
618 print $formproject->select_projects(-1, $projectid,
'fk_project', 0, 0, 1, 1, 0, 0, 0,
'', 1);
624 print
'<td class="tdtop">'.$langs->trans(
"Comments").
'</td>';
625 print
'<td class="tdtop"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_3.
'">'.
GETPOST(
'note',
'restricthtml').
'</textarea></td>';
629 print
'<tr><td colspan="2"><hr></td></tr>';
633 print
'<tr><td><label for="auto_create_paiement">'.$langs->trans(
'AutomaticCreationPayment').
'</label></td>';
634 print
'<td><input id="auto_create_paiement" name="auto_create_paiement" type="checkbox" ' . (empty($auto_create_paiement) ?
'' :
'checked="checked"') .
' value="1"></td></tr>'.
"\n";
637 if (isModEnabled(
"bank")) {
638 print
'<tr><td id="label_fk_account">';
639 print $form->editfieldkey(
'BankAccount',
'selectaccountid',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
640 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
641 $form->select_comptes($accountid,
"accountid", 0,
'', 1);
646 print
'<tr><td id="label_type_payment">';
647 print $form->editfieldkey(
'PaymentMode',
'selectpaymenttype',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
648 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
649 print $form->select_types_paiements(
GETPOST(
"paymenttype",
'aZ09'),
"paymenttype",
'');
653 print
'<tr class="hide_if_no_auto_create_payment"><td>';
654 print $form->editfieldkey(
'DatePayment',
'datep',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
655 print $form->selectDate((empty($datep) ?
'' : $datep),
"datep", 0, 0, 0,
'add', 1, 1);
659 print
'<tr class="hide_if_no_auto_create_payment"><td>';
660 print $form->editfieldkey(
'DateValue',
'datev',
'',
$object, 0).
'</td><td>';
661 print $form->selectDate((empty($datev) ? -1 : $datev),
"datev", 0, 0, 0,
'add', 1, 1);
665 if (isModEnabled(
"bank")) {
667 print
'<tr class="hide_if_no_auto_create_payment"><td><label for="num_payment">'.$langs->trans(
'Numero');
668 print
' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
669 print
'</label></td>';
670 print
'<td><input name="num_payment" id="num_payment" type="text" value="'.GETPOST(
"num_payment").
'"></td></tr>'.
"\n";
681 $parameters = array();
682 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
683 print $hookmanager->resPrint;
684 if (empty($reshook)) {
685 print
$object->showOptionals($extrafields,
'create');
692 print
'<div class="center">';
694 print
'<div class="hide_if_no_auto_create_payment paddingbottom">';
695 print
'<input type="checkbox" checked value="1" name="closepaidsalary">'.$langs->trans(
"ClosePaidSalaryAutomatically");
700 $addition_button = array(
701 'name' =>
'saveandnew',
702 'label_key' =>
'SaveAndNew',
704 print $form->buttonsSaveCancel(
"Save",
"Cancel", $addition_button);
708 print
'$( document ).ready(function() {';
709 print
'$("#updateAmountWithLastSalary").on("click", function updateAmountWithLastSalary() {
710 var fk_user = $("#fk_user").val()
711 var url = "'.DOL_URL_ROOT.
'/salaries/ajax/ajaxsalaries.php?fk_user="+fk_user;
712 console.log("We click on link to autofill salary amount url="+url);
718 console.log("Data returned: "+data);
720 if (typeof data == "object") {
721 console.log("data is already type object, no need to parse it");
724 console.log("data is type "+(typeof data));
725 item = JSON.parse(data);
727 if (item[0].key == "Amount") {
728 value = item[0].value;
729 console.log("amount returned = "+value);
731 $("#amount").val(item[0].value);
733 console.error("Error: Ajax url "+url+" has returned a null value.");
736 console.error("Error: Ajax url "+url+" has returned the wrong key.");
739 console.error("Error: Ajax url "+url+" has returned an empty page.");
745 alert("'.
dol_escape_js($langs->transnoentitiesnoconv(
"FillFieldFirst")).
'");
755 $head = salaries_prepare_head(
$object);
758 if ($action ===
'clone') {
759 $formquestion = array(
760 array(
'type' =>
'text',
'name' =>
'clone_label',
'label' => $langs->trans(
"Label"),
'value' => $langs->trans(
"CopyOf").
' '.
$object->label),
764 $formquestion[] = array(
'type' =>
'date',
'name' =>
'clone_date_start',
'label' => $langs->trans(
"DateStart"),
'value' => -1);
765 $formquestion[] = array(
'type' =>
'date',
'name' =>
'clone_date_end',
'label' => $langs->trans(
"DateEnd"),
'value' => -1);
766 $formquestion[] = array(
'type' =>
'text',
'name' =>
'amount',
'label' => $langs->trans(
"Amount"),
'value' =>
price(
$object->amount),
'morecss' =>
'width100 right');
768 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneSalary',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1, 280);
771 $formconfirm .=
"<script>
772 $('#clone_date_end').after($('<button id=\"fill_end_of_month\" class=\"dpInvisibleButtons\" style=\"color: var(--colortextlink);font-size: 0.8em;opacity: 0.7;margin-left:4px;\" type=\"button\">".$langs->trans(
'FillEndOfMonth').
"</button>'));
773 $('#fill_end_of_month').click(function(){
774 var clone_date_startmonth = +$('#clone_date_startmonth').val();
775 var clone_date_startyear = +$('#clone_date_startyear').val();
777 if (clone_date_startmonth && clone_date_startyear) {
778 end_date = new Date(clone_date_startyear, clone_date_startmonth , 0);
780 var currentDate = new Date();
781 var currentDay = currentDate.getDate();
782 if (currentDay <= 15) {
783 end_date = new Date(currentDate.getFullYear(), currentDate.getMonth(), 0);
785 end_date = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0);
788 $('#clone_date_end').val(formatDate(end_date,'".$langs->trans(
"FormatDateShortJavaInput").
"'));
789 $('#clone_date_endday').val(end_date.getDate());
790 $('#clone_date_endmonth').val(end_date.getMonth() + 1);
791 $('#clone_date_endyear').val(end_date.getFullYear());
796 if ($action ==
'paid') {
797 $text = $langs->trans(
'ConfirmPaySalary');
798 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
'PaySalary'), $text,
"confirm_paid",
'',
'', 2);
801 if ($action ==
'delete') {
802 $text = $langs->trans(
'ConfirmDeleteSalary');
803 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
'DeleteSalary'), $text,
'confirm_delete',
'',
'', 2);
806 if ($action ==
'edit') {
807 print
"<form name=\"charge\" action=\"".$_SERVER[
"PHP_SELF"].
"?id=$object->id&action=update\" method=\"post\">";
808 print
'<input type="hidden" name="token" value="'.newToken().
'">';
812 $parameters = array(
'formConfirm' => $formconfirm);
813 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
814 if (empty($reshook)) {
815 $formconfirm .= $hookmanager->resPrint;
816 } elseif ($reshook > 0) {
817 $formconfirm = $hookmanager->resPrint;
824 print
dol_get_fiche_head($head,
'card', $langs->trans(
"SalaryPayment"), -1,
'salary', 0,
'',
'', 0,
'', 1);
826 $linkback =
'<a href="'.DOL_URL_ROOT.
'/salaries/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
828 $morehtmlref =
'<div class="refidno">';
831 if ($action !=
'editlabel') {
832 $morehtmlref .= $form->editfieldkey(
"Label",
'label',
$object->label,
$object, $permissiontoadd,
'string',
'', 0, 1);
833 $morehtmlref .=
$object->label;
835 $morehtmlref .= $langs->trans(
'Label').
' : ';
836 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
837 $morehtmlref .=
'<input type="hidden" name="action" value="setlabel">';
838 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
839 $morehtmlref .=
'<input type="text" name="label" value="'.$object->label.
'"/>';
840 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
841 $morehtmlref .=
'</form>';
845 if ($action !=
'editfk_user') {
846 if (
$object->getSommePaiement() > 0 && !empty(
$object->fk_user)) {
847 $userstatic =
new User($db);
848 $result = $userstatic->fetch(
$object->fk_user);
850 $morehtmlref .=
'<br>' .$langs->trans(
'Employee').
' : '.$userstatic->getNomUrl(-1);
853 $morehtmlref .=
'<br>' . $form->editfieldkey(
"Employee",
'fk_user',
$object->label,
$object, $permissiontoadd,
'string',
'', 0, 1);
855 if (!empty(
$object->fk_user)) {
856 $userstatic =
new User($db);
857 $result = $userstatic->fetch(
$object->fk_user);
859 $morehtmlref .= $userstatic->getNomUrl(-1);
867 $morehtmlref .=
'<br>'.$langs->trans(
'Employee').
' : ';
868 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
869 $morehtmlref .=
'<input type="hidden" name="action" value="setfk_user">';
870 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
871 $morehtmlref .= $form->select_dolusers(
$object->fk_user,
'userid', 1);
872 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
873 $morehtmlref .=
'</form>';
876 $usercancreate = $permissiontoadd;
879 if (isModEnabled(
'project')) {
880 $langs->load(
"projects");
881 $morehtmlref .=
'<br>';
882 if ($usercancreate) {
883 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
884 if ($action !=
'classify') {
885 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
887 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, -1,
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
889 if (!empty(
$object->fk_project)) {
891 $proj->fetch(
$object->fk_project);
892 $morehtmlref .= $proj->getNomUrl(1);
894 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
900 $morehtmlref .=
'</div>';
902 $totalpaid =
$object->getSommePaiement();
903 $object->alreadypaid = $totalpaid;
904 $object->totalpaid = $totalpaid;
906 dol_banner_tab(
$object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref,
'', 0,
'',
'');
908 print
'<div class="fichecenter">';
909 print
'<div class="fichehalfleft">';
910 print
'<div class="underbanner clearboth"></div>';
912 print
'<table class="border centpercent tableforfield">';
914 if ($action ==
'edit') {
915 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"DateStartPeriod").
"</td><td>";
916 print $form->selectDate(
$object->datesp,
'datesp', 0, 0, 0,
'datesp', 1);
920 print
'<td class="titlefieldmiddle">' . $langs->trans(
"DateStartPeriod") .
'</td><td>';
925 if ($action ==
'edit') {
926 print
'<tr><td>'.$langs->trans(
"DateEndPeriod").
"</td><td>";
927 print $form->selectDate(
$object->dateep,
'dateep', 0, 0, 0,
'dateep', 1);
931 print
'<td>' . $langs->trans(
"DateEndPeriod") .
'</td><td>';
945 if ($action ==
'edit') {
946 print
'<tr><td class="fieldrequired">' . $langs->trans(
"Amount") .
'</td><td><input name="amount" size="10" value="' .
price(
$object->amount) .
'"></td></tr>';
948 print
'<tr><td>' . $langs->trans(
"Amount") .
'</td><td><span class="amount">' .
price(
$object->amount, 0, $langs, 1, -1, -1,
$conf->currency) .
'</span></td></tr>';
953 print
'<table class="nobordernopadding" width="100%"><tr><td>';
954 print $langs->trans(
'DefaultPaymentMode');
956 if ($action !=
'editmode') {
957 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>';
959 print
'</tr></table>';
962 if ($action ==
'editmode') {
963 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->type_payment,
'mode_reglement_id');
965 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->type_payment,
'none');
970 if (isModEnabled(
"bank")) {
971 print
'<tr><td class="nowrap">';
972 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
973 print $langs->trans(
'DefaultBankAccount');
975 if ($action !=
'editbankaccount' && $permissiontoadd) {
976 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>';
978 print
'</tr></table>';
980 if ($action ==
'editbankaccount') {
981 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'fk_account', 1);
983 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'none');
990 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
996 print
'<div class="fichehalfright">';
999 if (isModEnabled(
"bank")) {
1006 $sql =
"SELECT p.rowid, p.num_payment as num_payment, p.datep as dp, p.amount,";
1007 $sql .=
" c.code as type_code,c.libelle as paiement_type,";
1008 $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';
1009 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_salary as p";
1010 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
1011 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
1012 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as c ON p.fk_typepayment = c.id";
1013 $sql .=
", ".MAIN_DB_PREFIX.
"salary as salaire";
1014 $sql .=
" WHERE p.fk_salary = ".((int) $id);
1015 $sql .=
" AND p.fk_salary = salaire.rowid";
1016 $sql .=
" AND salaire.entity IN (".getEntity(
'tax').
")";
1017 $sql .=
" ORDER BY dp DESC";
1019 $resql = $db->query($sql);
1023 $num = $db->num_rows($resql);
1027 print
'<div class="div-table-responsive-no-min">';
1028 print
'<table class="noborder paymenttable">';
1029 print
'<tr class="liste_titre">';
1030 print
'<td>'.$langs->trans(
"RefPayment").
'</td>';
1031 print
'<td>'.$langs->trans(
"Date").
'</td>';
1032 print
'<td>'.$langs->trans(
"Type").
'</td>';
1033 if (isModEnabled(
"bank")) {
1034 print
'<td class="liste_titre right">'.$langs->trans(
'BankAccount').
'</td>';
1036 print
'<td class="right">'.$langs->trans(
"Amount").
'</td>';
1042 $bankaccountstatic =
new Account($db);
1044 $objp = $db->fetch_object($resql);
1046 $paymentsalarytemp->id = $objp->rowid;
1047 $paymentsalarytemp->ref = $objp->rowid;
1048 $paymentsalarytemp->num_payment = $objp->num_payment;
1049 $paymentsalarytemp->datep = $objp->dp;
1051 print
'<tr class="oddeven"><td>';
1052 print $paymentsalarytemp->getNomUrl(1);
1054 print
'<td>'.dol_print_date($db->jdate($objp->dp),
'dayhour',
'tzuserrel').
"</td>\n";
1055 $labeltype = $langs->trans(
"PaymentType".$objp->type_code) !=
"PaymentType".$objp->type_code ? $langs->trans(
"PaymentType".$objp->type_code) : $objp->paiement_type;
1056 print
"<td>".$labeltype.
' '.$objp->num_payment.
"</td>\n";
1057 if (isModEnabled(
"bank")) {
1058 $bankaccountstatic->id = $objp->baid;
1059 $bankaccountstatic->ref = $objp->baref;
1060 $bankaccountstatic->label = $objp->baref;
1061 $bankaccountstatic->number = $objp->banumber;
1062 $bankaccountstatic->currency_code = $objp->bacurrency_code;
1064 if (isModEnabled(
'accounting')) {
1065 $bankaccountstatic->account_number = $objp->account_number;
1068 $accountingjournal->fetch($objp->fk_accountancy_journal);
1069 $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
1072 print
'<td class="right">';
1073 if ($bankaccountstatic->id) {
1074 print $bankaccountstatic->getNomUrl(1,
'transactions');
1078 print
'<td class="right nowrap amountcard">'.price($objp->amount).
"</td>\n";
1080 $totalpaid += $objp->amount;
1084 print
'<tr class="oddeven"><td><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td>';
1085 print
'<td></td><td></td><td></td><td></td>';
1089 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AlreadyPaid").
' :</td><td class="right nowrap amountcard">'.
price($totalpaid).
"</td></tr>\n";
1090 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AmountExpected").
' :</td><td class="right nowrap amountcard">'.
price(
$object->amount).
"</td></tr>\n";
1092 $resteapayer = (float)
$object->amount - $totalpaid;
1093 $cssforamountpaymentcomplete =
'amountpaymentcomplete';
1095 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"RemainderToPay").
" :</td>";
1096 print
'<td class="right nowrap'.($resteapayer ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($resteapayer).
"</td></tr>\n";
1109 print
'<div class="clearboth"></div>';
1113 if ($action ==
'edit') {
1114 print $form->buttonsSaveCancel();
1118 $resteapayer =
price2num($resteapayer,
'MT');
1125 print
'<div class="tabsAction">'.
"\n";
1126 if ($action !=
'edit') {
1128 $parameters = array();
1129 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
1130 if (empty($reshook)) {
1131 if (empty($user->socid)) {
1132 $canSendMail =
true;
1134 print
dolGetButtonAction($langs->trans(
'SendMail'),
'',
'default', $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id .
'&action=presend&token='.newToken().
'&mode=init#formmailbeforetitle',
'', $canSendMail);
1139 if (
$object->status == $object::STATUS_PAID && $permissiontoadd) {
1144 if (
$object->status == $object::STATUS_UNPAID && $permissiontoadd) {
1150 print
dolGetButtonAction(
'', $langs->trans(
'DoPayment'),
'default', DOL_URL_ROOT.
'/salaries/paiement_salary.php?action=create&token='.
newToken().
'&id='.
$object->id,
'');
1155 if (
$object->status == $object::STATUS_UNPAID && (($resteapayer <= 0 && $object->amount > 0) || (
$object->amount <= 0)) && $permissiontoadd) {
1161 print
dolGetButtonAction(
'', $langs->trans(
'MakeTransferRequest'),
'default', DOL_URL_ROOT .
'/salaries/virement_request.php?id=' .
$object->id,
'');
1165 if ($permissiontoadd) {
1169 if ($permissiontodelete && empty($totalpaid)) {
1172 print
dolGetButtonAction($langs->trans(
'DisabledBecausePayments'), $langs->trans(
'Delete'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1180 if (
GETPOST(
'modelselected')) {
1181 $action =
'presend';
1184 if ($action !=
'presend') {
1185 print
'<div class="fichecenter"><div class="fichehalfleft">';
1186 print
'<a name="builddoc"></a>';
1188 $includedocgeneration = 1;
1191 if ($includedocgeneration) {
1193 $relativepath = $objref.
'/'.$objref.
'.pdf';
1194 $filedir =
$conf->salaries->dir_output.
'/'.$objref;
1195 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
1198 $delallowed = $permissiontoadd;
1199 print $formfile->showdocuments(
'salaries', $objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
1212 print
'</div><div class="fichehalfright">';
1219 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1223 print
'</div></div>';
1227 if (
GETPOST(
'modelselected')) {
1228 $action =
'presend';
1232 $modelmail =
'salary';
1233 $defaulttopic =
'InformationMessage';
1234 $diroutput =
$conf->salaries->dir_output;
1235 $trackid =
'salary'.$object->id;
1237 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
1240 $parameters = array();
1241 $reshook = $hookmanager->executeHooks(
'salaryCardTabAddMore', $parameters,
$object, $action);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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 bank accounts.
Class to manage accounting journals.
Class to manage payments of salaries.
Class to manage projects.
Class to manage salary payments.
Class to manage Dolibarr users.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
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 '.
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_get_fiche_end($notab=0)
Return tab footer of a card.
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.
dol_now($mode='auto')
Return date for now.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
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).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.