34require
'../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
37require_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/salaries/class/paymentsalary.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/salaries.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
44if (isModEnabled(
'project')) {
45 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
58$langs->loadLangs(array(
"compta",
"banks",
"bills",
"users",
"salaries",
"hrm",
"trips"));
59if (isModEnabled(
'project')) {
60 $langs->load(
"projects");
65$action =
GETPOST(
'action',
'aZ09');
66$cancel =
GETPOST(
'cancel',
'alpha');
67$backtopage =
GETPOST(
'backtopage',
'alpha');
68$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'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];
138$parameters = array();
140$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
145if (empty($reshook)) {
148 $backurlforlist = DOL_URL_ROOT.
'/salaries/list.php';
150 if (empty($backtopage) || ($cancel && empty($id))) {
151 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
152 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
153 $backtopage = $backurlforlist;
155 $backtopage = DOL_URL_ROOT.
'/salaries/card.php?id='.(
$id > 0 ?
$id :
'__ID__');
163 if (!empty($backtopageforcancel)) {
164 header(
"Location: ".$backtopageforcancel);
166 } elseif (!empty($backtopage)) {
167 header(
"Location: ".$backtopage);
174 $triggersendname =
'COMPANY_SENTBYMAIL';
176 $mode =
'emailfromthirdparty';
177 $trackid =
'sal'.$object->id;
178 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
182 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
186if ($action ==
'classin' && $permissiontoadd) {
188 $object->setProject($projectid);
192if ($action ==
'setlabel' && $permissiontoadd) {
199if ($action ==
'confirm_paid' && $permissiontoadd && $confirm ==
'yes') {
201 $result =
$object->setPaid($user);
204if ($action ==
'setfk_user' && $permissiontoadd) {
215if ($action ==
'reopen' && $permissiontoadd) {
218 $result =
$object->set_unpaid($user);
220 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
229if ($action ==
'setmode' && $permissiontoadd) {
238if ($action ==
'setbankaccount' && $permissiontoadd) {
246if ($action ==
'add' && empty($cancel) && $permissiontoadd) {
265 $object->type_payment = ($type_payment > 0 ? $type_payment : 0);
266 $object->fk_user_author = $user->id;
267 $object->fk_project = $projectid;
270 $fuser =
new User($db);
272 $object->salary = $fuser->salary;
275 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
280 if (!empty($auto_create_paiement) && empty($datep)) {
281 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DATE_PAIEMENT")),
null,
'errors');
284 if (empty($datesp) || empty($dateep)) {
285 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
289 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Employee")),
null,
'errors');
292 if (!empty($auto_create_paiement) && (empty($type_payment) || $type_payment < 0)) {
293 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PaymentMode")),
null,
'errors');
297 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount")),
null,
'errors');
300 if (isModEnabled(
"bank") && !empty($auto_create_paiement) && !
$object->accountid > 0) {
301 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankAccount")),
null,
'errors');
313 if (!empty($auto_create_paiement) && !$error) {
316 $paiement->fk_salary =
$object->id;
318 $paiement->datep = $datep;
319 $paiement->datev = $datev;
320 $paiement->amounts = array(
$object->id => $amount);
321 $paiement->fk_typepayment = $type_payment;
322 $paiement->num_payment =
GETPOST(
"num_payment",
'alphanohtml');
323 $paiement->note_private =
GETPOST(
"note",
'restricthtml');
326 $paymentid = $paiement->create($user, (
int)
GETPOST(
'closepaidsalary'));
327 if ($paymentid < 0) {
335 $result = $paiement->addPaymentToBank($user,
'payment_salary',
'(SalaryPayment)',
GETPOSTINT(
'accountid'),
'',
'');
336 if (!($result > 0)) {
346 if (
GETPOST(
'saveandnew',
'alpha')) {
348 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"));
351 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id);
362if ($action ==
'confirm_delete' && $permissiontodelete) {
364 $totalpaid =
$object->getSommePaiement();
366 if (empty($totalpaid)) {
372 header(
"Location: ".DOL_URL_ROOT.
'/salaries/list.php');
384if ($action ==
'update' && !
GETPOST(
"cancel") && $permissiontoadd) {
387 if (empty($amount)) {
388 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Amount")),
null,
'errors');
390 } elseif (!is_numeric($amount)) {
391 setEventMessages($langs->trans(
"ErrorFieldMustBeANumeric", $langs->transnoentities(
"Amount")),
null,
'errors');
400 $result =
$object->update($user);
407if ($action ==
'confirm_clone' && $confirm !=
'yes') {
411if ($action ==
'confirm_clone' && $confirm ==
'yes' && $permissiontoadd) {
423 if (
GETPOST(
'amount',
'alphanohtml')) {
427 if (
GETPOST(
'clone_label',
'alphanohtml')) {
437 $object->datesp = $newdatestart;
448 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
464if ($action ==
'update_extras' && $permissiontoeditextra) {
467 $attribute =
GETPOST(
'attribute',
'aZ09');
470 $ret = $extrafields->setOptionalsFromPost(
null,
$object, $attribute);
477 $result =
$object->updateExtraField($attribute,
'SALARY_MODIFY');
485 $action =
'edit_extras';
494$form =
new Form($db);
496if (isModEnabled(
'project')) {
500$title = $langs->trans(
'Salary').
" - ".
$object->ref;
501if ($action ==
'create') {
502 $title = $langs->trans(
"NewSalary");
517if ($action ==
'create' && $permissiontoadd) {
520 $pastmonthyear = $year_current;
521 if ($pastmonth == 0) {
532 $datesp =
dol_mktime(0, 0, 0, $datespmonth, $datespday, $datespyear);
533 $dateep =
dol_mktime(23, 59, 59, $dateepmonth, $dateepday, $dateepyear);
535 if (empty($datesp) || empty($dateep)) {
540 print
'<form name="salary" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
541 print
'<input type="hidden" name="token" value="'.newToken().
'">';
542 print
'<input type="hidden" name="action" value="add">';
544 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
546 if ($backtopageforcancel) {
547 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
552 if (!empty(
$conf->use_javascript_ajax)) {
553 print
"\n".
'<script type="text/javascript">';
555 $(document).ready(function () {
556 let onAutoCreatePaiementChange = function () {
557 if($("#auto_create_paiement").is(":checked")) {
558 $("#label_fk_account").find("span").addClass("fieldrequired");
559 $("#label_type_payment").find("span").addClass("fieldrequired");
560 $(".hide_if_no_auto_create_payment").show();
562 $("#label_fk_account").find("span").removeClass("fieldrequired");
563 $("#label_type_payment").find("span").removeClass("fieldrequired");
564 $(".hide_if_no_auto_create_payment").hide();
567 $("#radiopayment").click(function() {
568 $("#label").val($(this).data("label"));
570 $("#radiorefund").click(function() {
571 $("#label").val($(this).data("label"));
573 $("#auto_create_paiement").click(function () {
574 onAutoCreatePaiementChange();
576 onAutoCreatePaiementChange();
579 print
'</script>'.
"\n";
584 print
'<table class="border centpercent">';
587 print
'<tr><td class="titlefieldcreate">';
588 print $form->editfieldkey(
'Employee',
'fk_user',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
590 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);
595 print $form->editfieldkey(
'Label',
'label',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
596 print
'<input name="label" id="label" class="minwidth300" value="'.(GETPOST(
"label") ?
GETPOST(
"label") : $langs->trans(
"Salary")).
'">';
601 print $form->editfieldkey(
'DateStartPeriod',
'datesp',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
602 print $form->selectDate($datesp,
"datesp", 0, 0, 0,
'add');
607 print $form->editfieldkey(
'DateEndPeriod',
'dateep',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
608 print $form->selectDate($dateep,
"dateep", 0, 0, 0,
'add');
613 print $form->editfieldkey(
'Amount',
'amount',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
614 print
'<input name="amount" id="amount" class="minwidth75 maxwidth100" value="'.GETPOST(
"amount").
'"> ';
615 print
' <button class="dpInvisibleButtons datenowlink" id="updateAmountWithLastSalary" name="_useless" type="button">'.$langs->trans(
'UpdateAmountWithLastSalary').
'</a>';
620 if (isModEnabled(
'project')) {
623 print
'<tr><td>'.$langs->trans(
"Project").
'</td><td>';
624 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
625 print $formproject->select_projects(-1, (
string) $projectid,
'fk_project', 0, 0, 1, 1, 0, 0, 0,
'', 1);
631 print
'<td class="tdtop">'.$langs->trans(
"Comments").
'</td>';
632 print
'<td class="tdtop"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_3.
'">'.
GETPOST(
'note',
'restricthtml').
'</textarea></td>';
636 print
'<tr><td colspan="2"><hr></td></tr>';
640 print
'<tr><td><label for="auto_create_paiement">'.$langs->trans(
'AutomaticCreationPayment').
'</label></td>';
641 print
'<td><input id="auto_create_paiement" name="auto_create_paiement" type="checkbox" ' . (empty($auto_create_paiement) ?
'' :
'checked="checked"') .
' value="1"></td></tr>'.
"\n";
644 if (isModEnabled(
"bank")) {
645 print
'<tr><td id="label_fk_account">';
646 print $form->editfieldkey(
'BankAccount',
'selectaccountid',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
647 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
648 $form->select_comptes($accountid,
"accountid", 0,
'', 1);
653 print
'<tr><td id="label_type_payment">';
654 print $form->editfieldkey(
'PaymentMode',
'selectpaymenttype',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
655 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
656 print $form->select_types_paiements(
GETPOST(
"paymenttype",
'aZ09'),
"paymenttype",
'');
660 print
'<tr class="hide_if_no_auto_create_payment"><td>';
661 print $form->editfieldkey(
'DatePayment',
'datep',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
662 print $form->selectDate((empty($datep) ?
'' : $datep),
"datep", 0, 0, 0,
'add', 1, 1);
666 print
'<tr class="hide_if_no_auto_create_payment"><td>';
667 print $form->editfieldkey(
'DateValue',
'datev',
'',
$object, 0).
'</td><td>';
668 print $form->selectDate((empty($datev) ? -1 : $datev),
"datev", 0, 0, 0,
'add', 1, 1);
672 if (isModEnabled(
"bank")) {
674 print
'<tr class="hide_if_no_auto_create_payment"><td><label for="num_payment">'.$langs->trans(
'Numero');
675 print
' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
676 print
'</label></td>';
677 print
'<td><input name="num_payment" id="num_payment" type="text" value="'.GETPOST(
"num_payment").
'"></td></tr>'.
"\n";
688 $parameters = array();
689 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
690 print $hookmanager->resPrint;
691 if (empty($reshook)) {
692 print
$object->showOptionals($extrafields,
'create');
699 print
'<div class="center">';
701 print
'<div class="hide_if_no_auto_create_payment paddingbottom">';
702 print
'<input type="checkbox" checked value="1" name="closepaidsalary">'.$langs->trans(
"ClosePaidSalaryAutomatically");
707 $addition_button = array(
708 'name' =>
'saveandnew',
709 'label_key' =>
'SaveAndNew',
711 print $form->buttonsSaveCancel(
"Save",
"Cancel", $addition_button);
715 print
'$( document ).ready(function() {';
716 print
'$("#updateAmountWithLastSalary").on("click", function updateAmountWithLastSalary() {
717 var fk_user = $("#fk_user").val()
718 var url = "'.DOL_URL_ROOT.
'/salaries/ajax/ajaxsalaries.php?fk_user="+fk_user;
719 console.log("We click on link to autofill salary amount url="+url);
725 console.log("Data returned: "+data);
727 if (typeof data == "object") {
728 console.log("data is already type object, no need to parse it");
731 console.log("data is type "+(typeof data));
732 item = JSON.parse(data);
734 if (item[0].key == "Amount") {
735 value = item[0].value;
736 console.log("amount returned = "+value);
738 $("#amount").val(item[0].value);
740 console.error("Error: Ajax url "+url+" has returned a null value.");
743 console.error("Error: Ajax url "+url+" has returned the wrong key.");
746 console.error("Error: Ajax url "+url+" has returned an empty page.");
752 alert("'.
dol_escape_js($langs->transnoentitiesnoconv(
"FillFieldFirst")).
'");
762 $head = salaries_prepare_head(
$object);
765 if ($action ===
'clone') {
766 $formquestion = array(
767 array(
'type' =>
'text',
'name' =>
'clone_label',
'label' => $langs->trans(
"Label"),
'value' => $langs->trans(
"CopyOf").
' '.
$object->label),
772 $formquestion[] = array(
'type' =>
'date',
'name' =>
'clone_date_start',
'label' => $langs->trans(
"DateStart"),
'value' => (
$object->dateep) + 86400);
774 $formquestion[] = array(
'type' =>
'date',
'name' =>
'clone_date_start',
'label' => $langs->trans(
"DateStart"),
'value' => -1);
776 $formquestion[] = array(
'type' =>
'date',
'name' =>
'clone_date_end',
'label' => $langs->trans(
"DateEnd"),
'value' => -1);
777 $formquestion[] = array(
'type' =>
'text',
'name' =>
'amount',
'label' => $langs->trans(
"Amount"),
'value' =>
price(
$object->amount),
'morecss' =>
'width100 right');
779 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneSalary',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1, 300);
782 $formconfirm .=
"<script>
783 // Buttons for start date: previous month, current month, previous week, current week
784 $('#clone_date_start').after(
785 $('<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>')
786 .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>')
790 .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>')
791 .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>')";
796 $('#start_prev_month').click(function(){
797 var now = new Date();
798 var startPrevMonth = new Date(now.getFullYear(), now.getMonth() - 1, 1);
799 setStartDate(startPrevMonth);
802 $('#start_curr_month').click(function(){
803 var now = new Date();
804 var startCurrMonth = new Date(now.getFullYear(), now.getMonth(), 1);
805 setStartDate(startCurrMonth);
808 $('#start_prev_week').click(function(){
809 var now = new Date();
810 var startPrevWeek = new Date(now.setDate(now.getDate() - now.getDay() - 7));
811 startPrevWeek.setDate(startPrevWeek.getDate() + 1);
812 setStartDate(startPrevWeek);
815 $('#start_curr_week').click(function(){
816 var now = new Date();
817 var startCurrWeek = new Date(now.setDate(now.getDate() - now.getDay() + 1));
818 setStartDate(startCurrWeek);
821 function setStartDate(date) {
822 $('#clone_date_start').val(formatDate(date, '".$langs->trans(
"FormatDateShortJavaInput").
"'));
823 $('#clone_date_startday').val(date.getDate());
824 $('#clone_date_startmonth').val(date.getMonth() + 1);
825 $('#clone_date_startyear').val(date.getFullYear());
828 // Button for end date
829 $('#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>'));
830 $('#fill_end_of_month').click(function(){
831 var clone_date_startmonth = +$('#clone_date_startmonth').val();
832 var clone_date_startyear = +$('#clone_date_startyear').val();
835 if (clone_date_startmonth && clone_date_startyear) {
836 end_date = new Date(clone_date_startyear, clone_date_startmonth, 0);
838 var currentDate = new Date();
839 var currentDay = currentDate.getDate();
840 if (currentDay <= 15) {
841 end_date = new Date(currentDate.getFullYear(), currentDate.getMonth(), 0);
843 end_date = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0);
847 $('#clone_date_end').val(formatDate(end_date,'".$langs->trans(
"FormatDateShortJavaInput").
"'));
848 $('#clone_date_endday').val(end_date.getDate());
849 $('#clone_date_endmonth').val(end_date.getMonth() + 1);
850 $('#clone_date_endyear').val(end_date.getFullYear());
855 if ($action ==
'paid') {
856 $text = $langs->trans(
'ConfirmPaySalary');
857 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
'PaySalary'), $text,
"confirm_paid",
'',
'', 2);
860 if ($action ==
'delete') {
861 $text = $langs->trans(
'ConfirmDeleteSalary');
862 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
'DeleteSalary'), $text,
'confirm_delete',
'',
'', 2);
865 if ($action ==
'edit') {
866 print
"<form name=\"charge\" action=\"".$_SERVER[
"PHP_SELF"].
"?id=$object->id&action=update\" method=\"post\">";
867 print
'<input type="hidden" name="token" value="'.newToken().
'">';
871 $parameters = array(
'formConfirm' => $formconfirm);
872 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
873 if (empty($reshook)) {
874 $formconfirm .= $hookmanager->resPrint;
875 } elseif ($reshook > 0) {
876 $formconfirm = $hookmanager->resPrint;
883 print
dol_get_fiche_head($head,
'card', $langs->trans(
"SalaryPayment"), -1,
'salary', 0,
'',
'', 0,
'', 1);
885 $linkback =
'<a href="'.DOL_URL_ROOT.
'/salaries/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
887 $morehtmlref =
'<div class="refidno">';
890 if ($action !=
'editlabel') {
891 $morehtmlref .= $form->editfieldkey(
"Label",
'label',
$object->label,
$object, $permissiontoadd,
'string',
'', 0, 1);
892 $morehtmlref .=
$object->label;
894 $morehtmlref .= $langs->trans(
'Label').
' : ';
895 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
896 $morehtmlref .=
'<input type="hidden" name="action" value="setlabel">';
897 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
898 $morehtmlref .=
'<input type="text" name="label" value="'.$object->label.
'"/>';
899 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
900 $morehtmlref .=
'</form>';
904 if ($action !=
'editfk_user') {
905 if (
$object->getSommePaiement() > 0 && !empty(
$object->fk_user)) {
906 $userstatic =
new User($db);
907 $result = $userstatic->fetch(
$object->fk_user);
909 $morehtmlref .=
'<br>' .$langs->trans(
'Employee').
' : '.$userstatic->getNomUrl(-1);
912 $morehtmlref .=
'<br>' . $form->editfieldkey(
"Employee",
'fk_user',
$object->label,
$object, $permissiontoadd,
'string',
'', 0, 1);
914 if (!empty(
$object->fk_user)) {
915 $userstatic =
new User($db);
916 $result = $userstatic->fetch(
$object->fk_user);
918 $morehtmlref .= $userstatic->getNomUrl(-1);
926 $morehtmlref .=
'<br>'.$langs->trans(
'Employee').
' : ';
927 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
928 $morehtmlref .=
'<input type="hidden" name="action" value="setfk_user">';
929 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
930 $morehtmlref .= $form->select_dolusers(
$object->fk_user,
'userid', 1);
931 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
932 $morehtmlref .=
'</form>';
935 $usercancreate = $permissiontoadd;
938 if (isModEnabled(
'project')) {
939 $langs->load(
"projects");
940 $morehtmlref .=
'<br>';
941 if ($usercancreate) {
942 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
943 if ($action !=
'classify') {
944 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
946 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, -1, (
string)
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
948 if (!empty(
$object->fk_project)) {
950 $proj->fetch(
$object->fk_project);
951 $morehtmlref .= $proj->getNomUrl(1);
953 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
959 $morehtmlref .=
'</div>';
961 $totalpaid =
$object->getSommePaiement();
962 $object->alreadypaid = $totalpaid;
963 $object->totalpaid = $totalpaid;
965 dol_banner_tab(
$object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref,
'', 0,
'',
'');
967 print
'<div class="fichecenter">';
968 print
'<div class="fichehalfleft">';
969 print
'<div class="underbanner clearboth"></div>';
971 print
'<table class="border centpercent tableforfield">';
973 if ($action ==
'edit') {
974 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"DateStartPeriod").
"</td><td>";
975 print $form->selectDate(
$object->datesp,
'datesp', 0, 0, 0,
'datesp', 1);
979 print
'<td class="titlefieldmiddle">' . $langs->trans(
"DateStartPeriod") .
'</td><td>';
984 if ($action ==
'edit') {
985 print
'<tr><td>'.$langs->trans(
"DateEndPeriod").
"</td><td>";
986 print $form->selectDate(
$object->dateep,
'dateep', 0, 0, 0,
'dateep', 1);
990 print
'<td>' . $langs->trans(
"DateEndPeriod") .
'</td><td>';
1004 if ($action ==
'edit') {
1005 print
'<tr><td class="fieldrequired">' . $langs->trans(
"Amount") .
'</td><td><input name="amount" size="10" value="' .
price(
$object->amount) .
'"></td></tr>';
1007 print
'<tr><td>' . $langs->trans(
"Amount") .
'</td><td><span class="amount">' .
price(
$object->amount, 0, $langs, 1, -1, -1,
$conf->currency) .
'</span></td></tr>';
1012 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1013 print $langs->trans(
'DefaultPaymentMode');
1015 if ($action !=
'editmode') {
1016 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>';
1018 print
'</tr></table>';
1021 if ($action ==
'editmode') {
1022 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->type_payment,
'mode_reglement_id');
1024 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->type_payment,
'none');
1029 if (isModEnabled(
"bank")) {
1030 print
'<tr><td class="nowrap">';
1031 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
1032 print $langs->trans(
'DefaultBankAccount');
1034 if ($action !=
'editbankaccount' && $permissiontoadd) {
1035 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>';
1037 print
'</tr></table>';
1039 if ($action ==
'editbankaccount') {
1040 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
1042 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'none');
1049 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1055 print
'<div class="fichehalfright">';
1058 if (isModEnabled(
"bank")) {
1065 $sql =
"SELECT p.rowid, p.num_payment as num_payment, p.datep as dp, p.amount,";
1066 $sql .=
" c.code as type_code,c.libelle as paiement_type,";
1067 $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';
1068 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_salary as p";
1069 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
1070 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
1071 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as c ON p.fk_typepayment = c.id";
1072 $sql .=
", ".MAIN_DB_PREFIX.
"salary as salaire";
1073 $sql .=
" WHERE p.fk_salary = ".((int) $id);
1074 $sql .=
" AND p.fk_salary = salaire.rowid";
1075 $sql .=
" AND salaire.entity IN (".getEntity(
'tax').
")";
1076 $sql .=
" ORDER BY dp DESC";
1078 $resql = $db->query($sql);
1082 $num = $db->num_rows($resql);
1086 print
'<div class="div-table-responsive-no-min">';
1087 print
'<table class="noborder paymenttable">';
1088 print
'<tr class="liste_titre">';
1089 print
'<td>'.$langs->trans(
"RefPayment").
'</td>';
1090 print
'<td>'.$langs->trans(
"Date").
'</td>';
1091 print
'<td>'.$langs->trans(
"Type").
'</td>';
1092 if (isModEnabled(
"bank")) {
1093 print
'<td class="liste_titre right">'.$langs->trans(
'BankAccount').
'</td>';
1095 print
'<td class="right">'.$langs->trans(
"Amount").
'</td>';
1101 $bankaccountstatic =
new Account($db);
1103 $objp = $db->fetch_object($resql);
1105 $paymentsalarytemp->id = $objp->rowid;
1106 $paymentsalarytemp->ref = $objp->rowid;
1107 $paymentsalarytemp->num_payment = $objp->num_payment;
1108 $paymentsalarytemp->datep = $objp->dp;
1110 print
'<tr class="oddeven"><td>';
1111 print $paymentsalarytemp->getNomUrl(1);
1113 print
'<td>'.dol_print_date($db->jdate($objp->dp),
'dayhour',
'tzuserrel').
"</td>\n";
1114 $labeltype = $langs->trans(
"PaymentType".$objp->type_code) !=
"PaymentType".$objp->type_code ? $langs->trans(
"PaymentType".$objp->type_code) : $objp->paiement_type;
1115 print
"<td>".$labeltype.
' '.$objp->num_payment.
"</td>\n";
1116 if (isModEnabled(
"bank")) {
1117 $bankaccountstatic->id = $objp->baid;
1118 $bankaccountstatic->ref = $objp->baref;
1119 $bankaccountstatic->label = $objp->baref;
1120 $bankaccountstatic->number = $objp->banumber;
1121 $bankaccountstatic->currency_code = $objp->bacurrency_code;
1123 if (isModEnabled(
'accounting')) {
1124 $bankaccountstatic->account_number = $objp->account_number;
1127 $accountingjournal->fetch($objp->fk_accountancy_journal);
1128 $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
1131 print
'<td class="right">';
1132 if ($bankaccountstatic->id) {
1133 print $bankaccountstatic->getNomUrl(1,
'transactions');
1137 print
'<td class="right nowrap amountcard">'.price($objp->amount).
"</td>\n";
1139 $totalpaid += $objp->amount;
1143 print
'<tr class="oddeven"><td><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td>';
1144 print
'<td></td><td></td><td></td><td></td>';
1148 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AlreadyPaid").
' :</td><td class="right nowrap amountcard">'.
price($totalpaid).
"</td></tr>\n";
1149 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AmountExpected").
' :</td><td class="right nowrap amountcard">'.
price(
$object->amount).
"</td></tr>\n";
1151 $resteapayer = (float)
$object->amount - $totalpaid;
1152 $cssforamountpaymentcomplete =
'amountpaymentcomplete';
1154 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"RemainderToPay").
" :</td>";
1155 print
'<td class="right nowrap'.($resteapayer ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($resteapayer).
"</td></tr>\n";
1168 print
'<div class="clearboth"></div>';
1172 if ($action ==
'edit') {
1173 print $form->buttonsSaveCancel();
1177 $resteapayer =
price2num($resteapayer,
'MT');
1184 print
'<div class="tabsAction">'.
"\n";
1185 if ($action !=
'edit') {
1187 $parameters = array();
1188 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
1189 if (empty($reshook)) {
1190 if (empty($user->socid)) {
1191 $canSendMail =
true;
1193 print
dolGetButtonAction($langs->trans(
'SendMail'),
'',
'default', $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id .
'&action=presend&token='.newToken().
'&mode=init#formmailbeforetitle',
'', $canSendMail);
1198 if (
$object->status == $object::STATUS_PAID && $permissiontoadd) {
1203 if (
$object->status == $object::STATUS_UNPAID && $permissiontoadd) {
1209 print
dolGetButtonAction(
'', $langs->trans(
'MakeTransferRequest'),
'default', DOL_URL_ROOT .
'/salaries/virement_request.php?id=' .
$object->id,
'');
1214 print
dolGetButtonAction(
'', $langs->trans(
'DoPayment'),
'default', DOL_URL_ROOT.
'/salaries/paiement_salary.php?action=create&token='.
newToken().
'&id='.
$object->id,
'');
1219 if (
$object->status == $object::STATUS_UNPAID && (($resteapayer <= 0 && $object->amount > 0) || (
$object->amount <= 0)) && $permissiontoadd) {
1224 if ($permissiontoadd) {
1228 if ($permissiontodelete && empty($totalpaid)) {
1231 print
dolGetButtonAction($langs->trans(
'DisabledBecausePayments'), $langs->trans(
'Delete'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1239 if (
GETPOST(
'modelselected')) {
1240 $action =
'presend';
1243 if ($action !=
'presend') {
1244 print
'<div class="fichecenter"><div class="fichehalfleft">';
1245 print
'<a name="builddoc"></a>';
1247 $includedocgeneration = 1;
1250 if ($includedocgeneration) {
1252 $relativepath = $objref.
'/'.$objref.
'.pdf';
1253 $filedir =
$conf->salaries->dir_output.
'/'.$objref;
1254 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
1257 $delallowed = $permissiontoadd;
1258 print $formfile->showdocuments(
'salaries', $objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
1271 print
'</div><div class="fichehalfright">';
1278 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1282 print
'</div></div>';
1286 if (
GETPOST(
'modelselected')) {
1287 $action =
'presend';
1291 $modelmail =
'salary';
1292 $defaulttopic =
'InformationMessage';
1293 $diroutput =
$conf->salaries->dir_output;
1294 $trackid =
'salary'.$object->id;
1296 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
1299 $parameters = array();
1300 $reshook = $hookmanager->executeHooks(
'salaryCardTabAddMore', $parameters,
$object, $action);
$id
Support class for third parties, contacts, members, users or resources.
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, $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 '.
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.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
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_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
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.