35require
'../main.inc.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
45require_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/salaries/class/paymentsalary.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/lib/salaries.lib.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
53 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
54 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
58$langs->loadLangs(array(
"compta",
"banks",
"bills",
"users",
"salaries",
"hrm",
"trips"));
60 $langs->load(
"projects");
65$action =
GETPOST(
'action',
'aZ09');
66$cancel =
GETPOST(
'cancel',
'alpha');
67$backtopage =
GETPOST(
'backtopage',
'alpha');
68$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
70$backurlforlist =
GETPOST(
'backtopage',
'alpha');
72$label =
GETPOST(
'label',
'alphanohtml');
75if (
GETPOSTISSET(
'auto_create_paiement') || $action ===
'add') {
76 $auto_create_paiement =
GETPOSTINT(
"auto_create_paiement");
90$childids = $user->getAllChildIds(1);
93$extrafields->fetch_name_optionals_label(
$object->table_element);
96$hookmanager->initHooks(array(
'salarycard',
'globalcard'));
103 if ($user->hasRight(
'salaries',
'readall')) {
106 if ($user->hasRight(
'salaries',
'read') &&
$object->fk_user > 0 && in_array(
$object->fk_user, $childids)) {
117 $socid = $user->socid;
122$permissiontoread = $user->hasRight(
'salaries',
'read');
123$permissiontoadd = $user->hasRight(
'salaries',
'write');
124$permissiontodelete = $user->hasRight(
'salaries',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_UNPAID);
125$permissiontoeditextra = $permissiontoadd;
126if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
128 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
131$upload_dir =
$conf->salaries->multidir_output[
$conf->entity];
140$parameters = array();
141$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
143 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
146if (empty($reshook)) {
150 $upload_dir =
$conf->salaries->dir_output;
151 $permissiontoadd = $user->hasRight(
'salaries',
'write');
158 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
161 $trackid =
'sal'.$object->id;
162 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
166if ($action ==
'classin' && $permissiontoadd) {
168 $object->setProject($projectid);
172if ($action ==
'setlabel' && $permissiontoadd) {
175 $result =
$object->update($user);
182if ($action ==
'confirm_paid' && $permissiontoadd && $confirm ==
'yes') {
184 $result =
$object->setPaid($user);
187if ($action ==
'setfk_user' && $permissiontoadd) {
191 $result =
$object->update($user);
196 dol_print_error($db);
201if ($action ==
'reopen' && $permissiontoadd) {
204 $result =
$object->set_unpaid($user);
206 header(
'Location: '.
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' => $id]));
215if ($action ==
'setmode' && $permissiontoadd) {
224if ($action ==
'setbankaccount' && $permissiontoadd) {
232if ($action ==
'add' && empty($cancel) && $permissiontoadd) {
251 $object->type_payment = ($type_payment > 0 ? $type_payment : 0);
252 $object->fk_user_author = $user->id;
253 $object->fk_project = $projectid;
256 $fuser =
new User($db);
258 $object->salary = $fuser->salary;
261 $ret = $extrafields->setOptionalsFromPost(
null, $object);
266 if (!empty($auto_create_paiement) && empty($datep)) {
267 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DATE_PAIEMENT")),
null,
'errors');
270 if (empty($datesp) || empty($dateep)) {
271 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
275 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Employee")),
null,
'errors');
278 if (!empty($auto_create_paiement) && (empty($type_payment) || $type_payment < 0)) {
279 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PaymentMode")),
null,
'errors');
283 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount")),
null,
'errors');
287 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankAccount")),
null,
'errors');
299 if (!empty($auto_create_paiement) && !$error) {
302 $paiement->fk_salary =
$object->id;
304 $paiement->datep = $datep;
305 $paiement->datev = $datev;
306 $paiement->amounts = array(
$object->id => $amount);
307 $paiement->fk_typepayment = $type_payment;
308 $paiement->num_payment =
GETPOST(
"num_payment",
'alphanohtml');
309 $paiement->note_private =
GETPOST(
"note",
'restricthtml');
312 $paymentid = $paiement->create($user, (
int)
GETPOST(
'closepaidsalary'));
313 if ($paymentid < 0) {
315 setEventMessages($paiement->error,
null,
'errors');
321 $result = $paiement->addPaymentToBank($user,
'payment_salary',
'(SalaryPayment)',
GETPOSTINT(
'accountid'),
'',
'');
322 if (!($result > 0)) {
324 setEventMessages($paiement->error,
null,
'errors');
332 if (
GETPOST(
'saveandnew',
'alpha')) {
333 setEventMessages($langs->trans(
"RecordSaved"),
null);
335 'action' =>
'create',
336 'fk_project' => $projectid,
337 'accountid' => $accountid,
343 header(
"Location: ".
dolBuildUrl($_SERVER[
'PHP_SELF'], $query));
357if ($action ==
'confirm_delete' && $permissiontodelete) {
359 $totalpaid =
$object->getSommePaiement();
361 if (empty($totalpaid)) {
368 header(
"Location: ".
dolBuildUrl(DOL_URL_ROOT.
'/salaries/list.php'));
375 setEventMessages($langs->trans(
'DisabledBecausePayments'),
null,
'errors');
380if ($action ==
'update' && !
GETPOST(
"cancel") && $permissiontoadd) {
383 if (empty($amount)) {
384 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Amount")),
null,
'errors');
386 } elseif (!is_numeric($amount)) {
387 setEventMessages($langs->trans(
"ErrorFieldMustBeANumeric", $langs->transnoentities(
"Amount")),
null,
'errors');
396 $result =
$object->update($user);
403if ($action ==
'confirm_clone' && $confirm !=
'yes') {
407if ($action ==
'confirm_clone' && $confirm ==
'yes' && $permissiontoadd) {
419 if (
GETPOST(
'amount',
'alphanohtml')) {
423 if (
GETPOST(
'clone_label',
'alphanohtml')) {
433 $object->datesp = $newdatestart;
444 header(
"Location: ".
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' => $id]));
454 dol_print_error($db,
$object->error);
460if ($action ==
'update_extras' && $permissiontoeditextra) {
463 $attribute =
GETPOST(
'attribute',
'aZ09');
466 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute);
468 setEventMessages($extrafields->error,
$object->errors,
'errors');
473 $result =
$object->updateExtraField($attribute,
'SALARY_MODIFY');
481 $action =
'edit_extras';
489$form =
new Form($db);
495$title = $langs->trans(
'Salary').
" - ".
$object->ref;
496if ($action ==
'create') {
497 $title = $langs->trans(
"NewSalary");
511if ($action ==
'create' && $permissiontoadd) {
514 $pastmonthyear = $year_current;
515 if ($pastmonth == 0) {
526 $datesp =
dol_mktime(0, 0, 0, $datespmonth, $datespday, $datespyear);
527 $dateep =
dol_mktime(23, 59, 59, $dateepmonth, $dateepday, $dateepyear);
529 if (empty($datesp) || empty($dateep)) {
534 print
'<form name="salary" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'" method="POST">';
535 print
'<input type="hidden" name="token" value="'.newToken().
'">';
536 print
'<input type="hidden" name="action" value="add">';
538 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
540 if ($backtopageforcancel) {
541 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
546 if (!empty(
$conf->use_javascript_ajax)) {
547 print
"\n".
'<script type="text/javascript">';
549 $(document).ready(function () {
550 let onAutoCreatePaiementChange = function () {
551 if($("#auto_create_paiement").is(":checked")) {
552 $("#label_fk_account").find("span").addClass("fieldrequired");
553 $("#label_type_payment").find("span").addClass("fieldrequired");
554 $(".hide_if_no_auto_create_payment").show();
556 $("#label_fk_account").find("span").removeClass("fieldrequired");
557 $("#label_type_payment").find("span").removeClass("fieldrequired");
558 $(".hide_if_no_auto_create_payment").hide();
561 $("#radiopayment").click(function() {
562 $("#label").val($(this).data("label"));
564 $("#radiorefund").click(function() {
565 $("#label").val($(this).data("label"));
567 $("#auto_create_paiement").click(function () {
568 onAutoCreatePaiementChange();
570 onAutoCreatePaiementChange();
573 // Month shortcut keys for datesp / dateep
574 window.setSalaryDatePeriod = function(offset) {
575 var now = new Date();
576 var year = now.getFullYear();
577 var month = now.getMonth() + 1 + parseInt(offset);
579 if (month < 1) { month = 12; year--; }
580 if (month > 12) { month = 1; year++; }
582 var lastDay = new Date(year, month, 0).getDate();
584 var mm = String(month).padStart(2, "0");
585 var ld = String(lastDay).padStart(2, "0");
586 var yy = String(year);
589 $("#datespday").val("01");
590 $("#datespmonth").val(mm);
591 $("#datespyear").val(yy);
592 $("#datesp").val("01/" + mm + "/" + yy);
595 $("#dateepday").val(ld);
596 $("#dateepmonth").val(mm);
597 $("#dateepyear").val(yy);
598 $("#dateep").val(ld + "/" + mm + "/" + yy);
601 print
'</script>'.
"\n";
606 print
'<table class="border centpercent">';
609 print
'<tr><td class="titlefieldcreate">';
610 print $form->editfieldkey(
'Employee',
'fk_user',
'', $object, 0,
'string',
'', 1).
'</td><td>';
612 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);
617 print $form->editfieldkey(
'Label',
'label',
'', $object, 0,
'string',
'', 1).
'</td><td>';
618 print
'<input name="label" id="label" class="minwidth300" value="'.(GETPOST(
"label") ?
GETPOST(
"label") : $langs->trans(
"Salary")).
'">';
623 print $form->editfieldkey(
'DateStartPeriod',
'datesp',
'', $object, 0,
'string',
'', 1).
'</td><td>';
624 print $form->selectDate($datesp,
"datesp", 0, 0, 0,
'add');
627 if (!empty(
$conf->use_javascript_ajax)) {
628 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> ';
629 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> ';
630 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>';
636 print $form->editfieldkey(
'DateEndPeriod',
'dateep',
'', $object, 0,
'string',
'', 1).
'</td><td>';
637 print $form->selectDate($dateep,
"dateep", 0, 0, 0,
'add');
642 print $form->editfieldkey(
'Amount',
'amount',
'', $object, 0,
'string',
'', 1).
'</td><td>';
643 print
'<input name="amount" id="amount" class="minwidth75 maxwidth100" value="'.GETPOST(
"amount").
'"> ';
644 print
' <button class="dpInvisibleButtons datenowlink" id="updateAmountWithLastSalary" name="_useless" type="button">'.$langs->trans(
'UpdateAmountWithLastSalary').
'</a>';
652 print
'<tr><td>'.$langs->trans(
"Project").
'</td><td>';
653 print img_picto(
'',
'project',
'class="pictofixedwidth"');
654 print $formproject->select_projects(-1, (
string) $projectid,
'fk_project', 0, 0, 1, 1, 0, 0, 0,
'', 1);
660 print
'<td class="tdtop">'.$langs->trans(
"Comments").
'</td>';
661 print
'<td class="tdtop"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_3.
'">'.
GETPOST(
'note',
'restricthtml').
'</textarea></td>';
665 print
'<tr><td colspan="2"><hr></td></tr>';
669 print
'<tr><td><label for="auto_create_paiement">'.$langs->trans(
'AutomaticCreationPayment').
'</label></td>';
670 print
'<td><input id="auto_create_paiement" name="auto_create_paiement" type="checkbox" ' . (empty($auto_create_paiement) ?
'' :
'checked="checked"') .
' value="1"></td></tr>'.
"\n";
674 print
'<tr><td id="label_fk_account">';
675 print $form->editfieldkey(
'BankAccount',
'selectaccountid',
'', $object, 0,
'string',
'', 1).
'</td><td>';
676 print img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
677 $form->select_comptes($accountid,
"accountid", 0,
'', 1);
682 print
'<tr><td id="label_type_payment">';
683 print $form->editfieldkey(
'PaymentMode',
'selectpaymenttype',
'', $object, 0,
'string',
'', 1).
'</td><td>';
684 print img_picto(
'',
'bank',
'class="pictofixedwidth"');
685 print $form->select_types_paiements(
GETPOST(
"paymenttype",
'aZ09'),
"paymenttype",
'');
689 print
'<tr class="hide_if_no_auto_create_payment"><td>';
690 print $form->editfieldkey(
'DatePayment',
'datep',
'', $object, 0,
'string',
'', 1).
'</td><td>';
691 print $form->selectDate((empty($datep) ?
'' : $datep),
"datep", 0, 0, 0,
'add', 1, 1);
695 print
'<tr class="hide_if_no_auto_create_payment"><td>';
696 print $form->editfieldkey(
'DateValue',
'datev',
'', $object, 0).
'</td><td>';
697 print $form->selectDate((empty($datev) ? -1 : $datev),
"datev", 0, 0, 0,
'add', 1, 1);
703 print
'<tr class="hide_if_no_auto_create_payment"><td><label for="num_payment">'.$langs->trans(
'Numero');
704 print
' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
705 print
'</label></td>';
706 print
'<td><input name="num_payment" id="num_payment" type="text" value="'.GETPOST(
"num_payment").
'"></td></tr>'.
"\n";
710 $parameters = array();
711 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
712 print $hookmanager->resPrint;
713 if (empty($reshook)) {
714 print
$object->showOptionals($extrafields,
'create');
721 print
'<div class="center">';
723 print
'<div class="hide_if_no_auto_create_payment paddingbottom">';
724 print
'<input type="checkbox" checked value="1" name="closepaidsalary" id="closepaidsalary" class="marginrightonly"><label for="closepaidsalary" class="opacitymedium">'.$langs->trans(
"ClosePaidSalaryAutomatically").
'</label>';
729 $addition_button = array(
730 'name' =>
'saveandnew',
731 'label_key' =>
'SaveAndNew',
733 print $form->buttonsSaveCancel(
"Save",
"Cancel", $addition_button);
737 print
'$( document ).ready(function() {';
738 print
'$("#updateAmountWithLastSalary").on("click", function updateAmountWithLastSalary() {
739 var fk_user = $("#fk_user").val()
740 var url = "'.DOL_URL_ROOT.
'/salaries/ajax/ajaxsalaries.php?fk_user="+fk_user;
741 console.log("We click on link to autofill salary amount url="+url);
747 console.log("Data returned: "+data);
749 if (typeof data == "object") {
750 console.log("data is already type object, no need to parse it");
753 console.log("data is type "+(typeof data));
754 item = JSON.parse(data);
756 if (item[0].key == "Amount") {
757 value = item[0].value;
758 console.log("amount returned = "+value);
760 $("#amount").val(item[0].value);
762 console.error("Error: Ajax url "+url+" has returned a null value.");
765 console.error("Error: Ajax url "+url+" has returned the wrong key.");
768 console.error("Error: Ajax url "+url+" has returned an empty page.");
774 alert(\''.
dol_escape_js($langs->transnoentitiesnoconv(
"FillFieldFirst")).
'\');
784 $head = salaries_prepare_head($object);
786 $pageurl = dolBuildUrl($_SERVER['PHP_SELF
'], ['id' => $object->id]);
788 if ($action === 'clone
') {
789 $formquestion = array(
790 array('type' => 'text
', 'name' => 'clone_label
', 'label
' => $langs->trans("Label"), 'value
' => $langs->trans("CopyOf").' '.$object->label),
793 //$formquestion[] = array('type' => 'date', 'name' => 'clone_date_ech
', 'label
' => $langs->trans("Date"), 'value
' => -1);
794 if (!empty($object->dateep)) {
795 $formquestion[] = array('type' => 'date', 'name' => 'clone_date_start
', 'label
' => $langs->trans("DateStart"), 'value
' => ($object->dateep) + 86400);
797 $formquestion[] = array('type' => 'date', 'name' => 'clone_date_start
', 'label
' => $langs->trans("DateStart"), 'value
' => -1);
799 $formquestion[] = array('type' => 'date', 'name' => 'clone_date_end
', 'label
' => $langs->trans("DateEnd"), 'value
' => -1);
800 $formquestion[] = array('type' => 'text
', 'name' => 'amount', 'label
' => $langs->trans("Amount"), 'value
' => price($object->amount), 'morecss
' => 'width100 right
');
802 $formconfirm = $form->formconfirm(dolBuildUrl($_SERVER["PHP_SELF"], ['id' => $object->id]), $langs->trans('ToClone
'), $langs->trans('ConfirmCloneSalary
', $object->ref), 'confirm_clone
', $formquestion, 'yes
', 1, 0);
804 // Add buttons to fill start and end dates
805 $formconfirm .= "<script>
806 // Buttons for start date: previous month, current month, previous week, current week
807 $('#clone_date_start
').after(
808 $('<
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>')
809 .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>')
813 .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>')
814 .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>')";
819 $('#start_prev_month').click(function(){
820 var now = new Date();
821 var startPrevMonth = new Date(now.getFullYear(), now.getMonth() - 1, 1);
822 setStartDate(startPrevMonth);
825 $('#start_curr_month').click(function(){
826 var now = new Date();
827 var startCurrMonth = new Date(now.getFullYear(), now.getMonth(), 1);
828 setStartDate(startCurrMonth);
831 $('#start_prev_week').click(function(){
832 var now = new Date();
833 var startPrevWeek = new Date(now.setDate(now.getDate() - now.getDay() - 7));
834 startPrevWeek.setDate(startPrevWeek.getDate() + 1);
835 setStartDate(startPrevWeek);
838 $('#start_curr_week').click(function(){
839 var now = new Date();
840 var startCurrWeek = new Date(now.setDate(now.getDate() - now.getDay() + 1));
841 setStartDate(startCurrWeek);
844 function setStartDate(date) {
845 $('#clone_date_start').val(formatDate(date, '".$langs->trans(
"FormatDateShortJavaInput").
"'));
846 $('#clone_date_startday').val(date.getDate());
847 $('#clone_date_startmonth').val(date.getMonth() + 1);
848 $('#clone_date_startyear').val(date.getFullYear());
851 // Button for end date
852 $('#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>'));
853 $('#fill_end_of_month').click(function(){
854 var clone_date_startmonth = +$('#clone_date_startmonth').val();
855 var clone_date_startyear = +$('#clone_date_startyear').val();
858 if (clone_date_startmonth && clone_date_startyear) {
859 end_date = new Date(clone_date_startyear, clone_date_startmonth, 0);
861 var currentDate = new Date();
862 var currentDay = currentDate.getDate();
863 if (currentDay <= 15) {
864 end_date = new Date(currentDate.getFullYear(), currentDate.getMonth(), 0);
866 end_date = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0);
870 $('#clone_date_end').val(formatDate(end_date,'".$langs->trans(
"FormatDateShortJavaInput").
"'));
871 $('#clone_date_endday').val(end_date.getDate());
872 $('#clone_date_endmonth').val(end_date.getMonth() + 1);
873 $('#clone_date_endyear').val(end_date.getFullYear());
878 if ($action ==
'paid') {
879 $text = $langs->trans(
'ConfirmPaySalary');
880 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'PaySalary'), $text,
"confirm_paid",
'',
'', 2);
883 if ($action ==
'delete') {
884 $text = $langs->trans(
'ConfirmDeleteSalary');
885 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id]), $langs->trans(
'DeleteSalary'), $text,
'confirm_delete',
'',
'', 2);
888 if ($action ==
'edit') {
889 print
'<form name="charge" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id,
'action' =>
'update']).
'" method="post">';
890 print
'<input type="hidden" name="token" value="'.newToken().
'">';
894 $parameters = array(
'formConfirm' => $formconfirm);
895 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
896 if (empty($reshook)) {
897 $formconfirm .= $hookmanager->resPrint;
898 } elseif ($reshook > 0) {
899 $formconfirm = $hookmanager->resPrint;
906 print
dol_get_fiche_head($head,
'card', $langs->trans(
"SalaryPayment"), -1,
'salary', 0,
'',
'', 0,
'', ($action ==
'edit' ? 0 : 1));
908 $linkback =
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/salaries/list.php', [
'restore_lastsearch_values' => 1]).(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
910 $morehtmlref =
'<div class="refidno">';
913 if ($action !=
'editlabel') {
914 $morehtmlref .= $form->editfieldkey(
"Label",
'label',
$object->label, $object, $permissiontoadd,
'string',
'', 0, 1);
915 $morehtmlref .=
$object->label;
917 $morehtmlref .= $langs->trans(
'Label').
' : ';
918 $morehtmlref .=
'<form method="post" action="'.$pageurl.
'">';
919 $morehtmlref .=
'<input type="hidden" name="action" value="setlabel">';
920 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
921 $morehtmlref .=
'<input type="text" name="label" value="'.$object->label.
'"/>';
922 $morehtmlref .=
'<input type="submit" class="button valignmiddle smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
923 $morehtmlref .=
'</form>';
927 if ($action !=
'editfk_user') {
928 if (
$object->getSommePaiement() > 0 && !empty(
$object->fk_user)) {
929 $userstatic =
new User($db);
930 $result = $userstatic->fetch(
$object->fk_user);
932 $morehtmlref .=
'<br>'.$userstatic->getNomUrl(-1);
935 $morehtmlref .=
'<br>' . $form->editfieldkey(
"",
'fk_user',
$object->label, $object, $permissiontoadd,
'string',
'', 0, 1);
937 if (!empty(
$object->fk_user)) {
938 $userstatic =
new User($db);
939 $result = $userstatic->fetch(
$object->fk_user);
941 $morehtmlref .= $userstatic->getNomUrl(-1);
943 dol_print_error($db);
949 $morehtmlref .=
'<br>';
950 $morehtmlref .=
'<form method="post" action="'.$pageurl.
'">';
951 $morehtmlref .=
'<input type="hidden" name="action" value="setfk_user">';
952 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
953 $morehtmlref .= $form->select_dolusers(
$object->fk_user,
'userid', 1);
954 $morehtmlref .=
'<input type="submit" class="button valignmiddle smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
955 $morehtmlref .=
'</form>';
958 $usercancreate = $permissiontoadd;
962 $langs->load(
"projects");
963 $morehtmlref .=
'<br>';
964 if ($usercancreate) {
965 $morehtmlref .= img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
966 if ($action !=
'classify') {
967 $morehtmlref .=
'<a class="editfielda" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], [
'action' =>
'classify',
'id' =>
$object->id],
true).
'">'.img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
969 $morehtmlref .= $form->form_project($pageurl, -1, (
string)
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
971 if (!empty(
$object->fk_project)) {
973 $proj->fetch(
$object->fk_project);
974 $morehtmlref .= $proj->getNomUrl(1);
976 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
982 $morehtmlref .=
'</div>';
984 $totalpaid =
$object->getSommePaiement();
986 $object->totalpaid = $totalpaid;
987 $object->alreadypaid = $totalpaid;
989 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref,
'', 0,
'',
'');
991 print
'<div class="fichecenter">';
992 print
'<div class="fichehalfleft">';
993 print
'<div class="underbanner clearboth"></div>';
995 print
'<table class="border centpercent tableforfield">';
997 if ($action ==
'edit') {
998 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"DateStartPeriod").
"</td><td>";
999 print $form->selectDate(
$object->datesp,
'datesp', 0, 0, 0,
'datesp', 1);
1003 print
'<td class="titlefieldmiddle">' . $langs->trans(
"DateStartPeriod") .
'</td><td>';
1008 if ($action ==
'edit') {
1009 print
'<tr><td>'.$langs->trans(
"DateEndPeriod").
"</td><td>";
1010 print $form->selectDate(
$object->dateep,
'dateep', 0, 0, 0,
'dateep', 1);
1014 print
'<td>' . $langs->trans(
"DateEndPeriod") .
'</td><td>';
1019 if ($action ==
'edit') {
1020 print
'<tr><td class="fieldrequired">' . $langs->trans(
"Amount") .
'</td><td><input name="amount" size="10" value="' .
price(
$object->amount) .
'"></td></tr>';
1022 print
'<tr><td>' . $langs->trans(
"Amount") .
'</td><td><span class="amount">' .
price(
$object->amount, 0, $langs, 1, -1, -1,
$conf->currency) .
'</span></td></tr>';
1027 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1028 print $langs->trans(
'DefaultPaymentMode');
1030 if ($action !=
'editmode') {
1031 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>';
1033 print
'</tr></table>';
1036 if ($action ==
'editmode') {
1037 $form->form_modes_reglement($pageurl, (
string)
$object->type_payment,
'mode_reglement_id');
1039 $form->form_modes_reglement($pageurl, (
string)
$object->type_payment,
'none');
1045 print
'<tr><td class="nowrap">';
1046 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
1047 print $langs->trans(
'DefaultBankAccount');
1049 if ($action !=
'editbankaccount' && $permissiontoadd) {
1050 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>';
1052 print
'</tr></table>';
1054 if ($action ==
'editbankaccount') {
1055 $form->formSelectAccount($pageurl, (
string)
$object->fk_account,
'fk_account', 1);
1057 $form->formSelectAccount($pageurl, (
string)
$object->fk_account,
'none');
1064 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1070 print
'<div class="fichehalfright">';
1080 $sql =
"SELECT p.rowid, p.num_payment as num_payment, p.datep as dp, p.amount,";
1081 $sql .=
" c.code as type_code,c.libelle as paiement_type,";
1082 $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';
1083 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_salary as p";
1084 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
1085 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
1086 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as c ON p.fk_typepayment = c.id";
1087 $sql .=
", ".MAIN_DB_PREFIX.
"salary as salaire";
1088 $sql .=
" WHERE p.fk_salary = ".((int) $id);
1089 $sql .=
" AND p.fk_salary = salaire.rowid";
1090 $sql .=
" AND salaire.entity IN (".getEntity(
'tax').
")";
1091 $sql .=
" ORDER BY dp DESC";
1093 $resql = $db->query($sql);
1097 $num = $db->num_rows($resql);
1100 print
'<div class="div-table-responsive-no-min">';
1101 print
'<table class="noborder paymenttable">';
1102 print
'<tr class="liste_titre">';
1103 print
'<td>'.$langs->trans(
"RefPayment").
'</td>';
1104 print
'<td>'.$langs->trans(
"Date").
'</td>';
1105 print
'<td>'.$langs->trans(
"Type").
'</td>';
1107 print
'<td class="liste_titre right">'.$langs->trans(
'BankAccount').
'</td>';
1109 print
'<td class="right">'.$langs->trans(
"Amount").
'</td>';
1115 $bankaccountstatic =
new Account($db);
1116 $objp = $objp ??
null;
1118 $objp = $db->fetch_object($resql);
1120 $paymentsalarytemp->id = $objp->rowid;
1121 $paymentsalarytemp->ref = $objp->rowid;
1122 $paymentsalarytemp->num_payment = $objp->num_payment;
1123 $paymentsalarytemp->datep = $objp->dp;
1125 print
'<tr class="oddeven"><td>';
1126 print $paymentsalarytemp->getNomUrl(1);
1128 print
'<td>'.dol_print_date($db->jdate($objp->dp),
'dayhour',
'tzuserrel').
"</td>\n";
1129 $labeltype = $langs->trans(
"PaymentType".$objp->type_code) !=
"PaymentType".$objp->type_code ? $langs->trans(
"PaymentType".$objp->type_code) : $objp->paiement_type;
1130 print
"<td>".$labeltype.
' '.$objp->num_payment.
"</td>\n";
1132 $bankaccountstatic->id = $objp->baid;
1133 $bankaccountstatic->ref = $objp->baref;
1134 $bankaccountstatic->label = $objp->baref;
1135 $bankaccountstatic->number = $objp->banumber;
1136 $bankaccountstatic->currency_code = $objp->bacurrency_code;
1139 $bankaccountstatic->account_number = $objp->account_number;
1142 $accountingjournal->fetch($objp->fk_accountancy_journal);
1143 $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
1146 print
'<td class="right">';
1147 if ($bankaccountstatic->id) {
1148 print $bankaccountstatic->getNomUrl(1,
'transactions');
1152 print
'<td class="right nowrap amountcard">'.price($objp->amount).
"</td>\n";
1154 $totalpaid += $objp->amount;
1158 print
'<tr class="oddeven"><td><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td>';
1159 print
'<td></td><td></td><td></td><td></td>';
1163 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AlreadyPaid").
' :</td><td class="right nowrap amountcard">'.
price($totalpaid).
"</td></tr>\n";
1164 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AmountExpected").
' :</td><td class="right nowrap amountcard">'.
price(
$object->amount).
"</td></tr>\n";
1166 $resteapayer = (float)
$object->amount - $totalpaid;
1167 $cssforamountpaymentcomplete =
'amountpaymentcomplete';
1169 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"RemainderToPay").
" :</td>";
1170 print
'<td class="right nowrap'.($resteapayer ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($resteapayer).
"</td></tr>\n";
1177 dol_print_error($db);
1183 print
'<div class="clearboth"></div>';
1187 if ($action ==
'edit') {
1188 print $form->buttonsSaveCancel();
1192 $resteapayer =
price2num($resteapayer,
'MT');
1199 print
'<div class="tabsAction">'.
"\n";
1200 if ($action !=
'edit') {
1202 $parameters = array();
1203 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1204 if (empty($reshook)) {
1205 if (empty($user->socid)) {
1206 $canSendMail =
true;
1208 print dolGetButtonAction($langs->trans(
'SendMail'),
'',
'default',
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id,
'action' =>
'presend',
'mode' =>
'init'],
true).
'#formmailbeforetitle',
'', $canSendMail);
1213 if (
$object->status == $object::STATUS_PAID && $permissiontoadd) {
1214 print dolGetButtonAction(
'', $langs->trans(
'ReOpen'),
'default',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'reopen',
'id' =>
$object->id],
true),
'');
1218 if (
$object->status == $object::STATUS_UNPAID && $permissiontoadd) {
1219 print dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'edit',
'id' =>
$object->id]),
'');
1224 print dolGetButtonAction(
'', $langs->trans(
'MakeTransferRequest'),
'default',
dolBuildUrl(DOL_URL_ROOT .
'/salaries/virement_request.php', [
'id' =>
$object->id]),
'');
1229 print dolGetButtonAction(
'', $langs->trans(
'DoPayment'),
'default',
dolBuildUrl(DOL_URL_ROOT.
'/salaries/payment_salary.php', [
'action' =>
'create',
'id' =>
$object->id],
false),
'');
1234 if (
$object->status == $object::STATUS_UNPAID && (($resteapayer <= 0 && $object->
amount > 0) || (
$object->amount <= 0)) && $permissiontoadd) {
1235 print dolGetButtonAction(
'', $langs->trans(
'ClassifyPaid'),
'default',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'paid',
'id' =>
$object->id],
true),
'');
1239 if ($permissiontoadd) {
1240 print dolGetButtonAction($langs->trans(
'ToClone'), $langs->trans(
'ToClone'),
'clone',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'clone',
'id' =>
$object->id],
true),
'',
true, array(
'attr' => array(
'class' =>
'reposition')));
1243 if ($permissiontodelete && empty($totalpaid)) {
1244 print dolGetButtonAction($langs->trans(
'Delete'), $langs->trans(
'Delete'),
'delete',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'delete',
'id' =>
$object->id],
true),
'',
true, array(
'attr' => array(
'class' =>
'reposition'))).
"\n";
1246 print dolGetButtonAction($langs->trans(
'DisabledBecausePayments'), $langs->trans(
'Delete'),
'default',
dolBuildUrl($_SERVER[
'PHP_SELF']).
'#',
'',
false);
1254 if (
GETPOST(
'modelselected')) {
1255 $action =
'presend';
1258 if ($action !=
'presend') {
1259 print
'<div class="fichecenter"><div class="fichehalfleft">';
1260 print
'<a name="builddoc"></a>';
1262 $includedocgeneration = 1;
1265 if ($includedocgeneration) {
1271 $filedir =
$conf->salaries->dir_output.
'/'.
$object->element.
'/'.$objref;
1272 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
1275 $genallowed = ($user->hasRight(
'salaries',
'read') || $user->hasRight(
'salaries',
'readall'));
1276 $delallowed = $user->hasRight(
'salaries',
'write');
1278 print $formfile->showdocuments(
1286 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang
1300 print
'</div><div class="fichehalfright">';
1307 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1311 print
'</div></div>';
1315 if (
GETPOST(
'modelselected')) {
1316 $action =
'presend';
1320 $modelmail =
'salary';
1321 $defaulttopic =
'InformationMessage';
1322 $diroutput =
$conf->salaries->dir_output;
1323 $trackid =
'salary'.$object->id;
1325 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
1328 $parameters = array();
1329 $reshook = $hookmanager->executeHooks(
'salaryCardTabAddMore', $parameters, $object, $action);
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
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.
recordNotFound($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Displays an error page when a record is not found.
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...
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_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, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_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).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
multi select button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
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.
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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
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 date
$conf db name
Only used if Module[ID]Name translation string is not found.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
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.