34require
'../main.inc.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
44require_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/salaries/class/paymentsalary.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/lib/salaries.lib.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
52 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
53 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
57$langs->loadLangs(array(
"compta",
"banks",
"bills",
"users",
"salaries",
"hrm",
"trips"));
59 $langs->load(
"projects");
64$action =
GETPOST(
'action',
'aZ09');
65$cancel =
GETPOST(
'cancel',
'alpha');
66$backtopage =
GETPOST(
'backtopage',
'alpha');
67$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
69$backurlforlist =
GETPOST(
'backtopage',
'alpha');
71$label =
GETPOST(
'label',
'alphanohtml');
74if (GETPOSTISSET(
'auto_create_paiement') || $action ===
'add') {
75 $auto_create_paiement =
GETPOSTINT(
"auto_create_paiement");
89$childids = $user->getAllChildIds(1);
92$extrafields->fetch_name_optionals_label(
$object->table_element);
95$hookmanager->initHooks(array(
'salarycard',
'globalcard'));
102 if ($user->hasRight(
'salaries',
'readall')) {
105 if ($user->hasRight(
'salaries',
'read') &&
$object->fk_user > 0 && in_array(
$object->fk_user, $childids)) {
116 $socid = $user->socid;
121$permissiontoread = $user->hasRight(
'salaries',
'read');
122$permissiontoadd = $user->hasRight(
'salaries',
'write');
123$permissiontodelete = $user->hasRight(
'salaries',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_UNPAID);
124$permissiontoeditextra = $permissiontoadd;
125if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
127 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
130$upload_dir =
$conf->salaries->multidir_output[
$conf->entity];
139$parameters = array();
140$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
145if (empty($reshook)) {
149 $upload_dir =
$conf->salaries->dir_output;
150 $permissiontoadd = $user->hasRight(
'salaries',
'write');
157 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
160 $trackid =
'sal'.$object->id;
161 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
165if ($action ==
'classin' && $permissiontoadd) {
167 $object->setProject($projectid);
171if ($action ==
'setlabel' && $permissiontoadd) {
178if ($action ==
'confirm_paid' && $permissiontoadd && $confirm ==
'yes') {
180 $result =
$object->setPaid($user);
183if ($action ==
'setfk_user' && $permissiontoadd) {
194if ($action ==
'reopen' && $permissiontoadd) {
197 $result =
$object->set_unpaid($user);
199 header(
'Location: '.
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' => $id]));
208if ($action ==
'setmode' && $permissiontoadd) {
217if ($action ==
'setbankaccount' && $permissiontoadd) {
225if ($action ==
'add' && empty($cancel) && $permissiontoadd) {
244 $object->type_payment = ($type_payment > 0 ? $type_payment : 0);
245 $object->fk_user_author = $user->id;
246 $object->fk_project = $projectid;
251 $object->salary = $fuser->salary;
254 $ret = $extrafields->setOptionalsFromPost(
null, $object);
259 if (!empty($auto_create_paiement) && empty($datep)) {
260 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DATE_PAIEMENT")),
null,
'errors');
263 if (empty($datesp) || empty($dateep)) {
264 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
268 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Employee")),
null,
'errors');
271 if (!empty($auto_create_paiement) && (empty($type_payment) || $type_payment < 0)) {
272 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PaymentMode")),
null,
'errors');
276 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount")),
null,
'errors');
280 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankAccount")),
null,
'errors');
292 if (!empty($auto_create_paiement) && !$error) {
295 $paiement->fk_salary =
$object->id;
297 $paiement->datep = $datep;
298 $paiement->datev = $datev;
299 $paiement->amounts = array(
$object->id => $amount);
300 $paiement->fk_typepayment = $type_payment;
301 $paiement->num_payment =
GETPOST(
"num_payment",
'alphanohtml');
302 $paiement->note_private =
GETPOST(
"note",
'restricthtml');
305 $paymentid = $paiement->create($user, (
int)
GETPOST(
'closepaidsalary'));
306 if ($paymentid < 0) {
314 $result = $paiement->addPaymentToBank($user,
'payment_salary',
'(SalaryPayment)',
GETPOSTINT(
'accountid'),
'',
'');
315 if (!($result > 0)) {
325 if (
GETPOST(
'saveandnew',
'alpha')) {
328 'action' =>
'create',
329 'fk_project' => $projectid,
330 'accountid' => $accountid,
336 header(
"Location: ".
dolBuildUrl($_SERVER[
'PHP_SELF'], $query));
350if ($action ==
'confirm_delete' && $permissiontodelete) {
352 $totalpaid =
$object->getSommePaiement();
354 if (empty($totalpaid)) {
360 header(
"Location: ".
dolBuildUrl(DOL_URL_ROOT.
'/salaries/list.php'));
372if ($action ==
'update' && !
GETPOST(
"cancel") && $permissiontoadd) {
375 if (empty($amount)) {
376 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Amount")),
null,
'errors');
378 } elseif (!is_numeric($amount)) {
379 setEventMessages($langs->trans(
"ErrorFieldMustBeANumeric", $langs->transnoentities(
"Amount")),
null,
'errors');
388 $result =
$object->update($user);
395if ($action ==
'confirm_clone' && $confirm !=
'yes') {
399if ($action ==
'confirm_clone' && $confirm ==
'yes' && $permissiontoadd) {
411 if (
GETPOST(
'amount',
'alphanohtml')) {
415 if (
GETPOST(
'clone_label',
'alphanohtml')) {
425 $object->datesp = $newdatestart;
436 header(
"Location: ".
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' => $id]));
452if ($action ==
'update_extras' && $permissiontoeditextra) {
455 $attribute =
GETPOST(
'attribute',
'aZ09');
458 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute);
465 $result =
$object->updateExtraField($attribute,
'SALARY_MODIFY');
473 $action =
'edit_extras';
487$title = $langs->trans(
'Salary').
" - ".
$object->ref;
488if ($action ==
'create') {
489 $title = $langs->trans(
"NewSalary");
504if ($action ==
'create' && $permissiontoadd) {
507 $pastmonthyear = $year_current;
508 if ($pastmonth == 0) {
519 $datesp =
dol_mktime(0, 0, 0, $datespmonth, $datespday, $datespyear);
520 $dateep =
dol_mktime(23, 59, 59, $dateepmonth, $dateepday, $dateepyear);
522 if (empty($datesp) || empty($dateep)) {
527 print
'<form name="salary" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'" method="POST">';
528 print
'<input type="hidden" name="token" value="'.newToken().
'">';
529 print
'<input type="hidden" name="action" value="add">';
531 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
533 if ($backtopageforcancel) {
534 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
539 if (!empty(
$conf->use_javascript_ajax)) {
540 print
"\n".
'<script type="text/javascript">';
542 $(document).ready(function () {
543 let onAutoCreatePaiementChange = function () {
544 if($("#auto_create_paiement").is(":checked")) {
545 $("#label_fk_account").find("span").addClass("fieldrequired");
546 $("#label_type_payment").find("span").addClass("fieldrequired");
547 $(".hide_if_no_auto_create_payment").show();
549 $("#label_fk_account").find("span").removeClass("fieldrequired");
550 $("#label_type_payment").find("span").removeClass("fieldrequired");
551 $(".hide_if_no_auto_create_payment").hide();
554 $("#radiopayment").click(function() {
555 $("#label").val($(this).data("label"));
557 $("#radiorefund").click(function() {
558 $("#label").val($(this).data("label"));
560 $("#auto_create_paiement").click(function () {
561 onAutoCreatePaiementChange();
563 onAutoCreatePaiementChange();
566 // Month shortcut keys for datesp / dateep
567 window.setSalaryDatePeriod = function(offset) {
568 var now = new Date();
569 var year = now.getFullYear();
570 var month = now.getMonth() + 1 + parseInt(offset);
572 if (month < 1) { month = 12; year--; }
573 if (month > 12) { month = 1; year++; }
575 var lastDay = new Date(year, month, 0).getDate();
577 var mm = String(month).padStart(2, "0");
578 var ld = String(lastDay).padStart(2, "0");
579 var yy = String(year);
582 $("#datespday").val("01");
583 $("#datespmonth").val(mm);
584 $("#datespyear").val(yy);
585 $("#datesp").val("01/" + mm + "/" + yy);
588 $("#dateepday").val(ld);
589 $("#dateepmonth").val(mm);
590 $("#dateepyear").val(yy);
591 $("#dateep").val(ld + "/" + mm + "/" + yy);
594 print
'</script>'.
"\n";
599 print
'<table class="border centpercent">';
602 print
'<tr><td class="titlefieldcreate">';
603 print $form->editfieldkey(
'Employee',
'fk_user',
'', $object, 0,
'string',
'', 1).
'</td><td>';
605 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->select_dolusers(
GETPOSTINT(
'fk_user'),
'fk_user', 1,
null, 0,
'',
'',
'0', 0, 0,
'employee:=:1', 0,
'',
'maxwidth300', $noactive);
610 print $form->editfieldkey(
'Label',
'label',
'', $object, 0,
'string',
'', 1).
'</td><td>';
611 print
'<input name="label" id="label" class="minwidth300" value="'.(GETPOST(
"label") ?
GETPOST(
"label") : $langs->trans(
"Salary")).
'">';
616 print $form->editfieldkey(
'DateStartPeriod',
'datesp',
'', $object, 0,
'string',
'', 1).
'</td><td>';
617 print $form->selectDate($datesp,
"datesp", 0, 0, 0,
'add');
620 if (!empty(
$conf->use_javascript_ajax)) {
621 print
'<button type="button" class="dpInvisibleButtons" style="color: var(--colortextlink);font-size: 0.8em;opacity: 0.7;margin-left:4px;" onclick="setSalaryDatePeriod(-1)">'.$langs->trans(
'PreviousMonthShort').
'</button> ';
622 print
'<button type="button" class="dpInvisibleButtons" style="color: var(--colortextlink);font-size: 0.8em;opacity: 0.7;margin-left:4px;" onclick="setSalaryDatePeriod(0)">'.$langs->trans(
'CurrentMonthShort').
'</button> ';
623 print
'<button type="button" class="dpInvisibleButtons" style="color: var(--colortextlink);font-size: 0.8em;opacity: 0.7;margin-left:4px;" onclick="setSalaryDatePeriod(1)">'.$langs->trans(
'NextMonthShort').
'</button>';
629 print $form->editfieldkey(
'DateEndPeriod',
'dateep',
'', $object, 0,
'string',
'', 1).
'</td><td>';
630 print $form->selectDate($dateep,
"dateep", 0, 0, 0,
'add');
635 print $form->editfieldkey(
'Amount',
'amount',
'', $object, 0,
'string',
'', 1).
'</td><td>';
636 print
'<input name="amount" id="amount" class="minwidth75 maxwidth100" value="'.GETPOST(
"amount").
'"> ';
637 print
' <button class="dpInvisibleButtons datenowlink" id="updateAmountWithLastSalary" name="_useless" type="button">'.$langs->trans(
'UpdateAmountWithLastSalary').
'</a>';
645 print
'<tr><td>'.$langs->trans(
"Project").
'</td><td>';
646 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
647 print $formproject->select_projects(-1, (
string) $projectid,
'fk_project', 0, 0, 1, 1, 0, 0, 0,
'', 1);
653 print
'<td class="tdtop">'.$langs->trans(
"Comments").
'</td>';
654 print
'<td class="tdtop"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_3.
'">'.
GETPOST(
'note',
'restricthtml').
'</textarea></td>';
658 print
'<tr><td colspan="2"><hr></td></tr>';
662 print
'<tr><td><label for="auto_create_paiement">'.$langs->trans(
'AutomaticCreationPayment').
'</label></td>';
663 print
'<td><input id="auto_create_paiement" name="auto_create_paiement" type="checkbox" ' . (empty($auto_create_paiement) ?
'' :
'checked="checked"') .
' value="1"></td></tr>'.
"\n";
667 print
'<tr><td id="label_fk_account">';
668 print $form->editfieldkey(
'BankAccount',
'selectaccountid',
'', $object, 0,
'string',
'', 1).
'</td><td>';
669 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
670 $form->select_comptes($accountid,
"accountid", 0,
'', 1);
675 print
'<tr><td id="label_type_payment">';
676 print $form->editfieldkey(
'PaymentMode',
'selectpaymenttype',
'', $object, 0,
'string',
'', 1).
'</td><td>';
677 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
678 print $form->select_types_paiements(
GETPOST(
"paymenttype",
'aZ09'),
"paymenttype",
'');
682 print
'<tr class="hide_if_no_auto_create_payment"><td>';
683 print $form->editfieldkey(
'DatePayment',
'datep',
'', $object, 0,
'string',
'', 1).
'</td><td>';
684 print $form->selectDate((empty($datep) ?
'' : $datep),
"datep", 0, 0, 0,
'add', 1, 1);
688 print
'<tr class="hide_if_no_auto_create_payment"><td>';
689 print $form->editfieldkey(
'DateValue',
'datev',
'', $object, 0).
'</td><td>';
690 print $form->selectDate((empty($datev) ? -1 : $datev),
"datev", 0, 0, 0,
'add', 1, 1);
696 print
'<tr class="hide_if_no_auto_create_payment"><td><label for="num_payment">'.$langs->trans(
'Numero');
697 print
' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
698 print
'</label></td>';
699 print
'<td><input name="num_payment" id="num_payment" type="text" value="'.GETPOST(
"num_payment").
'"></td></tr>'.
"\n";
703 $parameters = array();
704 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
705 print $hookmanager->resPrint;
706 if (empty($reshook)) {
707 print
$object->showOptionals($extrafields,
'create');
714 print
'<div class="center">';
716 print
'<div class="hide_if_no_auto_create_payment paddingbottom">';
717 print
'<input type="checkbox" checked value="1" name="closepaidsalary" id="closepaidsalary" class="marginrightonly"><label for="closepaidsalary" class="opacitymedium">'.$langs->trans(
"ClosePaidSalaryAutomatically").
'</label>';
722 $addition_button = array(
723 'name' =>
'saveandnew',
724 'label_key' =>
'SaveAndNew',
726 print $form->buttonsSaveCancel(
"Save",
"Cancel", $addition_button);
730 print
'$( document ).ready(function() {';
731 print
'$("#updateAmountWithLastSalary").on("click", function updateAmountWithLastSalary() {
732 var fk_user = $("#fk_user").val()
733 var url = "'.DOL_URL_ROOT.
'/salaries/ajax/ajaxsalaries.php?fk_user="+fk_user;
734 console.log("We click on link to autofill salary amount url="+url);
740 console.log("Data returned: "+data);
742 if (typeof data == "object") {
743 console.log("data is already type object, no need to parse it");
746 console.log("data is type "+(typeof data));
747 item = JSON.parse(data);
749 if (item[0].key == "Amount") {
750 value = item[0].value;
751 console.log("amount returned = "+value);
753 $("#amount").val(item[0].value);
755 console.error("Error: Ajax url "+url+" has returned a null value.");
758 console.error("Error: Ajax url "+url+" has returned the wrong key.");
761 console.error("Error: Ajax url "+url+" has returned an empty page.");
767 alert("'.
dol_escape_js($langs->transnoentitiesnoconv(
"FillFieldFirst")).
'");
777 $head = salaries_prepare_head($object);
781 if ($action ===
'clone') {
782 $formquestion = array(
783 array(
'type' =>
'text',
'name' =>
'clone_label',
'label' => $langs->trans(
"Label"),
'value' => $langs->trans(
"CopyOf").
' '.
$object->label),
788 $formquestion[] = array(
'type' =>
'date',
'name' =>
'clone_date_start',
'label' => $langs->trans(
"DateStart"),
'value' => (
$object->dateep) + 86400);
790 $formquestion[] = array(
'type' =>
'date',
'name' =>
'clone_date_start',
'label' => $langs->trans(
"DateStart"),
'value' => -1);
792 $formquestion[] = array(
'type' =>
'date',
'name' =>
'clone_date_end',
'label' => $langs->trans(
"DateEnd"),
'value' => -1);
793 $formquestion[] = array(
'type' =>
'text',
'name' =>
'amount',
'label' => $langs->trans(
"Amount"),
'value' =>
price(
$object->amount),
'morecss' =>
'width100 right');
795 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneSalary',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1, 300);
798 $formconfirm .=
"<script>
799 // Buttons for start date: previous month, current month, previous week, current week
800 $('#clone_date_start').after(
801 $('<button id=\"start_prev_month\" class=\"dpInvisibleButtons\" style=\"color: var(--colortextlink);font-size: 0.8em;opacity: 0.7;margin-left:4px;\" type=\"button\">".$langs->trans(
'PreviousMonthShort').
"</button>')
802 .add('<button id=\"start_curr_month\" class=\"dpInvisibleButtons\" style=\"color: var(--colortextlink);font-size: 0.8em;opacity: 0.7;margin-left:4px;\" type=\"button\">".$langs->trans(
'CurrentMonthShort').
"</button>')
806 .add('<button id=\"start_prev_week\" class=\"dpInvisibleButtons\" style=\"color: var(--colortextlink);font-size: 0.8em;opacity: 0.7;margin-left:4px;\" type=\"button\">".$langs->trans(
'PreviousWeekShort').
"</button>')
807 .add('<button id=\"start_curr_week\" class=\"dpInvisibleButtons\" style=\"color: var(--colortextlink);font-size: 0.8em;opacity: 0.7;margin-left:4px;\" type=\"button\">".$langs->trans(
'CurrentWeekShort').
"</button>')";
812 $('#start_prev_month').click(function(){
813 var now = new Date();
814 var startPrevMonth = new Date(now.getFullYear(), now.getMonth() - 1, 1);
815 setStartDate(startPrevMonth);
818 $('#start_curr_month').click(function(){
819 var now = new Date();
820 var startCurrMonth = new Date(now.getFullYear(), now.getMonth(), 1);
821 setStartDate(startCurrMonth);
824 $('#start_prev_week').click(function(){
825 var now = new Date();
826 var startPrevWeek = new Date(now.setDate(now.getDate() - now.getDay() - 7));
827 startPrevWeek.setDate(startPrevWeek.getDate() + 1);
828 setStartDate(startPrevWeek);
831 $('#start_curr_week').click(function(){
832 var now = new Date();
833 var startCurrWeek = new Date(now.setDate(now.getDate() - now.getDay() + 1));
834 setStartDate(startCurrWeek);
837 function setStartDate(date) {
838 $('#clone_date_start').val(formatDate(date, '".$langs->trans(
"FormatDateShortJavaInput").
"'));
839 $('#clone_date_startday').val(date.getDate());
840 $('#clone_date_startmonth').val(date.getMonth() + 1);
841 $('#clone_date_startyear').val(date.getFullYear());
844 // Button for end date
845 $('#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>'));
846 $('#fill_end_of_month').click(function(){
847 var clone_date_startmonth = +$('#clone_date_startmonth').val();
848 var clone_date_startyear = +$('#clone_date_startyear').val();
851 if (clone_date_startmonth && clone_date_startyear) {
852 end_date = new Date(clone_date_startyear, clone_date_startmonth, 0);
854 var currentDate = new Date();
855 var currentDay = currentDate.getDate();
856 if (currentDay <= 15) {
857 end_date = new Date(currentDate.getFullYear(), currentDate.getMonth(), 0);
859 end_date = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0);
863 $('#clone_date_end').val(formatDate(end_date,'".$langs->trans(
"FormatDateShortJavaInput").
"'));
864 $('#clone_date_endday').val(end_date.getDate());
865 $('#clone_date_endmonth').val(end_date.getMonth() + 1);
866 $('#clone_date_endyear').val(end_date.getFullYear());
871 if ($action ==
'paid') {
872 $text = $langs->trans(
'ConfirmPaySalary');
873 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'PaySalary'), $text,
"confirm_paid",
'',
'', 2);
876 if ($action ==
'delete') {
877 $text = $langs->trans(
'ConfirmDeleteSalary');
878 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id]), $langs->trans(
'DeleteSalary'), $text,
'confirm_delete',
'',
'', 2);
881 if ($action ==
'edit') {
882 print
'<form name="charge" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id,
'action' =>
'update']).
'" method="post">';
883 print
'<input type="hidden" name="token" value="'.newToken().
'">';
887 $parameters = array(
'formConfirm' => $formconfirm);
888 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
889 if (empty($reshook)) {
890 $formconfirm .= $hookmanager->resPrint;
891 } elseif ($reshook > 0) {
892 $formconfirm = $hookmanager->resPrint;
899 print
dol_get_fiche_head($head,
'card', $langs->trans(
"SalaryPayment"), -1,
'salary', 0,
'',
'', 0,
'', 1);
901 $linkback =
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/salaries/list.php', [
'restore_lastsearch_values' => 1]).(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
903 $morehtmlref =
'<div class="refidno">';
906 if ($action !=
'editlabel') {
907 $morehtmlref .= $form->editfieldkey(
"Label",
'label',
$object->label, $object, $permissiontoadd,
'string',
'', 0, 1);
908 $morehtmlref .=
$object->label;
910 $morehtmlref .= $langs->trans(
'Label').
' : ';
911 $morehtmlref .=
'<form method="post" action="'.$pageurl.
'">';
912 $morehtmlref .=
'<input type="hidden" name="action" value="setlabel">';
913 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
914 $morehtmlref .=
'<input type="text" name="label" value="'.$object->label.
'"/>';
915 $morehtmlref .=
'<input type="submit" class="button valignmiddle smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
916 $morehtmlref .=
'</form>';
920 if ($action !=
'editfk_user') {
921 if (
$object->getSommePaiement() > 0 && !empty(
$object->fk_user)) {
923 $result = $userstatic->fetch(
$object->fk_user);
925 $morehtmlref .=
'<br>'.$userstatic->getNomUrl(-1);
928 $morehtmlref .=
'<br>' . $form->editfieldkey(
"",
'fk_user',
$object->label, $object, $permissiontoadd,
'string',
'', 0, 1);
930 if (!empty(
$object->fk_user)) {
932 $result = $userstatic->fetch(
$object->fk_user);
934 $morehtmlref .= $userstatic->getNomUrl(-1);
942 $morehtmlref .=
'<br>';
943 $morehtmlref .=
'<form method="post" action="'.$pageurl.
'">';
944 $morehtmlref .=
'<input type="hidden" name="action" value="setfk_user">';
945 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
946 $morehtmlref .= $form->select_dolusers(
$object->fk_user,
'userid', 1);
947 $morehtmlref .=
'<input type="submit" class="button valignmiddle smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
948 $morehtmlref .=
'</form>';
951 $usercancreate = $permissiontoadd;
955 $langs->load(
"projects");
956 $morehtmlref .=
'<br>';
957 if ($usercancreate) {
958 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
959 if ($action !=
'classify') {
960 $morehtmlref .=
'<a class="editfielda" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], [
'action' =>
'classify',
'id' =>
$object->id],
true).
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
962 $morehtmlref .= $form->form_project($pageurl, -1, (
string)
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
964 if (!empty(
$object->fk_project)) {
966 $proj->fetch(
$object->fk_project);
967 $morehtmlref .= $proj->getNomUrl(1);
969 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
975 $morehtmlref .=
'</div>';
977 $totalpaid =
$object->getSommePaiement();
979 $object->totalpaid = $totalpaid;
980 $object->alreadypaid = $totalpaid;
982 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref,
'', 0,
'',
'');
984 print
'<div class="fichecenter">';
985 print
'<div class="fichehalfleft">';
986 print
'<div class="underbanner clearboth"></div>';
988 print
'<table class="border centpercent tableforfield">';
990 if ($action ==
'edit') {
991 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"DateStartPeriod").
"</td><td>";
992 print $form->selectDate(
$object->datesp,
'datesp', 0, 0, 0,
'datesp', 1);
996 print
'<td class="titlefieldmiddle">' . $langs->trans(
"DateStartPeriod") .
'</td><td>';
1001 if ($action ==
'edit') {
1002 print
'<tr><td>'.$langs->trans(
"DateEndPeriod").
"</td><td>";
1003 print $form->selectDate(
$object->dateep,
'dateep', 0, 0, 0,
'dateep', 1);
1007 print
'<td>' . $langs->trans(
"DateEndPeriod") .
'</td><td>';
1012 if ($action ==
'edit') {
1013 print
'<tr><td class="fieldrequired">' . $langs->trans(
"Amount") .
'</td><td><input name="amount" size="10" value="' .
price(
$object->amount) .
'"></td></tr>';
1015 print
'<tr><td>' . $langs->trans(
"Amount") .
'</td><td><span class="amount">' .
price(
$object->amount, 0, $langs, 1, -1, -1,
$conf->currency) .
'</span></td></tr>';
1020 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1021 print $langs->trans(
'DefaultPaymentMode');
1023 if ($action !=
'editmode') {
1024 print
'<td class="right"><a class="editfielda" href="'.dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'editmode',
'id' =>
$object->id],
true).
'">'.
img_edit($langs->trans(
'SetMode'), 1).
'</a></td>';
1026 print
'</tr></table>';
1029 if ($action ==
'editmode') {
1030 $form->form_modes_reglement($pageurl, (
string)
$object->type_payment,
'mode_reglement_id');
1032 $form->form_modes_reglement($pageurl, (
string)
$object->type_payment,
'none');
1038 print
'<tr><td class="nowrap">';
1039 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
1040 print $langs->trans(
'DefaultBankAccount');
1042 if ($action !=
'editbankaccount' && $permissiontoadd) {
1043 print
'<td class="right"><a class="editfielda" href="'.dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'editbankaccount',
'id' =>
$object->id],
true).
'">'.
img_edit($langs->trans(
'SetBankAccount'), 1).
'</a></td>';
1045 print
'</tr></table>';
1047 if ($action ==
'editbankaccount') {
1048 $form->formSelectAccount($pageurl, (
string)
$object->fk_account,
'fk_account', 1);
1050 $form->formSelectAccount($pageurl, (
string)
$object->fk_account,
'none');
1057 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1063 print
'<div class="fichehalfright">';
1073 $sql =
"SELECT p.rowid, p.num_payment as num_payment, p.datep as dp, p.amount,";
1074 $sql .=
" c.code as type_code,c.libelle as paiement_type,";
1075 $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';
1076 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_salary as p";
1077 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
1078 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
1079 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as c ON p.fk_typepayment = c.id";
1080 $sql .=
", ".MAIN_DB_PREFIX.
"salary as salaire";
1081 $sql .=
" WHERE p.fk_salary = ".((int) $id);
1082 $sql .=
" AND p.fk_salary = salaire.rowid";
1083 $sql .=
" AND salaire.entity IN (".getEntity(
'tax').
")";
1084 $sql .=
" ORDER BY dp DESC";
1086 $resql =
$db->query($sql);
1090 $num =
$db->num_rows($resql);
1093 print
'<div class="div-table-responsive-no-min">';
1094 print
'<table class="noborder paymenttable">';
1095 print
'<tr class="liste_titre">';
1096 print
'<td>'.$langs->trans(
"RefPayment").
'</td>';
1097 print
'<td>'.$langs->trans(
"Date").
'</td>';
1098 print
'<td>'.$langs->trans(
"Type").
'</td>';
1100 print
'<td class="liste_titre right">'.$langs->trans(
'BankAccount').
'</td>';
1102 print
'<td class="right">'.$langs->trans(
"Amount").
'</td>';
1109 $objp = $objp ??
null;
1111 $objp =
$db->fetch_object($resql);
1113 $paymentsalarytemp->id = $objp->rowid;
1114 $paymentsalarytemp->ref = $objp->rowid;
1115 $paymentsalarytemp->num_payment = $objp->num_payment;
1116 $paymentsalarytemp->datep = $objp->dp;
1118 print
'<tr class="oddeven"><td>';
1119 print $paymentsalarytemp->getNomUrl(1);
1121 print
'<td>'.dol_print_date(
$db->jdate($objp->dp),
'dayhour',
'tzuserrel').
"</td>\n";
1122 $labeltype = $langs->trans(
"PaymentType".$objp->type_code) !=
"PaymentType".$objp->type_code ? $langs->trans(
"PaymentType".$objp->type_code) : $objp->paiement_type;
1123 print
"<td>".$labeltype.
' '.$objp->num_payment.
"</td>\n";
1125 $bankaccountstatic->id = $objp->baid;
1126 $bankaccountstatic->ref = $objp->baref;
1127 $bankaccountstatic->label = $objp->baref;
1128 $bankaccountstatic->number = $objp->banumber;
1129 $bankaccountstatic->currency_code = $objp->bacurrency_code;
1132 $bankaccountstatic->account_number = $objp->account_number;
1135 $accountingjournal->fetch($objp->fk_accountancy_journal);
1136 $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
1139 print
'<td class="right">';
1140 if ($bankaccountstatic->id) {
1141 print $bankaccountstatic->getNomUrl(1,
'transactions');
1145 print
'<td class="right nowrap amountcard">'.price($objp->amount).
"</td>\n";
1147 $totalpaid += $objp->amount;
1151 print
'<tr class="oddeven"><td><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td>';
1152 print
'<td></td><td></td><td></td><td></td>';
1156 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AlreadyPaid").
' :</td><td class="right nowrap amountcard">'.
price($totalpaid).
"</td></tr>\n";
1157 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AmountExpected").
' :</td><td class="right nowrap amountcard">'.
price(
$object->amount).
"</td></tr>\n";
1159 $resteapayer = (float)
$object->amount - $totalpaid;
1160 $cssforamountpaymentcomplete =
'amountpaymentcomplete';
1162 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"RemainderToPay").
" :</td>";
1163 print
'<td class="right nowrap'.($resteapayer ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($resteapayer).
"</td></tr>\n";
1176 print
'<div class="clearboth"></div>';
1180 if ($action ==
'edit') {
1181 print $form->buttonsSaveCancel();
1185 $resteapayer =
price2num($resteapayer,
'MT');
1192 print
'<div class="tabsAction">'.
"\n";
1193 if ($action !=
'edit') {
1195 $parameters = array();
1196 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1197 if (empty($reshook)) {
1198 if (empty($user->socid)) {
1199 $canSendMail =
true;
1201 print dolGetButtonAction($langs->trans(
'SendMail'),
'',
'default',
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id,
'action' =>
'presend',
'mode' =>
'init'],
true).
'#formmailbeforetitle',
'', $canSendMail);
1206 if (
$object->status == $object::STATUS_PAID && $permissiontoadd) {
1207 print dolGetButtonAction(
'', $langs->trans(
'ReOpen'),
'default',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'reopen',
'id' =>
$object->id],
true),
'');
1211 if (
$object->status == $object::STATUS_UNPAID && $permissiontoadd) {
1212 print dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'edit',
'id' =>
$object->id]),
'');
1217 print dolGetButtonAction(
'', $langs->trans(
'MakeTransferRequest'),
'default',
dolBuildUrl(DOL_URL_ROOT .
'/salaries/virement_request.php', [
'id' =>
$object->id]),
'');
1222 print dolGetButtonAction(
'', $langs->trans(
'DoPayment'),
'default',
dolBuildUrl(DOL_URL_ROOT.
'/salaries/payment_salary.php', [
'action' =>
'create',
'id' =>
$object->id],
false),
'');
1227 if (
$object->status == $object::STATUS_UNPAID && (($resteapayer <= 0 && $object->
amount > 0) || (
$object->amount <= 0)) && $permissiontoadd) {
1228 print dolGetButtonAction(
'', $langs->trans(
'ClassifyPaid'),
'default',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'paid',
'id' =>
$object->id],
true),
'');
1232 if ($permissiontoadd) {
1233 print dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'clone',
'id' =>
$object->id],
true),
'');
1236 if ($permissiontodelete && empty($totalpaid)) {
1237 print dolGetButtonAction(
'', $langs->trans(
'Delete'),
'delete',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'delete',
'id' =>
$object->id],
true),
'');
1239 print dolGetButtonAction($langs->trans(
'DisabledBecausePayments'), $langs->trans(
'Delete'),
'default',
dolBuildUrl($_SERVER[
'PHP_SELF']).
'#',
'',
false);
1247 if (
GETPOST(
'modelselected')) {
1248 $action =
'presend';
1251 if ($action !=
'presend') {
1252 print
'<div class="fichecenter"><div class="fichehalfleft">';
1253 print
'<a name="builddoc"></a>';
1255 $includedocgeneration = 1;
1258 if ($includedocgeneration) {
1264 $filedir =
$conf->salaries->dir_output.
'/'.
$object->element.
'/'.$objref;
1265 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
1268 $genallowed = ($user->hasRight(
'salaries',
'read') || $user->hasRight(
'salaries',
'readall'));
1269 $delallowed = $user->hasRight(
'salaries',
'write');
1271 print $formfile->showdocuments(
1279 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang
1293 print
'</div><div class="fichehalfright">';
1297 $morehtmlcenter = dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode',
dol_buildpath(
'/mymodule/myobject_agenda.php', 1).
'?id='.
$object->id);
1300 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1304 print
'</div></div>';
1308 if (
GETPOST(
'modelselected')) {
1309 $action =
'presend';
1313 $modelmail =
'salary';
1314 $defaulttopic =
'InformationMessage';
1315 $diroutput =
$conf->salaries->dir_output;
1316 $trackid =
'salary'.$object->id;
1318 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
1321 $parameters = array();
1322 $reshook = $hookmanager->executeHooks(
'salaryCardTabAddMore', $parameters, $object, $action);
$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 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_now($mode='gmt')
Return date for now.
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 '.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
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_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into JavaScript code.
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_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
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).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
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.