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';
49$langs->loadLangs(array(
"compta",
"banks",
"bills",
"users",
"salaries",
"hrm",
"trips"));
50if (isModEnabled(
'project')) {
51 $langs->load(
"projects");
56$action =
GETPOST(
'action',
'aZ09');
57$cancel =
GETPOST(
'cancel',
'alpha');
58$backtopage =
GETPOST(
'backtopage',
'alpha');
59$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
62$label =
GETPOST(
'label',
'alphanohtml');
65if (GETPOSTISSET(
'auto_create_paiement') || $action ===
'add') {
66 $auto_create_paiement =
GETPOSTINT(
"auto_create_paiement");
80$childids = $user->getAllChildIds(1);
83$extrafields->fetch_name_optionals_label(
$object->table_element);
86$hookmanager->initHooks(array(
'salarycard',
'globalcard'));
88if ($id > 0 || !empty($ref)) {
93 if ($user->hasRight(
'salaries',
'readall')) {
96 if ($user->hasRight(
'salaries',
'read') &&
$object->fk_user > 0 && in_array(
$object->fk_user, $childids)) {
107 $socid = $user->socid;
112$permissiontoread = $user->hasRight(
'salaries',
'read');
113$permissiontoadd = $user->hasRight(
'salaries',
'write');
114$permissiontodelete = $user->hasRight(
'salaries',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_UNPAID);
116$upload_dir = $conf->salaries->multidir_output[$conf->entity];
123$parameters = array();
125$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
130if (empty($reshook)) {
133 $backurlforlist = DOL_URL_ROOT.
'/salaries/list.php';
135 if (empty($backtopage) || ($cancel && empty($id))) {
136 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
137 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
138 $backtopage = $backurlforlist;
140 $backtopage = DOL_URL_ROOT.
'/salaries/card.php?id='.(
$id > 0 ?
$id :
'__ID__');
148 if (!empty($backtopageforcancel)) {
149 header(
"Location: ".$backtopageforcancel);
151 } elseif (!empty($backtopage)) {
152 header(
"Location: ".$backtopage);
159 $triggersendname =
'COMPANY_SENTBYMAIL';
161 $mode =
'emailfromthirdparty';
162 $trackid =
'sal'.$object->id;
163 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
167 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
171if ($action ==
'classin' && $permissiontoadd) {
173 $object->setProject($projectid);
177if ($action ==
'setlabel' && $permissiontoadd) {
184if ($action ==
'confirm_paid' && $permissiontoadd && $confirm ==
'yes') {
186 $result =
$object->setPaid($user);
189if ($action ==
'setfk_user' && $permissiontoadd) {
200if ($action ==
'reopen' && $permissiontoadd) {
203 $result =
$object->set_unpaid($user);
205 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
214if ($action ==
'setmode' && $permissiontoadd) {
223if ($action ==
'setbankaccount' && $permissiontoadd) {
231if ($action ==
'add' && empty($cancel) && $permissiontoadd) {
250 $object->type_payment = ($type_payment > 0 ? $type_payment : 0);
251 $object->fk_user_author = $user->id;
252 $object->fk_project = $projectid;
255 $fuser =
new User($db);
257 $object->salary = $fuser->salary;
260 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
265 if (!empty($auto_create_paiement) && empty($datep)) {
266 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DATE_PAIEMENT")),
null,
'errors');
269 if (empty($datesp) || empty($dateep)) {
270 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
274 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Employee")),
null,
'errors');
277 if (!empty($auto_create_paiement) && (empty($type_payment) || $type_payment < 0)) {
278 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PaymentMode")),
null,
'errors');
282 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount")),
null,
'errors');
285 if (isModEnabled(
"bank") && !empty($auto_create_paiement) && !
$object->accountid > 0) {
286 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankAccount")),
null,
'errors');
298 if (!empty($auto_create_paiement) && !$error) {
301 $paiement->fk_salary =
$object->id;
303 $paiement->datep = $datep;
304 $paiement->datev = $datev;
305 $paiement->amounts = array(
$object->id => $amount);
306 $paiement->fk_typepayment = $type_payment;
307 $paiement->num_payment =
GETPOST(
"num_payment",
'alphanohtml');
308 $paiement->note_private =
GETPOST(
"note",
'restricthtml');
311 $paymentid = $paiement->create($user, (
int)
GETPOST(
'closepaidsalary'));
312 if ($paymentid < 0) {
320 $result = $paiement->addPaymentToBank($user,
'payment_salary',
'(SalaryPayment)',
GETPOSTINT(
'accountid'),
'',
'');
321 if (!($result > 0)) {
331 if (
GETPOST(
'saveandnew',
'alpha')) {
333 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"));
336 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id);
347if ($action ==
'confirm_delete' && $permissiontodelete) {
349 $totalpaid =
$object->getSommePaiement();
351 if (empty($totalpaid)) {
357 header(
"Location: ".DOL_URL_ROOT.
'/salaries/list.php');
369if ($action ==
'update' && !
GETPOST(
"cancel") && $permissiontoadd) {
372 if (empty($amount)) {
373 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Amount")),
null,
'errors');
375 } elseif (!is_numeric($amount)) {
376 setEventMessages($langs->trans(
"ErrorFieldMustBeANumeric", $langs->transnoentities(
"Amount")),
null,
'errors');
385 $result =
$object->update($user);
392if ($action ==
'confirm_clone' && $confirm !=
'yes') {
396if ($action ==
'confirm_clone' && $confirm ==
'yes' && $permissiontoadd) {
408 if (
GETPOST(
'amount',
'alphanohtml')) {
412 if (
GETPOST(
'clone_label',
'alphanohtml')) {
422 $object->datesp = $newdatestart;
433 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
448if ($action ==
"update_extras" && $permissiontoadd) {
451 $attributekey =
GETPOST(
'attribute',
'alpha');
452 $attributekeylong =
'options_'.$attributekey;
454 if (GETPOSTISSET($attributekeylong.
'day') && GETPOSTISSET($attributekeylong.
'month') && GETPOSTISSET($attributekeylong.
'year')) {
459 $object->array_options[
'options_'.$attributekey] =
GETPOST($attributekeylong,
'alpha');
462 $result =
$object->insertExtraFields(empty($triggermodname) ?
'' : $triggermodname, $user);
468 $action =
'edit_extras';
476$form =
new Form($db);
478if (isModEnabled(
'project')) {
482$title = $langs->trans(
'Salary').
" - ".
$object->ref;
483if ($action ==
'create') {
484 $title = $langs->trans(
"NewSalary");
499if ($action ==
'create' && $permissiontoadd) {
502 $pastmonthyear = $year_current;
503 if ($pastmonth == 0) {
514 $datesp =
dol_mktime(0, 0, 0, $datespmonth, $datespday, $datespyear);
515 $dateep =
dol_mktime(23, 59, 59, $dateepmonth, $dateepday, $dateepyear);
517 if (empty($datesp) || empty($dateep)) {
522 print
'<form name="salary" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
523 print
'<input type="hidden" name="token" value="'.newToken().
'">';
524 print
'<input type="hidden" name="action" value="add">';
526 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
528 if ($backtopageforcancel) {
529 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
534 if (!empty($conf->use_javascript_ajax)) {
535 print
"\n".
'<script type="text/javascript">';
537 $(document).ready(function () {
538 let onAutoCreatePaiementChange = function () {
539 if($("#auto_create_paiement").is(":checked")) {
540 $("#label_fk_account").find("span").addClass("fieldrequired");
541 $("#label_type_payment").find("span").addClass("fieldrequired");
542 $(".hide_if_no_auto_create_payment").show();
544 $("#label_fk_account").find("span").removeClass("fieldrequired");
545 $("#label_type_payment").find("span").removeClass("fieldrequired");
546 $(".hide_if_no_auto_create_payment").hide();
549 $("#radiopayment").click(function() {
550 $("#label").val($(this).data("label"));
552 $("#radiorefund").click(function() {
553 $("#label").val($(this).data("label"));
555 $("#auto_create_paiement").click(function () {
556 onAutoCreatePaiementChange();
558 onAutoCreatePaiementChange();
561 print
'</script>'.
"\n";
566 print
'<table class="border centpercent">';
569 print
'<tr><td class="titlefieldcreate">';
570 print $form->editfieldkey(
'Employee',
'fk_user',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
572 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);
577 print $form->editfieldkey(
'Label',
'label',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
578 print
'<input name="label" id="label" class="minwidth300" value="'.(GETPOST(
"label") ?
GETPOST(
"label") : $langs->trans(
"Salary")).
'">';
583 print $form->editfieldkey(
'DateStartPeriod',
'datesp',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
584 print $form->selectDate($datesp,
"datesp", 0, 0, 0,
'add');
589 print $form->editfieldkey(
'DateEndPeriod',
'dateep',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
590 print $form->selectDate($dateep,
"dateep", 0, 0, 0,
'add');
595 print $form->editfieldkey(
'Amount',
'amount',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
596 print
'<input name="amount" id="amount" class="minwidth75 maxwidth100" value="'.GETPOST(
"amount").
'"> ';
597 print
' <button class="dpInvisibleButtons datenowlink" id="updateAmountWithLastSalary" name="_useless" type="button">'.$langs->trans(
'UpdateAmountWithLastSalary').
'</a>';
602 if (isModEnabled(
'project')) {
605 print
'<tr><td>'.$langs->trans(
"Project").
'</td><td>';
606 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
607 print $formproject->select_projects(-1, $projectid,
'fk_project', 0, 0, 1, 1, 0, 0, 0,
'', 1);
613 print
'<td class="tdtop">'.$langs->trans(
"Comments").
'</td>';
614 print
'<td class="tdtop"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_3.
'">'.
GETPOST(
'note',
'restricthtml').
'</textarea></td>';
618 print
'<tr><td colspan="2"><hr></td></tr>';
622 print
'<tr><td><label for="auto_create_paiement">'.$langs->trans(
'AutomaticCreationPayment').
'</label></td>';
623 print
'<td><input id="auto_create_paiement" name="auto_create_paiement" type="checkbox" ' . (empty($auto_create_paiement) ?
'' :
'checked="checked"') .
' value="1"></td></tr>'.
"\n";
626 if (isModEnabled(
"bank")) {
627 print
'<tr><td id="label_fk_account">';
628 print $form->editfieldkey(
'BankAccount',
'selectaccountid',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
629 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
630 $form->select_comptes($accountid,
"accountid", 0,
'', 1);
635 print
'<tr><td id="label_type_payment">';
636 print $form->editfieldkey(
'PaymentMode',
'selectpaymenttype',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
637 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
638 print $form->select_types_paiements(
GETPOST(
"paymenttype",
'aZ09'),
"paymenttype",
'');
642 print
'<tr class="hide_if_no_auto_create_payment"><td>';
643 print $form->editfieldkey(
'DatePayment',
'datep',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
644 print $form->selectDate((empty($datep) ?
'' : $datep),
"datep", 0, 0, 0,
'add', 1, 1);
648 print
'<tr class="hide_if_no_auto_create_payment"><td>';
649 print $form->editfieldkey(
'DateValue',
'datev',
'',
$object, 0).
'</td><td>';
650 print $form->selectDate((empty($datev) ? -1 : $datev),
"datev", 0, 0, 0,
'add', 1, 1);
654 if (isModEnabled(
"bank")) {
656 print
'<tr class="hide_if_no_auto_create_payment"><td><label for="num_payment">'.$langs->trans(
'Numero');
657 print
' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
658 print
'</label></td>';
659 print
'<td><input name="num_payment" id="num_payment" type="text" value="'.GETPOST(
"num_payment").
'"></td></tr>'.
"\n";
670 $parameters = array();
671 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
672 print $hookmanager->resPrint;
673 if (empty($reshook)) {
674 print
$object->showOptionals($extrafields,
'create');
681 print
'<div class="center">';
683 print
'<div class="hide_if_no_auto_create_payment paddingbottom">';
684 print
'<input type="checkbox" checked value="1" name="closepaidsalary">'.$langs->trans(
"ClosePaidSalaryAutomatically");
689 $addition_button = array(
690 'name' =>
'saveandnew',
691 'label_key' =>
'SaveAndNew',
693 print $form->buttonsSaveCancel(
"Save",
"Cancel", $addition_button);
697 print
'$( document ).ready(function() {';
698 print
'$("#updateAmountWithLastSalary").on("click", function updateAmountWithLastSalary() {
699 var fk_user = $("#fk_user").val()
700 var url = "'.DOL_URL_ROOT.
'/salaries/ajax/ajaxsalaries.php?fk_user="+fk_user;
701 console.log("We click on link to autofill salary amount url="+url);
707 console.log("Data returned: "+data);
709 if (typeof data == "object") {
710 console.log("data is already type object, no need to parse it");
713 console.log("data is type "+(typeof data));
714 item = JSON.parse(data);
716 if (item[0].key == "Amount") {
717 value = item[0].value;
718 console.log("amount returned = "+value);
720 $("#amount").val(item[0].value);
722 console.error("Error: Ajax url "+url+" has returned a null value.");
725 console.error("Error: Ajax url "+url+" has returned the wrong key.");
728 console.error("Error: Ajax url "+url+" has returned an empty page.");
734 alert("'.
dol_escape_js($langs->transnoentitiesnoconv(
"FillFieldFirst")).
'");
744 $head = salaries_prepare_head(
$object);
747 if ($action ===
'clone') {
748 $formquestion = array(
749 array(
'type' =>
'text',
'name' =>
'clone_label',
'label' => $langs->trans(
"Label"),
'value' => $langs->trans(
"CopyOf").
' '.
$object->label),
753 $formquestion[] = array(
'type' =>
'date',
'name' =>
'clone_date_start',
'label' => $langs->trans(
"DateStart"),
'value' => -1);
754 $formquestion[] = array(
'type' =>
'date',
'name' =>
'clone_date_end',
'label' => $langs->trans(
"DateEnd"),
'value' => -1);
755 $formquestion[] = array(
'type' =>
'text',
'name' =>
'amount',
'label' => $langs->trans(
"Amount"),
'value' =>
price(
$object->amount),
'morecss' =>
'width100 right');
757 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneSalary',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1, 280);
760 $formconfirm .=
"<script>
761 $('#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>'));
762 $('#fill_end_of_month').click(function(){
763 var clone_date_startmonth = +$('#clone_date_startmonth').val();
764 var clone_date_startyear = +$('#clone_date_startyear').val();
765 var end_date = new Date(clone_date_startyear, clone_date_startmonth, 0);
766 end_date.setMonth(clone_date_startmonth - 1);
767 $('#clone_date_end').val(formatDate(end_date,'".$langs->trans(
"FormatDateShortJavaInput").
"'));
768 $('#clone_date_endday').val(end_date.getDate());
769 $('#clone_date_endmonth').val(end_date.getMonth() + 1);
770 $('#clone_date_endyear').val(end_date.getFullYear());
775 if ($action ==
'paid') {
776 $text = $langs->trans(
'ConfirmPaySalary');
777 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
'PaySalary'), $text,
"confirm_paid",
'',
'', 2);
780 if ($action ==
'delete') {
781 $text = $langs->trans(
'ConfirmDeleteSalary');
782 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
'DeleteSalary'), $text,
'confirm_delete',
'',
'', 2);
785 if ($action ==
'edit') {
786 print
"<form name=\"charge\" action=\"".$_SERVER[
"PHP_SELF"].
"?id=$object->id&action=update\" method=\"post\">";
787 print
'<input type="hidden" name="token" value="'.newToken().
'">';
791 $parameters = array(
'formConfirm' => $formconfirm);
792 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
793 if (empty($reshook)) {
794 $formconfirm .= $hookmanager->resPrint;
795 } elseif ($reshook > 0) {
796 $formconfirm = $hookmanager->resPrint;
803 print
dol_get_fiche_head($head,
'card', $langs->trans(
"SalaryPayment"), -1,
'salary', 0,
'',
'', 0,
'', 1);
805 $linkback =
'<a href="'.DOL_URL_ROOT.
'/salaries/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
807 $morehtmlref =
'<div class="refidno">';
810 if ($action !=
'editlabel') {
811 $morehtmlref .= $form->editfieldkey(
"Label",
'label',
$object->label,
$object, $permissiontoadd,
'string',
'', 0, 1);
812 $morehtmlref .=
$object->label;
814 $morehtmlref .= $langs->trans(
'Label').
' : ';
815 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
816 $morehtmlref .=
'<input type="hidden" name="action" value="setlabel">';
817 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
818 $morehtmlref .=
'<input type="text" name="label" value="'.$object->label.
'"/>';
819 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
820 $morehtmlref .=
'</form>';
824 if ($action !=
'editfk_user') {
825 if (
$object->getSommePaiement() > 0 && !empty(
$object->fk_user)) {
826 $userstatic =
new User($db);
827 $result = $userstatic->fetch(
$object->fk_user);
829 $morehtmlref .=
'<br>' .$langs->trans(
'Employee').
' : '.$userstatic->getNomUrl(-1);
832 $morehtmlref .=
'<br>' . $form->editfieldkey(
"Employee",
'fk_user',
$object->label,
$object, $permissiontoadd,
'string',
'', 0, 1);
834 if (!empty(
$object->fk_user)) {
835 $userstatic =
new User($db);
836 $result = $userstatic->fetch(
$object->fk_user);
838 $morehtmlref .= $userstatic->getNomUrl(-1);
846 $morehtmlref .=
'<br>'.$langs->trans(
'Employee').
' : ';
847 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
848 $morehtmlref .=
'<input type="hidden" name="action" value="setfk_user">';
849 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
850 $morehtmlref .= $form->select_dolusers(
$object->fk_user,
'userid', 1);
851 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
852 $morehtmlref .=
'</form>';
855 $usercancreate = $permissiontoadd;
858 if (isModEnabled(
'project')) {
859 $langs->load(
"projects");
860 $morehtmlref .=
'<br>';
861 if ($usercancreate) {
862 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
863 if ($action !=
'classify') {
864 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
866 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, -1,
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
868 if (!empty(
$object->fk_project)) {
870 $proj->fetch(
$object->fk_project);
871 $morehtmlref .= $proj->getNomUrl(1);
873 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
879 $morehtmlref .=
'</div>';
881 $totalpaid =
$object->getSommePaiement();
882 $object->alreadypaid = $totalpaid;
883 $object->totalpaid = $totalpaid;
885 dol_banner_tab(
$object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref,
'', 0,
'',
'');
887 print
'<div class="fichecenter">';
888 print
'<div class="fichehalfleft">';
889 print
'<div class="underbanner clearboth"></div>';
891 print
'<table class="border centpercent tableforfield">';
893 if ($action ==
'edit') {
894 print
'<tr><td class="titlefield">'.$langs->trans(
"DateStartPeriod").
"</td><td>";
895 print $form->selectDate(
$object->datesp,
'datesp', 0, 0, 0,
'datesp', 1);
899 print
'<td class="titlefield">' . $langs->trans(
"DateStartPeriod") .
'</td><td>';
904 if ($action ==
'edit') {
905 print
'<tr><td>'.$langs->trans(
"DateEndPeriod").
"</td><td>";
906 print $form->selectDate(
$object->dateep,
'dateep', 0, 0, 0,
'dateep', 1);
910 print
'<td>' . $langs->trans(
"DateEndPeriod") .
'</td><td>';
924 if ($action ==
'edit') {
925 print
'<tr><td class="fieldrequired">' . $langs->trans(
"Amount") .
'</td><td><input name="amount" size="10" value="' .
price(
$object->amount) .
'"></td></tr>';
927 print
'<tr><td>' . $langs->trans(
"Amount") .
'</td><td><span class="amount">' .
price(
$object->amount, 0, $langs, 1, -1, -1, $conf->currency) .
'</span></td></tr>';
932 print
'<table class="nobordernopadding" width="100%"><tr><td>';
933 print $langs->trans(
'DefaultPaymentMode');
935 if ($action !=
'editmode') {
936 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>';
938 print
'</tr></table>';
941 if ($action ==
'editmode') {
942 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->type_payment,
'mode_reglement_id');
944 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->type_payment,
'none');
949 if (isModEnabled(
"bank")) {
950 print
'<tr><td class="nowrap">';
951 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
952 print $langs->trans(
'DefaultBankAccount');
954 if ($action !=
'editbankaccount' && $permissiontoadd) {
955 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>';
957 print
'</tr></table>';
959 if ($action ==
'editbankaccount') {
960 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'fk_account', 1);
962 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'none');
969 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
975 print
'<div class="fichehalfright">';
978 if (isModEnabled(
"bank")) {
985 $sql =
"SELECT p.rowid, p.num_payment as num_payment, p.datep as dp, p.amount,";
986 $sql .=
" c.code as type_code,c.libelle as paiement_type,";
987 $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';
988 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_salary as p";
989 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
990 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
991 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as c ON p.fk_typepayment = c.id";
992 $sql .=
", ".MAIN_DB_PREFIX.
"salary as salaire";
993 $sql .=
" WHERE p.fk_salary = ".((int) $id);
994 $sql .=
" AND p.fk_salary = salaire.rowid";
995 $sql .=
" AND salaire.entity IN (".getEntity(
'tax').
")";
996 $sql .=
" ORDER BY dp DESC";
998 $resql = $db->query($sql);
1002 $num = $db->num_rows($resql);
1006 print
'<div class="div-table-responsive-no-min">';
1007 print
'<table class="noborder paymenttable">';
1008 print
'<tr class="liste_titre">';
1009 print
'<td>'.$langs->trans(
"RefPayment").
'</td>';
1010 print
'<td>'.$langs->trans(
"Date").
'</td>';
1011 print
'<td>'.$langs->trans(
"Type").
'</td>';
1012 if (isModEnabled(
"bank")) {
1013 print
'<td class="liste_titre right">'.$langs->trans(
'BankAccount').
'</td>';
1015 print
'<td class="right">'.$langs->trans(
"Amount").
'</td>';
1021 $bankaccountstatic =
new Account($db);
1023 $objp = $db->fetch_object($resql);
1025 $paymentsalarytemp->id = $objp->rowid;
1026 $paymentsalarytemp->ref = $objp->rowid;
1027 $paymentsalarytemp->num_payment = $objp->num_payment;
1028 $paymentsalarytemp->datep = $objp->dp;
1030 print
'<tr class="oddeven"><td>';
1031 print $paymentsalarytemp->getNomUrl(1);
1033 print
'<td>'.dol_print_date($db->jdate($objp->dp),
'dayhour',
'tzuserrel').
"</td>\n";
1034 $labeltype = $langs->trans(
"PaymentType".$objp->type_code) !=
"PaymentType".$objp->type_code ? $langs->trans(
"PaymentType".$objp->type_code) : $objp->paiement_type;
1035 print
"<td>".$labeltype.
' '.$objp->num_payment.
"</td>\n";
1036 if (isModEnabled(
"bank")) {
1037 $bankaccountstatic->id = $objp->baid;
1038 $bankaccountstatic->ref = $objp->baref;
1039 $bankaccountstatic->label = $objp->baref;
1040 $bankaccountstatic->number = $objp->banumber;
1041 $bankaccountstatic->currency_code = $objp->bacurrency_code;
1043 if (isModEnabled(
'accounting')) {
1044 $bankaccountstatic->account_number = $objp->account_number;
1047 $accountingjournal->fetch($objp->fk_accountancy_journal);
1048 $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
1051 print
'<td class="right">';
1052 if ($bankaccountstatic->id) {
1053 print $bankaccountstatic->getNomUrl(1,
'transactions');
1057 print
'<td class="right nowrap amountcard">'.price($objp->amount).
"</td>\n";
1059 $totalpaid += $objp->amount;
1063 print
'<tr class="oddeven"><td><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td>';
1064 print
'<td></td><td></td><td></td><td></td>';
1068 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AlreadyPaid").
' :</td><td class="right nowrap amountcard">'.
price($totalpaid).
"</td></tr>\n";
1069 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AmountExpected").
' :</td><td class="right nowrap amountcard">'.
price(
$object->amount).
"</td></tr>\n";
1071 $resteapayer = (float)
$object->amount - $totalpaid;
1072 $cssforamountpaymentcomplete =
'amountpaymentcomplete';
1074 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"RemainderToPay").
" :</td>";
1075 print
'<td class="right nowrap'.($resteapayer ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($resteapayer).
"</td></tr>\n";
1088 print
'<div class="clearboth"></div>';
1092 if ($action ==
'edit') {
1093 print $form->buttonsSaveCancel();
1097 $resteapayer =
price2num($resteapayer,
'MT');
1104 print
'<div class="tabsAction">'.
"\n";
1105 if ($action !=
'edit') {
1107 $parameters = array();
1108 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
1109 if (empty($reshook)) {
1110 if (empty($user->socid)) {
1111 $canSendMail =
true;
1113 print
dolGetButtonAction($langs->trans(
'SendMail'),
'',
'default', $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id .
'&action=presend&token='.newToken().
'&mode=init#formmailbeforetitle',
'', $canSendMail);
1118 if (
$object->paye && $permissiontoadd) {
1123 if (
$object->paye == 0 && $permissiontoadd) {
1129 print
dolGetButtonAction(
'', $langs->trans(
'DoPayment'),
'default', DOL_URL_ROOT.
'/salaries/paiement_salary.php?action=create&token='.
newToken().
'&id='.
$object->id,
'');
1134 if (
$object->paye == 0 && (($resteapayer <= 0 && $object->amount > 0) || (
$object->amount <= 0)) && $permissiontoadd) {
1139 print
dolGetButtonAction(
'', $langs->trans(
'MakeTransferRequest'),
'default', DOL_URL_ROOT.
'/salaries/virement_request.php?id='.
$object->id,
'');
1142 if ($permissiontoadd) {
1146 if ($permissiontodelete && empty($totalpaid)) {
1149 print
dolGetButtonAction($langs->trans(
'DisabledBecausePayments'), $langs->trans(
'Delete'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1157 if (
GETPOST(
'modelselected')) {
1158 $action =
'presend';
1161 if ($action !=
'presend') {
1162 print
'<div class="fichecenter"><div class="fichehalfleft">';
1163 print
'<a name="builddoc"></a>';
1165 $includedocgeneration = 1;
1168 if ($includedocgeneration) {
1170 $relativepath = $objref.
'/'.$objref.
'.pdf';
1171 $filedir = $conf->salaries->dir_output.
'/'.$objref;
1172 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
1175 $delallowed = $permissiontoadd;
1176 print $formfile->showdocuments(
'salaries', $objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
1185 print
'</div><div class="fichehalfright">';
1192 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1196 print
'</div></div>';
1200 if (
GETPOST(
'modelselected')) {
1201 $action =
'presend';
1205 $modelmail =
'salary';
1206 $defaulttopic =
'InformationMessage';
1207 $diroutput = $conf->salaries->dir_output;
1208 $trackid =
'salary'.$object->id;
1210 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
1213 $parameters = array();
1214 $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.
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.