33require
'../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/salaries/class/paymentsalary.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/salaries.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
43if (isModEnabled(
'project')) {
44 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
57$langs->loadLangs(array(
"compta",
"banks",
"bills",
"users",
"salaries",
"hrm",
"trips"));
58if (isModEnabled(
'project')) {
59 $langs->load(
"projects");
64$action =
GETPOST(
'action',
'aZ09');
65$cancel =
GETPOST(
'cancel',
'alpha');
66$backtopage =
GETPOST(
'backtopage',
'alpha');
67$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
70$label =
GETPOST(
'label',
'alphanohtml');
73if (GETPOSTISSET(
'auto_create_paiement') || $action ===
'add') {
74 $auto_create_paiement =
GETPOSTINT(
"auto_create_paiement");
88$childids = $user->getAllChildIds(1);
91$extrafields->fetch_name_optionals_label(
$object->table_element);
94$hookmanager->initHooks(array(
'salarycard',
'globalcard'));
96if ($id > 0 || !empty($ref)) {
101 if ($user->hasRight(
'salaries',
'readall')) {
104 if ($user->hasRight(
'salaries',
'read') &&
$object->fk_user > 0 && in_array(
$object->fk_user, $childids)) {
115 $socid = $user->socid;
120$permissiontoread = $user->hasRight(
'salaries',
'read');
121$permissiontoadd = $user->hasRight(
'salaries',
'write');
122$permissiontodelete = $user->hasRight(
'salaries',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_UNPAID);
124$upload_dir =
$conf->salaries->multidir_output[
$conf->entity];
131$parameters = array();
133$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
138if (empty($reshook)) {
141 $backurlforlist = DOL_URL_ROOT.
'/salaries/list.php';
143 if (empty($backtopage) || ($cancel && empty($id))) {
144 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
145 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
146 $backtopage = $backurlforlist;
148 $backtopage = DOL_URL_ROOT.
'/salaries/card.php?id='.(
$id > 0 ?
$id :
'__ID__');
156 if (!empty($backtopageforcancel)) {
157 header(
"Location: ".$backtopageforcancel);
159 } elseif (!empty($backtopage)) {
160 header(
"Location: ".$backtopage);
167 $triggersendname =
'COMPANY_SENTBYMAIL';
169 $mode =
'emailfromthirdparty';
170 $trackid =
'sal'.$object->id;
171 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
175 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
179if ($action ==
'classin' && $permissiontoadd) {
181 $object->setProject($projectid);
185if ($action ==
'setlabel' && $permissiontoadd) {
192if ($action ==
'confirm_paid' && $permissiontoadd && $confirm ==
'yes') {
194 $result =
$object->setPaid($user);
197if ($action ==
'setfk_user' && $permissiontoadd) {
208if ($action ==
'reopen' && $permissiontoadd) {
211 $result =
$object->set_unpaid($user);
213 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
222if ($action ==
'setmode' && $permissiontoadd) {
231if ($action ==
'setbankaccount' && $permissiontoadd) {
239if ($action ==
'add' && empty($cancel) && $permissiontoadd) {
258 $object->type_payment = ($type_payment > 0 ? $type_payment : 0);
259 $object->fk_user_author = $user->id;
260 $object->fk_project = $projectid;
263 $fuser =
new User($db);
265 $object->salary = $fuser->salary;
268 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
273 if (!empty($auto_create_paiement) && empty($datep)) {
274 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DATE_PAIEMENT")),
null,
'errors');
277 if (empty($datesp) || empty($dateep)) {
278 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
282 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Employee")),
null,
'errors');
285 if (!empty($auto_create_paiement) && (empty($type_payment) || $type_payment < 0)) {
286 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PaymentMode")),
null,
'errors');
290 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount")),
null,
'errors');
293 if (isModEnabled(
"bank") && !empty($auto_create_paiement) && !
$object->accountid > 0) {
294 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankAccount")),
null,
'errors');
306 if (!empty($auto_create_paiement) && !$error) {
309 $paiement->fk_salary =
$object->id;
311 $paiement->datep = $datep;
312 $paiement->datev = $datev;
313 $paiement->amounts = array(
$object->id => $amount);
314 $paiement->fk_typepayment = $type_payment;
315 $paiement->num_payment =
GETPOST(
"num_payment",
'alphanohtml');
316 $paiement->note_private =
GETPOST(
"note",
'restricthtml');
319 $paymentid = $paiement->create($user, (
int)
GETPOST(
'closepaidsalary'));
320 if ($paymentid < 0) {
328 $result = $paiement->addPaymentToBank($user,
'payment_salary',
'(SalaryPayment)',
GETPOSTINT(
'accountid'),
'',
'');
329 if (!($result > 0)) {
339 if (
GETPOST(
'saveandnew',
'alpha')) {
341 header(
"Location: card.php?action=create&fk_project=" . urlencode((
string) ($projectid)) .
"&accountid=" . urlencode((
string) ($accountid)) .
'&paymenttype=' . urlencode((
string) (
GETPOSTINT(
'paymenttype'))) .
'&datepday=' .
GETPOSTINT(
"datepday") .
'&datepmonth=' .
GETPOSTINT(
"datepmonth") .
'&datepyear=' .
GETPOSTINT(
"datepyear"));
344 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id);
355if ($action ==
'confirm_delete' && $permissiontodelete) {
357 $totalpaid =
$object->getSommePaiement();
359 if (empty($totalpaid)) {
365 header(
"Location: ".DOL_URL_ROOT.
'/salaries/list.php');
377if ($action ==
'update' && !
GETPOST(
"cancel") && $permissiontoadd) {
380 if (empty($amount)) {
381 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Amount")),
null,
'errors');
383 } elseif (!is_numeric($amount)) {
384 setEventMessages($langs->trans(
"ErrorFieldMustBeANumeric", $langs->transnoentities(
"Amount")),
null,
'errors');
393 $result =
$object->update($user);
400if ($action ==
'confirm_clone' && $confirm !=
'yes') {
404if ($action ==
'confirm_clone' && $confirm ==
'yes' && $permissiontoadd) {
416 if (
GETPOST(
'amount',
'alphanohtml')) {
420 if (
GETPOST(
'clone_label',
'alphanohtml')) {
430 $object->datesp = $newdatestart;
441 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
456if ($action ==
"update_extras" && $permissiontoadd) {
459 $attributekey =
GETPOST(
'attribute',
'alpha');
460 $attributekeylong =
'options_'.$attributekey;
462 if (GETPOSTISSET($attributekeylong.
'day') && GETPOSTISSET($attributekeylong.
'month') && GETPOSTISSET($attributekeylong.
'year')) {
467 $object->array_options[
'options_'.$attributekey] =
GETPOST($attributekeylong,
'alpha');
470 $result =
$object->insertExtraFields(empty($triggermodname) ?
'' : $triggermodname, $user);
476 $action =
'edit_extras';
484$form =
new Form($db);
486if (isModEnabled(
'project')) {
490$title = $langs->trans(
'Salary').
" - ".
$object->ref;
491if ($action ==
'create') {
492 $title = $langs->trans(
"NewSalary");
507if ($action ==
'create' && $permissiontoadd) {
510 $pastmonthyear = $year_current;
511 if ($pastmonth == 0) {
522 $datesp =
dol_mktime(0, 0, 0, $datespmonth, $datespday, $datespyear);
523 $dateep =
dol_mktime(23, 59, 59, $dateepmonth, $dateepday, $dateepyear);
525 if (empty($datesp) || empty($dateep)) {
530 print
'<form name="salary" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
531 print
'<input type="hidden" name="token" value="'.newToken().
'">';
532 print
'<input type="hidden" name="action" value="add">';
534 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
536 if ($backtopageforcancel) {
537 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
542 if (!empty(
$conf->use_javascript_ajax)) {
543 print
"\n".
'<script type="text/javascript">';
545 $(document).ready(function () {
546 let onAutoCreatePaiementChange = function () {
547 if($("#auto_create_paiement").is(":checked")) {
548 $("#label_fk_account").find("span").addClass("fieldrequired");
549 $("#label_type_payment").find("span").addClass("fieldrequired");
550 $(".hide_if_no_auto_create_payment").show();
552 $("#label_fk_account").find("span").removeClass("fieldrequired");
553 $("#label_type_payment").find("span").removeClass("fieldrequired");
554 $(".hide_if_no_auto_create_payment").hide();
557 $("#radiopayment").click(function() {
558 $("#label").val($(this).data("label"));
560 $("#radiorefund").click(function() {
561 $("#label").val($(this).data("label"));
563 $("#auto_create_paiement").click(function () {
564 onAutoCreatePaiementChange();
566 onAutoCreatePaiementChange();
569 print
'</script>'.
"\n";
574 print
'<table class="border centpercent">';
577 print
'<tr><td class="titlefieldcreate">';
578 print $form->editfieldkey(
'Employee',
'fk_user',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
580 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->select_dolusers(
GETPOSTINT(
'fk_user'),
'fk_user', 1,
'', 0,
'',
'', 0, 0, 0,
'AND employee=1', 0,
'',
'maxwidth300', $noactive);
585 print $form->editfieldkey(
'Label',
'label',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
586 print
'<input name="label" id="label" class="minwidth300" value="'.(GETPOST(
"label") ?
GETPOST(
"label") : $langs->trans(
"Salary")).
'">';
591 print $form->editfieldkey(
'DateStartPeriod',
'datesp',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
592 print $form->selectDate($datesp,
"datesp", 0, 0, 0,
'add');
597 print $form->editfieldkey(
'DateEndPeriod',
'dateep',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
598 print $form->selectDate($dateep,
"dateep", 0, 0, 0,
'add');
603 print $form->editfieldkey(
'Amount',
'amount',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
604 print
'<input name="amount" id="amount" class="minwidth75 maxwidth100" value="'.GETPOST(
"amount").
'"> ';
605 print
' <button class="dpInvisibleButtons datenowlink" id="updateAmountWithLastSalary" name="_useless" type="button">'.$langs->trans(
'UpdateAmountWithLastSalary').
'</a>';
610 if (isModEnabled(
'project')) {
613 print
'<tr><td>'.$langs->trans(
"Project").
'</td><td>';
614 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
615 print $formproject->select_projects(-1, $projectid,
'fk_project', 0, 0, 1, 1, 0, 0, 0,
'', 1);
621 print
'<td class="tdtop">'.$langs->trans(
"Comments").
'</td>';
622 print
'<td class="tdtop"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_3.
'">'.
GETPOST(
'note',
'restricthtml').
'</textarea></td>';
626 print
'<tr><td colspan="2"><hr></td></tr>';
630 print
'<tr><td><label for="auto_create_paiement">'.$langs->trans(
'AutomaticCreationPayment').
'</label></td>';
631 print
'<td><input id="auto_create_paiement" name="auto_create_paiement" type="checkbox" ' . (empty($auto_create_paiement) ?
'' :
'checked="checked"') .
' value="1"></td></tr>'.
"\n";
634 if (isModEnabled(
"bank")) {
635 print
'<tr><td id="label_fk_account">';
636 print $form->editfieldkey(
'BankAccount',
'selectaccountid',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
637 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
638 $form->select_comptes($accountid,
"accountid", 0,
'', 1);
643 print
'<tr><td id="label_type_payment">';
644 print $form->editfieldkey(
'PaymentMode',
'selectpaymenttype',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
645 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
646 print $form->select_types_paiements(
GETPOST(
"paymenttype",
'aZ09'),
"paymenttype",
'');
650 print
'<tr class="hide_if_no_auto_create_payment"><td>';
651 print $form->editfieldkey(
'DatePayment',
'datep',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
652 print $form->selectDate((empty($datep) ?
'' : $datep),
"datep", 0, 0, 0,
'add', 1, 1);
656 print
'<tr class="hide_if_no_auto_create_payment"><td>';
657 print $form->editfieldkey(
'DateValue',
'datev',
'',
$object, 0).
'</td><td>';
658 print $form->selectDate((empty($datev) ? -1 : $datev),
"datev", 0, 0, 0,
'add', 1, 1);
662 if (isModEnabled(
"bank")) {
664 print
'<tr class="hide_if_no_auto_create_payment"><td><label for="num_payment">'.$langs->trans(
'Numero');
665 print
' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
666 print
'</label></td>';
667 print
'<td><input name="num_payment" id="num_payment" type="text" value="'.GETPOST(
"num_payment").
'"></td></tr>'.
"\n";
678 $parameters = array();
679 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
680 print $hookmanager->resPrint;
681 if (empty($reshook)) {
682 print
$object->showOptionals($extrafields,
'create');
689 print
'<div class="center">';
691 print
'<div class="hide_if_no_auto_create_payment paddingbottom">';
692 print
'<input type="checkbox" checked value="1" name="closepaidsalary">'.$langs->trans(
"ClosePaidSalaryAutomatically");
697 $addition_button = array(
698 'name' =>
'saveandnew',
699 'label_key' =>
'SaveAndNew',
701 print $form->buttonsSaveCancel(
"Save",
"Cancel", $addition_button);
705 print
'$( document ).ready(function() {';
706 print
'$("#updateAmountWithLastSalary").on("click", function updateAmountWithLastSalary() {
707 var fk_user = $("#fk_user").val()
708 var url = "'.DOL_URL_ROOT.
'/salaries/ajax/ajaxsalaries.php?fk_user="+fk_user;
709 console.log("We click on link to autofill salary amount url="+url);
715 console.log("Data returned: "+data);
717 if (typeof data == "object") {
718 console.log("data is already type object, no need to parse it");
721 console.log("data is type "+(typeof data));
722 item = JSON.parse(data);
724 if (item[0].key == "Amount") {
725 value = item[0].value;
726 console.log("amount returned = "+value);
728 $("#amount").val(item[0].value);
730 console.error("Error: Ajax url "+url+" has returned a null value.");
733 console.error("Error: Ajax url "+url+" has returned the wrong key.");
736 console.error("Error: Ajax url "+url+" has returned an empty page.");
742 alert("'.
dol_escape_js($langs->transnoentitiesnoconv(
"FillFieldFirst")).
'");
752 $head = salaries_prepare_head(
$object);
755 if ($action ===
'clone') {
756 $formquestion = array(
757 array(
'type' =>
'text',
'name' =>
'clone_label',
'label' => $langs->trans(
"Label"),
'value' => $langs->trans(
"CopyOf").
' '.
$object->label),
761 $formquestion[] = array(
'type' =>
'date',
'name' =>
'clone_date_start',
'label' => $langs->trans(
"DateStart"),
'value' => -1);
762 $formquestion[] = array(
'type' =>
'date',
'name' =>
'clone_date_end',
'label' => $langs->trans(
"DateEnd"),
'value' => -1);
763 $formquestion[] = array(
'type' =>
'text',
'name' =>
'amount',
'label' => $langs->trans(
"Amount"),
'value' =>
price(
$object->amount),
'morecss' =>
'width100 right');
765 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneSalary',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1, 280);
768 $formconfirm .=
"<script>
769 $('#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>'));
770 $('#fill_end_of_month').click(function(){
771 var clone_date_startmonth = +$('#clone_date_startmonth').val();
772 var clone_date_startyear = +$('#clone_date_startyear').val();
774 if (clone_date_startmonth && clone_date_startyear) {
775 end_date = new Date(clone_date_startyear, clone_date_startmonth , 0);
777 var currentDate = new Date();
778 var currentDay = currentDate.getDate();
779 if (currentDay <= 15) {
780 end_date = new Date(currentDate.getFullYear(), currentDate.getMonth(), 0);
782 end_date = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0);
785 $('#clone_date_end').val(formatDate(end_date,'".$langs->trans(
"FormatDateShortJavaInput").
"'));
786 $('#clone_date_endday').val(end_date.getDate());
787 $('#clone_date_endmonth').val(end_date.getMonth() + 1);
788 $('#clone_date_endyear').val(end_date.getFullYear());
793 if ($action ==
'paid') {
794 $text = $langs->trans(
'ConfirmPaySalary');
795 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
'PaySalary'), $text,
"confirm_paid",
'',
'', 2);
798 if ($action ==
'delete') {
799 $text = $langs->trans(
'ConfirmDeleteSalary');
800 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
'DeleteSalary'), $text,
'confirm_delete',
'',
'', 2);
803 if ($action ==
'edit') {
804 print
"<form name=\"charge\" action=\"".$_SERVER[
"PHP_SELF"].
"?id=$object->id&action=update\" method=\"post\">";
805 print
'<input type="hidden" name="token" value="'.newToken().
'">';
809 $parameters = array(
'formConfirm' => $formconfirm);
810 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
811 if (empty($reshook)) {
812 $formconfirm .= $hookmanager->resPrint;
813 } elseif ($reshook > 0) {
814 $formconfirm = $hookmanager->resPrint;
821 print
dol_get_fiche_head($head,
'card', $langs->trans(
"SalaryPayment"), -1,
'salary', 0,
'',
'', 0,
'', 1);
823 $linkback =
'<a href="'.DOL_URL_ROOT.
'/salaries/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
825 $morehtmlref =
'<div class="refidno">';
828 if ($action !=
'editlabel') {
829 $morehtmlref .= $form->editfieldkey(
"Label",
'label',
$object->label,
$object, $permissiontoadd,
'string',
'', 0, 1);
830 $morehtmlref .=
$object->label;
832 $morehtmlref .= $langs->trans(
'Label').
' : ';
833 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
834 $morehtmlref .=
'<input type="hidden" name="action" value="setlabel">';
835 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
836 $morehtmlref .=
'<input type="text" name="label" value="'.$object->label.
'"/>';
837 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
838 $morehtmlref .=
'</form>';
842 if ($action !=
'editfk_user') {
843 if (
$object->getSommePaiement() > 0 && !empty(
$object->fk_user)) {
844 $userstatic =
new User($db);
845 $result = $userstatic->fetch(
$object->fk_user);
847 $morehtmlref .=
'<br>' .$langs->trans(
'Employee').
' : '.$userstatic->getNomUrl(-1);
850 $morehtmlref .=
'<br>' . $form->editfieldkey(
"Employee",
'fk_user',
$object->label,
$object, $permissiontoadd,
'string',
'', 0, 1);
852 if (!empty(
$object->fk_user)) {
853 $userstatic =
new User($db);
854 $result = $userstatic->fetch(
$object->fk_user);
856 $morehtmlref .= $userstatic->getNomUrl(-1);
864 $morehtmlref .=
'<br>'.$langs->trans(
'Employee').
' : ';
865 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
866 $morehtmlref .=
'<input type="hidden" name="action" value="setfk_user">';
867 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
868 $morehtmlref .= $form->select_dolusers(
$object->fk_user,
'userid', 1);
869 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
870 $morehtmlref .=
'</form>';
873 $usercancreate = $permissiontoadd;
876 if (isModEnabled(
'project')) {
877 $langs->load(
"projects");
878 $morehtmlref .=
'<br>';
879 if ($usercancreate) {
880 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
881 if ($action !=
'classify') {
882 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
884 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, -1,
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
886 if (!empty(
$object->fk_project)) {
888 $proj->fetch(
$object->fk_project);
889 $morehtmlref .= $proj->getNomUrl(1);
891 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
897 $morehtmlref .=
'</div>';
899 $totalpaid =
$object->getSommePaiement();
900 $object->alreadypaid = $totalpaid;
901 $object->totalpaid = $totalpaid;
903 dol_banner_tab(
$object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref,
'', 0,
'',
'');
905 print
'<div class="fichecenter">';
906 print
'<div class="fichehalfleft">';
907 print
'<div class="underbanner clearboth"></div>';
909 print
'<table class="border centpercent tableforfield">';
911 if ($action ==
'edit') {
912 print
'<tr><td class="titlefield">'.$langs->trans(
"DateStartPeriod").
"</td><td>";
913 print $form->selectDate(
$object->datesp,
'datesp', 0, 0, 0,
'datesp', 1);
917 print
'<td class="titlefield">' . $langs->trans(
"DateStartPeriod") .
'</td><td>';
922 if ($action ==
'edit') {
923 print
'<tr><td>'.$langs->trans(
"DateEndPeriod").
"</td><td>";
924 print $form->selectDate(
$object->dateep,
'dateep', 0, 0, 0,
'dateep', 1);
928 print
'<td>' . $langs->trans(
"DateEndPeriod") .
'</td><td>';
942 if ($action ==
'edit') {
943 print
'<tr><td class="fieldrequired">' . $langs->trans(
"Amount") .
'</td><td><input name="amount" size="10" value="' .
price(
$object->amount) .
'"></td></tr>';
945 print
'<tr><td>' . $langs->trans(
"Amount") .
'</td><td><span class="amount">' .
price(
$object->amount, 0, $langs, 1, -1, -1,
$conf->currency) .
'</span></td></tr>';
950 print
'<table class="nobordernopadding" width="100%"><tr><td>';
951 print $langs->trans(
'DefaultPaymentMode');
953 if ($action !=
'editmode') {
954 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>';
956 print
'</tr></table>';
959 if ($action ==
'editmode') {
960 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->type_payment,
'mode_reglement_id');
962 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->type_payment,
'none');
967 if (isModEnabled(
"bank")) {
968 print
'<tr><td class="nowrap">';
969 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
970 print $langs->trans(
'DefaultBankAccount');
972 if ($action !=
'editbankaccount' && $permissiontoadd) {
973 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>';
975 print
'</tr></table>';
977 if ($action ==
'editbankaccount') {
978 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'fk_account', 1);
980 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'none');
987 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
993 print
'<div class="fichehalfright">';
996 if (isModEnabled(
"bank")) {
1003 $sql =
"SELECT p.rowid, p.num_payment as num_payment, p.datep as dp, p.amount,";
1004 $sql .=
" c.code as type_code,c.libelle as paiement_type,";
1005 $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';
1006 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_salary as p";
1007 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
1008 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
1009 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as c ON p.fk_typepayment = c.id";
1010 $sql .=
", ".MAIN_DB_PREFIX.
"salary as salaire";
1011 $sql .=
" WHERE p.fk_salary = ".((int) $id);
1012 $sql .=
" AND p.fk_salary = salaire.rowid";
1013 $sql .=
" AND salaire.entity IN (".getEntity(
'tax').
")";
1014 $sql .=
" ORDER BY dp DESC";
1016 $resql = $db->query($sql);
1020 $num = $db->num_rows($resql);
1024 print
'<div class="div-table-responsive-no-min">';
1025 print
'<table class="noborder paymenttable">';
1026 print
'<tr class="liste_titre">';
1027 print
'<td>'.$langs->trans(
"RefPayment").
'</td>';
1028 print
'<td>'.$langs->trans(
"Date").
'</td>';
1029 print
'<td>'.$langs->trans(
"Type").
'</td>';
1030 if (isModEnabled(
"bank")) {
1031 print
'<td class="liste_titre right">'.$langs->trans(
'BankAccount').
'</td>';
1033 print
'<td class="right">'.$langs->trans(
"Amount").
'</td>';
1039 $bankaccountstatic =
new Account($db);
1041 $objp = $db->fetch_object($resql);
1043 $paymentsalarytemp->id = $objp->rowid;
1044 $paymentsalarytemp->ref = $objp->rowid;
1045 $paymentsalarytemp->num_payment = $objp->num_payment;
1046 $paymentsalarytemp->datep = $objp->dp;
1048 print
'<tr class="oddeven"><td>';
1049 print $paymentsalarytemp->getNomUrl(1);
1051 print
'<td>'.dol_print_date($db->jdate($objp->dp),
'dayhour',
'tzuserrel').
"</td>\n";
1052 $labeltype = $langs->trans(
"PaymentType".$objp->type_code) !=
"PaymentType".$objp->type_code ? $langs->trans(
"PaymentType".$objp->type_code) : $objp->paiement_type;
1053 print
"<td>".$labeltype.
' '.$objp->num_payment.
"</td>\n";
1054 if (isModEnabled(
"bank")) {
1055 $bankaccountstatic->id = $objp->baid;
1056 $bankaccountstatic->ref = $objp->baref;
1057 $bankaccountstatic->label = $objp->baref;
1058 $bankaccountstatic->number = $objp->banumber;
1059 $bankaccountstatic->currency_code = $objp->bacurrency_code;
1061 if (isModEnabled(
'accounting')) {
1062 $bankaccountstatic->account_number = $objp->account_number;
1065 $accountingjournal->fetch($objp->fk_accountancy_journal);
1066 $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
1069 print
'<td class="right">';
1070 if ($bankaccountstatic->id) {
1071 print $bankaccountstatic->getNomUrl(1,
'transactions');
1075 print
'<td class="right nowrap amountcard">'.price($objp->amount).
"</td>\n";
1077 $totalpaid += $objp->amount;
1081 print
'<tr class="oddeven"><td><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td>';
1082 print
'<td></td><td></td><td></td><td></td>';
1086 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AlreadyPaid").
' :</td><td class="right nowrap amountcard">'.
price($totalpaid).
"</td></tr>\n";
1087 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AmountExpected").
' :</td><td class="right nowrap amountcard">'.
price(
$object->amount).
"</td></tr>\n";
1089 $resteapayer = (float)
$object->amount - $totalpaid;
1090 $cssforamountpaymentcomplete =
'amountpaymentcomplete';
1092 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"RemainderToPay").
" :</td>";
1093 print
'<td class="right nowrap'.($resteapayer ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($resteapayer).
"</td></tr>\n";
1106 print
'<div class="clearboth"></div>';
1110 if ($action ==
'edit') {
1111 print $form->buttonsSaveCancel();
1115 $resteapayer =
price2num($resteapayer,
'MT');
1122 print
'<div class="tabsAction">'.
"\n";
1123 if ($action !=
'edit') {
1125 $parameters = array();
1126 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
1127 if (empty($reshook)) {
1128 if (empty($user->socid)) {
1129 $canSendMail =
true;
1131 print
dolGetButtonAction($langs->trans(
'SendMail'),
'',
'default', $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id .
'&action=presend&token='.newToken().
'&mode=init#formmailbeforetitle',
'', $canSendMail);
1136 if (
$object->status == $object::STATUS_PAID && $permissiontoadd) {
1141 if (
$object->status == $object::STATUS_UNPAID && $permissiontoadd) {
1147 print
dolGetButtonAction(
'', $langs->trans(
'DoPayment'),
'default', DOL_URL_ROOT.
'/salaries/paiement_salary.php?action=create&token='.
newToken().
'&id='.
$object->id,
'');
1152 if (
$object->status == $object::STATUS_UNPAID && (($resteapayer <= 0 && $object->amount > 0) || (
$object->amount <= 0)) && $permissiontoadd) {
1158 print
dolGetButtonAction(
'', $langs->trans(
'MakeTransferRequest'),
'default', DOL_URL_ROOT .
'/salaries/virement_request.php?id=' .
$object->id,
'');
1162 if ($permissiontoadd) {
1166 if ($permissiontodelete && empty($totalpaid)) {
1169 print
dolGetButtonAction($langs->trans(
'DisabledBecausePayments'), $langs->trans(
'Delete'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1177 if (
GETPOST(
'modelselected')) {
1178 $action =
'presend';
1181 if ($action !=
'presend') {
1182 print
'<div class="fichecenter"><div class="fichehalfleft">';
1183 print
'<a name="builddoc"></a>';
1185 $includedocgeneration = 1;
1188 if ($includedocgeneration) {
1190 $relativepath = $objref.
'/'.$objref.
'.pdf';
1191 $filedir =
$conf->salaries->dir_output.
'/'.$objref;
1192 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
1195 $delallowed = $permissiontoadd;
1196 print $formfile->showdocuments(
'salaries', $objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
1209 print
'</div><div class="fichehalfright">';
1216 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1220 print
'</div></div>';
1224 if (
GETPOST(
'modelselected')) {
1225 $action =
'presend';
1229 $modelmail =
'salary';
1230 $defaulttopic =
'InformationMessage';
1231 $diroutput =
$conf->salaries->dir_output;
1232 $trackid =
'salary'.$object->id;
1234 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
1237 $parameters = array();
1238 $reshook = $hookmanager->executeHooks(
'salaryCardTabAddMore', $parameters,
$object, $action);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage bank accounts.
Class to manage accounting journals.
Class to manage payments of salaries.
Class to manage projects.
Class to manage salary payments.
Class to manage Dolibarr users.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.