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)) {
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') {
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();
766 if (clone_date_startmonth && clone_date_startyear) {
767 end_date = new Date(clone_date_startyear, clone_date_startmonth , 0);
769 var currentDate = new Date();
770 var currentDay = currentDate.getDate();
771 if (currentDay <= 15) {
772 end_date = new Date(currentDate.getFullYear(), currentDate.getMonth(), 0);
774 end_date = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0);
777 $('#clone_date_end').val(formatDate(end_date,'".$langs->trans(
"FormatDateShortJavaInput").
"'));
778 $('#clone_date_endday').val(end_date.getDate());
779 $('#clone_date_endmonth').val(end_date.getMonth() + 1);
780 $('#clone_date_endyear').val(end_date.getFullYear());
785 if ($action ==
'paid') {
786 $text = $langs->trans(
'ConfirmPaySalary');
787 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
'PaySalary'), $text,
"confirm_paid",
'',
'', 2);
790 if ($action ==
'delete') {
791 $text = $langs->trans(
'ConfirmDeleteSalary');
792 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
'DeleteSalary'), $text,
'confirm_delete',
'',
'', 2);
795 if ($action ==
'edit') {
796 print
"<form name=\"charge\" action=\"".$_SERVER[
"PHP_SELF"].
"?id=$object->id&action=update\" method=\"post\">";
797 print
'<input type="hidden" name="token" value="'.newToken().
'">';
801 $parameters = array(
'formConfirm' => $formconfirm);
802 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
803 if (empty($reshook)) {
804 $formconfirm .= $hookmanager->resPrint;
805 } elseif ($reshook > 0) {
806 $formconfirm = $hookmanager->resPrint;
813 print
dol_get_fiche_head($head,
'card', $langs->trans(
"SalaryPayment"), -1,
'salary', 0,
'',
'', 0,
'', 1);
815 $linkback =
'<a href="'.DOL_URL_ROOT.
'/salaries/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
817 $morehtmlref =
'<div class="refidno">';
820 if ($action !=
'editlabel') {
821 $morehtmlref .= $form->editfieldkey(
"Label",
'label',
$object->label,
$object, $permissiontoadd,
'string',
'', 0, 1);
822 $morehtmlref .=
$object->label;
824 $morehtmlref .= $langs->trans(
'Label').
' : ';
825 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
826 $morehtmlref .=
'<input type="hidden" name="action" value="setlabel">';
827 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
828 $morehtmlref .=
'<input type="text" name="label" value="'.$object->label.
'"/>';
829 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
830 $morehtmlref .=
'</form>';
834 if ($action !=
'editfk_user') {
835 if (
$object->getSommePaiement() > 0 && !empty(
$object->fk_user)) {
836 $userstatic =
new User($db);
837 $result = $userstatic->fetch(
$object->fk_user);
839 $morehtmlref .=
'<br>' .$langs->trans(
'Employee').
' : '.$userstatic->getNomUrl(-1);
842 $morehtmlref .=
'<br>' . $form->editfieldkey(
"Employee",
'fk_user',
$object->label,
$object, $permissiontoadd,
'string',
'', 0, 1);
844 if (!empty(
$object->fk_user)) {
845 $userstatic =
new User($db);
846 $result = $userstatic->fetch(
$object->fk_user);
848 $morehtmlref .= $userstatic->getNomUrl(-1);
856 $morehtmlref .=
'<br>'.$langs->trans(
'Employee').
' : ';
857 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
858 $morehtmlref .=
'<input type="hidden" name="action" value="setfk_user">';
859 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
860 $morehtmlref .= $form->select_dolusers(
$object->fk_user,
'userid', 1);
861 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
862 $morehtmlref .=
'</form>';
865 $usercancreate = $permissiontoadd;
868 if (isModEnabled(
'project')) {
869 $langs->load(
"projects");
870 $morehtmlref .=
'<br>';
871 if ($usercancreate) {
872 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
873 if ($action !=
'classify') {
874 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
876 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, -1,
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
878 if (!empty(
$object->fk_project)) {
880 $proj->fetch(
$object->fk_project);
881 $morehtmlref .= $proj->getNomUrl(1);
883 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
889 $morehtmlref .=
'</div>';
891 $totalpaid =
$object->getSommePaiement();
892 $object->alreadypaid = $totalpaid;
893 $object->totalpaid = $totalpaid;
895 dol_banner_tab(
$object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref,
'', 0,
'',
'');
897 print
'<div class="fichecenter">';
898 print
'<div class="fichehalfleft">';
899 print
'<div class="underbanner clearboth"></div>';
901 print
'<table class="border centpercent tableforfield">';
903 if ($action ==
'edit') {
904 print
'<tr><td class="titlefield">'.$langs->trans(
"DateStartPeriod").
"</td><td>";
905 print $form->selectDate(
$object->datesp,
'datesp', 0, 0, 0,
'datesp', 1);
909 print
'<td class="titlefield">' . $langs->trans(
"DateStartPeriod") .
'</td><td>';
914 if ($action ==
'edit') {
915 print
'<tr><td>'.$langs->trans(
"DateEndPeriod").
"</td><td>";
916 print $form->selectDate(
$object->dateep,
'dateep', 0, 0, 0,
'dateep', 1);
920 print
'<td>' . $langs->trans(
"DateEndPeriod") .
'</td><td>';
934 if ($action ==
'edit') {
935 print
'<tr><td class="fieldrequired">' . $langs->trans(
"Amount") .
'</td><td><input name="amount" size="10" value="' .
price(
$object->amount) .
'"></td></tr>';
937 print
'<tr><td>' . $langs->trans(
"Amount") .
'</td><td><span class="amount">' .
price(
$object->amount, 0, $langs, 1, -1, -1, $conf->currency) .
'</span></td></tr>';
942 print
'<table class="nobordernopadding" width="100%"><tr><td>';
943 print $langs->trans(
'DefaultPaymentMode');
945 if ($action !=
'editmode') {
946 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>';
948 print
'</tr></table>';
951 if ($action ==
'editmode') {
952 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->type_payment,
'mode_reglement_id');
954 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->type_payment,
'none');
959 if (isModEnabled(
"bank")) {
960 print
'<tr><td class="nowrap">';
961 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
962 print $langs->trans(
'DefaultBankAccount');
964 if ($action !=
'editbankaccount' && $permissiontoadd) {
965 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>';
967 print
'</tr></table>';
969 if ($action ==
'editbankaccount') {
970 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'fk_account', 1);
972 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'none');
979 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
985 print
'<div class="fichehalfright">';
988 if (isModEnabled(
"bank")) {
995 $sql =
"SELECT p.rowid, p.num_payment as num_payment, p.datep as dp, p.amount,";
996 $sql .=
" c.code as type_code,c.libelle as paiement_type,";
997 $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';
998 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_salary as p";
999 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
1000 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
1001 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as c ON p.fk_typepayment = c.id";
1002 $sql .=
", ".MAIN_DB_PREFIX.
"salary as salaire";
1003 $sql .=
" WHERE p.fk_salary = ".((int) $id);
1004 $sql .=
" AND p.fk_salary = salaire.rowid";
1005 $sql .=
" AND salaire.entity IN (".getEntity(
'tax').
")";
1006 $sql .=
" ORDER BY dp DESC";
1008 $resql = $db->query($sql);
1012 $num = $db->num_rows($resql);
1016 print
'<div class="div-table-responsive-no-min">';
1017 print
'<table class="noborder paymenttable">';
1018 print
'<tr class="liste_titre">';
1019 print
'<td>'.$langs->trans(
"RefPayment").
'</td>';
1020 print
'<td>'.$langs->trans(
"Date").
'</td>';
1021 print
'<td>'.$langs->trans(
"Type").
'</td>';
1022 if (isModEnabled(
"bank")) {
1023 print
'<td class="liste_titre right">'.$langs->trans(
'BankAccount').
'</td>';
1025 print
'<td class="right">'.$langs->trans(
"Amount").
'</td>';
1031 $bankaccountstatic =
new Account($db);
1033 $objp = $db->fetch_object($resql);
1035 $paymentsalarytemp->id = $objp->rowid;
1036 $paymentsalarytemp->ref = $objp->rowid;
1037 $paymentsalarytemp->num_payment = $objp->num_payment;
1038 $paymentsalarytemp->datep = $objp->dp;
1040 print
'<tr class="oddeven"><td>';
1041 print $paymentsalarytemp->getNomUrl(1);
1043 print
'<td>'.dol_print_date($db->jdate($objp->dp),
'dayhour',
'tzuserrel').
"</td>\n";
1044 $labeltype = $langs->trans(
"PaymentType".$objp->type_code) !=
"PaymentType".$objp->type_code ? $langs->trans(
"PaymentType".$objp->type_code) : $objp->paiement_type;
1045 print
"<td>".$labeltype.
' '.$objp->num_payment.
"</td>\n";
1046 if (isModEnabled(
"bank")) {
1047 $bankaccountstatic->id = $objp->baid;
1048 $bankaccountstatic->ref = $objp->baref;
1049 $bankaccountstatic->label = $objp->baref;
1050 $bankaccountstatic->number = $objp->banumber;
1051 $bankaccountstatic->currency_code = $objp->bacurrency_code;
1053 if (isModEnabled(
'accounting')) {
1054 $bankaccountstatic->account_number = $objp->account_number;
1057 $accountingjournal->fetch($objp->fk_accountancy_journal);
1058 $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
1061 print
'<td class="right">';
1062 if ($bankaccountstatic->id) {
1063 print $bankaccountstatic->getNomUrl(1,
'transactions');
1067 print
'<td class="right nowrap amountcard">'.price($objp->amount).
"</td>\n";
1069 $totalpaid += $objp->amount;
1073 print
'<tr class="oddeven"><td><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td>';
1074 print
'<td></td><td></td><td></td><td></td>';
1078 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AlreadyPaid").
' :</td><td class="right nowrap amountcard">'.
price($totalpaid).
"</td></tr>\n";
1079 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AmountExpected").
' :</td><td class="right nowrap amountcard">'.
price(
$object->amount).
"</td></tr>\n";
1081 $resteapayer =
$object->amount - $totalpaid;
1082 $cssforamountpaymentcomplete =
'amountpaymentcomplete';
1084 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"RemainderToPay").
" :</td>";
1085 print
'<td class="right nowrap'.($resteapayer ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($resteapayer).
"</td></tr>\n";
1098 print
'<div class="clearboth"></div>';
1102 if ($action ==
'edit') {
1103 print $form->buttonsSaveCancel();
1107 $resteapayer =
price2num($resteapayer,
'MT');
1114 print
'<div class="tabsAction">'.
"\n";
1115 if ($action !=
'edit') {
1117 $parameters = array();
1118 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
1119 if (empty($reshook)) {
1120 if (empty($user->socid)) {
1121 $canSendMail =
true;
1123 print
dolGetButtonAction($langs->trans(
'SendMail'),
'',
'default', $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id .
'&action=presend&token='.newToken().
'&mode=init#formmailbeforetitle',
'', $canSendMail);
1128 if (
$object->paye && $permissiontoadd) {
1133 if (
$object->paye == 0 && $permissiontoadd) {
1139 print
dolGetButtonAction(
'', $langs->trans(
'DoPayment'),
'default', DOL_URL_ROOT.
'/salaries/paiement_salary.php?action=create&token='.
newToken().
'&id='.
$object->id,
'');
1144 if (
$object->paye == 0 && (($resteapayer <= 0 && $object->amount > 0) || (
$object->amount <= 0)) && $permissiontoadd) {
1149 print
dolGetButtonAction(
'', $langs->trans(
'MakeTransferRequest'),
'default', DOL_URL_ROOT.
'/salaries/virement_request.php?id='.
$object->id,
'');
1152 if ($permissiontoadd) {
1156 if ($permissiontodelete && empty($totalpaid)) {
1159 print
dolGetButtonAction($langs->trans(
'DisabledBecausePayments'), $langs->trans(
'Delete'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1167 if (
GETPOST(
'modelselected')) {
1168 $action =
'presend';
1171 if ($action !=
'presend') {
1172 print
'<div class="fichecenter"><div class="fichehalfleft">';
1173 print
'<a name="builddoc"></a>';
1175 $includedocgeneration = 1;
1178 if ($includedocgeneration) {
1180 $relativepath = $objref.
'/'.$objref.
'.pdf';
1181 $filedir = $conf->salaries->dir_output.
'/'.$objref;
1182 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
1185 $delallowed = $permissiontoadd;
1186 print $formfile->showdocuments(
'salaries', $objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
1195 print
'</div><div class="fichehalfright">';
1202 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1206 print
'</div></div>';
1210 if (
GETPOST(
'modelselected')) {
1211 $action =
'presend';
1215 $modelmail =
'salary';
1216 $defaulttopic =
'InformationMessage';
1217 $diroutput = $conf->salaries->dir_output;
1218 $trackid =
'salary'.$object->id;
1220 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
1223 $parameters = array();
1224 $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()
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.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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 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.